From d4d6630f59aeb4908e22073303f9f12aa46dd300 Mon Sep 17 00:00:00 2001 From: ekultek Date: Sat, 11 Nov 2017 06:25:33 -0600 Subject: [PATCH] patches an error where if you are unable to retrieve the headers it will fail, will not just output that it is unable to retreive the headers (issue #141) --- etc/checksum/md5sum.md5 | 6 ++--- lib/core/settings.py | 26 ++++++++----------- lib/header_check/__init__.py | 48 ++++++++++++++++++++++++------------ zeus.py | 21 +++++----------- 4 files changed, 51 insertions(+), 50 deletions(-) diff --git a/etc/checksum/md5sum.md5 b/etc/checksum/md5sum.md5 index 2bd4409..462e1b3 100644 --- a/etc/checksum/md5sum.md5 +++ b/etc/checksum/md5sum.md5 @@ -1,4 +1,4 @@ -8bccb97e08a1bcc4790c51db3d499aa3 ./zeus.py +9726a4e665a6a26574cac4499129c924 ./zeus.py 4b32db388e8acda35570c734d27c950c ./etc/scripts/launch_sqlmap.sh 6ad5f22ec4a6f8324bfb1b01ab6d51ec ./etc/scripts/cleanup.sh 155c9482f690f1482f324a7ffd8b8098 ./etc/scripts/fix_pie.sh @@ -50,8 +50,8 @@ b1c3413ca94bb98be64e1ebfedf156ae ./lib/attacks/xss_scan/__init__.py 21faf4679cdeaa731029a48f8963d6e7 ./lib/attacks/nmap_scan/nmap_opts.py 1faa2b5dfad6eb538bbfe42942d2a9da ./lib/core/errors.py d41d8cd98f00b204e9800998ecf8427e ./lib/core/__init__.py -c13c469a791a06ebab05c901f12102c6 ./lib/core/settings.py -f2ad9e0f0177484c2ab00bbd3ee52153 ./lib/header_check/__init__.py +26f86784a5c63bb4dfc3a3cc6b617be4 ./lib/core/settings.py +60d6f072cc80f08e9214131dc33fe63a ./lib/header_check/__init__.py d41d8cd98f00b204e9800998ecf8427e ./var/google_search/__init__.py a576adcbf0c7c4e7feca1016d632e53b ./var/google_search/search.py d41d8cd98f00b204e9800998ecf8427e ./var/__init__.py diff --git a/lib/core/settings.py b/lib/core/settings.py index dfc95a7..4d5c682 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -37,7 +37,6 @@ from lib.attacks.nmap_scan.nmap_opts import NMAP_API_OPTS from lib.attacks import ( nmap_scan, sqlmap_scan, - intel_me # TODO:/ completely remove ) try: @@ -53,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.2".format(PATCH_ID) +VERSION = "1.2.3.{}".format(PATCH_ID) # colors to output depending on the version VERSION_TYPE_COLORS = {"dev": 33, "stable": 92, "other": 30} @@ -821,13 +820,15 @@ def check_for_protection(protected, attack_type): """ check if the provided target URL has header protection against an attack type """ - items = [item.lower() for item in protected] - if attack_type in items or "all" in items: - protected.clear() # clear the set - logger.warning(set_color( - "provided target seems to have protection against this attack type...", level=30 - )) - return True + if protected is not None: + items = [item.lower() for item in protected] + + if attack_type in items or "all" in items: + protected.clear() # clear the set + logger.warning(set_color( + "provided target seems to have protection against this attack type...", level=30 + )) + return True def deprecation(target_version, method, connect=True, *args, **kwargs): @@ -865,7 +866,6 @@ def run_attacks(url, **kwargs): """ nmap = kwargs.get("nmap", False) sqlmap = kwargs.get("sqlmap", False) - intel = kwargs.get("intel", False) # TODO:/ completely remove xss = kwargs.get("xss", False) admin = kwargs.get("admin", False) verbose = kwargs.get("verbose", False) @@ -874,7 +874,6 @@ def run_attacks(url, **kwargs): auto_start = kwargs.get("auto_start", False) sqlmap_arguments = kwargs.get("sqlmap_args", None) nmap_arguments = kwargs.get("nmap_args", None) - run_ip_address = kwargs.get("run_ip", False) # TODO:/ completely remove show_all = kwargs.get("show_all", False) do_threading = kwargs.get("do_threading", False) batch = kwargs.get("batch", False) @@ -890,7 +889,6 @@ def run_attacks(url, **kwargs): "port": nmap, "xss": xss, "admin": admin, - "intel": intel, # TODO:/ completely remove "whois": whois, "clickjacking": clickjacking } @@ -930,10 +928,6 @@ def run_attacks(url, **kwargs): url_ip_address, verbose=verbose, opts=create_arguments(nmap=True, nmap_args=nmap_arguments) ) - elif intel: # TODO:/ completely remove - return deprecation( - "1.3", intel_me.main_intel_amt, connect=False - ) elif admin: main( url, show=show_all, diff --git a/lib/header_check/__init__.py b/lib/header_check/__init__.py index 5f8bc58..e321273 100644 --- a/lib/header_check/__init__.py +++ b/lib/header_check/__init__.py @@ -1,8 +1,8 @@ -import json - import requests from xml.dom import minidom +from requests.exceptions import ConnectionError +from var.auto_issue.github import request_issue_creation from lib.core.settings import ( logger, set_color, HEADER_XML_DATA, @@ -11,7 +11,7 @@ from lib.core.settings import ( write_to_log_file, HEADER_RESULT_PATH, replace_http, - PROTECTED + shutdown ) @@ -91,17 +91,33 @@ def main_header_check(url, **kwargs): logger.info(set_color( "attempting to get request headers for '{}'...".format(url.strip()) )) - found_headers = load_headers(url, proxy=proxy, agent=agent, xforward=xforward) - if verbose: - logger.debug(set_color( - "fetched {}...".format(found_headers), level=10 - )) - headers_established = [str(h) for h in compare_headers(found_headers, comparable_headers)] - for key in definition.iterkeys(): - if any(key in h.lower() for h in headers_established): - logger.warning(set_color( - "provided target has {}...".format(definition[key][0]), level=30 + try: + found_headers = load_headers(url, proxy=proxy, agent=agent, xforward=xforward) + except (ConnectionError, Exception) as e: + if "Max retries exceeded with url:" in str(e): + found_headers = None + else: + logger.exception(set_color( + "Zeus has hit an unexpected error and cannot continue '{}'...".format(e), level=50 )) - for key in found_headers.iterkeys(): - protection[key] = found_headers[key] - return write_to_log_file(protection, HEADER_RESULT_PATH, "{}-headers.json".format(replace_http(url))) + request_issue_creation() + shutdown() + + if found_headers is not None: + if verbose: + logger.debug(set_color( + "fetched {}...".format(found_headers), level=10 + )) + headers_established = [str(h) for h in compare_headers(found_headers, comparable_headers)] + for key in definition.iterkeys(): + if any(key in h.lower() for h in headers_established): + logger.warning(set_color( + "provided target has {}...".format(definition[key][0]), level=30 + )) + for key in found_headers.iterkeys(): + protection[key] = found_headers[key] + return write_to_log_file(protection, HEADER_RESULT_PATH, "{}-headers.json".format(replace_http(url))) + else: + logger.error(set_color( + "unable to retrieve headers for site '{}'...".format(url.strip()), level=40 + )) diff --git a/zeus.py b/zeus.py index 7388804..8554590 100755 --- a/zeus.py +++ b/zeus.py @@ -75,8 +75,6 @@ if __name__ == "__main__": help="Run a Sqlmap SQLi scan on the discovered URL's") attacks.add_option("-p", "--port-scan", dest="runPortScan", action="store_true", help="Run a Nmap port scan on the discovered URL's") - attacks.add_option("-i", "--intel-check", dest="intelCheck", action="store_true", - help=optparse.SUPPRESS_HELP) # TODO:/ completely remove attacks.add_option("-a", "--admin-panel", dest="adminPanelFinder", action="store_true", help="Search for the websites admin panel") attacks.add_option("-x", "--xss-scan", dest="runXssScan", action="store_true", @@ -101,8 +99,6 @@ if __name__ == "__main__": help="Show all connections made during the admin panel search") attacks.add_option("--tamper", dest="tamperXssPayloads", metavar="TAMPER-SCRIPT", help="Send the XSS payloads through tampering before sending to the target") - attacks.add_option("--run-ip-address", dest="runAgainstIpAddress", action="store_true", - help=optparse.SUPPRESS_HELP) # TODO:/ completely remove attacks.add_option("--thread", dest="threadPanels", action="store_true", help=optparse.SUPPRESS_HELP) attacks.add_option("--auto", dest="autoStartSqlmap", action="store_true", @@ -269,9 +265,8 @@ if __name__ == "__main__": shutdown() options = [ opt.runSqliScan, opt.runPortScan, - opt.intelCheck, opt.adminPanelFinder, - opt.runXssScan, opt.performWhoisLookup, - opt.performClickjackingScan + opt.adminPanelFinder, opt.runXssScan, + opt.performWhoisLookup, opt.performClickjackingScan ] if any(options): with open(urls_to_use) as urls: @@ -291,18 +286,14 @@ if __name__ == "__main__": run_attacks( url.strip(), sqlmap=opt.runSqliScan, nmap=opt.runPortScan, - intel=opt.intelCheck, # TODO:/ completely remove - xss=opt.runXssScan, - whois=opt.performWhoisLookup, admin=opt.adminPanelFinder, + xss=opt.runXssScan, whois=opt.performWhoisLookup, admin=opt.adminPanelFinder, clickjacking=opt.performClickjackingScan, verbose=opt.runInVerbose, batch=opt.runInBatch, auto_start=opt.autoStartSqlmap, xforward=opt.forwardedForRandomIP, sqlmap_args=opt.sqlmapArguments, nmap_args=opt.nmapArguments, - run_ip=opt.runAgainstIpAddress, # TODO:/ completely remove - show_all=opt.showAllConnections, - do_threading=opt.threadPanels, tamper_script=opt.tamperXssPayloads, - timeout=opt.controlTimeout, proxy=proxy_to_use, agent=agent_to_use, - conf_file=opt.sqlmapConfigFile + show_all=opt.showAllConnections, do_threading=opt.threadPanels, + tamper_script=opt.tamperXssPayloads, timeout=opt.controlTimeout, + proxy=proxy_to_use, agent=agent_to_use, conf_file=opt.sqlmapConfigFile )