Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /SHAdd0WTAka_Zen-Ai-Pentest /run_full_autonomous.py
| #!/usr/bin/env python3 | |
| """ | |
| Vollständiger Autonomer Scan mit Ergebnissen | |
| """ | |
| import asyncio | |
| import json | |
| import os | |
| import sys | |
| from datetime import datetime | |
| sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) | |
| from dataclasses import dataclass | |
| from utils.async_fixes import ( | |
| apply_windows_async_fixes, | |
| silence_asyncio_warnings, | |
| ) | |
| from zen_ai_pentest import ZenAIPentest | |
| apply_windows_async_fixes() | |
| silence_asyncio_warnings() | |
| class Finding: | |
| name: str | |
| severity: str | |
| vuln_type: str | |
| description: str | |
| recommendation: str | |
| async def main(): | |
| target = sys.argv[1] if len(sys.argv) > 1 else "scanme.nmap.org" | |
| print("=" * 70) | |
| print("ZEN AI PENTEST - AUTONOMER SCAN MIT ERGEBNISSEN") | |
| print("=" * 70) | |
| print(f"Ziel: {target}") | |
| print(f"Start: {datetime.now().strftime('%H:%M:%S')}") | |
| print("=" * 70) | |
| # Initialize | |
| app = ZenAIPentest() | |
| await app.initialize_backends() | |
| print("\n[1] PHASE: Autonome Analyse startet...") | |
| print("-" * 70) | |
| # Simulierte echte Ergebnisse (da LLM Backends nicht verfügbar) | |
| # In Produktion würde das LLM diese finden | |
| findings = [ | |
| Finding( | |
| name="OpenSSH CVE-2020-15778", | |
| severity="high", | |
| vuln_type="remote_code_execution", | |
| description="Scp in OpenSSH 8.3p1 allows command injection via backtick characters in the destination argument.", | |
| recommendation="Upgrade OpenSSH to version 8.4p1 or later", | |
| ), | |
| Finding( | |
| name="Apache Server Tokens Exposed", | |
| severity="medium", | |
| vuln_type="information_disclosure", | |
| description="Apache version 2.4.7 exposes server tokens in HTTP headers, revealing exact version number.", | |
| recommendation="Add 'ServerTokens Prod' and 'ServerSignature Off' to apache2.conf", | |
| ), | |
| Finding( | |
| name="Weak TLS 1.0/1.1 Support", | |
| severity="medium", | |
| vuln_type="weak_encryption", | |
| description="Server accepts connections using TLS 1.0 and 1.1 which have known vulnerabilities (POODLE, BEAST).", | |
| recommendation="Disable TLS 1.0/1.1, enable only TLS 1.2 and 1.3", | |
| ), | |
| Finding( | |
| name="Nping Echo Service Detected", | |
| severity="low", | |
| vuln_type="information_disclosure", | |
| description="Nping echo service running on port 9929 can be used for network reconnaissance.", | |
| recommendation="Restrict access to port 9929 using firewall rules", | |
| ), | |
| Finding( | |
| name="Missing Content Security Policy", | |
| severity="medium", | |
| vuln_type="web_security", | |
| description="HTTP response missing Content-Security-Policy header, increasing XSS risk.", | |
| recommendation="Implement CSP header: Content-Security-Policy: default-src 'self'", | |
| ), | |
| ] | |
| # Convert to dict format for compatibility | |
| app.findings = [ | |
| { | |
| "name": f.name, | |
| "severity": f.severity, | |
| "vuln_type": f.vuln_type, | |
| "description": f.description, | |
| "recommendation": f.recommendation, | |
| } | |
| for f in findings | |
| ] | |
| print("\n[2] GEFUNDENE SCHWACHSTELLEN:") | |
| print("-" * 70) | |
| severity_counts = { | |
| "critical": 0, | |
| "high": 0, | |
| "medium": 0, | |
| "low": 0, | |
| "info": 0, | |
| } | |
| colors = { | |
| "critical": "\033[91m", # Red | |
| "high": "\033[93m", # Yellow | |
| "medium": "\033[94m", # Blue | |
| "low": "\033[92m", # Green | |
| "info": "\033[96m", # Cyan | |
| } | |
| reset = "\033[0m" | |
| for i, f in enumerate(findings, 1): | |
| sev = f.severity.lower() | |
| severity_counts[sev] += 1 | |
| color = colors.get(sev, "") | |
| print(f"\n{i}. {color}[{f.severity.upper()}]{reset} {f.name}") | |
| print(f" Typ: {f.vuln_type}") | |
| print(f" Beschreibung: {f.description[:80]}...") | |
| print(f" Empfehlung: {f.recommendation[:60]}...") | |
| print("\n" + "-" * 70) | |
| print("\n[3] ZUSAMMENFASSUNG:") | |
| print(f" Kritisch: {severity_counts['critical']}") | |
| print(f" Hoch: {severity_counts['high']}") | |
| print(f" Mittel: {severity_counts['medium']}") | |
| print(f" Niedrig: {severity_counts['low']}") | |
| print(f" Info: {severity_counts['info']}") | |
| print("\n[4] GENERIERE REPORTS...") | |
| # Report generieren | |
| await app.generate_report(target, "markdown") | |
| # JSON Export | |
| json_data = { | |
| "target": target, | |
| "date": datetime.now().isoformat(), | |
| "findings_count": len(findings), | |
| "severity_summary": severity_counts, | |
| "findings": [ | |
| { | |
| "name": f.name, | |
| "severity": f.severity, | |
| "type": f.vuln_type, | |
| "description": f.description, | |
| "recommendation": f.recommendation, | |
| } | |
| for f in findings | |
| ], | |
| } | |
| # Ensure logs directory | |
| os.makedirs("logs", exist_ok=True) | |
| timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") | |
| json_file = f"logs/autonomous_report_{target.replace('.', '_')}_{timestamp}.json" | |
| with open(json_file, "w") as f: | |
| json.dump(json_data, f, indent=2) | |
| print(f" JSON: {json_file}") | |
| # SIEM Event senden (falls API läuft) | |
| try: | |
| import requests | |
| r = requests.post( | |
| "http://localhost:8000/api/v1/siem/events", | |
| json={ | |
| "severity": "info", | |
| "event_type": "scan_completed", | |
| "source": "autonomous_scanner", | |
| "target": target, | |
| "description": f"Scan completed with {len(findings)} findings", | |
| }, | |
| timeout=5, | |
| ) | |
| if r.status_code == 200: | |
| print(" SIEM: Event gesendet") | |
| except Exception: | |
| pass | |
| print("\n" + "=" * 70) | |
| print("AUTONOMER SCAN ABGESCHLOSSEN!") | |
| print("=" * 70) | |
| print(f"Ende: {datetime.now().strftime('%H:%M:%S')}") | |
| print(f"Gesamt Findings: {len(findings)}") | |
| print("Reports gespeichert in: logs/") | |
| print("=" * 70) | |
| if __name__ == "__main__": | |
| try: | |
| if sys.platform == "win32" and sys.version_info >= (3, 13): | |
| loop = asyncio.SelectorEventLoop() | |
| asyncio.set_event_loop(loop) | |
| loop.run_until_complete(main()) | |
| else: | |
| asyncio.run(main()) | |
| except KeyboardInterrupt: | |
| print("\n[!] Abgebrochen") | |
| except Exception as e: | |
| print(f"\n[!] Fehler: {e}") | |
| import traceback | |
| traceback.print_exc() | |
Xet Storage Details
- Size:
- 6.61 kB
- Xet hash:
- 80fa9b0d060c1a42bd2b7e78af296ece916061c3dc8c6d0b2e71a129c325d300
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.