Skip to content

deekshithaby/ThreatIntelAI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ ThreatIntelAI - AI-Powered Security Log Analysis & Incident Response

An intelligent system that ingests security logs, detects anomalous patterns, and leverages Google Generative AI to explain incidents and suggest mitigation strategies.

Python Flask Streamlit AI License

🎯 Features

βœ… Real-time Log Analysis - Upload CSV/TXT security logs instantly
βœ… AI Threat Detection - Identifies 4+ threat categories using pattern matching
βœ… Automated Risk Scoring - Real-time severity assessment (High/Medium/Low)
βœ… AI-Generated Reports - Google Gemini creates comprehensive incident reports
βœ… Interactive Security Bot - Ask questions, get expert security advice
βœ… Beautiful Visualizations - Interactive threat breakdown charts with Plotly
βœ… JSON Export - Download detailed analysis reports for compliance

πŸ—οΈ System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    STREAMLIT FRONTEND (Port 8501)               β”‚
β”‚  βœ“ File Upload & Visualization                  β”‚
β”‚  βœ“ Real-time Threat Dashboard                   β”‚
β”‚  βœ“ AI-Powered Security Bot Chat                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                 β”‚ HTTP/REST API
                 β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚      FLASK BACKEND (Port 5000)                  β”‚
β”‚  βœ“ Anomaly Detection Engine                     β”‚
β”‚  βœ“ Pattern-Based Threat Scoring                 β”‚
β”‚  βœ“ AI Report Generation                         β”‚
β”‚  βœ“ Security Q&A Processing                      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                 β”‚
                 β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    GOOGLE GENERATIVE AI (Gemini 2.0)            β”‚
β”‚  βœ“ Incident Report Writing                      β”‚
β”‚  βœ“ Expert Security Guidance                     β”‚
β”‚  βœ“ Threat Analysis & Explanations               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Quick Start

Prerequisites

  • Python 3.12+
  • Google Generative AI API Key (free tier)
  • 2 minutes setup

Installation

# Clone repository
git clone https://github.com/deekshithaby/ThreatIntelAI.git
cd ThreatIntelAI

# Install dependencies
pip install -r requirements.txt

# Create .env file with your Google API key
echo 'GOOGLE_API_KEY=your_key_here' > .env

Running the Application

Terminal 1 - Start Backend:

python3 backend.py

Expected:

πŸš€ Flask Backend Starting...
πŸ“ http://localhost:5000
βœ… AI Chatbot ENABLED (Google Gemini)

Terminal 2 - Start Frontend:

streamlit run app.py

Expected:

Local URL: http://localhost:8501

Open Browser:

http://localhost:8501

πŸ“Š How It Works

1. Upload Logs

User uploads security logs (CSV/TXT) containing system events, authentication attempts, network activity.

2. Anomaly Detection

Backend analyzes logs for threats:

  • Brute Force Attacks - Multiple failed login attempts
  • Privilege Escalation - Unauthorized sudo/admin access
  • Data Exfiltration - Suspicious data transfers
  • System Anomalies - Crashes, errors, timeouts

3. Risk Assessment

Threats are quantified:

  • πŸ”΄ High Risk (>10 anomalies)
  • 🟑 Medium Risk (3-10 anomalies)
  • 🟒 Low Risk (<3 anomalies)

4. AI Analysis

Google Gemini generates:

  • Executive summary
  • Root cause analysis
  • Immediate action items
  • Long-term remediation plans
  • Prevention strategies

5. Interactive Security Bot

Ask questions like:

  • "What does this threat mean?"
  • "How do I fix this?"
  • "What are my top 3 risks?"

AI responds with expert security guidance.

πŸ” Detected Threats

Threat Detection Method Severity
Brute Force Attack Failed login patterns πŸ”΄ Critical
Privilege Escalation Sudo/admin access logs πŸ”΄ Critical
Data Exfiltration Large transfer detection 🟑 High
System Anomaly Error/crash patterns 🟑 Medium

πŸ“‘ API Endpoints

POST /detect-anomalies

Detects threats in logs.

{
  "logs": "log file content"
}

Response:

{
  "threat_scores": {...},
  "total_anomalies": 14,
  "top_threat": "Brute Force Attack",
  "risk_level": "πŸ”΄ High"
}

POST /incident-report

Generates AI incident report.

POST /ask-security

Answers security questions about threats.

πŸ› οΈ Tech Stack

Component Technology
Frontend Streamlit
Backend Flask (REST API)
Detection Regex pattern matching
AI/LLM Google Generative AI (Gemini)
Visualization Plotly
Data Processing Pandas, NumPy

πŸ“ˆ Resume Bullet Points

  • Built AI-driven security log analysis system to detect and classify anomalous patterns across multiple threat categories
  • Designed Flask REST API backend with pattern-based anomaly detection achieving real-time threat scoring
  • Integrated Google Generative AI (Gemini) for automated incident report generation and expert security guidance
  • Developed Streamlit frontend with interactive visualizations and AI-powered security chatbot
  • Implemented full-stack architecture connecting data ingestion β†’ analysis β†’ visualization β†’ AI explanation

πŸš€ Future Enhancements

  • Real-time log streaming from SIEM tools
  • Machine learning-based anomaly detection (Isolation Forest, Autoencoders)
  • Database integration for log persistence
  • Multi-user dashboard with role-based access control
  • Automated alert notifications (email, Slack)
  • Integration with security tools (Splunk, Datadog, ELK)
  • Docker containerization & Kubernetes deployment
  • Advanced threat intelligence correlation
  • MITRE ATT&CK framework mapping

πŸ“„ License

MIT License - Free for educational and commercial use

πŸ‘¨β€πŸ’» Author

Created as an AI security automation project.


Status: Active Development
Last Updated: January 6, 2025

About

AI-Powered Security Log Analysis & Incident Response System

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages