Skip to content

freddycodes23/ZeroDayAlerts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ZeroDayAlerts

A comprehensive Python-based web application for monitoring and receiving notifications about Zero-Day CVE (Common Vulnerabilities and Exposures) alerts.

Features

  • Real-time CVE Monitoring: Automatically fetches the latest CVE data from NIST's National Vulnerability Database
  • Zero-Day Detection: Uses intelligent heuristics to identify potential zero-day vulnerabilities
  • Custom Notifications: Email alerts with customizable filters for severity, vendors, and vulnerability types
  • Interactive Dashboard: Modern web interface with real-time statistics and filtering capabilities
  • REST API: Full API for programmatic access to CVE data
  • Automated Scheduling: Background tasks for continuous monitoring and notifications

Tech Stack

  • Backend: Python, Flask, SQLAlchemy
  • Frontend: Python (Flask templates with Jinja2), Bootstrap 5, JavaScript
  • Database: SQLite (default), PostgreSQL/MySQL supported
  • Scheduling: APScheduler for background tasks
  • Email: SMTP integration for notifications
  • API: RESTful API for CVE data access

Quick Start

Prerequisites

  • Python 3.8+
  • pip (Python package manager)

Installation

  1. Clone the repository:

    git clone https://github.com/freddycodes23/ZeroDayAlerts.git
    cd ZeroDayAlerts
  2. Install dependencies:

    pip install -r requirements.txt
  3. Configure environment variables:

    cp .env.example .env
    # Edit .env with your configuration
  4. Initialize the database:

    python manage.py init-db
  5. Create sample data (optional):

    python manage.py create-sample-data
  6. Run the application:

    python app.py

The application will be available at http://localhost:5000

Configuration

Environment Variables

Create a .env file with the following variables:

# Application
SECRET_KEY=your-secret-key-here
DATABASE_URL=sqlite:///zeroday_alerts.db

# Email Configuration (for notifications)
MAIL_SERVER=smtp.gmail.com
MAIL_PORT=587
MAIL_USE_TLS=True
MAIL_USERNAME=your-email@gmail.com
MAIL_PASSWORD=your-app-password

# CVE API
CVE_API_URL=https://services.nvd.nist.gov/rest/json/cves/2.0

Email Setup

For Gmail:

  1. Enable 2-factor authentication
  2. Generate an app-specific password
  3. Use the app password in MAIL_PASSWORD

Usage

Web Interface

  1. Home Page: View latest CVE alerts with filtering options
  2. Dashboard: Real-time statistics and zero-day alerts overview
  3. Subscribe: Configure notification preferences
  4. Alert Details: Detailed information about specific CVEs

Management Commands

# Fetch latest CVEs
python manage.py fetch-cves --days 7

# Send notifications
python manage.py send-notifications

# Initialize database
python manage.py init-db

# Create sample data
python manage.py create-sample-data

API Endpoints

  • GET /api/alerts - List all alerts with pagination and filtering
  • GET /api/alerts/{id} - Get specific alert details
  • GET /api/alerts/recent - Get recent alerts
  • GET /api/alerts/zero-day - Get zero-day alerts only
  • GET /api/stats - Get application statistics
  • POST /api/subscribe - Subscribe to notifications

API Examples

# Get recent critical alerts
curl "http://localhost:5000/api/alerts?severity=CRITICAL&page=1"

# Get zero-day alerts
curl "http://localhost:5000/api/alerts/zero-day"

# Subscribe to notifications
curl -X POST "http://localhost:5000/api/subscribe" \
  -H "Content-Type: application/json" \
  -d '{"email": "user@example.com", "name": "John Doe", "severity_filter": ["HIGH", "CRITICAL"]}'

Project Structure

ZeroDayAlerts/
├── app/
│   ├── __init__.py          # Flask app factory
│   ├── models.py            # Database models
│   ├── cve_fetcher.py       # CVE data fetching logic
│   ├── notifications.py     # Email notification service
│   ├── scheduler.py         # Background task scheduler
│   ├── main/                # Main blueprint
│   │   ├── routes.py        # Web routes
│   │   └── forms.py         # Web forms
│   ├── api/                 # API blueprint
│   │   └── routes.py        # API endpoints
│   ├── templates/           # Jinja2 templates
│   └── static/              # CSS, JS, images
├── config.py                # Configuration
├── app.py                   # Application entry point
├── manage.py               # CLI management commands
├── requirements.txt        # Python dependencies
└── .env                    # Environment variables

Database Schema

CVEAlert

  • CVE ID, description, severity, CVSS score
  • Publication and modification dates
  • Vendor and product information
  • Zero-day classification flag

User

  • Email, name, subscription status
  • Creation date and activity status

NotificationPreference

  • Severity filters, vendor filters
  • Zero-day only option
  • Email notification settings

NotificationLog

  • Notification history and delivery status

Automated Tasks

The application includes automated background tasks:

  • CVE Fetching: Runs every 4 hours to get latest CVE data
  • Notifications: Checks every 30 minutes for new alerts to send
  • Database Cleanup: Periodic cleanup of old notification logs

Security Features

  • Input Validation: All user inputs are validated and sanitized
  • CSRF Protection: Forms include CSRF tokens
  • Email Verification: Email addresses are validated
  • Rate Limiting: API endpoints can be rate-limited
  • Secure Headers: Security headers are set automatically

Deployment

Production Setup

  1. Use a production WSGI server:

    pip install gunicorn
    gunicorn -w 4 -b 0.0.0.0:8000 app:app
  2. Use a production database:

    DATABASE_URL=postgresql://user:password@localhost/zeroday_alerts
  3. Set up reverse proxy (nginx/Apache)

  4. Configure SSL/TLS for HTTPS

  5. Set up monitoring and logging

Docker Deployment

FROM python:3.9-slim

WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt

COPY . .
EXPOSE 5000

CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5000", "app:app"]

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/new-feature)
  3. Commit your changes (git commit -am 'Add new feature')
  4. Push to the branch (git push origin feature/new-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

  • Documentation: Check the code comments and docstrings
  • Issues: Open an issue on GitHub for bugs or feature requests
  • Security: Report security vulnerabilities privately

Acknowledgments

  • NIST NVD: CVE data source
  • Flask: Web framework
  • Bootstrap: Frontend framework
  • Contributors: Thanks to all contributors

Note: This application is for educational and monitoring purposes. Always verify CVE information from official sources before taking action.

About

Notifications app for zero-day alerts as they become known.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors