diff --git a/lib/attacks/admin_panel_finder/__init__.py b/lib/attacks/admin_panel_finder/__init__.py index c8344e6..16864b5 100644 --- a/lib/attacks/admin_panel_finder/__init__.py +++ b/lib/attacks/admin_panel_finder/__init__.py @@ -135,7 +135,7 @@ def check_for_admin_page(url, exts, protocol="http://", **kwargs): def __load_extensions(filename="{}/etc/link_ext.txt"): """ - load the extenstions to use from the etc/link_ext file + load the extensions to use from the etc/link_ext file """ with open(filename.format(os.getcwd())) as ext: return ext.readlines() diff --git a/lib/core/settings.py b/lib/core/settings.py index acc31fe..67d147a 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -16,14 +16,14 @@ import bin.unzip_gecko import lib.core.errors try: - raw_input # Python 2 + raw_input # Python 2 except NameError: raw_input = input # Python 3 # clone link CLONE = "https://github.com/ekultek/zeus-scanner.git" # current version -VERSION = "1.0.51" +VERSION = "1.0.52" # colors to output depending on the version VERSION_TYPE_COLORS = {"dev": 33, "stable": 92, "other": 30} # version string formatting @@ -122,7 +122,8 @@ URL_EXCLUDES = ( "www.google.com", "map.google.com", "mail.google.com", "drive.google.com", "news.google.com", "accounts.google.com", "books.google.com" ) -DBMS_ERRORS = { # regular expressions used for DBMS recognition based on error message response +# regular expressions used for DBMS recognition based on error message response +DBMS_ERRORS = { "MySQL": (r"SQL syntax.*MySQL", r"Warning.*mysql_.*", r"valid MySQL result", r"MySqlClient\."), "PostgreSQL": (r"PostgreSQL.*ERROR", r"Warning.*\Wpg_.*", r"valid PostgreSQL result", r"Npgsql\."), "Microsoft SQL Server": (r"Driver.* SQL[\-\_\ ]*Server", r"OLE DB.* SQL Server", @@ -151,6 +152,7 @@ def create_log_name(log_path="{}/log", filename="zeus-log-{}.log"): full_log_path = "{}/{}".format(log_path.format(os.getcwd()), filename.format(find_file_amount + 1)) return full_log_path + # console logger and file logger settings logger = logging.getLogger("zeus-log") logger.setLevel(logging.DEBUG) @@ -185,11 +187,11 @@ def set_color(org_string, level=None): set the console log color, this will kinda mess with the file log but whatever """ color_levels = { - 10: "\033[36m{}\033[0m", # DEBUG - 20: "\033[32m{}\033[0m", # INFO *default - 30: "\033[33m{}\033[0m", # WARNING - 40: "\033[31m{}\033[0m", # ERROR - 50: "\033[7;31;31m{}\033[0m" # FATAL/CRITICAL/EXCEPTION + 10: "\033[36m{}\033[0m", # DEBUG + 20: "\033[32m{}\033[0m", # INFO *default + 30: "\033[33m{}\033[0m", # WARNING + 40: "\033[31m{}\033[0m", # ERROR + 50: "\033[7;31;31m{}\033[0m" # FATAL/CRITICAL/EXCEPTION } if level is None: return color_levels[20].format(org_string) @@ -275,6 +277,7 @@ def replace_http(url): delete the queries from the URL """ return data.split("/")[0] + try: url_list = url.split("//") new_url = url_list[1] @@ -316,7 +319,7 @@ def prompt(question, opts=None): ) -def find_application(application, opt="path", verbose=False): +def find_application(application, opt="path"): """ find the given application on the users system by parsing the given configuration file """ @@ -382,12 +385,12 @@ def fix_log_file(logfile=get_latest_log_file(CURRENT_LOG_FILE_PATH)): retval = "" escape_seq_regex = re.compile("\033\[\d+[*m]") with open(logfile, "r+") as to_fix: - for line in to_fix.readlines(): - retval += escape_seq_regex.sub("", line) + for line in to_fix.readlines(): + retval += escape_seq_regex.sub("", line) open(logfile, "w").close() with open(logfile, "a+") as fixed: - for line in retval.split("\n"): - fixed.write(line + "\n") + for line in retval.split("\n"): + fixed.write(line + "\n") def write_to_log_file(data_to_write, path, filename): @@ -449,4 +452,34 @@ def get_browser_version(): "failed to parse '{}' for version number...".format(output), level=50 )) return "failed to gather" - return major, minor \ No newline at end of file + return major, minor + + +def config_headers(**kwargs): + """ + configure the request headers, this will configure user agents and proxies + """ + proxy = kwargs.get("proxy", None) + rand_proxy = kwargs.get("proxy_file", None) + personal_agent = kwargs.get("p_agent", None) + rand_agent = kwargs.get("rand_agent", None) + verbose = kwargs.get("verbose", False) + if proxy is not None: + proxy_retval = proxy + elif rand_proxy is not None: + if verbose: + logger.debug(set_color( + "loading random proxy from '{}'...".format(rand_proxy), level=10 + )) + with open(rand_proxy) as proxies: + possible = proxies.readlines() + proxy_retval = random.choice(possible).strip() + else: + proxy_retval = None + if personal_agent is not None: + agent = personal_agent + elif rand_agent: + agent = grab_random_agent(verbose=verbose) + else: + agent = DEFAULT_USER_AGENT + return proxy_retval, agent diff --git a/var/google_search/search.py b/var/google_search/search.py index 1a68112..f862d83 100644 --- a/var/google_search/search.py +++ b/var/google_search/search.py @@ -1,6 +1,7 @@ import os import re import time +import subprocess try: from urllib import ( unquote, @@ -36,7 +37,8 @@ from lib.core.settings import ( get_proxy_type, prompt, EXTRACTED_URL_LOG, - URL_EXCLUDES + URL_EXCLUDES, + CLEANUP_TOOL_PATH ) try: @@ -178,8 +180,8 @@ def get_urls(query, url, verbose=False, warning=True, **kwargs): if not str(do_continue).lower().startswith("n"): # shutdown and write the URL to a file write_to_log_file(retval, EXTRACTED_URL_LOG, "extracted-url-{}.log") logger.info(set_color( - "it is advised to use the built in blackwidow crawler with the extracted URL " - "(IE -b '{}')".format(retval) + "it is advised to extract the URL's from the produced URL written to the above " + "(IE open the log, copy the url into firefox)...".format(retval) )) shutdown() except Exception as e: @@ -251,6 +253,28 @@ def parse_search_results( "check your installation and make sure it is in /usr/lib, if you " "find it there, restart your system and try again...", level=50 )) + elif "connection refused" in str(e): + logger.fatal(set_color( + "there are to many sessions of firefox opened and selenium cannot " + "create a new one...", level=50 + )) + do_autoclean = prompt( + "would you like to attempt to auto clean the open sessions", opts="yN" + ) + if do_autoclean.lower().startswith("y"): + logger.warning(set_color( + "this will kill all instances of the firefox web browser...", level=30 + )) + subprocess.call(["sudo", "sh", CLEANUP_TOOL_PATH]) + logger.info(set_color( + "all open sessions of firefox killed, it should be safe to re-run " + "Zeus..." + )) + else: + logger.warning(set_color( + "kill off the open sessions of firefox and re-run Zeus...", level=30 + )) + shutdown() else: logger.exception(set_color( "{} failed to gather the URL from search engine, caught exception '{}' " @@ -386,4 +410,4 @@ def search_multiple_pages(query, link_amount, verbose=False, **kwargs): else: logger.error(set_color( "unable to extract URL's from results...", level=40 - )) + )) \ No newline at end of file diff --git a/zeus.py b/zeus.py index 8bfc7fb..90fb6a9 100755 --- a/zeus.py +++ b/zeus.py @@ -2,7 +2,6 @@ import optparse import os -import random import subprocess import time @@ -10,7 +9,6 @@ try: import http.client as http_client # Python 3 except ImportError: import httplib as http_client # Python 2 -from selenium.webdriver.remote.errorhandler import WebDriverException from var import blackwidow from var.google_search import search @@ -34,7 +32,6 @@ from lib.core.settings import ( logger, set_color, get_latest_log_file, - grab_random_agent, CURRENT_LOG_FILE_PATH, AUTHORIZED_SEARCH_ENGINES, URL_LOG_PATH, @@ -48,10 +45,9 @@ from lib.core.settings import ( SQLMAP_MAN_PAGE_URL, get_true_url, fix_log_file, - DEFAULT_USER_AGENT, SPIDER_LOG_PATH, - CLEANUP_TOOL_PATH, - FIX_PROGRAM_INSTALL_PATH + FIX_PROGRAM_INSTALL_PATH, + config_headers ) if __name__ == "__main__": @@ -258,31 +254,6 @@ if __name__ == "__main__": )) - def __config_headers(): - """ - configure the request headers, this will configure user agents and proxies - """ - if opt.proxyConfig is not None: - proxy = opt.proxyConfig - elif opt.proxyFileRand is not None: - if opt.runInVerbose: - logger.debug(set_color( - "loading random proxy from '{}'...".format(opt.proxyFileRand), level=10 - )) - with open(opt.proxyFileRand) as proxies: - possible = proxies.readlines() - proxy = random.choice(possible).strip() - else: - proxy = None - if opt.usePersonalAgent is not None: - agent = opt.usePersonalAgent - elif opt.useRandomAgent: - agent = grab_random_agent(verbose=opt.runInVerbose) - else: - agent = DEFAULT_USER_AGENT - return proxy, agent - - def __config_search_engine(verbose=False): """ configure the search engine if a one different from google is given @@ -493,7 +464,11 @@ if __name__ == "__main__": ) - proxy_to_use, agent_to_use = __config_headers() + proxy_to_use, agent_to_use = config_headers( + proxy=opt.proxyConfig, proxy_file=opt.proxyFileRand, + p_agent=opt.usePersonalAgent, rand_agent=opt.useRandomAgent, + verbose=opt.runInVerbose + ) search_engine = __config_search_engine(verbose=opt.runInVerbose) try: @@ -654,40 +629,6 @@ if __name__ == "__main__": "do not interrupt the browser when selenium is running, " "it will cause Zeus to crash...", level=30 )) - except WebDriverException as e: - if "connection refused" in str(e): - logger.fatal(set_color( - "there are to many sessions of firefox opened and selenium cannot " - "create a new one...", level=50 - )) - do_autoclean = prompt( - "would you like to attempt auto clean", opts="yN" - ) - if do_autoclean.lower().startswith("y"): - logger.warning(set_color( - "this will kill all instances of the firefox web browser...", level=30 - )) - subprocess.call(["sudo", "sh", CLEANUP_TOOL_PATH]) - logger.info(set_color( - "all open sessions of firefox killed, it should be safe to re-run " - "Zeus..." - )) - elif "Service geckodriver unexpectedly exited" in str(e): - logger.fatal(set_color( - "it seems that your firefox version is not compatible with the geckodriver " - "version. please update firefox and try again...", level=50 - )) - else: - logger.info(set_color( - "kill off the open sessions of firefox and re-run Zeus..." - )) - shutdown() - else: - logger.exception(set_color( - "Zeus has run into an unexpected error from selenium webdriver and cannot continue " - "error info '{}'...".format(str(e)) - )) - request_issue_creation() except Exception as e: if "url did not match a true url" in str(e).lower(): logger.error(set_color( @@ -697,6 +638,12 @@ if __name__ == "__main__": "fix the URL you want to scan and try again...", level=40 )) shutdown() + elif "Service geckodriver unexpectedly exited" in str(e): + logger.fatal(set_color( + "it seems that your firefox version is not compatible with the geckodriver " + "version. please update firefox and try again...", level=50 + )) + shutdown() elif "Max retries exceeded with url" in str(e): logger.fatal(set_color( "you have hit the max retries, to continue using Zeus "