Beispiel #1
0
    def load_ips(self, file_of_ips):

        # Check to make sure file given is a valid file
        if os.path.isfile(file_of_ips):
            # read in IPs from a file
            with open(file_of_ips, "r") as ip_file:
                ip_addr_dictionary = ip_file.readlines()
            total_ips = len(ip_addr_dictionary)

            # Cast each IP its own object
            for ip in ip_addr_dictionary:
                activated_ip_object = ip_object.IP_Information(ip.strip())
                if ip in self.ip_objects:
                    self.ip_objects[ip][1] = self.ip_objects[ip][1] + 1
                else:
                    self.ip_objects[ip] = [activated_ip_object, 1]

            print helpers.color("[*] Loaded " + str(total_ips) + " IPs")

        else:
            print helpers.color("\n\n[*] Error: Invalid file path provided!",
                                warning=True)
            print helpers.color(
                "[*] Error: Please provide the valid path to a file.",
                warning=True)
        return
Beispiel #2
0
    def load_ips(self, file_of_systems):

        # Check to make sure file given is a valid file
        if os.path.isfile(file_of_systems):
            # read in IPs from a file
            with open(file_of_systems, "r") as system_file:
                justmetadata_system_list = system_file.readlines()
            total_systems = len(justmetadata_system_list)

            # Cast each IP its own object
            for system in justmetadata_system_list:
                activated_system_object = ip_object.IP_Information(
                    system.strip())
                if system in self.system_objects:
                    self.system_objects[system][
                        1] = self.system_objects[system][1] + 1
                else:
                    self.system_objects[system] = [activated_system_object, 1]

            print helpers.color("[*] Loaded " + str(total_systems) +
                                " systems")

        else:
            print helpers.color("\n\n[*] Error: Invalid file path provided!",
                                warning=True)
            print helpers.color(
                "[*] Error: Please provide the valid path to a file.",
                warning=True)
        return
Beispiel #3
0
    def load_ips(self, file_of_systems):

        # Check to make sure file given is a valid file
        if os.path.isfile(file_of_systems):
            # read in IPs from a file
            with open(file_of_systems, "r") as system_file:
                justmetadata_system_list = system_file.readlines()
            total_systems = 0

            # Cast each IP its own object
            for system in justmetadata_system_list:
                if "/" in system:
                    try:
                        for ip in netaddr.IPSet([system]):
                            ip = str(ip)
                            activated_system_object = ip_object.IP_Information(ip)
                            if ip in self.system_objects:
                                self.system_objects[ip][1] = self.system_objects[ip][1] + 1
                                total_systems += 1
                            else:
                                self.system_objects[ip] = [activated_system_object, 1]
                                total_systems += 1
                    except netaddr.core.AddrFormatError:
                        print helpers.color("[*] Error: Bad IP CIDR range detected! (" + str(system).strip() + ")", warning=True)
                        continue
                else:
                    activated_system_object = ip_object.IP_Information(system.strip())
                    if system in self.system_objects:
                        self.system_objects[system][1] = self.system_objects[system][1] + 1
                        total_systems += 1
                    else:
                        self.system_objects[system] = [activated_system_object, 1]
                        total_systems += 1

            print helpers.color("[*] Loaded " + str(total_systems) + " systems")

        else:
            print helpers.color("\n\n[*] Error: Invalid file path provided!", warning=True)
            print helpers.color("[*] Error: Please provide the valid path to a file.", warning=True)
        return
Beispiel #4
0
 def add_ip(self, ipstring):
     total_systems = 0
     ipstring = ipstring.strip()
     if "/" in ipstring:
         try:
             for ip in netaddr.IPSet([ipstring]):
                 ip = str(ip)
                 activated_system_object = ip_object.IP_Information(ip)
                 if ip in self.system_objects:
                     print helpers.color(
                         "[*] Warning: Skipped duplicate IP ! (" +
                         str(ipstring).strip() + ")",
                         warning=True)
                     return total_systems
                 else:
                     self.system_objects[ip] = [activated_system_object, 1]
                     total_systems += 1
         except netaddr.core.AddrFormatError:
             print helpers.color(
                 "[*] Error: Bad IP CIDR range detected! (" +
                 str(ipstring).strip() + ")",
                 warning=True)
             return 0
     else:
         activated_system_object = ip_object.IP_Information(
             ipstring.strip())
         if ipstring in self.system_objects:
             print helpers.color("[*] Warning: Skipped duplicate IP ! (" +
                                 str(ipstring).strip() + ")",
                                 warning=True)
             return total_systems
         else:
             self.system_objects[ipstring] = [activated_system_object, 1]
             total_systems += 1
     print helpers.color("[*] Added " + ipstring)
     return total_systems