A comprehensive email security system that automatically detects, quarantines, and responds to phishing attempts using machine learning and rule-based detection.
- Machine Learning Classifier: Trained on phishing datasets using scikit-learn
- Rule-Based Engine: Pattern matching for suspicious keywords, URLs, and domains
- Attachment Analysis: OCR text extraction and VirusTotal scanning
- Multi-layered Detection: Combines ML predictions with rule-based analysis
- MailHog Integration: For testing environments
- Postfix Support: For production mail servers
- Real-time Processing: Continuous email monitoring
- Attachment Handling: Safe analysis of email attachments
- Secure Storage: SQLite database for quarantined emails
- Risk Scoring: Detailed threat assessment
- Safe Preview: Read-only email viewing with disabled links
- Bulk Management: Release, delete, or mark false positives
- Automated Blacklisting: Domain and IP blocking
- Smart Notifications: User and SOC team alerts
- Response Tracking: Detailed incident logging
- Escalation Rules: Risk-based alert prioritization
- Interactive Quizzes: Security awareness testing
- Progress Tracking: Individual performance metrics
- Gamification: Leaderboards and achievements
- Personalized Training: Recommendations based on exposure
- Web Dashboard: Real-time security overview
- Detailed Reports: Threat statistics and trends
- Performance Metrics: System health monitoring
- Export Capabilities: Data export for analysis
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Email Server βββββΆβ Detection βββββΆβ Quarantine β
β MailHog/Postfixβ β ML + Rules β β SQLite DB β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β
βΌ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Web Dashboard β β Incident β β User Training β
β Flask App β β Response β β Quiz System β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β
βΌ
βββββββββββββββββββ
β Monitoring β
β ELK + Grafana β
βββββββββββββββββββ
- Python 3.8+
- Docker & Docker Compose (optional)
- SQLite3
git clone https://github.com/suhasdk18/phishing-detection-system.git
cd phishing-detection-system
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txtcp config.yml.example config.yml
# Edit config.yml with your settingspython main.py --init-dbOption A: Using Docker Compose (Recommended)
docker-compose up -dOption B: Manual Setup
# Start MailHog for testing
docker run -d -p 1025:1025 -p 8025:8025 mailhog/mailhog
# Start Detection System
python main.py
# In another terminal, start Web Dashboard
python app.py- Web Dashboard: http://localhost:5000
- MailHog UI: http://localhost:8025
- Grafana: http://localhost:3000 (admin/admin)
- Kibana: http://localhost:5601
Navigate to http://localhost:5000 to access the main dashboard featuring:
- Real-time threat overview
- Quarantined email management
- User training portal
- System statistics
# Start monitoring
python main.py --mode monitor --interval 30
# Train ML model
python main.py --mode train --dataset data/phishing_dataset.csv
# Test single batch
python main.py --mode test
# Initialize databases
python main.py --init-dbGET /api/stats- System statisticsGET /api/quarantine- List quarantined emailsPOST /api/quarantine/{id}/release- Release emailPOST /api/quarantine/{id}/delete- Delete emailGET /api/training/quiz- Get quiz questionsPOST /api/training/submit- Submit quiz answers
phishing-detection-system/
βββ main.py # Main application entry point
βββ app.py # Web dashboard application
βββ requirements.txt # Python dependencies
βββ config.yml # Configuration file
βββ docker-compose.yml # Docker services setup
βββ Dockerfile # Container image definition
βββ README.md # This file
βββ .env.example # Environment variables template
βββ .gitignore # Git ignore rules
βββ src/ # Source code modules
β βββ detection/ # ML and rule-based detection
β βββ quarantine/ # Email quarantine system
β βββ response/ # Incident response automation
β βββ training/ # User training system
β βββ utils/ # Utility functions
βββ templates/ # HTML templates for web UI
βββ static/ # CSS, JS, and image assets
βββ data/ # Data storage directory
β βββ models/ # ML models
β βββ datasets/ # Training datasets
β βββ quarantine/ # Quarantined emails
βββ logs/ # Application logs
βββ tests/ # Unit and integration tests
βββ docs/ # Additional documentation
Edit config.yml to customize the system:
# Email server settings
email:
mode: "mailhog" # or "postfix"
host: "localhost"
port: 8025
# Detection thresholds
detection:
ml_threshold: 0.7
rule_threshold: 50
combined_threshold: 0.6
# External APIs
apis:
virustotal_key: "your_api_key"
abuseipdb_key: "your_api_key"
# Notifications
notifications:
smtp_host: "localhost"
smtp_port: 1025
from_address: "[email protected]"
soc_email: "[email protected]"python -m pytest tests/unit/python -m pytest tests/integration/curl -X POST http://localhost:8025/api/v1/messages \
-H "Content-Type: application/json" \
-d '{
"from": "[email protected]",
"to": ["[email protected]"],
"subject": "URGENT: Verify your account immediately",
"body": "Click here to verify: http://malicious-link.com"
}'Access Grafana at http://localhost:3000 with:
- Username:
admin - Password:
admin
Pre-configured dashboards include:
- Email Processing Overview
- Threat Detection Statistics
- System Performance Metrics
- User Training Progress
Kibana available at http://localhost:5601 for:
- Log analysis and searching
- Custom visualizations
- Alert management
- Data exploration
- Sandboxed Email Preview: Safe viewing without executing malicious content
- Automated Quarantine: Immediate isolation of suspicious emails
- Blacklist Management: Dynamic blocking of malicious senders/domains
- Audit Trail: Comprehensive logging of all security events
- Access Controls: Role-based permissions for dashboard access
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
suhasdk18
- Email: [email protected]
- GitHub: @suhasdk18
- PhishTank for phishing URL datasets
- VirusTotal for malware detection API
- scikit-learn for machine learning capabilities
- Flask for web framework
- The cybersecurity community for threat intelligence
If you encounter any issues or have questions:
- Check the Issues page
- Review the documentation in the
docs/directory - Contact the maintainer at [email protected]
- v1.0.0 - Initial release with basic detection and quarantine
- v1.1.0 - Added user training system and web dashboard
- v1.2.0 - Integrated ELK stack and Grafana monitoring
- v1.3.0 - Enhanced ML models and attachment analysis
β Star this repo if you find it helpful!