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

Commit af917c6

Browse files
committed
Build 242 - Updated config to call gobuster with slash and without slash for best results.
1 parent 036c49c commit af917c6

File tree

6 files changed

+58
-34
lines changed

6 files changed

+58
-34
lines changed

celerystalk

+23-6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Usage:
1919
celerystalk db ([workspaces]|[workspace]|[services]|[ports]|[hosts]|[vhosts]|[paths]|[paths_only]|[tasks]) [-h]
2020
celerystalk db export [-h]
2121
celerystalk db paths_only limit [-h]
22+
celerystalk db paths_include_404s [-h]
2223
celerystalk admin ([start]|[stop]|[restart]|[reset]|[backup]|[restore]) [-f <restore_file>] [-h]
2324
celerystalk interactive [-h]
2425
celerystalk (help | -h | --help)
@@ -89,7 +90,7 @@ import csv
8990

9091
from lib.nmap import nmapcommand
9192

92-
build=str(243)
93+
build=str(244)
9394

9495

9596
def print_banner():
@@ -611,7 +612,8 @@ def main(arguments):
611612
./celerystalk db ports
612613
Show hosts: ./celerystalk db hosts
613614
Show vhosts only ./celerystalk db vhosts
614-
Show paths: ./celerystalk db paths
615+
Show paths (404s excluded): ./celerystalk db paths
616+
Show paths & include 404s ./celerystalk db paths_include_404s
615617
Show paths (no table) ./celerystalk db paths_only
616618
Show tasks: ./celerystalk db tasks
617619
Export tables to csv ./celerystalk db export
@@ -679,15 +681,29 @@ def main(arguments):
679681
print(services_table)
680682
print("\n\n")
681683
elif arguments["paths"]:
682-
print("[+] Showing paths for the [{0}] workspace\n".format(workspace))
683-
columns = ["IP", "Port", "Path"]
684+
print("[+] Showing paths for the [{0}] workspace (excluding 404s)\n To show table with 404s use:\n ./celerystalk db paths_include_404s\n".format(workspace))
685+
columns = ["IP", "Port", "Path","Status"]
686+
paths_rows = lib.db.get_all_paths_exclude_404(workspace)
687+
paths_table = PrettyTable(columns)
688+
paths_table.align[columns[0]] = "l"
689+
paths_table.align[columns[1]] = "l"
690+
paths_table.align[columns[2]] = "l"
691+
paths_table.align[columns[3]] = "l"
692+
for row in paths_rows:
693+
paths_table.add_row(row[1:5])
694+
print(paths_table)
695+
print("\n\n")
696+
elif arguments["paths_include_404s"]:
697+
print("[+] Showing all paths for the [{0}] workspace\n".format(workspace))
698+
columns = ["IP", "Port", "Path","Status"]
684699
paths_rows = lib.db.get_all_paths(workspace)
685700
paths_table = PrettyTable(columns)
686701
paths_table.align[columns[0]] = "l"
687702
paths_table.align[columns[1]] = "l"
688703
paths_table.align[columns[2]] = "l"
704+
paths_table.align[columns[3]] = "l"
689705
for row in paths_rows:
690-
paths_table.add_row(row[1:4])
706+
paths_table.add_row(row[1:5])
691707
print(paths_table)
692708
print("\n\n")
693709
elif arguments["paths_only"]:
@@ -698,7 +714,7 @@ def main(arguments):
698714
for path in paths:
699715
print path
700716
else:
701-
paths_rows = lib.db.get_all_paths(workspace)
717+
paths_rows = lib.db.get_all_paths_exclude_404(workspace)
702718
for row in paths_rows:
703719
sys.stdout.write(row[3]+"\n")
704720
print("\n")
@@ -752,6 +768,7 @@ def main(arguments):
752768
print("[+] Saved all paths in the [{0}] workspace to {1}".format(workspace,paths_output_file))
753769
paths_filename = workspace + "_paths.txt"
754770
paths_output_file = os.path.join(output_dir, paths_filename)
771+
paths_rows = lib.db.get_all_paths_exclude_404(workspace)
755772
with open(paths_output_file, 'wb') as f:
756773
for path in paths_rows:
757774
f.write(path[3] + "\n")

lib/csimport.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def import_url(url,workspace,output_base_dir):
237237
url_path = ''
238238

239239
url_screenshot_filename = scan_output_base_file_dir + url_path.replace("/", "_") + ".png"
240-
db_path = (vhost, port, url.rstrip("/"), 0, url_screenshot_filename, workspace)
240+
db_path = (vhost, port, url.rstrip("/"), 0, 0, url_screenshot_filename,workspace)
241241
db.insert_new_path(db_path)
242242
# print("Found Url: " + str(url))
243243
#urls_to_screenshot.append((url, url_screenshot_filename))
@@ -246,7 +246,7 @@ def import_url(url,workspace,output_base_dir):
246246
# print(result)
247247

248248

249-
db_path = (vhost, port, url.rstrip("/"), 0, url_screenshot_filename, workspace)
249+
db_path = (vhost, port, url.rstrip("/"), 0, 0, url_screenshot_filename, workspace)
250250
lib.db.insert_new_path(db_path)
251251
else:
252252
print("[!] {0} is explicitly marked as out of scope. Skipping...".format(vhost))
@@ -527,7 +527,7 @@ def process_nmap_data(nmap_report,workspace, target=None):
527527
db_path = db.get_path(path, workspace)
528528
if not db_path:
529529
url_screenshot_filename = scan_output_base_file_dir + ".png"
530-
db_path = (ip, scanned_service_port, path, 0, url_screenshot_filename, workspace)
530+
db_path = (ip, scanned_service_port, path, 0, 0, url_screenshot_filename, workspace)
531531
db.insert_new_path(db_path)
532532

533533

@@ -558,7 +558,7 @@ def process_nmap_data(nmap_report,workspace, target=None):
558558
db_path = db.get_path(path, workspace)
559559
if not db_path:
560560
url_screenshot_filename = scan_output_base_file_dir + ".png"
561-
db_path = (vhost, scanned_service_port, path, 0, url_screenshot_filename, workspace)
561+
db_path = (vhost, scanned_service_port, path, 0, 0, url_screenshot_filename, workspace)
562562
db.insert_new_path(db_path)
563563

564564

lib/db.py

+15-8
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,9 @@ def create_path_table():
9797
ip text NOT NULL,
9898
port int NOT NULL,
9999
path text NOT NULL UNIQUE,
100+
url_status int,
100101
submitted int,
101-
url_screenshot_filename text,
102+
url_screenshot_filename text,
102103
workspace text NOT NULL
103104
); """
104105

@@ -639,31 +640,37 @@ def insert_new_path(db_path):
639640
:param db_path:
640641
:return:
641642
"""
642-
sql = '''INSERT OR IGNORE INTO paths(ip,port,path,submitted,url_screenshot_filename,workspace)
643-
VALUES(?,?,?,?,?,?) '''
643+
sql = '''INSERT OR IGNORE INTO paths(ip,port,path,url_status,submitted,url_screenshot_filename,workspace)
644+
VALUES(?,?,?,?,?,?,?) '''
644645
CUR.execute(sql, db_path)
645646
CONNECTION.commit()
646647

647648
def get_all_paths(workspace):
648-
CUR.execute("SELECT * FROM paths WHERE workspace = ? ORDER BY ip,port,path", (workspace,))
649+
CUR.execute("SELECT * FROM paths WHERE workspace = ? ORDER BY ip,port,path,url_status", (workspace,))
649650
all_paths = CUR.fetchall()
650651
CONNECTION.commit()
651652
return all_paths
652653

653-
def get_all_paths_for_host(ip):
654-
CUR.execute("SELECT ip,port,path,url_screenshot_filename,workspace FROM paths WHERE ip = ? ORDER BY port,path", (ip,))
654+
def get_all_paths_exclude_404(workspace):
655+
CUR.execute("SELECT * FROM paths WHERE workspace = ? AND url_status != 404 ORDER BY ip,port,path,url_status", (workspace,))
656+
all_paths = CUR.fetchall()
657+
CONNECTION.commit()
658+
return all_paths
659+
660+
def get_all_paths_for_host_exclude_404(ip):
661+
CUR.execute("SELECT ip,port,path,url_screenshot_filename,workspace FROM paths WHERE ip = ? AND url_status != 404 ORDER BY port,path", (ip,))
655662
all_paths_for_host = CUR.fetchall()
656663
CONNECTION.commit()
657664
return all_paths_for_host
658665

659666
def get_all_paths_for_host_path_only(ip,workspace):
660-
CUR.execute("SELECT path FROM paths WHERE ip = ? AND workspace = ?", (ip,workspace))
667+
CUR.execute("SELECT path FROM paths WHERE ip = ? AND workspace = ? AND url_status != 404", (ip,workspace))
661668
all_paths_for_host = CUR.fetchall()
662669
CONNECTION.commit()
663670
return all_paths_for_host
664671

665672
def get_x_paths_for_host_path_only(ip,workspace,config_max):
666-
CUR.execute("SELECT path FROM paths WHERE ip = ? AND workspace = ? LIMIT ?", (ip,workspace,config_max))
673+
CUR.execute("SELECT path FROM paths WHERE ip = ? AND workspace = ? AND AND url_status != 404 LIMIT ?", (ip,workspace,config_max))
667674
all_paths_for_host = CUR.fetchall()
668675
CONNECTION.commit()
669676
return all_paths_for_host

lib/report.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ def report(workspace,config_file,target_list=None):
381381
combined_report_file.write("\n<br>" + services_table_html + "\n<br>")
382382
combined_report_file.write("\n</div>")
383383

384-
all_paths = lib.db.get_all_paths_for_host(vhost)
384+
all_paths = lib.db.get_all_paths_for_host_exclude_404(vhost)
385385
#print(str(all_paths))
386386
#print(len(all_paths))
387387
if len(all_paths) > 0:

lib/screenshot.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def screenshot_command(arguments):
4141

4242
# lib.screenshot.screenshot_all_paths(workspace)
4343
#TODO: change this to reflect number of screenshots taken based on config.ini max
44-
paths_len = len(lib.db.get_all_paths(workspace))
44+
paths_len = len(lib.db.get_all_paths_exclude_404(workspace))
4545
max_paths_len = len(get_max_screenshots(workspace,config_file))
4646
max = lib.config_parser.get_screenshot_max(config_file)
4747
print("[+]\n[+] There are [{0}] paths in the DB").format(str(paths_len))
@@ -65,7 +65,7 @@ def aquatone_all_paths(workspace,simulation=None,config_file=None):
6565
#print("in aquatone all_paths")
6666
urls_to_screenshot = []
6767
#TODO: Instead of just grabbing all paths here, maybe add some logic to see if only new paths should be scanned or something. at a minimum, as they are grabbed, we need to update the "screenshot taken" column and put the auatone directory or something like that.
68-
paths = lib.db.get_all_paths(workspace)
68+
paths = lib.db.get_all_paths_exclude_404(workspace)
6969
celery_path = lib.db.get_current_install_path()[0][0]
7070
outdir = lib.db.get_output_dir_for_workspace(workspace)[0][0]
7171
outdir = os.path.join(outdir,'celerystalkReports/aquatone/')

parsers/generic_urlextract.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -63,29 +63,29 @@ def is_url_in_scope(url):
6363
else:
6464
return str(False)
6565

66-
def insert_url_into_db(vhost,port,url,workspace):
67-
db_path = (vhost, port, url, 0, "", workspace)
66+
def insert_url_into_db(vhost,port,url,url_status, workspace):
67+
db_path = (vhost, port, url, url_status, 0, "", workspace)
6868
lib.db.insert_new_path(db_path)
69-
print("Found Url: " + str(url))
7069

7170
def extract_in_scope_urls_from_task_output(tool_output):
7271
urls = extract_urls(tool_output)
72+
valid_url_count = 0
7373
for url in urls:
74-
exists,vhost,port,url,workspace = is_url_in_scope(url)
75-
if exists == "True":
74+
is_in_scope,vhost,port,url,workspace = is_url_in_scope(url)
75+
if is_in_scope == "True":
7676
url_status = check_if_page_exists(url)
77-
if url_status:
78-
insert_url_into_db(vhost, port, url, workspace)
77+
print(url,url_status)
78+
if url_status != 999:
79+
insert_url_into_db(vhost, port, url, url_status, workspace)
80+
valid_url_count += 1
81+
return valid_url_count
82+
83+
7984

8085
def check_if_page_exists(url):
8186
try:
8287
response = requests.head(url, timeout=5, verify=False)
8388
status_code = response.status_code
84-
reason = response.reason
8589
except requests.exceptions.ConnectionError:
8690
status_code = 999
87-
reason = 'ConnectionError'
88-
if status_code == 200:
89-
return status_code
90-
else:
91-
print("Skipping Url (not found): " + str(url))
91+
return status_code

0 commit comments

Comments
 (0)