"import os\nimport sys\nimport random\nimport time\nimport urllib3\nfrom bs4 import BeautifulSoup\nfrom concurrent.futures import ThreadPoolExecutor\nfrom threading import Lock\nimport requests\nfrom colorama import Fore, init\n\nnow_time = time.strftime('%Y-%m-%d %H-%M')\n\nlock = Lock()\n\ndef read_dorks(dorks):\n\twith open(dorks, mode='r', encoding='utf-8') as file:\n\t content = [result.strip() for result in file.readlines()]\n\t return len(content), content\n\ndef google_search(query, filename):\n\ttry:\n\t urllib3.disable_warnings()\n\t filename = os.path.join(os.getcwd(), f'{filename}.txt')\n\t domains = ['fr','it','ca','co.uk','ru','co.jp','co.kr','com.au','co.in','com.br','com.ar','com.bg','com.na','co.za','co','co.th','com.nl','co.ug','co.nz','es','se','nl','ch','at','dk','be','pl','fi','ie','pt','gr', 'com.tw', 'com', 'co.uk', 'de', 'ca', 'co.kr', 'com.mx', 'co.za']\n\t random_domain = random.choice(domains)\n\t url = f'https://www.google.{random_domain}/search?q={query}&num=100'\n\t headers = {\n\t 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36',\n\t 'accept-language': 'zh-CN,zh;q=0.9',\n\t 'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.7',\n\t 'referer': 'https://www.google.com/',\n\t 'origin': 'https://www.google.com',\n\t 'Sec-Fetch-Site': 'same-origin',\n\t 'Sec-Fetch-Mode': 'navigate',\n\t 'Sec-Fetch-User': '?1',\n\t 'Sec-Fetch-Dest': 'document'\n\t }\n\t proxies = {'http': 'http://127.0.0.1:7890', 'https': 'http://127.0.0.1:7890'}\n\t response = requests.get(url=url, headers=headers, proxies=proxies, verify=False, timeout=10)\n\t soup = BeautifulSoup(response.content, 'html.parser')\n\t find_div = soup.find_all('div', {'class': 'yuRUbf'})\n\t urls = [url.findNext('a')['href'] + '\n' for url in find_div if 'google.com' not in url.findNext('a')['href']]\n\t write_urls(filename, urls)\n\t return len(urls)\n\texcept Exception as e:\n\t print(Fore.RED + f'{now_time}[Error]{"-" * 10}>{e}' + Fore.RESET)\n\t return 0\n\ndef write_urls(filename, urls):\n\twith open(filename, mode='a+', encoding='utf-8') as file:\n\t file.writelines(urls)\n\nif name == 'main':\n\twhile True:\n\t try:\n\t init()\n\t dorks_file = input(Fore.YELLOW + f'\n{now_time}[INFO]{"-" * 10}>input file:' + Fore.RESET)\n\t filename = input(Fore.YELLOW + f'\n{now_time}[INFO]{"-" * 10}>output file:' + Fore.RESET)\n\t dork_total_num, query_list = read_dorks(dorks_file)\n\t dork_finish_num = url_num = 0\n\t with ThreadPoolExecutor(max_workers=20) as executor:\n\t for i, query in enumerate(query_list):\n\t future = executor.submit(google_search, query, filename)\n\t url_count = future.result()\n\t url_num += url_count\n\t dork_finish_num += 1\n\t print(Fore.GREEN + f'\r{now_time}[INFO]{"-" * 10}>get Urlnumber:{url_num} Dorsk number:{dork_finish_num} / {dork_total_num}', end='' + Fore.RESET)\n\t input(Fore.YELLOW + f'\n\n{now_time}[INFO]{"-" * 10}>final huiche' + Fore.RESET)\n\t break\n\t except FileNotFoundError:\n\t print(Fore.RED + f'{now_time}[Error]{"-" * 10}>file not found' + Fore.RESET)\n\t except KeyboardInterrupt:\n\t sys.exit(1)\n


原文地址: https://www.cveoy.top/t/topic/pqQV 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录