File size: 1,781 Bytes
5e0bd20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""
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()