Example #1
0
def get_computer_ip():
    try:
        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        s.connect(("8.8.8.8", 80))
        ip = s.getsockname()[0]
        s.close()
        return ip
    except Exception, e:
        Logger.fatal(str(e))
Example #2
0
 def on_scan_button_cb(self, instance):
     Logger.fatal("Starting the scanner")
     my_ip = get_computer_ip()
     if not my_ip:
         Logger.fatal('Cannot init scanner, failed to find IP, aborting')
         return
     self.shell_control.execute_shell_flow_commannd(self.scanner_id, {
         'subnet': my_ip,
         'mask': 16,
         'nthreads': 100
     })
     self.scan_button.disabled = True
    def __scan_job_thread(self):
        Logger.info('Starting scan job thread')
        # Finish adding all the jobs
        try:
            if self.start_sub:
                self.start_sub()
            while self.__has_more_jobs() and self.is_running_scan:
                self.__validate_jobs()
                if self.__cant_insert_job():
                    time.sleep(1)
                    continue
                ip = self.__get_next_ip()
                if ip:
                    Logger.info('Starting job for = ' + ip)
                    job = threading.Thread(target=self.__scan_thread,
                                           args=(ip, ))
                    job.start()
                    self.running_jobs.append(job)

            # Wait for the remaining jobs to end
            self.__wait_for_jobs_to_end()
        except Exception, e:
            Logger.fatal(str(e))
Example #4
0
 def remove_ip(self, ip):
     if self.list_adapter.data.index(ip) != -1:
         Logger.fatal("Removing IP = " + ip)
         self.list_adapter.data.remove(ip)
Example #5
0
 def add_ip(self, ip):
     Logger.fatal("Adding IP = " + ip)
     self.list_adapter.data.append(ip)
     self.populate()