From 29ee4ebedbb7ecea34665aaf918665cd01ee9020 Mon Sep 17 00:00:00 2001 From: Johnshall Date: Sat, 12 Feb 2022 22:40:34 +0800 Subject: [PATCH] Simple scanner --- factory/scanner.py | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 factory/scanner.py diff --git a/factory/scanner.py b/factory/scanner.py new file mode 100644 index 0000000..353d337 --- /dev/null +++ b/factory/scanner.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- + +# 简单的扫描直连/代理工具 + +import requests +import threading + +domains = [] +domains_proxy = [] +domains_direct = [] +requests_header = { + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36', + 'Cache-Control': 'max-age=0', + 'Accept-Language': 'zh-CN,zh;q=0.8,zh-HK;q=0.6,zh-TW;q=0.4,en;q=0.2', + 'Connection': 'keep-alive' +} + +# thread to judge direct/proxy +class DomainScaner(threading.Thread): + def __init__(self): + threading.Thread.__init__(self) + + def run(self): + while len(domains): + domain = domains.pop(0) + is_proxy = False + try: + requests.get('http://www.' + domain, timeout=10, headers=requests_header) + except BaseException: + try: + requests.get('http://' + domain, timeout=10, headers=requests_header) + except BaseException: + is_proxy = True + + if is_proxy: + domains_proxy.append(domain) + else: + domains_direct.append(domain) + + print('[Doamins Remain: %d]\tProxy %s:%s' % (len(domains), is_proxy, domain) ) + + + global scaner_thread_num + scaner_thread_num -= 1 + +# Start Thread +scaner_thread_num = 0 +for i in range(5): + DomainScaner().start() + scaner_thread_num += 1 + +# wait thread done +while scaner_thread_num: + pass + +print('domains_proxy:\t',domains_proxy) +print('domains_direct:\t',domains_direct)