
ThreatSentry AI is an intelligent threat hunting dashboard that leverages machine learning to proactively identify and prioritize risks in your network. It automates the process of collecting device information, enriching it with vulnerability data, and assessing risk levels, enabling security teams to focus on the most critical threats.
Automate external asset discovery, intelligently enrich with multi-source data, and leverage ensemble machine learning to predict and prioritize risk. Transform alert fatigue into actionable intelligence.
ThreatSentry AI eliminates security alert fatigue and enables proactive threat hunting through intelligent risk prioritization. It combines automated asset discovery, multi-source data enrichment, and advanced machine learning to transform raw security data into actionable intelligence.
Project Lead: EclipseManic
Development Note: This comprehensive enterprise security platform was architected and developed by a single developer with assistance from AI development tools for code generation, optimization, and documentation—demonstrating the viability of AI-augmented software engineering for complex systems.
Modern security teams face unprecedented challenges:
ThreatSentry AI solves these problems through:
![Automated Security Alert Email Template]
HTML formatted email with risk summary, CVE details, and remediation guidance sent via SendGrid
![ThreatSentry AI Dashboard - Main Threat Hunting Interface]
Real-time risk visualization with sortable device table and risk distribution bar chart
![Device Table with Risk Indicators]
Sortable and filterable device listing with color-coded risk levels (Green=Low, Yellow=Medium, Red=High)
![Advanced Filters - CVSS Range, Organization, Country, Risk Level]
Powerful filtering controls with CVSS range, organization, country, and risk level filters + "Clear All" button
![Search Input - Multi-Column Search Across Entire Database]
Intelligent search that spans entire device database, not just currently displayed rows
![Load More Button - Pagination Controls]
Optimized pagination system for handling thousands of devices efficiently
![Analytics Tab - Risk Trends and CVE Analysis]
Historical risk trends, vulnerability analysis, and organization-wise security metrics
![Tools Tab - Model Status and Data Export]
Model training information, performance metrics, data export, and advanced filtering options
![Automated Security Alert Email]
HTML formatted email with executive summary, vulnerability details, and remediation guidance
![Scan Trigger Dialog]
Execute Shodan + NVD enrichment with detailed error reporting and progress indication
┌─────────────────────────────────────────────────────────────┐
│ ThreatSentry AI │
├─────────────────────────────────────────────────────────────┤
│ Scheduler (APScheduler) │
├──────────┬──────────────┬──────────────┬───────────┬─────────┤
│ │ │ │ │ │
▼ ▼ ▼ ▼ ▼ ▼
Shodan NVD Lib CMDB SIEM Patch Network
Collector Collector Collector Collector Mgmt Monitor
│ │ │ │ │
└──────────────┴──────────────┴───────────┴─────────┘
│
▼
┌─────────────────┐
│ SQLite DB │
│ (40+ Columns) │
└────────┬────────┘
│
┌──────────────────┼──────────────────┐
▼ ▼ ▼
Feature Engine Model Training Predictions
│ │ │
└─────────┬───────┴──────────┬──────┘
▼ ▼
┌──────────────────────┐
│ Ensemble Model │
│ (RF + GB + MLP) │
└──────────┬───────────┘
│
┌────────────┼────────────┐
▼ ▼ ▼
PyQt5 GUI Email Alerts Analytics
Discovery Phase (Configurable interval, default 30 min)
Analysis Phase
Alerting Phase
Model Retraining (Configurable interval, default 60 min)
git clone https://github.com/EclipseManic/ThreatSentry-AI.git
cd ThreatSentry-AI
# On Windows
python -m venv .venv
.venv\Scripts\activate
# On macOS/Linux
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
Create a .env file in the project root:
cp .env.example .env # If provided, or create new
Edit .env with your credentials:
# Required - Threat Discovery
SHODAN_API_KEY=your_shodan_api_key_here
SHODAN_QUERY= # Leave empty to use presets
SHODAN_QUERY_EMPTY_TO_PRESET=True # Use preset queries when SHODAN_QUERY is empty
# Optional - Email Alerts
SENDGRID_API_KEY=your_sendgrid_key_here
[email protected] # Must be verified in SendGrid
[email protected],[email protected]
# Optional - Internal Enrichment (Implement in collectors/)
CMDB_API_ENDPOINT=https://cmdb.internal/api
CMDB_API_KEY=your_cmdb_key
SIEM_API_ENDPOINT=https://siem.internal/api
SIEM_API_KEY=your_siem_key
# Configuration
SCAN_INTERVAL_MINUTES=30 # How often to scan for new assets
RETRAIN_INTERVAL_MINUTES=60 # How often to retrain the model
MAX_SHODAN_RESULTS=50 # Results per Shodan query
LOG_LEVEL=INFO # DEBUG, INFO, WARNING, ERROR
# Paths (Optional)
SQLITE_PATH=data/db/threat_sentric_ai.db
MODEL_PATH=data/models/rf_model.pkl
LOG_FILE_PATH=data/logs/threat_sentric_ai.log
python -c "from data import init_db; init_db()"
python run.py
The dashboard will launch with the scheduler running in the background.
![Dashboard Main Interface with All Tabs] Overview, Analytics, and Tools tabs for comprehensive threat assessment
![Organization and Country Filters with Device List] Sortable device table with color-coded risk indicators (Green=Low, Yellow=Medium, Red=High)
![Risk Distribution Bar Chart] Overall security posture visualization with device counts per risk level
![Analytics Panel - Risk Trends and Metrics]
![Tools Panel - Model Status and Export
core/config.py)SHODAN_QUERIES = {
"default": "product:apache",
"web_apps": "http.title:\"login\" org:\"Your Company\"",
"database": "port:27017 OR port:3306",
"iot": "device:camera OR device:printer",
"rdp": "port:3389",
"vpn": "port:500 OR port:1194"
}
Implement in collectors/ directory:
_collect() method with your API callscore/scheduler.py)Edit alerts/email_alerts.py:
Core Identifiers: ip, org, country, first_seen, last_seen
Vulnerability: cve_count, max_cvss, vulnerabilities (rel)
Security Metrics: auth_failures_24h, traffic_anomaly_score, patch_lag_days
Risk Assessment: risk_label, risk_score, confidence_score
Context: network_segment, service_category, is_critical_service
Compliance: compliance_requirements, data_sensitivity_level
Historical: incident_history_count, last_compromise_date, false_positive_count
Alerting: notified, alert_history
Linked to Device: device_id (FK)
CVE Info: cve_id, cvss, summary
.env file. Dashboard will show error but continue processingcollectors/nvd_collector.py keyword listENABLE_EMAIL_ALERTS environment variable set to True.env to GitContributions are welcome! Please see CONTRIBUTING.md for guidelines.
Areas for enhancement:
This project is licensed under the MIT License—see LICENSE file for details.
Made with ❤️ by EclipseManic | Securing Tomorrow's Infrastructure Today pip install -r requirements.txt
---
## 🔐 Configuration
### 1. Environment Variables (`.env` file)
Create a `.env` file in the root directory with the following structure:
```bash
# --- Shodan API Key (Required) ---
SHODAN_API_KEY="YOUR_SHODAN_API_KEY"
# --- SendGrid Email Alerts (Required) ---
SENDGRID_API_KEY="YOUR_SENDGRID_API_KEY"
SENDER_EMAIL="[email protected]"
ALERT_RECIPIENTS="[email protected],[email protected]"
# --- Database ---
SQLITE_PATH="threat_sentric_ai.db"
# --- Model ---
MODEL_PATH="threatsentry_model.pkl"
# --- Scheduler ---
SCAN_INTERVAL_MINUTES="30"
RETRAIN_INTERVAL_MINUTES="60"
RETRAIN_ON_SCHEDULE="True"
# --- Shodan Query Behavior Control ---
SHODAN_QUERY=""
SHODAN_QUERY_EMPTY_TO_PRESET="True"
# --- Logging ---
LOG_LEVEL="INFO" # DEBUG, INFO, WARNING, ERROR, CRITICAL
# --- Internal System Credentials (Optional - Add as needed for your collectors) ---
# CMDB_API_ENDPOINT="..."
# CMDB_API_KEY="..."
# SIEM_API_ENDPOINT="..."
# SIEM_API_KEY="..."
# PATCH_API_ENDPOINT="..."
# PATCH_API_KEY="..."
# NETWORK_MONITOR_ENDPOINT="..."
# NETWORK_MONITOR_KEY="..."
The app loads environment variables via
os.getenv()inconfig.py.
Never commit this file to version control.
config.py)Modify the SHODAN_QUERIES dictionary to define your custom query presets:
SHODAN_QUERIES = {
"default": "product:apache",
"org": 'org:"Your Company Name"',
"net": 'net:"123.45.67.0/24"',
"ssl": 'ssl:"yourcompany.com"',
"hostname": 'hostname:".yourcompany.com"',
"rdp": 'port:3389 "remote desktop"',
"mongodb": 'port:27017 "mongodb"',
"ics_modbus": 'port:502 "modbus"',
"vuln_example": 'vuln:CVE-2024-12345',
"http_login": 'http.title:"Login" org:"Your Company"'
}
If SHODAN_QUERY in .env is empty and SHODAN_QUERY_EMPTY_TO_PRESET=True,
the scheduler will automatically cycle through these presets.
⚠️ Important: The internal collectors (
cmdb_collector.py,siem_collector.py,patch_collector.py,network_monitor_collector.py) are placeholders.
Replace the placeholder logic with real integrations to your systems.
You’ll need to:
Device model attributes.Without these integrations, the model will lack context for accurate predictions.
python scripts/generate_realistic_training_data.py --count 1000
Creates scripts/my_training_data.json.
You can upload this file through the GUI’s Upload option to initialize training data.
python run.py
The GUI will open and the scheduler will start scanning, enriching, and predicting automatically.
.env file (even with placeholder keys).config.py.python scripts/generate_realistic_training_data.py --count 500
python run.py
scripts/my_training_data.json# Generate 1000 records
python scripts/generate_realistic_training_data.py --count 1000
# View cleanup options
python scripts/clear_db_enhanced.py --help
# Delete all devices & vulnerabilities
python scripts/clear_db_enhanced.py --delete-devices --delete-vulns
# Reset notified flag
python scripts/clear_db_enhanced.py --reset-notified
# Dangerous full reset
python scripts/reset_db.py
This project was developed by EclipseManic.
While code contributions are currently closed, your feedback and bug reports are highly appreciated.
Please open an Issue to share your thoughts or report a problem.
This project is licensed under the MIT License.
See the LICENSE file for details.
| Layer | Technologies |
|---|
| Backend | Python 3.9+, SQLAlchemy ORM, APScheduler |
| ML/AI | Scikit-learn (Random Forest, Gradient Boosting, MLP), NumPy, Joblib |
| Frontend | PyQt5, Matplotlib, Custom theme manager |
| Data | Pandas, NumPy, SQLite3 |
| APIs | Shodan, NVDLib, SendGrid, Requests |
| Utilities | Python-dotenv, Logging module, Config management |
| Issue | Solution |
|---|
| Slow dashboard load | Increase pagination size in config |
| High CPU during training | Reduce n_estimators in model/advanced_model.py |
| High memory usage | Enable logging cleanup, reduce chart resolution |
| Slow Shodan scans | Reduce MAX_SHODAN_RESULTS, use more specific queries |
| Slow NVD enrichment | Implement API caching, reduce product keyword extraction |
| Script | Description |
|---|
| run.py | Main entry point. Starts DB, scheduler, and GUI. |
| scheduler.py | Handles periodic scanning, enrichment, prediction, and retraining. |
| scripts/generate_realistic_training_data.py | Generates realistic training data for testing or bootstrapping. |
| scripts/clear_db_enhanced.py | Interactively clean database or reset notification flags. |
| scripts/reset_db.py | Completely resets the database. Use with caution. |