Skip to content

Xyness/Phantom

Repository files navigation

Phantom — Attack Surface Analyzer

A security reconnaissance and attack surface analysis framework combining a Rust async port scanner, Python recon modules, FastAPI backend, and Next.js dashboard.

Disclaimer: Phantom is intended for authorized security assessments only. Always obtain explicit permission before scanning any target. Unauthorized scanning may violate laws and regulations.

Screenshot

Phantom Dashboard

Architecture

phantom/
├── scanner/       # Rust async TCP port scanner (tokio, clap)
├── recon/         # Python recon modules (DNS, TLS, HTTP, OSINT, Exposure)
├── api/           # FastAPI backend (orchestration, scoring, PDF export)
├── dashboard/     # Next.js + Tailwind + Recharts (interactive dashboard)
├── db/            # PostgreSQL schema
├── scripts/       # Utility scripts
└── docker-compose.yml

Features

  • Port Scanner — Async TCP connect scan with semaphore-based rate limiting and banner grabbing (Rust/tokio)
  • DNS Recon — A/AAAA/MX/NS/TXT/CNAME resolution, zone transfer detection, subdomain enumeration (wordlist + crt.sh)
  • TLS Analysis — Certificate validity, protocol version audit, HSTS check
  • HTTP Security — Security headers scoring, technology stack detection, CORS analysis
  • OSINT — WHOIS, ASN (RDAP), certificate transparency monitoring
  • Exposure Detection — Sensitive path fuzzing, .git exposure, secrets in headers, robots.txt analysis
  • CVE Matching — Local curated database (~100 CVEs) with regex banner matching
  • Risk Scoring — Weighted severity formula (critical=10, high=7, medium=4, low=1) on a 0-100 scale
  • PDF Reports — HTML-to-PDF generation via Jinja2 + WeasyPrint
  • Scan Comparison — Diff findings, ports, and subdomains between scans
  • Dark Dashboard — Interactive UI with risk gauge, severity charts, findings table, and comparison view

Quick Start

Using Docker Compose (recommended)

cp .env.example .env
docker compose up --build

Manual Setup

# 1. Database
docker compose up db -d

# 2. Scanner
cd scanner && cargo build --release

# 3. Recon modules
cd recon && pip install -e ".[dev]"

# 4. API
cd api && pip install -e ".[dev]"
uvicorn app.main:app --reload

# 5. Dashboard
cd dashboard && npm install && npm run dev

API Reference

Method Endpoint Description
POST /api/v1/scans Create and launch a new scan
GET /api/v1/scans List all scans
GET /api/v1/scans/{id} Get scan details
GET /api/v1/scans/{id}/findings Get scan findings (filterable)
GET /api/v1/scans/{id}/report/json Export JSON report
GET /api/v1/scans/{id}/report/pdf Export PDF report
POST /api/v1/comparisons Compare two scans
GET /health Health check

Create a Scan

curl -X POST http://localhost:8000/api/v1/scans \
  -H "Content-Type: application/json" \
  -d '{
    "target": "example.com",
    "ports": "22,80,443,8000-9000",
    "modules": ["dns", "tls", "http", "osint", "exposure"],
    "confirm_authorization": true
  }'

The confirm_authorization: true field is required — it serves as an explicit acknowledgment that you have permission to scan the target.

Running Tests

# All tests
./scripts/run-tests.sh

# Individual components
cd scanner && cargo test
cd recon && pytest tests/ -v
cd api && pytest tests/ -v
cd dashboard && npm run build

Technology Stack

Component Technology
Port Scanner Rust, tokio, clap
Recon Modules Python 3.12, httpx, dnspython, cryptography
Backend FastAPI, SQLAlchemy (async), Pydantic v2
Database PostgreSQL 16
Dashboard Next.js 14, Tailwind CSS, Recharts
PDF Export Jinja2, WeasyPrint
Containerization Docker, Docker Compose

Design Decisions

  1. Rust scanner as subprocess — Clean process boundary, independent testing, JSON stdout interface
  2. Async everywhere — FastAPI, SQLAlchemy async, httpx, asyncio.gather for concurrent recon
  3. Background tasks via asyncio.create_task — Simplicity over Celery for scan orchestration
  4. Weighted severity scoring — Reconnaissance-focused (not CVSS), logarithmic scaling to 100
  5. Curated local CVE database — No external API dependency, regex-based banner matching
  6. Authorization gate — Every active scan requires explicit confirm_authorization: true

License

MIT License — see LICENSE for details.

About

A security reconnaissance and attack surface analysis framework combining a Rust async port scanner, Python recon modules, FastAPI backend, and Next.js dashboard.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors