From 3004ca55958396cd625ad77888ddfdb8d8cab05a Mon Sep 17 00:00:00 2001 From: ekultek Date: Wed, 4 Oct 2017 14:15:54 -0500 Subject: [PATCH] can now extract from google webcache URL's --- lib/settings.py | 2 +- var/google_search/search.py | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/settings.py b/lib/settings.py index af15b57..1b4e4f1 100644 --- a/lib/settings.py +++ b/lib/settings.py @@ -22,7 +22,7 @@ except NameError: # clone link CLONE = "https://github.com/ekultek/zeus-scanner.git" # current version -VERSION = "1.0.28.8fb0" +VERSION = "1.0.29" # 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 f5d5e4b..d003ded 100644 --- a/var/google_search/search.py +++ b/var/google_search/search.py @@ -67,6 +67,13 @@ def bypass_ip_block(url, content_sep=("continue=", "Fid", "%")): return __add_https(url[0:content_list_end[-1][-1] - 1]) +def extract_webcache_url(webcache_url, splitter=("%2Bext", ":")): + webcache_regex = re.compile(r"(?<=q=).*?(?=[&\"])") + data = "".join(webcache_regex.findall(webcache_url)) + to_extract = data.split(splitter[0])[0] + return "http:" + to_extract.split(splitter[1])[3] + + 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 @@ -172,7 +179,10 @@ def parse_search_results( """ Parse a webpage from Google for URL's with a GET(query) parameter """ - exclude = "google" or "webcache" or "youtube" + exclude = ( + "www.google.com", "map.google.com", "mail.google.com", "drive.google.com", + "news.google.com", "accounts.google.com" + ) splitter = "&" retval = set() query_url = None @@ -254,9 +264,14 @@ def parse_search_results( for urls in list(found_urls): for url in list(urls): url = unquote(url) - if URL_QUERY_REGEX.match(url) and exclude not in url: + if URL_QUERY_REGEX.match(url) and not any(l in url for l in exclude): if isinstance(url, unicode): url = str(url).encode("utf-8") + if "webcache" in url: + logger.info(set_color( + "received webcache URL, extracting URL from webcache..." + )) + url = extract_webcache_url(url) if verbose: try: logger.debug(set_color( @@ -266,6 +281,10 @@ def parse_search_results( logger.debug(set_color( "found '{}'...".format(str(url).split(splitter)[0]), level=10 )) + except AttributeError: + logger.debug(set_color( + "found '{}...".format(str(url)), level=10 + )) retval.add(url.split("&")[0]) logger.info(set_color( "found a total of {} URL's with a GET parameter...".format(len(retval))