From daca2ac1a290c443a5a3f44795c5062b18eae994 Mon Sep 17 00:00:00 2001 From: ekultek Date: Fri, 29 Sep 2017 17:46:54 -0500 Subject: [PATCH] patch for file logging issue (issue #10) --- lib/settings.py | 16 ++++++++++++++-- zeus.py | 4 +++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/settings.py b/lib/settings.py index 8858665..311ecea 100644 --- a/lib/settings.py +++ b/lib/settings.py @@ -22,7 +22,7 @@ except NameError: # clone link CLONE = "https://github.com/ekultek/zeus-scanner.git" # current version -VERSION = "1.0.22" +VERSION = "1.0.22.b34b" # colors to output depending on the version VERSION_TYPE_COLORS = {"dev": 33, "stable": 92, "other": 30} # version string formatting @@ -368,4 +368,16 @@ def create_tree(start, conns, down="|", over="-", sep="-" * 40): def get_true_url(url): data = url.split("/") - return "{}//{}".format(data[0], data[2]) \ No newline at end of file + return "{}//{}".format(data[0], data[2]) + + +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) + open(logfile, "w").close() + with open(logfile, "a+") as fixed: + for line in retval.split("\n"): + fixed.write(line + "\n") \ No newline at end of file diff --git a/zeus.py b/zeus.py index c724ddf..4d485fa 100755 --- a/zeus.py +++ b/zeus.py @@ -44,7 +44,8 @@ from lib.settings import ( URL_REGEX, URL_QUERY_REGEX, NMAP_MAN_PAGE_URL, SQLMAP_MAN_PAGE_URL, - get_true_url + get_true_url, + fix_log_file ) if __name__ == "__main__": @@ -551,4 +552,5 @@ if __name__ == "__main__": "ran into exception '{}' exception has been saved to log file...".format(e), level=50 )) + fix_log_file() shutdown() \ No newline at end of file