Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
Build 217 - Can get banner with python3 and no errors! #112
Browse files Browse the repository at this point in the history
  • Loading branch information
sethsec committed Aug 23, 2019
1 parent 7569ec0 commit a34b85c
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 38 deletions.
2 changes: 1 addition & 1 deletion celerystalk
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ import csv

from lib.nmap import nmapcommand

build=str(216)
build=str(217)

def print_banner():

Expand Down
2 changes: 1 addition & 1 deletion lib/administrative.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def restore_all_workspaces(restore_file):
workspaces = lib.db.get_all_workspaces()
if workspaces:
print("[!] There is already a current workspace. This will backup the currnt DB and OVERWRITE it with the new one.")
answer = raw_input("Are you sure you want to continue? (y\N): ")
answer = input("Are you sure you want to continue? (y|N): ")
print("")
if (answer == "Y") or (answer == "y"):
backup_all_workspaces()
Expand Down
10 changes: 5 additions & 5 deletions lib/config_parser.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections import OrderedDict
from ConfigParser import ConfigParser
import configparser


class MultiOrderedDict(OrderedDict):
Expand All @@ -13,7 +13,7 @@ def __setitem__(self, key, value):


def read_config_ini(config_file=None):
config = ConfigParser()
config = configparser.ConfigParser()
config.read([config_file])
supported_services = []
for (key,val) in config.items("nmap-service-names"):
Expand Down Expand Up @@ -46,7 +46,7 @@ def get_user_config(config_file):


def extract_bb_nmap_options(config_file=None):
config = ConfigParser(allow_no_value=True)
config = configparser.ConfigParser(allow_no_value=True)
config.read([config_file])

for (key, val) in config.items("nmap-commands"):
Expand All @@ -56,7 +56,7 @@ def extract_bb_nmap_options(config_file=None):
return options

def extract_udp_scan_nmap_options(config_file=None):
config = ConfigParser(allow_no_value=True)
config = configparser.ConfigParser(allow_no_value=True)
config.read([config_file])

for (key, val) in config.items("nmap-commands"):
Expand All @@ -66,7 +66,7 @@ def extract_udp_scan_nmap_options(config_file=None):
return options

def read_bb_scope_ini(bb_scope_file):
bb_config = ConfigParser(allow_no_value=True)
bb_config = configparser.ConfigParser(allow_no_value=True)
bb_config.read([bb_scope_file])

in_scope_domains = []
Expand Down
6 changes: 3 additions & 3 deletions lib/csimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import lib.db
import lib.utils
from lib import db
import urlparse
from urllib import parse as urlparse
import os
import csv

Expand Down Expand Up @@ -85,7 +85,7 @@ def import_scope(scope_file,workspace):
else:
db_vhost = (ip, ip, 1, 0, 0, workspace) # add it to the vhosts db and mark as in scope
lib.db.create_vhost(db_vhost)
except Exception, e:
except Exception as e:
# Putting this try/except here because i have a feeling that at some point we will see
# something like 192.168.0.0-192.168.200.255 or something like that. Not handling that
# right now.
Expand Down Expand Up @@ -185,7 +185,7 @@ def import_url(url,workspace,output_base_dir):
vhost_explicitly_out_of_scope = lib.db.is_vhost_explicitly_out_of_scope(vhost, workspace)
if not vhost_explicitly_out_of_scope: # and if the vhost is not explicitly out of scope
if in_scope == 0:
answer = raw_input(
answer = input(
"[+] {0} is not in scope. Would you like to to add {1}/{0} to the list of in scope hosts?".format(vhost,
ip))
if (answer == "Y") or (answer == "y") or (answer == ""):
Expand Down
2 changes: 1 addition & 1 deletion lib/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def help_db(self):

def do_quit(self, args):
"""Quits the program."""
print "Quitting."
print("Quitting.")
raise SystemExit

def do_db(self,args):
Expand Down
8 changes: 4 additions & 4 deletions lib/nmap.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import sys
from ConfigParser import ConfigParser
import configparser
from celery import chain
from kombu import uuid

import lib.utils
import tasks
from lib import config_parser, utils
import lib.db
import lib.config_parser
import lib.utils
import os


def nmap_scan_subdomain_host(vhost,workspace,simulation,output_base_dir,config_file=None):
celery_path = sys.path[0]
config_nmap_options = config_parser.extract_bb_nmap_options(config_file=config_file)
config = ConfigParser(allow_no_value=True)
config = configparser.ConfigParser(allow_no_value=True)
config.read(['config.ini'])

vhost_explicitly_out_of_scope = lib.db.is_vhost_explicitly_out_of_scope(vhost, workspace)
Expand Down
2 changes: 1 addition & 1 deletion lib/query.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import time
import db
import lib.db
import os
from lib.utils import get_terminal_width

Expand Down
10 changes: 5 additions & 5 deletions lib/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ def populate_report_data(report_file,vhost,workspace):
report_file.write("Output File:\t" + normalized_output_file + '\n')
report_file.write("Status:\t\t" + status + '\n')
report_file.write('-' * 50 + '\n\n')
except OSError, e:
except OSError:
report_file.write('\n')
report_file.write('-' * 50 + '\n')
report_file.write("Command Name:\t" + command_name+ '\n')
Expand All @@ -947,7 +947,7 @@ def populate_report_data(report_file,vhost,workspace):
if linecount > 300:
report_file.write("\nSnip... Only displaying first 300 of the total " + str(
linecount) + " lines...\n")
except IOError, e:
except IOError:
#dont tell the user at the concole that file didnt exist.
pass

Expand Down Expand Up @@ -1015,7 +1015,7 @@ def get_command_header_and_info(vhost,normalized_output_file,command_name,comman
command_header_html_string = command_header_html_string + "<tr><td>Status:</td><td>" + status + ' [No Output Data]</td></tr>\n'
else:
command_header_html_string = command_header_html_string + "<tr><td>Status:</td><td>" + status + '</td></tr>\n'
except OSError, e:
except OSError:
command_header_html_string = command_header_html_string + "<tr><td>Command:</td><td>" + command + '</td></tr>\n'
command_header_html_string = command_header_html_string + "\nError!: No such file or directory: " + normalized_output_file + "</td></tr>\n"
# command_header_html_string = command_header_html_string + "{0} did not produce any data\n".format(command_name))
Expand Down Expand Up @@ -1046,7 +1046,7 @@ def convert_file_contents_to_html(normalized_output_file):
if linecount > 300:
file_html_string = file_html_string + "\nSnip... Only displaying first 300 of the total " + str(
linecount) + " lines...\n"
except IOError, e:
except IOError:
# dont tell the user at the concole that file didnt exist.
pass
file_html_string = file_html_string + " </div>"
Expand All @@ -1064,4 +1064,4 @@ def convert_file_contents_to_html2(normalized_output_file):

def command_footer_html(tasks_for_output_file):
for task in tasks_for_output_file:
print {}
print(task)
4 changes: 2 additions & 2 deletions lib/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from celery import chain
import socket
import re
import urlparse
from urllib import parse as urlparse
import lib.db
from random import shuffle

Expand Down Expand Up @@ -108,7 +108,7 @@ def aquatone_host(urls_to_screenshot,vhost,workspace,simulation,scan_output_base
populated_command = replace_user_config_options(config_file,populated_command)

#print(populated_command)
except Exception, e:
except Exception as e:
print(e)
print("[!] Error: In the config file, there needs to be one (and only one) enabled aquatone command.")
exit()
Expand Down
2 changes: 1 addition & 1 deletion lib/screenshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def aquatone_all_paths(workspace,simulation=None,config_file=None):
if cmd_name == "aquatone":
populated_command = celery_path + "/celerystalk db paths_only limit | " + cmd.replace("[OUTPUT]", outdir)
#print(populated_command)
except Exception, e:
except Exception as e:
print(e)
print("[!] Error: In the config file, there needs to be one (and only one) enabled aquatone command.")
exit()
Expand Down
12 changes: 6 additions & 6 deletions lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
from libnessus.parser import NessusParser
from netaddr import IPAddress, IPRange, IPNetwork
import socket
import db
from lib import db
from lib import config_parser
import os
import re
import lib.db
import lib.config_parser



def task_splitter(id):
Expand Down Expand Up @@ -147,7 +147,7 @@ def start_celery_worker(config_file):
popen_string = "celery -A tasks worker --concurrency=%s -Ofair -q --pidfile ./%%n.pid --logfile ./log/celeryWorker.log > /dev/null 2>&1" % (str(concurrent_tasks))
p = Popen(popen_string, shell=True)

except Exception, e:
except Exception as e:
#print(e)
p = Popen(
"celery -A tasks worker -Ofair -q --pidfile ./%n.pid --logfile ./log/celeryWorker.log > /dev/null 2>&1",
Expand Down Expand Up @@ -223,7 +223,7 @@ def target_splitter(target_networks):
# Putting this try/except here because i have a feeling that at some point we will see
# something like 192.168.0.0-192.168.200.255 or something like that. Not handling that
# right now.
print(error)
print("error")
else:
# If there is no "-" in the line, we can deal with it as a simple network or IPAddress. Luckily
# IPNetwork automatically converts an IP without a CIDR into /32 CIDR, and it works just like
Expand Down Expand Up @@ -275,7 +275,7 @@ def check_for_new_default_config():
if user_config_age < default_config_age:
print("[!] [config_default.ini] pulled from git is newer than the the current [config.ini] file.")
print("[!] This is most likely because a new tool or possibly a new feature has been added.\n")
answer = raw_input("[+] Would you like backup your current config and replace [config.ini] with the new version? (y\N)")
answer = input("[+] Would you like backup your current config and replace [config.ini] with the new version? (y|N)")
print("")
if (answer == "Y") or (answer == "y"):
from shutil import copyfile
Expand Down
6 changes: 3 additions & 3 deletions lib/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def create_workspace(workspace,arguments):
if arguments["-o"]: #and the user specified a workspace
arg_output_dir = os.path.join(arguments["-o"], '')
if arg_output_dir != output_dir: # if the user specified output dir is not the same as the db output_dir, ask the user whether they want to update it or ignore the command line output_dir
output_dir_answer = raw_input(
"[!] The DB shows that the output directory for the [{0}] workspace is [{1}].\n[+] Do you want to update the output directory to [{2}]? (y\N)".format(
output_dir_answer = input(
"[!] The DB shows that the output directory for the [{0}] workspace is [{1}].\n[+] Do you want to update the output directory to [{2}]? (y|N)".format(
workspace, output_dir, arg_output_dir))
print("")
if (output_dir_answer == "Y") or (
Expand All @@ -46,7 +46,7 @@ def create_workspace(workspace,arguments):
print("[+] Workspace: " + workspace + " already exists and is the current workspace: " + workspace + "\n")
else:
print("[+] Workspace: " + workspace + " already exists but it is not the current workspace\n")
answer = raw_input("[+] Would you like to switch to this workspace? [Y\\n] ")
answer = input("[+] Would you like to switch to this workspace? [Y\\n] ")
if (answer == "Y") or (answer == "y") or (answer == ""):
lib.db.update_current_workspace(workspace)

Expand Down
2 changes: 1 addition & 1 deletion parsers/generic_urlextract.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import re
import lib.db
import lib.utils
import urlparse
from urllib import parse as urlparse


#TODO: Add this when i move project to python3
Expand Down
6 changes: 3 additions & 3 deletions setup/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ elif [ "$DISTRO" == "ubuntu" ]; then
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" -y
apt-get update -y
apt-get install docker-ce docker-ce-cli containerd.io python-pip python3-pip unzip redis-server chromium jq -y
apt-get install docker-ce docker-ce-cli containerd.io python-pip python3-pip unzip redis-server chromium jq python3-pip -y
fi


Expand All @@ -76,7 +76,7 @@ echo "******************************************"
echo "* Installing python requirements via pip *"
echo "******************************************"
echo ""
pip install -r requirements.txt --upgrade
pip3 install -r requirements.txt --upgrade


echo ""
Expand All @@ -89,7 +89,7 @@ if [ ! -f /opt/python-libnessus/python_libnessus.egg-info ]; then
cd /opt/
git clone https://github.com/bmx0r/python-libnessus.git
cd python-libnessus
python setup.py install
python3 setup.py install
fi


Expand Down
3 changes: 2 additions & 1 deletion setup/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ bleach
selenium
prettytable
pyvirtualdisplay
ansi2html
ansi2html
configparser==3.7.4

0 comments on commit a34b85c

Please sign in to comment.