Modular Python-based network scanner with AI risk analysis, service detection, and secure scanning controls.
Browser / UI
│ HTTP
▼
Flask app
│
└──▶ External services — Google Gemini
- Language: Python
- Backend: Flask
- Integrations: Google Gemini
- Python 3.10+
git clone https://github.com/SabarishR08/network-port-scanner.git
cd network-port-scannerpython -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txtpython main.pyPowerScan is an AI-assisted network reconnaissance tool that combines port scanning with concise risk analysis and controlled scanning modes.
PowerScan is a modular network reconnaissance tool built with Python and Flask.
It extends a traditional TCP port scanner with service detection, AI-based risk classification, scan history comparison, and exportable reports.
Most port scanners return raw network data. PowerScan focuses on interpreting that data by attaching short, consistent risk explanations and enforcing safer scanning defaults.
PowerScan now shows which provider produced each risk result in the UI:
If Gemini is unavailable or rate-limited, PowerScan automatically falls back to Groq. If both fail, the result is marked as Fallback and still returns a deterministic risk line.
- Modular backend architecture:
config.pyfor environment and runtime settingsscanner.pyfor scanning/profiles/banner logicanalyzer.pyfor Gemini + Groq AI analysisutils.pyfor helper logic (classification, recommendations, parsing)main.pyfor API endpoints + orchestration
- Multi-threaded TCP scanning with configurable timeout and workers
- Smart service detection and banner probing:
- HTTP request probe (
GET / HTTP/1.1) - SSH handshake/banner detection
- Service/version normalization
- HTTP request probe (
- AI risk analyzer with strict one-line output parsing:
Risk: <Low/Medium/High> | Reason: <...>
- Batched AI analysis (single request for all open ports) for lower latency/cost
- AI provider fallback chain:
- Gemini first
- Groq fallback
- Deterministic fallback if both providers fail
- AI source attribution per port (
gemini,groq,fallback) shown in UI - Scan profiles:
quick_scan(top 100 ports)full_scan(1-65535)stealth_scan(lower threads, higher timeout)web_scan(80, 443, 8080)customrange
- SAFE_MODE / ADVANCED_MODE target controls:
- SAFE_MODE allows only
127.0.0.1,scanme.nmap.org, and private ranges - ADVANCED_MODE allows all targets
- SAFE_MODE allows only
- Target classification:
localhost,private,public- Warning flag for public scans
- Result enrichment per open port:
port,service,banner,risk,reason,ai_source
- Recommendation engine based on exposed services
- Persistent scan history in SQLite
- History comparison:
- new ports detected
- ports closed
- Report export:
TXTJSONPDF
- Frontend dashboard:
- Progress + status polling
- Risk and reason columns
- AI source badge column
- Comparison and recommendations panels
- Python 3.10+
- pip
git clone https://github.com/SabarishR08/network-port-scanner.git
cd network-port-scanner
pip install -r requirements.txtCreate a .env file at project root:
GEMINI_API_KEY=your_gemini_key
GROQ_API_KEY=your_groq_key
GEMINI_MODEL=gemini-2.0-flash
GROQ_MODEL=llama-3.1-8b-instant
# Optional runtime settings
HOST=0.0.0.0
PORT=5000
SCAN_MODE=SAFE_MODE
MAX_ACTIVE_JOBS=3
MAX_STORED_JOBS=50python portscanergui.pyOpen:
http://127.0.0.1:5000
POST /api/scan/start- start a new scanPOST /api/scan/<job_id>/stop- stop/close active job (compat endpoint)GET /api/scan/<job_id>/status- job status and resultsGET /api/scan/<job_id>/export?format=txt|json|pdf- export reportGET /api/history?limit=20- list historyGET /api/history/<job_id>- load one history item
{
"target": "scanme.nmap.org",
"profile": "web_scan",
"mode": "SAFE_MODE",
"banner_grab": true,
"timeout": 0.6,
"max_workers": 120
}network-port-scanner/
├── portscanergui.py
├── main.py
├── scanner.py
├── analyzer.py
├── utils.py
├── config.py
├── templates/
│ └── index.html
├── static/
│ ├── app.js
│ └── styles.css
├── requirements.txt
├── .env # local only (ignored)
├── scan_history.db # runtime DB
└── README.md
- Scan only systems you own or have permission to test.
- Store API keys in
.env; do not commit them. - Public targets trigger a warning in the UI/API.
- SAFE_MODE is recommended for controlled environments.
Unauthorized scanning may be illegal in your jurisdiction. Use responsibly and only with permission.
MIT — © 2026 Sabarish R.