patch for file logging issue (issue #10)

This commit is contained in:
ekultek 2017-09-29 17:46:54 -05:00
parent eb9f9a5e75
commit daca2ac1a2
2 changed files with 17 additions and 3 deletions

View file

@ -22,7 +22,7 @@ except NameError:
# clone link
CLONE = "https://github.com/ekultek/zeus-scanner.git"
# current version <major.minor.commit.patch ID>
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])
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")

View file

@ -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()