Skip to content

Commit

Permalink
Minor bug-fix regarding option --output-dir. Ref: #905
Browse files Browse the repository at this point in the history
  • Loading branch information
stasinopoulos committed May 3, 2024
1 parent 8684693 commit 1f99ecd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
1 change: 1 addition & 0 deletions doc/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## Version 4.0 (TBA)
* Fixed: Minor bug-fix regarding option `--output-dir`.
* Revised: Improvement regarding option `--skip` for excluding certain parameter(s) from testing.
* Revised: Improvement regarding specifying which parameter(s) to test (i.e. `-p` option).
* Revised: Improvement regarding processing / ignoring custom injection marker (i.e. asterisk `*`).
Expand Down
25 changes: 15 additions & 10 deletions src/utils/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import re
import sys
import time
import tempfile
import sqlite3
from datetime import date
from datetime import datetime
Expand Down Expand Up @@ -54,10 +55,13 @@ def logs_filename_creation(url):
menu.options.output_dir = os.path.abspath(menu.options.output_dir)
if os.path.isdir(menu.options.output_dir):
output_dir = menu.options.output_dir
warn_msg = "Using '" + output_dir + "' as the output directory."
print(settings.print_warning_msg(warn_msg))
else:
error_msg = "The '" + menu.options.output_dir + "' is not directory."
print(settings.print_critical_msg(error_msg))
raise SystemExit()
output_dir = tempfile.mkdtemp(prefix=settings.APPLICATION)
warn_msg = "Unable to create output directory '" + menu.options.output_dir + "'. "
warn_msg += "Using temporary directory '" + output_dir + "' instead."
print(settings.print_warning_msg(warn_msg))
else:
output_dir = settings.OUTPUT_DIR
path_creation(os.path.dirname(settings.OUTPUT_DIR))
Expand All @@ -67,7 +71,6 @@ def logs_filename_creation(url):

# The logs filename construction.
filename = create_log_file(url, output_dir)

return filename

"""
Expand All @@ -89,11 +92,9 @@ def create_log_file(url, output_dir):
if os.path.exists(menu.options.session_file):
settings.SESSION_FILE = menu.options.session_file
else:
err_msg = "The provided session file ('" + \
menu.options.session_file + \
"') does not exist."
print(settings.print_critical_msg(err_msg))
raise SystemExit()
err_msg = "The provided session file ('" + menu.options.session_file + "') does not exist."
print(settings.print_critical_msg(err_msg))
raise SystemExit()
else:
settings.SESSION_FILE = logs_path + "session.db"

Expand All @@ -119,6 +120,10 @@ def create_log_file(url, output_dir):
error_msg = str(err_msg.args[0]) + "."
print(settings.print_critical_msg(error_msg))
raise SystemExit()

if not menu.options.output_dir:
filename = os.path.abspath(filename)

return filename

"""
Expand Down Expand Up @@ -180,7 +185,7 @@ def executed_command(filename, cmd, output):
def logs_notification(filename):
# Save command history.
if not menu.options.no_logging:
info_msg = "Fetched data logged to text files under '" + os.getcwd() + "/" + filename + "'."
info_msg = "Fetched data logged to text files under '" + filename + "'."
print(settings.print_info_msg(info_msg))

"""
Expand Down
2 changes: 1 addition & 1 deletion src/utils/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "4.0"
REVISION = "40"
REVISION = "41"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
Expand Down

0 comments on commit 1f99ecd

Please sign in to comment.