From 526807c7ff64b7b59823a748eaf4d2f0964f0a9b Mon Sep 17 00:00:00 2001 From: ekultek Date: Tue, 26 Sep 2017 18:20:43 -0500 Subject: [PATCH] basic implement of Google IP bypass done (more work to be done) --- lib/settings.py | 14 +++++++++++-- var/google_search/search.py | 40 +++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/lib/settings.py b/lib/settings.py index 287dea5..2747c42 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.18" +VERSION = "1.0.18.94c6" # colors to output depending on the version VERSION_TYPE_COLORS = {"dev": 33, "stable": 92, "other": 30} # version string formatting @@ -380,4 +380,14 @@ def create_tree(start, conns, down="|", over="-", sep="-" * 40): down, over, con ) ) - print(sep) \ No newline at end of file + print(sep) + + +def add_https(url): + """ + add https:// to a url + """ + if "https://" in url: + return url + else: + return "https://{}".format(url.split("://")[-1]) \ No newline at end of file diff --git a/var/google_search/search.py b/var/google_search/search.py index f1cdbc0..a5c0a36 100644 --- a/var/google_search/search.py +++ b/var/google_search/search.py @@ -1,4 +1,5 @@ import os +import re import time import urllib @@ -17,9 +18,33 @@ from lib.settings import ( URL_REGEX, shutdown, create_dir, + add_https ) +def bypass_ip_block(url, content_sep=("continue=", "Fid", "%")): + """ + bypass Google's IP blocking by extracting the true URL from the ban URL. + """ + if isinstance(url, unicode): + url = str(url) + index_list = [] + index_list_2 = [] + if content_sep[0] in url: + data_list = url.split(content_sep[0]) + url_to_use = data_list[1] + else: + url_to_use = url + + for m in re.finditer(content_sep[1], url_to_use): + index_list.append((m.start(), m.end())) + splice_to_use = index_list[-1][-1] + + for m2 in re.finditer(content_sep[2], url[0:splice_to_use]): + index_list_2.append((m2.start(), m2.end())) + return add_https(url[0:index_list_2[-1][-1] - 1]) + + 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 @@ -93,6 +118,21 @@ def get_urls(query, url, verbose=False, warning=True, user_agent=None, proxy=Non "obtaining URL from selenium..." )) retval = browser.current_url + if "http://ipv6.google.com" or "http://ipv4.google.com" in retval: + logger.warning(set_color( + "it appears that Google is attempting to block your IP address, attempting bypass...", level=30 + )) + try: + retval = bypass_ip_block(retval) + except IndexError: + logger.warning(set_color( + "for now the IP ban bypass will only work for queries that have Google's search syntax " + "in them. (IE inurl:, incontext:, incontent:)" + )) + raise NotImplementedError( + "bypass for query '{}' is not implemented yet, try again with a different dork, " + "or change your IP address...".format(query) + ) if verbose: logger.debug(set_color( "found current URL from selenium browser '{}'...".format(retval), level=10