while writing to a log file, if the file is already present, it will now write to a seperate file with the duplicate number in it, IE www.google.com-clickjacking.html will be www.google.com(1).html, www.google.com(2).html, etc.. (issue #140)

This commit is contained in:
ekultek 2017-11-08 14:00:31 -06:00
parent 864983250f
commit 856e38b970
3 changed files with 20 additions and 14 deletions

View file

@ -1,4 +1,4 @@
f7dfe15a281f72ff02f937a51838c614 ./zeus.py
1d2385527ffff7ac671f186bf8c4d92a ./zeus.py
4b32db388e8acda35570c734d27c950c ./etc/scripts/launch_sqlmap.sh
6ad5f22ec4a6f8324bfb1b01ab6d51ec ./etc/scripts/cleanup.sh
155c9482f690f1482f324a7ffd8b8098 ./etc/scripts/fix_pie.sh
@ -52,8 +52,8 @@ d41d8cd98f00b204e9800998ecf8427e ./lib/attacks/whois_lookup/__init__.py
a0b5265f235a266f7a48874c3d1e08f9 ./lib/attacks/intel_me/__init__.py
1faa2b5dfad6eb538bbfe42942d2a9da ./lib/core/errors.py
d41d8cd98f00b204e9800998ecf8427e ./lib/core/__init__.py
ecb1912f467c0c3d6fc58975f9317126 ./lib/core/settings.py
623830ef2e6f389c961edcb5bc135132 ./lib/header_check/__init__.py
f95463ef8eac7c5255d1093a5e20b5a6 ./lib/core/settings.py
c265970650a068c0f0cdfcdb756c9914 ./lib/header_check/__init__.py
d41d8cd98f00b204e9800998ecf8427e ./var/google_search/__init__.py
e9f1e2624154401840b0b118216ba82e ./var/google_search/search.py
d41d8cd98f00b204e9800998ecf8427e ./var/__init__.py

View file

@ -44,7 +44,7 @@ PATCH_ID = str(subprocess.check_output(["git", "rev-parse", "origin/master"]))[:
CLONE = "https://github.com/ekultek/zeus-scanner.git"
# current version <major.minor.commit.patch ID>
VERSION = "1.1.22".format(PATCH_ID)
VERSION = "1.1.23.{}".format(PATCH_ID)
# colors to output depending on the version
VERSION_TYPE_COLORS = {"dev": 33, "stable": 92, "other": 30}
@ -495,20 +495,20 @@ def write_to_log_file(data_to_write, path, filename):
os.getcwd()
))) + 1)
)
to_search = filename.split("-")[0]
amount = len([f for f in os.listdir(path) if to_search in f])
new_filename = "{}({}).{}".format(
filename.split("-")[0], amount, filename.split(".")[-1]
)
with open(full_file_path, "a+") as log:
data = re.sub(r'\s+', '', log.read())
if re.match(r'^<.+>$', data): # matches HTML and XML
try:
log.write(etree.tostring(data_to_write, pretty_print=True))
except TypeError:
# usually happens when the file already exists
# TODO:/ skip writing to the file, or write to the file with a (1), (2), etc at the end
logger.warning(set_color(
"unable to serialize {} data, writing as plain text...".format(
filename.split(".")[-1].upper()
), level=30
))
log.write(data_to_write)
return write_to_log_file(data_to_write, path, new_filename)
elif amount > 0:
return write_to_log_file(data_to_write, path, new_filename)
else:
if isinstance(data_to_write, list):
for item in data_to_write:
@ -770,7 +770,7 @@ def check_for_protection(protected, attack_type):
check if the provided target URL has header protection against an attack type
"""
items = [item.lower() for item in protected]
if attack_type in items:
if attack_type in items or "all" in items:
protected.clear() # clear the set
logger.warning(set_color(
"provided target seems to have protection against this attack type...", level=30

View file

@ -589,10 +589,16 @@ if __name__ == "__main__":
"try updating the timeout with the --time-sec flag (IE --time-sec 10)", level=50
))
shutdown()
else:
elif "No such file or directory" in str(e):
logger.exception(e)
logger.fatal(set_color(
"provided file does not exist, make sure you have the full path...", level=50
))
else:
logger.exception(set_color(
"Zeus has hit an unexpected error and cannot continue, error code '{}'...".format(e), level=50
))
request_issue_creation()
except KeyboardInterrupt:
logger.error(set_color(
"user aborted process...", level=40