From 1eb861ae16d40c387bd010f27640f1dc189c96d9 Mon Sep 17 00:00:00 2001 From: ekultek Date: Sat, 11 Nov 2017 16:30:03 -0600 Subject: [PATCH] patch for a reported issue (private) where if there are no URL's left it will keep going until it hits the max page, will now stop --- etc/checksum/md5sum.md5 | 4 ++-- lib/core/settings.py | 5 ++++- var/google_search/search.py | 27 +++++++++++++++++---------- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/etc/checksum/md5sum.md5 b/etc/checksum/md5sum.md5 index 416d42a..ccf4ea0 100644 --- a/etc/checksum/md5sum.md5 +++ b/etc/checksum/md5sum.md5 @@ -50,10 +50,10 @@ d8fab18b15d1546f6585fe926c27868f ./lib/attacks/whois_lookup/whois.py 21faf4679cdeaa731029a48f8963d6e7 ./lib/attacks/nmap_scan/nmap_opts.py 1faa2b5dfad6eb538bbfe42942d2a9da ./lib/core/errors.py d41d8cd98f00b204e9800998ecf8427e ./lib/core/__init__.py -7dfba7fabe755c6d9946097b41426458 ./lib/core/settings.py +3dbc63c72d9e6b75630899561f333ab4 ./lib/core/settings.py ad6622a5170e4ec74b5172f12ddcba9f ./lib/header_check/__init__.py d41d8cd98f00b204e9800998ecf8427e ./var/google_search/__init__.py -049b8a1cc93dc44b12dd93efdf785412 ./var/google_search/search.py +670fb7fa0c618ce9712e0f73f7752925 ./var/google_search/search.py d41d8cd98f00b204e9800998ecf8427e ./var/__init__.py d41d8cd98f00b204e9800998ecf8427e ./var/auto_issue/__init__.py dadca85c232153021ba9ff253d8ee1d9 ./var/auto_issue/github.py diff --git a/lib/core/settings.py b/lib/core/settings.py index ccc2fb2..ecdd920 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -52,7 +52,7 @@ PATCH_ID = str(subprocess.check_output(["git", "rev-parse", "origin/master"]))[: CLONE = "https://github.com/ekultek/zeus-scanner.git" # current version -VERSION = "1.2.6".format(PATCH_ID) +VERSION = "1.2.7.{}".format(PATCH_ID) # colors to output depending on the version VERSION_TYPE_COLORS = {"dev": 33, "stable": 92, "other": 30} @@ -177,6 +177,9 @@ URL_QUERY_REGEX = re.compile(r"(.*)[?|#](.*){1}\=(.*)") # regex to recognize a URL URL_REGEX = re.compile(r"((https?):((//)|(\\\\))+([\w\d:#@%/;$()~_?\+-=\\\.&](#!)?)*)") +# regex to discover if there are any results on the page +NO_RESULTS_REGEX = re.compile("did not match with any results.", re.IGNORECASE) + # search engines that the application can use AUTHORIZED_SEARCH_ENGINES = { "aol": "http://aol.com", diff --git a/var/google_search/search.py b/var/google_search/search.py index 15c329f..a9f09b7 100644 --- a/var/google_search/search.py +++ b/var/google_search/search.py @@ -43,7 +43,8 @@ from lib.core.settings import ( create_random_ip, rewrite_all_paths, AUTHORIZED_SEARCH_ENGINES, - MAX_PAGE_NUMBER + MAX_PAGE_NUMBER, + NO_RESULTS_REGEX ) try: @@ -588,17 +589,23 @@ def search_multiple_pages(query, link_amount, verbose=False, **kwargs): if page_request.status_code == 200: html_page = page_request.content soup = BeautifulSoup(html_page, "html.parser") - for link in soup.findAll(attrib): - redirect = link.get(desc) - if redirect is not None: - if not any(ex in redirect for ex in URL_EXCLUDES): - if URL_REGEX.match(redirect): - retval.add(redirect) - if page_number < MAX_PAGE_NUMBER: - page_number += 1 + if not NO_RESULTS_REGEX.findall(str(soup)): + for link in soup.findAll(attrib): + redirect = link.get(desc) + if redirect is not None: + if not any(ex in redirect for ex in URL_EXCLUDES): + if URL_REGEX.match(redirect): + retval.add(redirect) + if page_number < MAX_PAGE_NUMBER: + page_number += 1 + else: + logger.warning(set_color( + "hit max page number {}...".format(MAX_PAGE_NUMBER), level=30 + )) + break else: logger.warning(set_color( - "hit max page number {}...".format(MAX_PAGE_NUMBER), level=30 + "no more results found for given query '{}'...".format(query), level=30 )) break except KeyboardInterrupt: