Esempio n. 1
0
    def check_exist_ip(self):

        self.ip_lock.acquire()
        tmp_ip_list = [x for x in self.gws_ip_list]
        self.ip_lock.release()

        for ip_str in tmp_ip_list:

            result = check_ip.test_gws(ip_str)
            if not result:
                if not self.network_is_ok():
                    logging.warn(
                        "check_exist_ip network is fail, check your network connection."
                    )
                    return

                logging.info("check_exist_ip fail ip:%s ", ip_str)
                self.report_connect_fail(ip_str, force_remove=True)
            else:
                self.update_ip(ip_str, result.handshake_time)
                logging.info("check_exist_ip update ip:%s server:%s time:%d",
                             ip_str, result.server_type, result.handshake_time)

            time.sleep(1)

        self.save_ip_list()
Esempio n. 2
0
    def scan_ip_worker(self):
        while self.searching_thread_count <= self.scan_ip_thread_num:
            if not connect_control.allow_scan():
                time.sleep(10)
                continue

            try:
                time.sleep(1)
                ip_int = ip_range.get_ip()
                ip_str = ip_utils.ip_num_to_string(ip_int)
                if self.is_bad_ip(ip_str):
                    continue

                result = check_ip.test_gws(ip_str)
                if not result:
                    continue

                if self.add_ip(ip_str, result.handshake_time, result.domain, result.server_type):
                    #logging.info("add  %s  CN:%s  type:%s  time:%d  gws:%d ", ip_str,
                    #     result.domain, result.server_type, result.handshake_time, len(self.gws_ip_list))
                    logging.info("scan_ip add ip:%s time:%d", ip_str, result.handshake_time)
                    scan_ip_log.info("Add %s time:%d CN:%s type:%s", ip_str, result.handshake_time, result.domain, result.server_type)
                    self.remove_slowest_ip()
                    self.save_ip_list()
            except check_ip.HoneypotError as e:
                self.report_bad_ip(ip_str)
                connect_control.fall_into_honeypot()
                continue
            except Exception as e:
                logging.exception("google_ip.runJob fail:%s", e)

        self.ncount_lock.acquire()
        self.searching_thread_count -= 1
        self.ncount_lock.release()
        logging.info("scan_ip_worker exit")
Esempio n. 3
0
    def runJob(self):
        while True:  #not self.is_ip_enough() and self.searching_thread_count < 2:
            if not connect_control.allow_connect():
                break

            try:
                time.sleep(1)
                ip_int = ip_range.get_ip()
                ip_str = ip_utils.ip_num_to_string(ip_int)
                if self.is_bad_ip(ip_str):
                    continue

                result = check_ip.test_gws(ip_str)
                if not result:
                    continue

                if self.add_ip(ip_str, result.handshake_time, result.domain,
                               result.server_type):
                    #logging.info("add  %s  CN:%s  type:%s  time:%d  gws:%d ", ip_str,
                    #     result.domain, result.server_type, result.handshake_time, len(self.gws_ip_list))
                    logging.info("check_ip add ip:%s time:%d", ip_str,
                                 result.handshake_time)
                    self.remove_slowest_ip()
                    self.save_ip_list()
            except check_ip.HoneypotError as e:
                self.report_bad_ip(ip_str)
                connect_control.fall_into_honeypot()
                break
            except Exception as e:
                logging.exception("google_ip.runJob fail:%s", e)

        self.ncount_lock.acquire()
        self.searching_thread_count -= 1
        self.ncount_lock.release()
Esempio n. 4
0
    def check_ip(self, ip_str):
        result = check_ip.test_gws(ip_str)
        if not result:
            return False

        if self.add_ip(ip_str, result.handshake_time, result.domain, result.server_type):
            logging.info("add  %s  CN:%s  type:%s  time:%d  gws:%d ", ip_str,
                 result.domain, result.server_type, result.handshake_time, len(self.gws_ip_list))

        return True
Esempio n. 5
0
    def check_ip(self, ip_str):
        result = check_ip.test_gws(ip_str)
        if not result:
            return False

        if self.add_ip(ip_str, result.handshake_time, result.domain, result.server_type):
            #logging.info("add  %s  CN:%s  type:%s  time:%d  gws:%d ", ip_str,
            #     result.domain, result.server_type, result.handshake_time, len(self.gws_ip_list))
            logging.info("check_ip add ip:%s time:%d", ip_str, result.handshake_time)

        return True
Esempio n. 6
0
    def req_test_ip_handler(self):
        req = urlparse.urlparse(self.path).query
        reqs = urlparse.parse_qs(req, keep_blank_values=True)
        data = ''

        ip = reqs['ip'][0]
        result = check_ip.test_gws(ip)
        if not result:
            data = "{'res':'fail'}"
        else:
            data = json.dumps("{'ip':'%s', 'handshake':'%s', 'server':'%s', 'domain':'%s'}" %
                  (ip, result.handshake_time, result.server_type, result.domain))

        self.send_response('text/html', data)
Esempio n. 7
0
    def req_test_ip_handler(self):
        req = urlparse.urlparse(self.path).query
        reqs = urlparse.parse_qs(req, keep_blank_values=True)
        data = ''

        ip = reqs['ip'][0]
        result = check_ip.test_gws(ip)
        if not result:
            data = "{'res':'fail'}"
        else:
            data = json.dumps("{'ip':'%s', 'handshake':'%s', 'server':'%s', 'domain':'%s'}" %
                  (ip, result.handshake_time, result.server_type, result.domain))

        self.send_response('text/html', data)
Esempio n. 8
0
    def scan_ip_worker(self):
        while self.searching_thread_count <= self.scan_ip_thread_num and connect_control.keep_running:
            if not connect_control.allow_scan():
                time.sleep(10)
                continue

            try:
                time.sleep(1)
                ip_int = ip_range.get_ip()
                ip_str = ip_utils.ip_num_to_string(ip_int)
                if self.is_bad_ip(ip_str):
                    continue

                connect_control.start_connect_register()
                result = check_ip.test_gws(ip_str)
                connect_control.end_connect_register()
                if not result:
                    continue

                if self.add_ip(ip_str, result.handshake_time, result.domain,
                               result.server_type):
                    #logging.info("add  %s  CN:%s  type:%s  time:%d  gws:%d ", ip_str,
                    #     result.domain, result.server_type, result.handshake_time, len(self.gws_ip_list))
                    xlog.info("scan_ip add ip:%s time:%d", ip_str,
                              result.handshake_time)
                    scan_ip_log.info("Add %s time:%d CN:%s type:%s", ip_str,
                                     result.handshake_time, result.domain,
                                     result.server_type)
                    self.remove_slowest_ip()
                    self.save_ip_list()
            except check_ip.HoneypotError as e:
                self.report_bad_ip(ip_str)
                connect_control.fall_into_honeypot()
                continue
            except Exception as e:
                xlog.exception("google_ip.runJob fail:%s", e)

        self.ncount_lock.acquire()
        self.searching_thread_count -= 1
        self.ncount_lock.release()
        xlog.info("scan_ip_worker exit")
Esempio n. 9
0
    def check_exist_ip(self):
        self.ip_lock.acquire()
        tmp_ip_list = [x for x in self.gws_ip_list]
        self.ip_lock.release()

        for ip_str in tmp_ip_list:

            result = check_ip.test_gws(ip_str)
            if not result:
                if not self.network_is_ok():
                    logging.warn("check_exist_ip network is fail, check your network connection.")
                    return

                logging.info("check_exist_ip fail ip:%s ", ip_str)
                self.report_connect_fail(ip_str)
            else:
                self.update_ip(ip_str, result.handshake_time)
                logging.info("check_exist_ip update ip:%s server:%s time:%d", ip_str, result.server_type, result.handshake_time)

            time.sleep(1)

        self.save_ip_list()
Esempio n. 10
0
    def check_exist_ip(self):
        self.ip_lock.acquire()
        tmp_ip_list = [x for x in self.gws_ip_list]
        self.ip_lock.release()

        for ip_str in tmp_ip_list:
            if not connect_control.allow_connect():
                break

            if self.is_bad_ip(ip_str):
                self.report_connect_fail(ip_str, force_remove=True)
                continue

            try:
                result = check_ip.test_gws(ip_str)
            except check_ip.HoneypotError as e:
                self.report_bad_ip(ip_str)
                connect_control.fall_into_honeypot()
                break
            except Exception as e:
                logging.exception("check_exist_ip fail:%s", e)

            if not result:
                if not check_ip.network_is_ok():
                    logging.warn(
                        "check_exist_ip network is fail, check your network connection."
                    )
                    return

                logging.info("check_exist_ip fail ip:%s ", ip_str)
                self.report_connect_fail(ip_str)
            else:
                self.update_ip(ip_str, result.handshake_time)
                logging.info("check_exist_ip update ip:%s server:%s time:%d",
                             ip_str, result.server_type, result.handshake_time)

            time.sleep(1)

        self.save_ip_list()
Esempio n. 11
0
    def check_exist_ip(self):
        self.ip_lock.acquire()
        tmp_ip_list = [x for x in self.gws_ip_list]
        self.ip_lock.release()

        for ip_str in tmp_ip_list:
            if not connect_control.allow_connect():
                break

            if self.is_bad_ip(ip_str):
                self.report_connect_fail(ip_str, force_remove=True)
                continue

            try:
                result = check_ip.test_gws(ip_str)
            except check_ip.HoneypotError as e:
                self.report_bad_ip(ip_str)
                connect_control.fall_into_honeypot()
                break
            except Exception as e:
                logging.exception("check_exist_ip fail:%s", e)

            if not result:
                if not self.network_is_ok():
                    logging.warn("check_exist_ip network is fail, check your network connection.")
                    return

                logging.info("check_exist_ip fail ip:%s ", ip_str)
                self.report_connect_fail(ip_str)
            else:
                self.update_ip(ip_str, result.handshake_time)
                logging.info("check_exist_ip update ip:%s server:%s time:%d", ip_str, result.server_type, result.handshake_time)

            time.sleep(1)

        self.save_ip_list()