A Flask-based web application for detecting and analyzing cybersecurity threats using both machine learning models and VirusTotal API integration.
- User Authentication: Secure login/registration system with role-based access control (admin/user)
- Threat Detection: Analyze URLs, IPs, domains, and file hashes for potential threats
- Database Integration: SQLAlchemy ORM with support for SQLite, MySQL, and PostgreSQL
- VirusTotal API: Real-time threat analysis using VirusTotal API (with fallback simulation)
- Admin Panel: Admin users can view all system users and their activities
- Dashboard: Overview of security metrics and recent activity
- Scan History: Track and review previous threat analysis results
- Backend: Flask (Python 3.11+)
- Database: SQLAlchemy with support for SQLite, MySQL, PostgreSQL
- Authentication: Flask-Login with password hashing using Werkzeug
- Frontend: Jinja2 templates with Tailwind CSS and Material Icons
- API Integration: VirusTotal API for threat intelligence
- Clone the repository
- Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Set up environment variables (optional but recommended):
export VIRUSTOTAL_API_KEY="your_virustotal_api_key_here" export SECRET_KEY="your_secret_key_here"
- Run the application:
python main.py
- Visit http://localhost:5000 in your browser
- Use the default admin credentials to log in:
- Username:
admin - Password:
admin123
- Username:
The application can be configured using environment variables or by modifying app/config.py:
VIRUSTOTAL_API_KEY: Your VirusTotal API key for real threat analysisSECRET_KEY: Flask secret key for session managementDATABASE_URL: Database connection string (defaults to SQLite)
app/
├── __init__.py # Application factory with Flask-Login user_loader
├── app.py # Application factory pattern (deprecated, now in __init__.py)
├── config.py # Configuration settings
├── models.py # SQLAlchemy models (User, ScanRecord)
├── utils.py # Utility functions (VirusTotal API integration)
├── routes/
│ ├── auth.py # Authentication routes (login, register, logout)
│ └── main.py # Main application routes
├── static/ # Static assets (CSS, JS, icons)
└── templates/ # Jinja2 templates
- User: Stores user information with username, email, hashed password, and role (user/admin)
- ScanRecord: Stores threat analysis results with input value, scan type, verdict, and confidence
POST /analyze: Analyze a URL, IP, domain, or file hash for threatsGET /dashboard: User dashboard with security metricsGET /admin/users: Admin panel to view all users (admin only)
- Passwords are hashed using Werkzeug's secure hashing
- Session management using Flask-Login
- Role-based access controls for admin functionality
- Input validation and sanitization
The application integrates with the VirusTotal API for real-time threat intelligence. When an API key is provided, the application will:
- Submit the input (URL, IP, domain, or file hash) to VirusTotal
- Retrieve analysis results from security vendors
- Calculate a confidence score based on the number of vendors flagging the input as malicious
If no API key is provided, the application falls back to simulated analysis results.
To customize the application for your environment:
- Update
app/config.pywith your preferred settings - Modify templates in the
templates/directory to change the UI - Add new analysis functions in
app/utils.py - Extend the models in
app/models.pyas needed