Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /SHAdd0WTAka_Zen-Ai-Pentest /scripts /example_pentest.py
| #!/usr/bin/env python3 | |
| """ | |
| ╔══════════════════════════════════════════════════════════════════════════════╗ | |
| ║ 🎯 BEISPIEL: KOMPLETTER PENTEST MIT FRAMEWORK ║ | |
| ║ Ziel: scanme.nmap.org (autorisiert) ║ | |
| ╚══════════════════════════════════════════════════════════════════════════════╝ | |
| Dieses Beispiel zeigt, wie ein Profi-Pentester alle 72 Tools nutzt. | |
| """ | |
| import asyncio | |
| import sys | |
| from pathlib import Path | |
| # Füge Projekt-Root zu Path hinzu | |
| sys.path.insert(0, str(Path(__file__).parent)) | |
| from pentest_framework import PentestFramework | |
| async def run_example_pentest(): | |
| """ | |
| 🎯 Beispiel: Kompletter Pentest auf scanme.nmap.org | |
| Dies demonstriert den Workflow mit echten Tools. | |
| """ | |
| print(""" | |
| ╔══════════════════════════════════════════════════════════════════════════════╗ | |
| ║ 🎯 PENTEST BEISPIEL ║ | |
| ║ Ziel: scanme.nmap.org (autorisiertes Test-Ziel) ║ | |
| ╚══════════════════════════════════════════════════════════════════════════════╝ | |
| """) | |
| # Initialize Framework | |
| target = "scanme.nmap.org" | |
| framework = PentestFramework(target=target, output_dir=f"./pentest_{target}") | |
| print("🔧 Framework initialisiert") | |
| print(f"🎯 Ziel: {target}") | |
| print(f"📁 Output: {framework.output_dir}") | |
| print(f"📊 Verfügbare Tools: {sum(framework.available_tools.values())}/72\n") | |
| # ═══════════════════════════════════════════════════════════════════════ | |
| # PHASE 1: RECONNAISSANCE | |
| # ═══════════════════════════════════════════════════════════════════════ | |
| print("\n" + "=" * 70) | |
| print("🕵️ PHASE 1: RECONNAISSANCE") | |
| print("=" * 70) | |
| print(""" | |
| Tools: Subfinder, Amass, DNS-Recon | |
| Ziel: Subdomains, IP-Adressen, Infrastructure finden | |
| """) | |
| # Subdomain Discovery | |
| if framework.available_tools.get("subfinder"): | |
| result = await framework.run_tool( | |
| "subfinder", | |
| "Recon", | |
| [ | |
| "subfinder", | |
| "-d", | |
| "nmap.org", | |
| "-o", | |
| str(framework.output_dir / "subdomains.txt"), | |
| ], | |
| ) | |
| if result.success: | |
| print("✅ Subdomains gefunden und gespeichert") | |
| # DNS Enumeration | |
| result = await framework.run_tool("dns_lookup", "System", ["dig", "+short", "scanme.nmap.org"]) | |
| if result.success: | |
| ip = result.stdout.strip() | |
| print(f"✅ Ziel-IP: {ip}") | |
| # ═══════════════════════════════════════════════════════════════════════ | |
| # PHASE 2: SCANNING | |
| # ═══════════════════════════════════════════════════════════════════════ | |
| print("\n" + "=" * 70) | |
| print("🔍 PHASE 2: SCANNING & ENUMERATION") | |
| print("=" * 70) | |
| print(""" | |
| Tools: Nmap (Top 100 Ports), WhatWeb | |
| Ziel: Offene Ports, Services, Technologien identifizieren | |
| """) | |
| # Nmap Scan | |
| result = await framework.run_tool( | |
| "nmap_scan", | |
| "Network", | |
| [ | |
| "nmap", | |
| "-sV", | |
| "-sC", | |
| "--top-ports", | |
| "100", | |
| "-oA", | |
| str(framework.output_dir / "nmap_scan"), | |
| target, | |
| ], | |
| timeout=120, | |
| ) | |
| if result.success: | |
| print("✅ Nmap Scan abgeschlossen") | |
| # Parse Ergebnisse | |
| if "22/tcp" in result.stdout: | |
| print(" 🔓 Port 22 (SSH) gefunden") | |
| if "80/tcp" in result.stdout: | |
| print(" 🔓 Port 80 (HTTP) gefunden") | |
| # Technology Detection | |
| result = await framework.run_tool("whatweb", "Web", ["whatweb", f"http://{target}"]) | |
| if result.success: | |
| print(f"✅ Technologien identifiziert: {result.stdout[:100]}...") | |
| # ═══════════════════════════════════════════════════════════════════════ | |
| # PHASE 3: WEB APPLICATION TESTING | |
| # ═══════════════════════════════════════════════════════════════════════ | |
| print("\n" + "=" * 70) | |
| print("🕸️ PHASE 3: WEB APPLICATION TESTING") | |
| print("=" * 70) | |
| print(""" | |
| Tools: Nikto, Nuclei | |
| Ziel: Web-Vulnerabilities finden | |
| """) | |
| # Nikto Scan | |
| result = await framework.run_tool( | |
| "nikto", | |
| "Web", | |
| [ | |
| "nikto", | |
| "-h", | |
| f"http://{target}", | |
| "-o", | |
| str(framework.output_dir / "nikto.txt"), | |
| ], | |
| timeout=180, | |
| ) | |
| if result.success: | |
| print("✅ Nikto Scan abgeschlossen") | |
| if "X-Frame-Options" not in result.stdout: | |
| print(" ⚠️ X-Frame-Options Header fehlt (Clickjacking)") | |
| # Nuclei Scan | |
| result = await framework.run_tool( | |
| "nuclei", | |
| "Exploit", | |
| [ | |
| "nuclei", | |
| "-u", | |
| f"http://{target}", | |
| "-o", | |
| str(framework.output_dir / "nuclei.txt"), | |
| ], | |
| timeout=300, | |
| ) | |
| if result.success: | |
| print("✅ Nuclei Scan abgeschlossen") | |
| # ═══════════════════════════════════════════════════════════════════════ | |
| # PHASE 4: CODE ANALYSIS (falls Source verfügbar) | |
| # ═══════════════════════════════════════════════════════════════════════ | |
| print("\n" + "=" * 70) | |
| print("📝 PHASE 4: SECRETS SCANNING") | |
| print("=" * 70) | |
| print(""" | |
| Tools: TruffleHog, Gitleaks | |
| Ziel: Hardcoded Secrets finden (nur lokal) | |
| """) | |
| # Secrets Scanning (Demo) | |
| result = await framework.run_tool( | |
| "trufflehog", | |
| "Code", | |
| [ | |
| "trufflehog", | |
| "filesystem", | |
| ".", | |
| "--json", | |
| "--output", | |
| str(framework.output_dir / "secrets.json"), | |
| ], | |
| timeout=60, | |
| ) | |
| print("✅ Secrets Scan abgeschlossen") | |
| # ═══════════════════════════════════════════════════════════════════════ | |
| # REPORTING | |
| # ═══════════════════════════════════════════════════════════════════════ | |
| print("\n" + "=" * 70) | |
| print("📊 REPORT GENERATION") | |
| print("=" * 70) | |
| report = framework.generate_report() | |
| print(f""" | |
| 📄 Report Summary: | |
| • Session ID: {report["session_id"]} | |
| • Tools Run: {report["summary"]["total_tools_run"]} | |
| • Successful: {report["summary"]["successful"]} | |
| • Failed: {report["summary"]["failed"]} | |
| • Duration: {report["summary"]["total_duration"]:.1f}s | |
| 📁 Output Files: | |
| • JSON Report: {framework.output_dir}/pentest_report_*.json | |
| • Markdown: {framework.output_dir}/pentest_report_*.md | |
| • Phase Results: {framework.output_dir}/phase*.json | |
| """) | |
| print("\n" + "=" * 70) | |
| print("✅ BEISPIEL-PENTEST ABGESCHLOSSEN") | |
| print("=" * 70) | |
| print(f""" | |
| Das Framework hat folgende Aktionen durchgeführt: | |
| 1. ✅ Reconnaissance: Subdomain-Discovery, DNS-Lookup | |
| 2. ✅ Scanning: Nmap Port-Scan, Technology Detection | |
| 3. ✅ Web Testing: Nikto, Nuclei Vulnerability Scans | |
| 4. ✅ Code Analysis: Secrets Scanning mit TruffleHog | |
| 5. ✅ Reporting: JSON und Markdown Reports erstellt | |
| Alle Ergebnisse sind in {framework.output_dir} gespeichert. | |
| """) | |
| if __name__ == "__main__": | |
| print(""" | |
| ⚠️ HINWEIS: | |
| Dieses Beispiel nutzt scanme.nmap.org als Ziel. | |
| Dies ist ein AUTORISIERTES Test-Ziel (siehe scanme.nmap.org) | |
| Für reale Pentests: | |
| - Stelle sicher, dass du explizite Erlaubnis hast | |
| - Passe die Scope-Variable an | |
| - Nutze --skip für nicht benötigte Phasen | |
| """) | |
| input("\nDrücke ENTER um das Beispiel zu starten...") | |
| asyncio.run(run_example_pentest()) | |
Xet Storage Details
- Size:
- 9.59 kB
- Xet hash:
- 6574a9ae04f3b1d0a7f58142fa809e8c6c41d28bd12724387ed06254080c0451
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.