From 92baed3a9f9e19c3353f9001cc06ae71545c087a Mon Sep 17 00:00:00 2001 From: ekultek Date: Fri, 8 Sep 2017 10:12:24 -0500 Subject: [PATCH] edited the get_urls function to obfuscate user-agent changes --- lib/settings.py | 2 +- var/google_search/search.py | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/settings.py b/lib/settings.py index 36e797f..2f899b9 100644 --- a/lib/settings.py +++ b/lib/settings.py @@ -17,7 +17,7 @@ import bin.unzip_gecko # clone link CLONE = "https://github.com/ekultek/zeus-scanner.git" # current version -VERSION = "1.0.1" +VERSION = "1.0.2.e25" # colors to output depending on the version VERSION_TYPE_COLORS = {"dev": 33, "stable": 92, "other": 30} # version string formatting diff --git a/var/google_search/search.py b/var/google_search/search.py index 827e7eb..4327962 100644 --- a/var/google_search/search.py +++ b/var/google_search/search.py @@ -19,7 +19,7 @@ from lib.settings import ( ) -def get_urls(query, url, verbose=False, warning=True, **kwargs): +def get_urls(query, url, verbose=False, warning=True, user_agent=None, proxy=None, **kwargs): """ Bypass Google captchas and Google API by using selenium-webdriver to gather the Google URL. This will open a robot controlled browser window and attempt @@ -51,7 +51,18 @@ def get_urls(query, url, verbose=False, warning=True, **kwargs): logger.debug(set_color( "running selenium-webdriver and launching browser..", level=10 )) - browser = webdriver.Firefox() + + if user_agent is not None: + if verbose: + logger.debug(set_color( + "adjusting user-agent to '{}'...".format(user_agent) + )) + profile = webdriver.FirefoxProfile() + profile.set_preference("general.useragent.override", user_agent) + browser = webdriver.Firefox(profile) + else: + browser = webdriver.Firefox() + logger.info(set_color("browser will open shortly..")) browser.get(url) if verbose: @@ -138,7 +149,7 @@ def parse_search_results( "attempting to gather query URL..." )) try: - query_url = get_urls(query, url, verbose=verbose) + query_url = get_urls(query, url, verbose=verbose, user_agent=user_agent) except Exception as e: if "WebDriverException" in str(e): logger.exception(set_color(