Share
## https://sploitus.com/exploit?id=118BD7C3-9E08-5E20-B90F-402659FBF5F2
# ๐Ÿ›ก๏ธ CyberGuard AI โ€” Cyber Threat Intelligence System

An **AI-powered, NLP-based Cyber Threat Intelligence System** built with
DistilBERT, Streamlit, and Python. Detects and classifies 6 threat types
from raw text with explainable AI, NER, keyword extraction, and PDF reports.

---

## ๐Ÿš€ Quick Start

### 1. Install dependencies
```bash
cd cyber_threat_intel
pip install -r requirements.txt
```

### 2. Launch the app (no training needed โ€” uses rule-based engine instantly)
```bash
streamlit run app.py
```

### 3. (Optional) Train DistilBERT for higher accuracy
```bash
python train.py
streamlit run app.py   # now uses the fine-tuned model
```

---

## ๐Ÿ“ Project Structure

```
cyber_threat_intel/
โ”œโ”€โ”€ app.py                      # Main Streamlit dashboard
โ”œโ”€โ”€ train.py                    # DistilBERT training pipeline
โ”œโ”€โ”€ requirements.txt
โ”‚
โ”œโ”€โ”€ config/
โ”‚   โ””โ”€โ”€ settings.py             # Global config, constants, paths
โ”‚
โ”œโ”€โ”€ data/
โ”‚   โ””โ”€โ”€ data_generator.py       # Synthetic dataset generator
โ”‚
โ”œโ”€โ”€ nlp/
โ”‚   โ””โ”€โ”€ preprocessor.py         # Text cleaning, NER, keyword extraction
โ”‚
โ”œโ”€โ”€ models/
โ”‚   โ”œโ”€โ”€ classifier.py           # DistilBERT fine-tune + inference
โ”‚   โ”œโ”€โ”€ rule_based.py           # Keyword-frequency fallback
โ”‚   โ””โ”€โ”€ saved/                  # Saved model weights (after training)
โ”‚
โ”œโ”€โ”€ intelligence/
โ”‚   โ”œโ”€โ”€ engine.py               # Threat analysis orchestration
โ”‚   โ””โ”€โ”€ report_generator.py     # PDF / text report generator
โ”‚
โ”œโ”€โ”€ ui/
โ”‚   โ””โ”€โ”€ components.py           # Reusable Streamlit UI components
โ”‚
โ”œโ”€โ”€ reports/                    # Auto-saved PDF/text reports
โ””โ”€โ”€ assets/                     # Static assets
```

---

## ๐ŸŽฏ Detected Threat Types

| Threat | Severity | Description |
|---|---|---|
| โœ… Benign | None | Normal security communications |
| ๐ŸŽฃ Phishing | High | Credential harvesting, social engineering |
| ๐Ÿฆ  Malware | Critical | Trojans, RATs, spyware, botnets |
| ๐Ÿ’ฐ Ransomware | Critical | File encryption, ransom demands |
| ๐Ÿ’ฅ DDoS | High | Volumetric/application layer flood attacks |
| ๐Ÿ’‰ SQL Injection | High | Database query manipulation attacks |

---

## ๐Ÿง  System Architecture

```
Input Text
    โ”‚
    โ–ผ
NLP Preprocessor โ”€โ”€โ–บ Text Cleaning, Tokenization, Lemmatization
    โ”‚
    โ”œโ”€โ”€โ–บ Named Entity Recognition (IPs, URLs, Emails, CVEs, Hashes)
    โ”‚
    โ”œโ”€โ”€โ–บ Keyword Extraction (per threat category)
    โ”‚
    โ–ผ
Classifier
    โ”œโ”€โ”€ DistilBERT (if trained model exists)
    โ””โ”€โ”€ Rule-Based Fallback (always available)
    โ”‚
    โ–ผ
Threat Intel Engine โ”€โ”€โ–บ Severity + Risk Score + XAI Reasoning
    โ”‚
    โ–ผ
Streamlit Dashboard โ”€โ”€โ–บ Charts, Entity Tags, Recommendations
    โ”‚
    โ–ผ
PDF Report Generator
```

---

## โšก Features

- ๐Ÿ” **Real-time analysis** โ€” instant results as you type/submit
- ๐Ÿง  **DistilBERT** โ€” transformer-based multi-class classification
- ๐ŸŽฏ **Confidence scoring** โ€” probability distribution across all 6 classes
- ๐Ÿ”Ž **NER** โ€” extracts IPs, URLs, emails, CVEs, file hashes
- ๐Ÿท๏ธ **Keyword extraction** โ€” maps to threat categories
- ๐Ÿงฉ **Explainable AI** โ€” human-readable reasoning for each prediction
- ๐Ÿ“Š **Interactive charts** โ€” gauge, donut, bar charts via Plotly
- ๐Ÿ“„ **PDF reports** โ€” downloadable threat intelligence reports
- ๐Ÿ•’ **Analysis history** โ€” tracks all analyses in session
- โšก **Rule-based fallback** โ€” works without GPU/training

---

## ๐Ÿ“ฆ Requirements

- Python 3.9+
- 4GB RAM minimum (8GB recommended for training)
- GPU optional (CPU inference supported)