Spaces:
Runtime error
Runtime error
| """ | |
| Example: scanning DVWA running in Docker. | |
| Prerequisites | |
| ------------- | |
| 1. Install Docker | |
| 2. Run DVWA: ``docker run -d -p 8080:80 vulnerables/web-dvwa`` | |
| 3. Visit http://localhost:8080/setup.php and click "Create / Reset Database" | |
| 4. Install IntelliScan: ``pip install -e .`` | |
| Run this example | |
| ---------------- | |
| :: | |
| python examples/dvwa_scan.py | |
| """ | |
| from pathlib import Path | |
| from intelliscan import IntelliScan | |
| def main() -> None: | |
| scanner = IntelliScan( | |
| target="http://localhost:8080", | |
| auth=("admin", "password"), | |
| train_ml=True, | |
| report_pdf=Path("dvwa_report.pdf"), | |
| ) | |
| result = scanner.run() | |
| print("\n" + "=" * 50) | |
| print("DVWA scan complete") | |
| print("=" * 50) | |
| print(f"Target: {result.target}") | |
| print(f"Duration: {result.duration:.1f}s") | |
| print(f"Pages crawled: {result.crawl_stats['pages_visited']}") | |
| print(f"Forms found: {result.crawl_stats['forms']}") | |
| print(f"Injections sent: {result.injection_count}") | |
| print() | |
| print("Vulnerabilities by type:") | |
| for vt, stats in result.vulnerability_stats.items(): | |
| rate = stats["vulnerable"] / stats["total"] * 100 if stats["total"] else 0 | |
| print(f" {vt.upper():<8} {stats['vulnerable']:>3}/{stats['total']:<3} ({rate:.0f}%)") | |
| if result.ml_metrics: | |
| print("\nML classifier metrics:") | |
| print(f" Accuracy: {result.ml_metrics['accuracy']*100:.1f}%") | |
| print(f" F1-Score: {result.ml_metrics['f1_weighted']*100:.1f}%") | |
| print( | |
| f" CV F1: {result.ml_metrics['cv_mean']:.2f} +/- " | |
| f"{result.ml_metrics['cv_std']:.2f}" | |
| ) | |
| if result.report_path: | |
| print(f"\nPDF report: {result.report_path}") | |
| if __name__ == "__main__": | |
| main() | |