diff --git a/etc/checksum/md5sum.md5 b/etc/checksum/md5sum.md5 index b7dd38f..6de3f79 100644 --- a/etc/checksum/md5sum.md5 +++ b/etc/checksum/md5sum.md5 @@ -70,17 +70,17 @@ d41d8cd98f00b204e9800998ecf8427e ./lib/attacks/__init__.py d2846e039fefee741db24dd64f7bd50e ./lib/attacks/whois_lookup/whois.py d2846e039fefee741db24dd64f7bd50e ./lib/attacks/admin_panel_finder/__init__.py b5cd5e913cc62112776153bdf0f60fa4 ./lib/attacks/xss_scan/__init__.py -63c45495ec1ed2e98946bef514d8805e ./lib/attacks/nmap_scan/__init__.py +353dc2653372e78962bd0398df9a2f5f ./lib/attacks/nmap_scan/__init__.py 216999fa0e84866d5c1d96d5676034e4 ./lib/attacks/nmap_scan/nmap_opts.py 6f5d4adc7777b6696d4b290367364a38 ./lib/header_check/__init__.py -777fef12812b6363a21b244f775dced1 ./lib/core/common.py +39221756c132732dbdc2b14772dcab11 ./lib/core/common.py 1faa2b5dfad6eb538bbfe42942d2a9da ./lib/core/errors.py d41d8cd98f00b204e9800998ecf8427e ./lib/core/__init__.py -c7ef2ee7fa1280432e21b9c90c542b58 ./lib/core/settings.py +571cc38c0e47f4395d34a749e92d42a7 ./lib/core/settings.py 4b507b34677b414b8338475fea2c012a ./lib/core/cache.py 9a02e5b913d210350545ac26510a63c9 ./var/search/__init__.py -1c11255dbb09c0889dd0aa739a437f95 ./var/search/selenium_search.py -63ba132381a0cc2d7629852bd5e4aa17 ./var/search/pgp_search.py +0545ee54ade186681b25d157fb32f350 ./var/search/selenium_search.py +8f8a7e791f91f0ef3544f2ed8364ab56 ./var/search/pgp_search.py d41d8cd98f00b204e9800998ecf8427e ./var/__init__.py d41d8cd98f00b204e9800998ecf8427e ./var/auto_issue/__init__.py 0c11c16126baf789388a661bbbefb149 ./var/auto_issue/github.py diff --git a/lib/attacks/nmap_scan/__init__.py b/lib/attacks/nmap_scan/__init__.py index 2e92fee..cecea75 100644 --- a/lib/attacks/nmap_scan/__init__.py +++ b/lib/attacks/nmap_scan/__init__.py @@ -1,7 +1,5 @@ import json import socket -import shlex -import subprocess import nmap @@ -140,17 +138,8 @@ def perform_port_scan(url, scanner=NmapHook, **kwargs): lib.core.settings.logger.fatal(lib.core.settings.set_color( "nmap was not found on your system...", level=50 )) - question = lib.core.common.prompt( - "would you like to automatically install it", opts="yN" + lib.core.common.run_fix( + "would you like to automatically install it", + "sudo sh {}".format(lib.core.settings.NMAP_INSTALLER_TOOL), + "nmap is not installed, please install it in order to continue..." ) - if question.lower().startswith("y"): - install_nmap_command = shlex.split("sudo sh {}".format(lib.core.settings.NMAP_INSTALLER_TOOL)) - subprocess.call(install_nmap_command) - lib.core.settings.logger.info(lib.core.settings.set_color( - "nmap has been successfully installed, re-running...", level=25 - )) - perform_port_scan(url, verbose=verbose, opts=opts) - else: - lib.core.settings.logger.fatal(lib.core.settings.set_color( - "nmap is not installed, please install it in order to continue...", level=50 - )) diff --git a/lib/core/common.py b/lib/core/common.py index d8dd1b1..95dccc4 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -2,6 +2,8 @@ import os import re import json import time +import shlex +import subprocess try: from urllib import ( # python 2 unquote @@ -244,3 +246,23 @@ def pause(): return prompt( message, paused=True ) + + +def run_fix(message, command, fail_message, exit_process=False): + """ + run the fix script for the program + """ + do_fix = prompt( + message, opts="yN" + ) + if do_fix.lower().startswith("y"): + cmd = shlex.split(command) + subprocess.call(cmd) + if exit_process: + lib.core.settings.logger.info(lib.core.settings.set_color( + "command completed successfully, should be safe to re-run Zeus..." + )) + else: + lib.core.settings.logger.fatal(lib.core.settings.set_color( + fail_message, level=50 + )) diff --git a/lib/core/settings.py b/lib/core/settings.py index 7ac1761..71f5703 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -46,7 +46,7 @@ CLONE = "https://github.com/ekultek/zeus-scanner.git" ISSUE_LINK = "https://github.com/ekultek/zeus-scanner/issues" # current version -VERSION = "1.3.3".format(PATCH_ID) +VERSION = "1.3.4.{}".format(PATCH_ID) # colors to output depending on the version VERSION_TYPE_COLORS = {"dev": 33, "stable": 92, "other": 30} diff --git a/var/search/pgp_search.py b/var/search/pgp_search.py index c8e3563..927cf19 100644 --- a/var/search/pgp_search.py +++ b/var/search/pgp_search.py @@ -165,9 +165,9 @@ def pgp_main(query, verbose=False): html = obtain_html( lib.core.settings.AUTHORIZED_SEARCH_ENGINES["pgp"], query, agent=lib.core.settings.DEFAULT_USER_AGENT ) - except ReadTimeout: + except (Exception, ReadTimeout): lib.core.settings.logger.warning(lib.core.settings.set_color( - "connection timed out, assuming no PGP keys...", level=30 + "connection failed, assuming no PGP keys...", level=30 )) html = None if html is not None: diff --git a/var/search/selenium_search.py b/var/search/selenium_search.py index 91d4104..1c6f324 100644 --- a/var/search/selenium_search.py +++ b/var/search/selenium_search.py @@ -1,7 +1,5 @@ import os import time -import shlex -import subprocess try: from urllib import ( # python 2 @@ -29,7 +27,8 @@ from lib.core.common import ( HTTP_HEADER, URLParser, shutdown, - prompt + prompt, + run_fix ) from lib.core.settings import ( logger, @@ -271,49 +270,28 @@ def parse_search_results(query, url_to_search, verbose=False, **kwargs): "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): + elif "connection refused" in str(e).lower(): 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" + run_fix( + "would you like to attempt to auto clean the open sessions", + "sudo sh {}".format(CLEANUP_TOOL_PATH), + "kill off the open sessions of firefox and re-run Zeus...", + exit_process=True ) - if do_autoclean.lower().startswith("y"): - logger.warning(set_color( - "this will kill all instances of the firefox web browser...", level=30 - )) - auto_clean_command = shlex.split("sudo sh {}".format(CLEANUP_TOOL_PATH)) - subprocess.call(auto_clean_command) - 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() elif "Program install error!" in str(e): - do_fix = prompt( + logger.error(set_color( "seems the program is having some trouble installing would you like " - "to try and automatically fix this issue", opts="yN" + "to try and automatically fix this issue", level=40 + )) + run_fix( + "would you like to attempt to fix this issue automatically", + "sudo sh {}".format(FIX_PROGRAM_INSTALL_PATH), + "you can manually try and re-install Xvfb to fix the problem...", + exit_process=True ) - if do_fix.lower().startswith("y"): - logger.info(set_color( - "attempting to reinstall failing dependency..." - )) - do_fix_command = shlex.split("sudo sh {}".format(FIX_PROGRAM_INSTALL_PATH)) - subprocess.call(do_fix_command) - logger.info(set_color( - "successfully installed, you should be good to re-run Zeus..." - )) - shutdown() - else: - logger.info(set_color( - "you can automatically try and re-install Xvfb to fix the problem..." - )) - shutdown() elif "Message: Reached error page:" in str(e): logger.fatal(set_color( "geckodriver has hit an error that usually means it needs to be reinstalled...", level=50 @@ -338,20 +316,13 @@ def parse_search_results(query, url_to_search, verbose=False, **kwargs): logger.fatal(set_color( "it appears that firefox, selenium, and geckodriver are not playing nice with one another...", level=50 )) - question = prompt( - "would you like to attempt to resolve this issue automatically", opts="yN" + run_fix( + "would you like to attempt to resolve this issue automatically", + "sudo sh {}".format(REINSTALL_TOOL), + ("you will need to reinstall firefox to a later version, update selenium, and reinstall the " + "geckodriver to continue using Zeus..."), + exit_process=True ) - if question.lower().startswith("y"): - reinstall_command = shlex.split("sudo sh {}".format(REINSTALL_TOOL)) - subprocess.call(reinstall_command) - rewrite_all_paths() - shutdown() - else: - logger.fatal(set_color( - "you will need to reinstall firefox to a later version, update selenium, and reinstall the " - "geckodriver to continue using Zeus...", level=50 - )) - shutdown() else: logger.exception(set_color( "{} failed to gather the URL from search engine, caught exception '{}' "