From 639eddb2e5a6323786fa2da82abbbd696b10e268 Mon Sep 17 00:00:00 2001 From: Seth Art Date: Sun, 25 Aug 2019 23:09:03 -0400 Subject: [PATCH] Build 218 - More python3 bugs knocked out. #112 --- celerystalk | 2 +- lib/cancel.py | 1 + lib/query.py | 20 ++++++++++---------- lib/report.py | 11 ++++++----- lib/scan.py | 2 +- lib/screenshot.py | 4 ++-- 6 files changed, 21 insertions(+), 19 deletions(-) diff --git a/celerystalk b/celerystalk index e90ad06..1f9fe60 100755 --- a/celerystalk +++ b/celerystalk @@ -89,7 +89,7 @@ import csv from lib.nmap import nmapcommand -build=str(217) +build=str(218) def print_banner(): diff --git a/lib/cancel.py b/lib/cancel.py index 1341637..af4c819 100644 --- a/lib/cancel.py +++ b/lib/cancel.py @@ -24,6 +24,7 @@ def cancel_tasks(id, workspace,ip=None): elif ip: running_tasks = db.get_running_tasks(workspace,ip) pending_tasks = db.get_pending_tasks(workspace,ip) + paused_tasks = db.get_paused_tasks(workspace) running_pending_paused_task_list = running_tasks + pending_tasks + paused_tasks for task in running_pending_paused_task_list: task_list.append(task[0]) diff --git a/lib/query.py b/lib/query.py index cc6e963..3a9b27c 100644 --- a/lib/query.py +++ b/lib/query.py @@ -9,20 +9,20 @@ def query_sqlite(workspace, target=None, repeat=None, summary=None): if not terminal_width: terminal_width = 80 - completed_count = db.get_completed_task_count(workspace) - pending_count = db.get_pending_task_count(workspace) - total_count = db.get_total_tasks(workspace) - running_rows = db.get_running_tasks(workspace) - completed_rows = db.get_completed_tasks(workspace) - pending_rows = db.get_pending_tasks(workspace) - cancelled_rows = db.get_cancelled_tasks(workspace) - paused_rows = db.get_paused_tasks(workspace) + completed_count = lib.db.get_completed_task_count(workspace) + pending_count = lib.db.get_pending_task_count(workspace) + total_count = lib.db.get_total_tasks(workspace) + running_rows = lib.db.get_running_tasks(workspace) + completed_rows = lib.db.get_completed_tasks(workspace) + pending_rows = lib.db.get_pending_tasks(workspace) + cancelled_rows = lib.db.get_cancelled_tasks(workspace) + paused_rows = lib.db.get_paused_tasks(workspace) loadavg = float("{0:.1f}".format(os.getloadavg()[0])) banner = "celerystalk Status | Workspace Name: {0} | CPU Load Avg: {1}".format(workspace,loadavg) print("*" * terminal_width) - print(" " * ((terminal_width / 2) - (len(banner) / 2)) + banner) - print("\n" + " " * ((terminal_width / 2) - 40) + "Submitted: {0} | Queued: {3} | Running: {2} | Completed: {1} | Cancelled: {4} | Paused: {5}".format(total_count[0][0], completed_count[0][0], len(running_rows), pending_count[0][0], len(cancelled_rows), len(paused_rows))) + print(" " * int((terminal_width / 2) - (len(banner) / 2)) + banner) + print("\n" + " " * int((terminal_width / 2) - 40) + "Submitted: {0} | Queued: {3} | Running: {2} | Completed: {1} | Cancelled: {4} | Paused: {5}".format(total_count[0][0], completed_count[0][0], len(running_rows), pending_count[0][0], len(cancelled_rows), len(paused_rows))) print("*" * terminal_width) if summary: diff --git a/lib/report.py b/lib/report.py index 497d99f..ab724e6 100644 --- a/lib/report.py +++ b/lib/report.py @@ -71,7 +71,7 @@ def aquatone_parse_paths(): with open(aquatone_session_file, 'r') as aquatone_file: aquatone_file_json = simplejson.load(aquatone_file) - for key,value in aquatone_file_json['pages'].iteritems(): + for key,value in aquatone_file_json['pages'].items(): #print(page) path = value['url'] screenshot_path = value['screenshotPath'] @@ -239,7 +239,7 @@ def report(workspace,config_file,target_list=None): print("*" * terminal_width) banner = "Text based report file per target" - print(" " * ((terminal_width / 2) - (len(banner) / 2)) + banner) + print(" " * int((terminal_width / 2) - (len(banner) / 2)) + banner) print("*" * terminal_width + "\n") # HTML Report @@ -507,7 +507,7 @@ def report(workspace,config_file,target_list=None): print("\n") print("*" * terminal_width) banner = "Combined Report files" - print(" " * ((terminal_width / 2) - (len(banner) / 2)) + banner ) + print(" " * int((terminal_width / 2) - (len(banner) / 2)) + banner) print("*" * terminal_width + "\n") print("[+] Report file (All workspace hosts): {0} (has screenshots!!!)".format(combined_report_file_name)) @@ -515,7 +515,7 @@ def report(workspace,config_file,target_list=None): print("*" * terminal_width) banner = "Suggestions for viewing your html report:" - print(" " * ((terminal_width / 2) - (len(banner) / 2)) + banner ) + print(" " * int((terminal_width / 2) - (len(banner) / 2)) + banner) print("*" * terminal_width + "\n") print("[+] Option 1: Open with local firefox (works over ssh with x forwarding)") print("\t\tfirefox " + combined_report_file_name + " &") @@ -1032,7 +1032,8 @@ def convert_file_contents_to_html(normalized_output_file): try: with open(normalized_output_file, "r") as scan_file: for line in scan_file: - line = unicode(line, errors='ignore') + # disabling this for python3. this might cause issues. + #line = unicode(line, errors='ignore') try: sanitized = bleach.clean(line) except: diff --git a/lib/scan.py b/lib/scan.py index c2e0c64..8b96334 100644 --- a/lib/scan.py +++ b/lib/scan.py @@ -76,7 +76,7 @@ def process_db_vhosts(workspace, simulation, target_list=None,dont_scan_ips=None def replace_user_config_options(config_file,populated_command): rep = lib.config_parser.get_user_config(config_file) rep = dict((k, v) for k, v in rep) - for k,v in rep.iteritems(): + for k,v in rep.items(): k = k.upper() populated_command = populated_command.replace("[" + k + "]",v) return populated_command diff --git a/lib/screenshot.py b/lib/screenshot.py index ad2180f..0e86c64 100644 --- a/lib/screenshot.py +++ b/lib/screenshot.py @@ -43,9 +43,9 @@ def screenshot_command(arguments): paths_len = len(lib.db.get_all_paths(workspace)) max_paths_len = len(get_max_screenshots(workspace,config_file)) max = lib.config_parser.get_screenshot_max(config_file) - print("[+]\n[+] There are [{0}] paths in the DB").format(str(paths_len)) + print("[+]\n[+] There are [{0}] paths in the DB" % (str(paths_len))) #print("[+] max_screenshots_per_vhost set to: [{0}]").format(str(max)) - print("[+] Tasking aquatone to take [{0}] screenshots per host for a total of [{1}] screenshots\n[+]\n[+]").format(str(max),str(max_paths_len)) + print("[+] Tasking aquatone to take [{0}] screenshots per host for a total of [{1}] screenshots\n[+]\n[+]" % str(max),str(max_paths_len)) lib.screenshot.aquatone_all_paths(workspace) def get_max_screenshots(workspace,config_file):