diff --git a/.gitignore b/.gitignore index 78dd485..37d6385 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ log/ geckodriver.log *.pyc .idea/ -bin/ \ No newline at end of file +bin/executed \ No newline at end of file diff --git a/bin/__init__.py b/bin/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bin/executed b/bin/executed new file mode 100644 index 0000000..5a03bd3 --- /dev/null +++ b/bin/executed @@ -0,0 +1 @@ +FALSE \ No newline at end of file diff --git a/bin/geckodriver-v0.18.0-linux32.tar.gz b/bin/geckodriver-v0.18.0-linux32.tar.gz new file mode 100644 index 0000000..063e5a2 Binary files /dev/null and b/bin/geckodriver-v0.18.0-linux32.tar.gz differ diff --git a/bin/geckodriver-v0.18.0-linux64.tar.gz b/bin/geckodriver-v0.18.0-linux64.tar.gz new file mode 100644 index 0000000..0f08ad6 Binary files /dev/null and b/bin/geckodriver-v0.18.0-linux64.tar.gz differ diff --git a/bin/unzip_gecko.py b/bin/unzip_gecko.py new file mode 100644 index 0000000..d0caaf1 --- /dev/null +++ b/bin/unzip_gecko.py @@ -0,0 +1,84 @@ +import os +import platform +import tarfile + +import whichcraft + +import lib.settings + + +def check_if_run(file_check="{}/bin/executed"): + """ + check if the application has been run before by reading the executed file + """ + with open(file_check.format(os.getcwd())) as exc: + if "FALSE" in exc.read(): + return True + return False + + +def untar_gecko(filename="{}/bin/geckodriver-v0.18.0-linux{}.tar.gz", verbose=False): + """ + untar the correct gecko driver for your computer architecture + """ + arch_info = {"64bit": "64", "32bit": "32"} + file_arch = arch_info[platform.architecture()[0]] + tar = tarfile.open(filename.format(os.getcwd(), file_arch), "r:gz") + if verbose: + lib.settings.logger.debug(lib.settings.set_color( + "extracting the correct driver for your architecture...", level=10 + )) + try: + tar.extractall("/usr/bin") + if verbose: + lib.settings.logger.debug(lib.settings.set_color( + "driver extracted into /usr/bin (you may change this, but ensure that it " + "is in your PATH)...", level=10 + )) + except Exception as e: + if "[Errno 13] Permission denied: '/usr/bin/geckodriver'" in str(e): + lib.settings.logger.exception(lib.settings.set_color( + "first run must be ran as root (sudo python zeus.py)...", level=50 + )) + else: + lib.settings.logger.exception(lib.settings.set_color( + "ran into exception '{}', logged to current log file...".format(e), level=50 + )) + exit(-1) + tar.close() + + +def ensure_placed(item="geckodriver", verbose=False): + """ + use whichcraft to ensure that the driver has been placed in your PATH variable + """ + if verbose: + lib.settings.logger.debug(lib.settings.set_color( + "ensuring that the driver exists in your system path...", level=10 + )) + if not whichcraft.which(item): + lib.settings.logger.fatal(lib.settings.set_color( + "the executable '{}' does not appear to be in your /usr/bin PATH. " + "please untar the correct geckodriver (if not already done) and move " + "it to /usr/bin.".format(item), level=50 + )) + exit(-1) + else: + if verbose: + lib.settings.logger.debug(lib.settings.set_color( + "driver exists, continuing...", level=10 + )) + return True + + +def main(rewrite="{}/bin/executed", verbose=False): + """ + main method + """ + if check_if_run(): + untar_gecko(verbose=verbose) + if ensure_placed(verbose=verbose): + with open(rewrite.format(os.getcwd()), "w") as rw: + rw.write("TRUE") + else: + pass diff --git a/zeus.py b/zeus.py index 6f1259e..e9ec660 100644 --- a/zeus.py +++ b/zeus.py @@ -24,6 +24,7 @@ from lib.settings import ( AUTHORIZED_SEARCH_ENGINES, URL_LOG_PATH, replace_http, + prompt ) if __name__ == "__main__": @@ -80,6 +81,8 @@ if __name__ == "__main__": help="Start searching for sqlmap in this given path") misc.add_option("--show", dest="showSqlmapArguments", action="store_true", help="Show the arguments that the sqlmap API understands") + misc.add_option("--batch", dest="runInBatch", action="store_true", + help="Skip the questions and run in default batch mode") parser.add_option_group(mandatory) parser.add_option_group(attacks) @@ -201,6 +204,32 @@ if __name__ == "__main__": )) return retval + def __run_attacks(url, sqlmap=False, verbose=False, nmap=False, given_path=None, auto=False, batch=False): + """ + run the attacks if any are requested + """ + if not batch: + question = prompt( + "would you like to process found URL: '{}'".format(url), opts=["y", "N"] + ) + else: + question = "y" + + if question.lower().startswith("y"): + if sqlmap: + return sqlmap_scan.sqlmap_scan_main(url.strip(), verbose=verbose, opts=__create_sqlmap_arguments(), + auto_search=auto, given_path=given_path) + elif nmap: + url_ip_address = replace_http(url.strip()) + return nmap_scan.perform_port_scan(url_ip_address, verbose=verbose) + else: + pass + else: + logger.warning(set_color( + "skipping '{}'...".format(url) + )) + + proxy_to_use, agent_to_use = __config_headers() search_engine = __config_search_engine(verbose=opt.runInVerbose) @@ -221,16 +250,12 @@ if __name__ == "__main__": pass urls_to_use = get_latest_log_file(URL_LOG_PATH) - with open(urls_to_use) as urls: - for url in urls.readlines(): - if opt.runSqliScan: - sqlmap_scan.sqlmap_scan_main(url.strip(), verbose=opt.runInVerbose, - opts=__create_sqlmap_arguments(), - auto_search=opt.autoStartSqlmap, - given_path=opt.givenSearchPath) - elif opt.runPortScan: - url_to_use = replace_http(url.strip()) - nmap_scan.perform_port_scan(url_to_use, verbose=opt.runInVerbose) + if opt.runSqliScan or opt.runPortScan: + with open(urls_to_use) as urls: + for url in urls.readlines(): + __run_attacks(url.strip(), sqlmap=opt.runSqliScan, nmap=opt.runPortScan, + given_path=opt.givenSearchPath, auto=opt.autoStartSqlmap, + batch=opt.runInBatch) elif opt.dorkFileToUse is not None: with open(opt.dorkFileToUse) as dorks: @@ -251,16 +276,12 @@ if __name__ == "__main__": pass urls_to_use = get_latest_log_file(URL_LOG_PATH) - with open(urls_to_use) as urls: - for url in urls.readlines(): - if opt.runSqliScan: - sqlmap_scan.sqlmap_scan_main(url.strip(), verbose=opt.runInVerbose, - opts=__create_sqlmap_arguments(), - auto_search=opt.autoStartSqlmap, - given_path=opt.givenSearchPath) - elif opt.runPortScan: - url_to_use = replace_http(url.strip()) - nmap_scan.perform_port_scan(url_to_use, verbose=opt.runInVerbose) + if opt.runSqliScan or opt.runPortScan: + with open(urls_to_use) as urls: + for url in urls.readlines(): + __run_attacks(url.strip(), sqlmap=opt.runSqliScan, nmap=opt.runPortScan, + given_path=opt.givenSearchPath, auto=opt.autoStartSqlmap, + batch=opt.runInBatch) else: logger.critical(set_color( "failed to provide a mandatory argument, you will be redirected to the help menu...", level=50