Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /SHAdd0WTAka_Zen-Ai-Pentest /integration /cli.py
| #!/usr/bin/env python3 | |
| """ | |
| Zen Pentest Integration CLI | |
| Command-line interface for orchestrating classic pentesting tools | |
| """ | |
| import asyncio | |
| import json | |
| import sys | |
| from pathlib import Path | |
| import click | |
| from rich.console import Console | |
| from rich.json import JSON | |
| from rich.panel import Panel | |
| # Add parent to path | |
| sys.path.insert(0, str(Path(__file__).parent.parent)) | |
| from modules.tool_orchestrator import PENTEST_TOOLS, ToolOrchestrator | |
| console = Console() | |
| def cli(ctx, bridge): | |
| """Zen Pentest Integration CLI - Orchestrate classic tools""" | |
| ctx.ensure_object(dict) | |
| ctx.obj["bridge_url"] = bridge | |
| def tools(ctx): | |
| """List available tools""" | |
| console.print(Panel.fit("[bold cyan]Available Pentesting Tools[/]")) | |
| for name, config in PENTEST_TOOLS.items(): | |
| console.print(f"\n[bold green]{name}[/]") | |
| console.print(f" [dim]{config.description}[/]") | |
| console.print(f" Endpoint: {config.bridge_endpoint}") | |
| console.print(f" Duration: ~{config.typical_duration}s") | |
| def nmap(ctx, target, scan_type, ports, wait): | |
| """Run Nmap port scan""" | |
| bridge_url = ctx.obj["bridge_url"] | |
| async def run(): | |
| async with ToolOrchestrator(bridge_url) as orch: | |
| console.print(f"[bold]Starting Nmap {scan_type} scan against {target}...[/]") | |
| result = await orch.scan_with_nmap(target, scan_type=scan_type, ports=ports) | |
| scan_id = result["scan_id"] | |
| console.print(f"Scan ID: [cyan]{scan_id}[/]") | |
| if wait: | |
| console.print("Waiting for completion...") | |
| status = await orch.wait_for_scan(scan_id) | |
| console.print(f"Status: [green]{status['status']}[/]") | |
| if status["status"] == "completed": | |
| results = await orch.get_scan_results(scan_id) | |
| console.print(JSON(json.dumps(results, indent=2))) | |
| asyncio.run(run()) | |
| def sqlmap(ctx, url, level, risk, wait): | |
| """Run SQLMap scan""" | |
| bridge_url = ctx.obj["bridge_url"] | |
| async def run(): | |
| async with ToolOrchestrator(bridge_url) as orch: | |
| console.print(f"[bold]Starting SQLMap scan against {url}...[/]") | |
| result = await orch.scan_with_sqlmap(url, level=level, risk=risk) | |
| scan_id = result["scan_id"] | |
| console.print(f"Scan ID: [cyan]{scan_id}[/]") | |
| if wait: | |
| console.print("Waiting for completion... (this may take a while)") | |
| status = await orch.wait_for_scan(scan_id, timeout=7200) | |
| console.print(f"Status: [green]{status['status']}[/]") | |
| asyncio.run(run()) | |
| def nuclei(ctx, target, severity, wait): | |
| """Run Nuclei vulnerability scan""" | |
| bridge_url = ctx.obj["bridge_url"] | |
| async def run(): | |
| async with ToolOrchestrator(bridge_url) as orch: | |
| console.print(f"[bold]Starting Nuclei scan against {target}...[/]") | |
| result = await orch.scan_with_nuclei(target, severity=severity) | |
| scan_id = result["scan_id"] | |
| console.print(f"Scan ID: [cyan]{scan_id}[/]") | |
| if wait: | |
| console.print("Waiting for completion...") | |
| status = await orch.wait_for_scan(scan_id, timeout=1800) | |
| console.print(f"Status: [green]{status['status']}[/]") | |
| if status["status"] == "completed": | |
| results = await orch.get_scan_results(scan_id) | |
| console.print(JSON(json.dumps(results, indent=2))) | |
| asyncio.run(run()) | |
| def gobuster(ctx, url, wordlist, extensions): | |
| """Run Gobuster directory scan""" | |
| bridge_url = ctx.obj["bridge_url"] | |
| async def run(): | |
| async with ToolOrchestrator(bridge_url) as orch: | |
| console.print(f"[bold]Starting Gobuster scan against {url}...[/]") | |
| result = await orch.scan_with_gobuster(url, wordlist=wordlist, extensions=extensions) | |
| scan_id = result["scan_id"] | |
| console.print(f"Scan ID: [cyan]{scan_id}[/]") | |
| console.print("Waiting for completion...") | |
| status = await orch.wait_for_scan(scan_id, timeout=600) | |
| console.print(f"Status: [green]{status['status']}[/]") | |
| asyncio.run(run()) | |
| def amass(ctx, domain, active): | |
| """Enumerate subdomains with Amass""" | |
| bridge_url = ctx.obj["bridge_url"] | |
| async def run(): | |
| async with ToolOrchestrator(bridge_url) as orch: | |
| mode = "active" if active else "passive" | |
| console.print(f"[bold]Starting Amass {mode} enumeration for {domain}...[/]") | |
| result = await orch.enumerate_subdomains(domain, active=active) | |
| scan_id = result["scan_id"] | |
| console.print(f"Scan ID: [cyan]{scan_id}[/]") | |
| console.print("Waiting for completion... (this may take several minutes)") | |
| status = await orch.wait_for_scan(scan_id, timeout=3600) | |
| console.print(f"Status: [green]{status['status']}[/]") | |
| if status["status"] == "completed": | |
| results = await orch.get_scan_results(scan_id) | |
| subdomains = results.get("results", []) | |
| console.print(f"\n[bold]Found {len(subdomains)} subdomains:[/]") | |
| for subdomain in subdomains[:20]: # Show first 20 | |
| console.print(f" • {subdomain}") | |
| if len(subdomains) > 20: | |
| console.print(f" ... and {len(subdomains) - 20} more") | |
| asyncio.run(run()) | |
| def comprehensive(ctx, target, scan_type): | |
| """Run comprehensive multi-tool scan""" | |
| bridge_url = ctx.obj["bridge_url"] | |
| async def run(): | |
| async with ToolOrchestrator(bridge_url) as orch: | |
| results = await orch.run_comprehensive_scan(target, scan_type) | |
| orch.display_scan_summary(results) | |
| # Save results | |
| output_file = f"scan_results_{target.replace('/', '_')}_{scan_type}.json" | |
| with open(output_file, "w") as f: | |
| json.dump(results, f, indent=2) | |
| console.print(f"\n[green]Results saved to: {output_file}[/]") | |
| asyncio.run(run()) | |
| def status(ctx, scan_id): | |
| """Check scan status""" | |
| bridge_url = ctx.obj["bridge_url"] | |
| async def run(): | |
| async with ToolOrchestrator(bridge_url) as orch: | |
| status = await orch.get_scan_status(scan_id) | |
| console.print(JSON(json.dumps(status, indent=2, default=str))) | |
| asyncio.run(run()) | |
| def results(ctx, scan_id): | |
| """Get scan results""" | |
| bridge_url = ctx.obj["bridge_url"] | |
| async def run(): | |
| async with ToolOrchestrator(bridge_url) as orch: | |
| scan_results = await orch.get_scan_results(scan_id) | |
| console.print(JSON(json.dumps(scan_results, indent=2, default=str))) | |
| asyncio.run(run()) | |
| if __name__ == "__main__": | |
| cli() | |
Xet Storage Details
- Size:
- 8.51 kB
- Xet hash:
- 62512f591dd51662a9d76ea5bc8cfd6cac92c90f47ecc6021a4b1e231853e32a
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.