From 9eca1950cb226bc8b88979826a09bafc02e95214 Mon Sep 17 00:00:00 2001 From: ekultek Date: Mon, 20 Nov 2017 14:04:11 -0600 Subject: [PATCH] created constants of all the log filenames, adjusted files accordingly --- etc/checksum/md5sum.md5 | 16 ++++----- lib/attacks/admin_panel_finder/__init__.py | 18 ++++++---- lib/attacks/clickjacking_scan/__init__.py | 2 +- lib/attacks/gist_lookup/__init__.py | 2 +- lib/attacks/whois_lookup/whois.py | 2 +- lib/core/settings.py | 40 +++++++++++++++++++++- lib/header_check/__init__.py | 19 ++++++---- var/blackwidow/__init__.py | 5 +-- var/google_search/search.py | 17 +++++---- 9 files changed, 87 insertions(+), 34 deletions(-) diff --git a/etc/checksum/md5sum.md5 b/etc/checksum/md5sum.md5 index c11ef74..b92fd4d 100644 --- a/etc/checksum/md5sum.md5 +++ b/etc/checksum/md5sum.md5 @@ -52,25 +52,25 @@ a0fedc86cfb4a370e6c1a606010812ed ./lib/tamper_scripts/space2null_encode.pyc 694231b4c2f99406481c34ced85ddfe1 ./lib/tamper_scripts/base64_encode.py 6ac38bec8c32eab57efa01f7a06dff14 ./lib/tamper_scripts/space2null_encode.py 3b8c95a6a3b7cecce5118f2fb1ccc6b8 ./lib/tamper_scripts/appendnull_encode.py -a39c2376b66ff3a2fa239c97a69e891f ./lib/attacks/clickjacking_scan/__init__.py +0357667b47ce0055ed345f9d43e7c74f ./lib/attacks/clickjacking_scan/__init__.py d41d8cd98f00b204e9800998ecf8427e ./lib/attacks/__init__.py 7272a7fd0b0c2e9192bc4adb6154d2f0 ./lib/attacks/sqlmap_scan/__init__.py aa7268a8f085734a6c577c86440f7a1b ./lib/attacks/sqlmap_scan/sqlmap_opts.py d41d8cd98f00b204e9800998ecf8427e ./lib/attacks/whois_lookup/__init__.py -ef5dc31f38028aa0d73258b36f0e36f9 ./lib/attacks/whois_lookup/whois.py -4c8cc6050796510f242539267292cfb2 ./lib/attacks/admin_panel_finder/__init__.py +8bce49d65071969243e98f01fc77dc35 ./lib/attacks/whois_lookup/whois.py +14503e7af9f6346f81788a07a94684e0 ./lib/attacks/admin_panel_finder/__init__.py edb971a085a2c3be9277def5a0f14d49 ./lib/attacks/xss_scan/__init__.py 27358f26bda30d7356143c3ea1fa99c5 ./lib/attacks/nmap_scan/__init__.py 21faf4679cdeaa731029a48f8963d6e7 ./lib/attacks/nmap_scan/nmap_opts.py -7eff376f860e72ff32094cd96d86a6a2 ./lib/attacks/gist_lookup/__init__.py +5abc7ca54977e9e0447305cb4bd48d9b ./lib/attacks/gist_lookup/__init__.py 1faa2b5dfad6eb538bbfe42942d2a9da ./lib/core/errors.py d41d8cd98f00b204e9800998ecf8427e ./lib/core/__init__.py -c631f2b8aec464b0a771f71bb6d1d137 ./lib/core/settings.py +60a6b8319c942c4c663e9144f092ddc5 ./lib/core/settings.py aa541bfde844b009227f664749a39ea8 ./lib/core/common.py -7198de0a126cca4b06c31b205e2a5e23 ./lib/header_check/__init__.py +1477efbe270c386057b0170faee4335f ./lib/header_check/__init__.py d41d8cd98f00b204e9800998ecf8427e ./var/google_search/__init__.py -180a9deb0c4937bc22ec1d18c7b540d5 ./var/google_search/search.py +647e92795bc53c13ed4bf6022525adcd ./var/google_search/search.py d41d8cd98f00b204e9800998ecf8427e ./var/__init__.py d41d8cd98f00b204e9800998ecf8427e ./var/auto_issue/__init__.py 4c7c008b28eaac5afb57a4bea46f1b19 ./var/auto_issue/github.py -059765fe1ae084ad267d4b7aa7a34032 ./var/blackwidow/__init__.py \ No newline at end of file +5e262d79a1e54e4aeb4f500536be59a5 ./var/blackwidow/__init__.py \ No newline at end of file diff --git a/lib/attacks/admin_panel_finder/__init__.py b/lib/attacks/admin_panel_finder/__init__.py index 180545b..dd80921 100644 --- a/lib/attacks/admin_panel_finder/__init__.py +++ b/lib/attacks/admin_panel_finder/__init__.py @@ -72,14 +72,18 @@ def check_for_externals(url, data_sep="-" * 30, **kwargs): lib.core.settings.logger.info(lib.core.settings.set_color( "robots.txt page will be saved into a file...", level=25 )) - return lib.core.common.write_to_log_file(data, lib.core.settings.ROBOTS_PAGE_PATH, "{}-robots_text.log".format(url)) + return lib.core.common.write_to_log_file( + data, lib.core.settings.ROBOTS_PAGE_PATH, lib.core.settings.ROBOTS_TXT_FILENAME.format( + lib.core.settings.replace_http(url) + ) + ) elif sitemap: lib.core.settings.logger.info(lib.core.settings.set_color( "found a sitemap, saving to file...", level=25 )) return lib.core.common.write_to_log_file( - data, lib.core.settings.SITEMAP_FILE_LOG_PATH, "{}-sitemap.xml".format( - lib.core.settings.replace_http(url) + data, lib.core.settings.SITEMAP_FILE_LOG_PATH, lib.core.settings.SITEMAP_FILENAME.format( + lib.core.settings.replace_http(url) ) ) @@ -167,9 +171,11 @@ def check_for_admin_page(url, exts, protocol="http://", **kwargs): "only writing successful connections to log file...", level=30 )) if len(connections) > 0: - lib.core.common.write_to_log_file(list(connections), lib.core.settings.ADMIN_PAGE_FILE_PATH, "{}-admin-page.log".format( - lib.core.settings.replace_http(url) - )) + lib.core.common.write_to_log_file( + list(connections), lib.core.settings.ADMIN_PAGE_FILE_PATH, lib.core.settings.ADMIN_PAGE_FILE_PATH.format( + lib.core.settings.replace_http(url) + ) + ) def __load_extensions(filename="{}/etc/text_files/link_ext.txt"): diff --git a/lib/attacks/clickjacking_scan/__init__.py b/lib/attacks/clickjacking_scan/__init__.py index 8e1d1fc..c98f1ba 100644 --- a/lib/attacks/clickjacking_scan/__init__.py +++ b/lib/attacks/clickjacking_scan/__init__.py @@ -97,7 +97,7 @@ def clickjacking_main(url, **kwargs): lib.core.common.write_to_log_file( data, lib.core.settings.CLICKJACKING_RESULTS_PATH, - "{}-clickjacking.html".format(lib.core.settings.replace_http(url)) + lib.core.settings.CLICKJACKING_FILENAME.format(lib.core.settings.replace_http(url)) ) else: lib.core.settings.logger.error(lib.core.settings.set_color( diff --git a/lib/attacks/gist_lookup/__init__.py b/lib/attacks/gist_lookup/__init__.py index 3229f98..6b50a58 100644 --- a/lib/attacks/gist_lookup/__init__.py +++ b/lib/attacks/gist_lookup/__init__.py @@ -83,7 +83,7 @@ def check_files_for_information(found_url, data_to_search): )) total_found.add(found_url) lib.core.common.write_to_log_file( - data.content, lib.core.settings.GIST_MATCH_LOG, "gist-match-{}.log" + data.content, lib.core.settings.GIST_MATCH_LOG, lib.core.settings.GIST_FILENAME ) return len(total_found) diff --git a/lib/attacks/whois_lookup/whois.py b/lib/attacks/whois_lookup/whois.py index b7031d5..05bf6ae 100644 --- a/lib/attacks/whois_lookup/whois.py +++ b/lib/attacks/whois_lookup/whois.py @@ -101,5 +101,5 @@ def whois_lookup_main(domain, **kwargs): return None lib.core.common.write_to_log_file( raw_information, lib.core.settings.WHOIS_RESULTS_LOG_PATH, - "{}-whois.json".format(domain) + lib.core.settings.WHOIS_LOOKUP_FILENAME.format(domain) ) \ No newline at end of file diff --git a/lib/core/settings.py b/lib/core/settings.py index a349d3b..165837a 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -55,7 +55,7 @@ CLONE = "https://github.com/ekultek/zeus-scanner.git" ISSUE_LINK = "https://github.com/ekultek/zeus-scanner/issues" # current version -VERSION = "1.2.22.{}".format(PATCH_ID) +VERSION = "1.2.24".format(PATCH_ID) # colors to output depending on the version VERSION_TYPE_COLORS = {"dev": 33, "stable": 92, "other": 30} @@ -177,6 +177,44 @@ BLACKLIST_FILE_PATH = "{}/log/blacklist".format(os.getcwd()) # the current log file being used CURRENT_LOG_FILE_PATH = "{}/log".format(os.getcwd()) +# filename for sitemap log file +SITEMAP_FILENAME = "{}-sitemap.xml" + +# filename for robots.txt log file +ROBOTS_TXT_FILENAME = "{}-robots_text.log" + +# filename for found admin pages log file +ADMIN_PAGE_FILENAME = "{}-admin-page.log" + +# filename for clickjacking log file +CLICKJACKING_FILENAME = "{}-clickjacking.html" + +# filename for gists log file +GIST_FILENAME = "gist-match-{}.log" + +# filename for whois lookup log file +WHOIS_LOOKUP_FILENAME = "{}-whois.json" + +# filename for unknown firewall log file +UNKNOWN_FIREWALL_FILENAME = "{}-fingerprint.html" + +# filename for found cookies log +COOKIE_FILENAME = "{}-cookie.log" + +# filename for found headers log +HEADERS_FILENAME = "{}-headers.json" + +EXTRACTED_URL_FILENAME = "extracted-url-{}.log" + +# filename for the URL log +URL_FILENAME = "url-log-{}.log" + +# filename for the blacklist log +BLACKLIST_FILENAME = ".blacklist" + +# filename for the blackwidow crawler log +BLACKWIDOW_FILENAME = "blackwidow-log-{}.log" + # github autohorization token path GITHUB_AUTH_PATH = "{}/etc/auths/git_auth".format(os.getcwd()) diff --git a/lib/header_check/__init__.py b/lib/header_check/__init__.py index d80a765..a855369 100644 --- a/lib/header_check/__init__.py +++ b/lib/header_check/__init__.py @@ -23,7 +23,10 @@ from lib.core.settings import ( DETECT_FIREWALL_PATH, ISSUE_LINK, DBMS_ERRORS, - UNKNOWN_FIREWALL_FINGERPRINT_PATH + UNKNOWN_FIREWALL_FINGERPRINT_PATH, + UNKNOWN_FIREWALL_FILENAME, + COOKIE_FILENAME, + HEADERS_FILENAME ) @@ -94,9 +97,11 @@ def detect_protection(url, **kwargs): "written to a log file...".format(ISSUE_LINK), level=30 )) full_finger_print = "HTTP/1.1 {}\n{}\n{}".format(status, headers, html) - write_to_log_file(full_finger_print, UNKNOWN_FIREWALL_FINGERPRINT_PATH, "{}-fingerprint.html".format( - replace_http(url) - )) + write_to_log_file( + full_finger_print, UNKNOWN_FIREWALL_FINGERPRINT_PATH, UNKNOWN_FIREWALL_FILENAME.format( + replace_http(url) + ) + ) else: retval = None @@ -162,12 +167,12 @@ def load_headers(url, **kwargs): cookie_value = req.cookies.values() write_to_log_file( "{}={}".format(''.join(cookie_start), ''.join(cookie_value)), - COOKIE_LOG_PATH, "{}-cookie.log".format(replace_http(url)) + COOKIE_LOG_PATH, COOKIE_FILENAME.format(replace_http(url)) ) except Exception: write_to_log_file( [c for c in req.cookies.itervalues()], COOKIE_LOG_PATH, - "{}-cookie.log".format(replace_http(url)) + COOKIE_FILENAME.format(replace_http(url)) ) return req.headers @@ -252,7 +257,7 @@ def main_header_check(url, **kwargs): logger.info(set_color( "writing found headers to log file...", level=25 )) - return write_to_log_file(protection, HEADER_RESULT_PATH, "{}-headers.json".format(replace_http(url))) + return write_to_log_file(protection, HEADER_RESULT_PATH, HEADERS_FILENAME.format(replace_http(url))) else: logger.error(set_color( "unable to retrieve headers for site '{}'...".format(url.strip()), level=40 diff --git a/var/blackwidow/__init__.py b/var/blackwidow/__init__.py index da38505..c0819ca 100644 --- a/var/blackwidow/__init__.py +++ b/var/blackwidow/__init__.py @@ -7,6 +7,7 @@ import requests from bs4 import BeautifulSoup import lib.core.errors +import lib.core.common import lib.core.settings import var.auto_issue.github @@ -151,8 +152,8 @@ def blackwidow_main(url, **kwargs): len(found), url ) )) - lib.core.settings.write_to_log_file(found, path=lib.core.settings.SPIDER_LOG_PATH, - filename="blackwidow-log-{}.log") + lib.core.common.write_to_log_file(found, path=lib.core.settings.SPIDER_LOG_PATH, + filename=lib.core.settings.BLACKWIDOW_FILENAME) else: lib.core.settings.logger.fatal(lib.core.settings.set_color( "did not find any usable links from '{}'...".format(url), level=50 diff --git a/var/google_search/search.py b/var/google_search/search.py index 2421d72..1ba4e43 100644 --- a/var/google_search/search.py +++ b/var/google_search/search.py @@ -53,7 +53,10 @@ from lib.core.settings import ( parse_blacklist, BLACKLIST_FILE_PATH, calculate_success, - REINSTALL_TOOL + REINSTALL_TOOL, + EXTRACTED_URL_FILENAME, + URL_FILENAME, + BLACKLIST_FILENAME ) try: @@ -308,7 +311,7 @@ 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") + write_to_log_file(retval, EXTRACTED_URL_LOG, EXTRACTED_URL_FILENAME) logger.info(set_color( "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) @@ -571,7 +574,7 @@ def parse_search_results(query, url_to_search, verbose=False, **kwargs): true_retval.add(url) if len(true_retval) != 0: - file_path = write_to_log_file(true_retval, URL_LOG_PATH, "url-log-{}.log") + file_path = write_to_log_file(true_retval, URL_LOG_PATH, URL_FILENAME) if show_success: amount_of_urls = len(open(file_path).readlines()) success_rate = calculate_success(amount_of_urls) @@ -582,7 +585,7 @@ def parse_search_results(query, url_to_search, verbose=False, **kwargs): logger.fatal(set_color( "did not find any URLs with given query '{}' writing query to blacklist...".format(query), level=50 )) - write_to_log_file(query, BLACKLIST_FILE_PATH, ".blacklist", blacklist=True) + write_to_log_file(query, BLACKLIST_FILE_PATH, BLACKLIST_FILENAME, blacklist=True) shutdown() logger.info(set_color( "found a total of {} URLs with given query '{}'...".format(len(true_retval), query) @@ -666,7 +669,7 @@ def search_multiple_pages(query, link_amount, verbose=False, **kwargs): logger.error(set_color( "user aborted, dumping already found URL(s)...", level=40 )) - write_to_log_file(retval, URL_LOG_PATH, "url-log-{}.log") + write_to_log_file(retval, URL_LOG_PATH, URL_FILENAME) logger.info(set_color( "found a total of {} URL(s)...".format(len(retval)), level=25 )) @@ -682,7 +685,7 @@ def search_multiple_pages(query, link_amount, verbose=False, **kwargs): logger.info(set_color( "a total of {} URL(s) found out of the requested {}...".format(len(retval), link_amount), level=25 )) - file_path = write_to_log_file(retval, URL_LOG_PATH, "url-log-{}.log") + file_path = write_to_log_file(retval, URL_LOG_PATH, URL_FILENAME) if show_success: amount_of_urls = len(open(file_path).readlines()) success_rate = calculate_success(amount_of_urls) @@ -694,4 +697,4 @@ def search_multiple_pages(query, link_amount, verbose=False, **kwargs): logger.warning(set_color( "did not find any links with given query '{}' writing to blacklist...".format(query), level=30 )) - write_to_log_file(query, BLACKLIST_FILE_PATH, ".blacklist") + write_to_log_file(query, BLACKLIST_FILE_PATH, BLACKLIST_FILENAME)