Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /SHAdd0WTAka_Zen-Ai-Pentest /pentest_quickstart.py
| #!/usr/bin/env python3 | |
| """ | |
| 🛡️ Zen-AI-Pentest Quickstart | |
| Schneller Pentest-Workflow für eine Ziel-Website | |
| Verwendung: | |
| python pentest_quickstart.py --target example.com | |
| python pentest_quickstart.py --target https://example.com --full | |
| """ | |
| import argparse | |
| import asyncio | |
| import json | |
| import sys | |
| from datetime import datetime | |
| from pathlib import Path | |
| # Framework-Module | |
| sys.path.insert(0, str(Path(__file__).parent)) | |
| class PentestWorkflow: | |
| """Automatisierter Pentest-Workflow""" | |
| def __init__(self, target: str, output_dir: str = "reports"): | |
| self.target = target.replace("https://", "").replace("http://", "").rstrip("/") | |
| self.output_dir = Path(output_dir) | |
| self.output_dir.mkdir(exist_ok=True) | |
| self.timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") | |
| self.findings = [] | |
| async def run_reconnaissance(self): | |
| """Phase 1: Reconnaissance""" | |
| print("\n" + "=" * 60) | |
| print("🔍 PHASE 1: RECONNAISSANCE") | |
| print("=" * 60) | |
| try: | |
| from tools.subdomain_enum import SubdomainEnumerator | |
| print(f"[+] Enumerating subdomains for {self.target}...") | |
| enumerator = SubdomainEnumerator() | |
| subdomains = enumerator.enumerate(self.target) | |
| print(f"[+] Found {len(subdomains)} subdomains") | |
| self.findings.append( | |
| { | |
| "phase": "reconnaissance", | |
| "type": "subdomains", | |
| "data": subdomains, | |
| } | |
| ) | |
| except Exception as e: | |
| print(f"[!] Reconnaissance error: {e}") | |
| async def run_port_scan(self): | |
| """Phase 2: Port Scanning""" | |
| print("\n" + "=" * 60) | |
| print("🔍 PHASE 2: PORT SCANNING") | |
| print("=" * 60) | |
| try: | |
| from tools.nmap_integration import NmapScanner | |
| print(f"[+] Scanning {self.target} (top 1000 ports)...") | |
| scanner = NmapScanner() | |
| result = scanner.scan_top_ports(self.target) | |
| print(f"[+] Scan complete - {len(result.get('ports', []))} open ports") | |
| self.findings.append({"phase": "port_scan", "data": result}) | |
| except Exception as e: | |
| print(f"[!] Port scan error: {e}") | |
| async def run_web_scan(self): | |
| """Phase 3: Web Application Scanning""" | |
| print("\n" + "=" * 60) | |
| print("🕷️ PHASE 3: WEB APPLICATION SCANNING") | |
| print("=" * 60) | |
| try: | |
| from tools.nuclei_integration import NucleiScanner | |
| target_url = f"https://{self.target}" | |
| print(f"[+] Running Nuclei scan on {target_url}...") | |
| nuclei = NucleiScanner() | |
| results = nuclei.scan( | |
| target_url, | |
| templates=["cves", "vulnerabilities", "misconfiguration"], | |
| rate_limit=100, | |
| ) | |
| vulnerabilities = results.get("vulnerabilities", []) | |
| print(f"[+] Found {len(vulnerabilities)} vulnerabilities") | |
| for vuln in vulnerabilities[:5]: # Zeige Top 5 | |
| severity = vuln.get("severity", "unknown") | |
| name = vuln.get("name", "Unknown") | |
| print(f" [{severity.upper()}] {name}") | |
| self.findings.append({"phase": "web_scan", "data": results}) | |
| except Exception as e: | |
| print(f"[!] Web scan error: {e}") | |
| async def run_secret_scan(self): | |
| """Phase 4: Secret Detection""" | |
| print("\n" + "=" * 60) | |
| print("🔐 PHASE 4: SECRET DETECTION") | |
| print("=" * 60) | |
| try: | |
| from tools.trufflehog_integration import TruffleHogScanner | |
| print(f"[+] Scanning for secrets in {self.target}...") | |
| scanner = TruffleHogScanner() | |
| results = scanner.scan_website(self.target) | |
| secrets = results.get("secrets", []) | |
| print(f"[+] Found {len(secrets)} potential secrets") | |
| self.findings.append({"phase": "secret_scan", "data": results}) | |
| except Exception as e: | |
| print(f"[!] Secret scan error: {e}") | |
| async def run_autonomous_analysis(self): | |
| """Phase 5: Autonomous KI-Analyse""" | |
| print("\n" + "=" * 60) | |
| print("🤖 PHASE 5: AUTONOMOUS AI ANALYSIS") | |
| print("=" * 60) | |
| try: | |
| from autonomous.agent_loop import PentestAgent | |
| target_url = f"https://{self.target}" | |
| print(f"[+] Starting autonomous agent for {target_url}...") | |
| print("[+] Agent will analyze and suggest next steps...") | |
| agent = PentestAgent(target=target_url) | |
| analysis = agent.analyze_target() | |
| print("[+] Analysis complete") | |
| print(f" Risk Level: {analysis.get('risk_level', 'unknown')}") | |
| print(f" Recommendations: {len(analysis.get('recommendations', []))}") | |
| self.findings.append({"phase": "autonomous_analysis", "data": analysis}) | |
| except Exception as e: | |
| print(f"[!] Autonomous analysis error: {e}") | |
| def generate_report(self): | |
| """Generate final report""" | |
| print("\n" + "=" * 60) | |
| print("📊 GENERATING REPORT") | |
| print("=" * 60) | |
| report_file = self.output_dir / f"pentest_{self.target}_{self.timestamp}.json" | |
| report = { | |
| "target": self.target, | |
| "timestamp": self.timestamp, | |
| "summary": { | |
| "total_phases": len(self.findings), | |
| "findings_count": sum(len(f.get("data", [])) for f in self.findings), | |
| }, | |
| "findings": self.findings, | |
| } | |
| with open(report_file, "w") as f: | |
| json.dump(report, f, indent=2) | |
| print(f"[+] Report saved to: {report_file}") | |
| # Summary | |
| print("\n" + "=" * 60) | |
| print("📋 PENTEST SUMMARY") | |
| print("=" * 60) | |
| print(f"Target: {self.target}") | |
| print(f"Date: {self.timestamp}") | |
| print(f"Phases completed: {len(self.findings)}") | |
| print(f"Report: {report_file}") | |
| async def run_full_scan(self): | |
| """Run complete pentest workflow""" | |
| print("\n" + "🚀 " + "=" * 58) | |
| print(f" STARTING FULL PENTEST: {self.target}") | |
| print("=" * 58) | |
| await self.run_reconnaissance() | |
| await self.run_port_scan() | |
| await self.run_web_scan() | |
| await self.run_secret_scan() | |
| await self.run_autonomous_analysis() | |
| self.generate_report() | |
| async def run_quick_scan(self): | |
| """Run quick scan (Nuclei + Basic Recon)""" | |
| print("\n" + "⚡ " + "=" * 58) | |
| print(f" STARTING QUICK SCAN: {self.target}") | |
| print("=" * 58) | |
| await self.run_web_scan() | |
| await self.run_secret_scan() | |
| self.generate_report() | |
| def main(): | |
| parser = argparse.ArgumentParser( | |
| description="Zen-AI-Pentest Quickstart", | |
| formatter_class=argparse.RawDescriptionHelpFormatter, | |
| epilog=""" | |
| Beispiele: | |
| # Quick Scan (Nuclei + Secrets) | |
| python pentest_quickstart.py --target example.com | |
| # Full Pentest (alle Phasen) | |
| python pentest_quickstart.py --target example.com --full | |
| # Mit benutzerdefiniertem Output | |
| python pentest_quickstart.py --target example.com --full --output ./my_reports | |
| """, | |
| ) | |
| parser.add_argument("--target", "-t", required=True, help="Ziel-Website (z.B. example.com)") | |
| parser.add_argument( | |
| "--full", | |
| "-f", | |
| action="store_true", | |
| help="Vollständiger Pentest (alle Phasen)", | |
| ) | |
| parser.add_argument( | |
| "--output", | |
| "-o", | |
| default="reports", | |
| help="Output-Verzeichnis (default: reports)", | |
| ) | |
| args = parser.parse_args() | |
| # Safety Check | |
| print("\n" + "⚠️ " + "=" * 58) | |
| print(" SICHERHEITSHINWEIS") | |
| print("=" * 58) | |
| print(f"Ziel: {args.target}") | |
| print("\nStellen Sie sicher, dass:") | |
| print(" ✓ Sie Berechtigung für dieses Ziel haben") | |
| print(" ✓ Der Scope klar definiert ist") | |
| print(" ✓ Ein Notfall-Kontakt verfügbar ist") | |
| confirm = input("\nMöchten Sie fortfahren? (ja/nein): ") | |
| if confirm.lower() not in ["ja", "yes", "j", "y"]: | |
| print("Abgebrochen.") | |
| return | |
| # Starte Workflow | |
| workflow = PentestWorkflow(args.target, args.output) | |
| try: | |
| if args.full: | |
| asyncio.run(workflow.run_full_scan()) | |
| else: | |
| asyncio.run(workflow.run_quick_scan()) | |
| except KeyboardInterrupt: | |
| print("\n\n[!] Unterbrochen durch Benutzer") | |
| workflow.generate_report() | |
| except Exception as e: | |
| print(f"\n[!] Fehler: {e}") | |
| raise | |
| if __name__ == "__main__": | |
| main() | |
Xet Storage Details
- Size:
- 8.7 kB
- Xet hash:
- 77eec961cab7b564697d122155d131fd2b1737359d67d8c9234935746f6956c3
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.