""" NeuroSploit v3 - WAF Detector WAF fingerprinting, bypass strategy database, and payload adaptation for autonomous pentesting. Detects 15+ WAF vendors and provides per-WAF bypass techniques. """ import logging import re from dataclasses import dataclass, field from typing import Dict, List, Optional, Any logger = logging.getLogger(__name__) @dataclass class WAFMatch: """A detected WAF.""" name: str # "cloudflare", "aws_waf", etc. confidence: float # 0.0-1.0 detection_method: str # "header", "body", "server", "probe" evidence: str @dataclass class WAFResult: """Complete WAF detection result.""" detected_wafs: List[WAFMatch] = field(default_factory=list) blocking_patterns: Dict[str, bool] = field(default_factory=dict) recommended_delay: float = 0.1 # 15+ WAF signatures WAF_SIGNATURES = { "cloudflare": { "headers": ["cf-ray", "cf-request-id", "cf-cache-status"], "body": ["cloudflare", "ray id:", "error 1020", "error 1015"], "server": ["cloudflare"], }, "aws_waf": { "headers": ["x-amzn-requestid", "x-amzn-errortype"], "body": ["request blocked", "aws waf"], "server": ["cloudfront", "amazons3"], }, "akamai": { "headers": ["x-akamai-session-info", "akamai-origin-hop"], "body": ["akamai", "ghost"], "server": ["akamaighost"], }, "imperva": { "headers": ["x-iinfo", "x-cdn"], "body": ["imperva", "incapsula incident", "incapsula"], "server": ["imperva"], }, "modsecurity": { "headers": ["x-denied-reason", "x-modsecurity"], "body": ["mod_security", "modsecurity", "noyb"], "server": [], }, "f5_bigip": { "headers": ["x-waf-status", "x-cnection"], "body": ["the requested url was rejected"], "server": ["big-ip", "bigip", "f5"], }, "sucuri": { "headers": ["x-sucuri-id", "x-sucuri-cache"], "body": ["sucuri", "sucuri website firewall", "cloudproxy"], "server": ["sucuri"], }, "barracuda": { "headers": ["barra_counter_session"], "body": ["barracuda", "barracuda networks"], "server": [], }, "fortinet": { "headers": ["x-fw-server"], "body": ["fortigate", "fortiweb", "fortinet"], "server": ["fortiweb"], }, "citrix": { "headers": ["citrix-transactionid", "cneonction", "nncoection"], "body": ["citrix", "netscaler appfw"], "server": ["netscaler"], }, "azure_waf": { "headers": ["x-azure-ref", "x-ms-forbidden-ip"], "body": ["azure application gateway", "azure front door"], "server": ["microsoft-azure-application-gateway"], }, "gcp_armor": { "headers": ["x-cloud-trace-context"], "body": ["google cloud armor", "forbidden by security policy"], "server": ["google frontend", "gfe"], }, "wordfence": { "headers": [], "body": ["wordfence", "generated by wordfence", "this response was generated by wordfence"], "server": [], }, "cloudfront": { "headers": ["x-amz-cf-id", "x-amz-cf-pop"], "body": ["cloudfront", "error from cloudfront"], "server": ["cloudfront"], }, "fastly": { "headers": ["x-fastly-request-id", "fastly-restarts"], "body": ["fastly error"], "server": ["fastly"], }, "reblaze": { "headers": ["rbzid"], "body": ["reblaze", "access denied (rbz)"], "server": ["reblaze"], }, } # Bypass strategies per WAF BYPASS_STRATEGIES = { "cloudflare": { "xss": [ "unicode_escape", # \u003cscript\u003e "svg_payload", # "comment_injection", # ipt> "case_mixing", #