An open API service indexing awesome lists of open source software.

https://github.com/hq969/cyber-threat-intelligence-analyzer

Cybersecurity Threat Intelligence Analyzer โ€” Log analysis tool with rule-based detections and ML anomaly detection, featuring a Streamlit dashboard and CLI support.
https://github.com/hq969/cyber-threat-intelligence-analyzer

cybersecurity docker machine-learning pytest security-monitoring streamlit threat-intelligence

Last synced: about 2 months ago
JSON representation

Cybersecurity Threat Intelligence Analyzer โ€” Log analysis tool with rule-based detections and ML anomaly detection, featuring a Streamlit dashboard and CLI support.

Awesome Lists containing this project

README

          

# ๐Ÿ”’ Cybersecurity Threat Intelligence Analyzer

A Python-based **threat intelligence tool** that ingests logs (CSV, JSON, Apache access logs), normalizes them, applies **rule-based detections** (brute-force, error spikes, suspicious UAs/paths, request floods), and runs **ML anomaly detection** (IsolationForest) to highlight unusual IP behavior.

Includes:
- ๐Ÿ“Š **Streamlit dashboard** for interactive analysis
- โšก **CLI mode** for headless batch processing
- ๐Ÿณ **Dockerfile** for containerized deployment
- โœ… **Tests** with pytest
- ๐Ÿ“ **Sample logs** for quick testing

---

## ๐Ÿš€ Features
- **Multiple log formats** supported (CSV, JSON, Apache combined log format)
- **Rule-based detections**:
- Brute-force login attempts (failed-login bursts)
- High error ratios (e.g. HTTP 5xx floods)
- Suspicious paths (`/wp-admin`, `/phpmyadmin`, `.env`, etc.)
- Suspicious user agents (e.g., `sqlmap`, `nmap`, curl, requests)
- Request floods (per-IP spikes)
- **ML anomaly detection**:
- IsolationForest on per-IP request features
- Flags outliers in traffic patterns
- **Exportable results** (CSV outputs)
- **Interactive dashboard** with charts

---

## ๐Ÿ“ฆ Installation

```bash
git clone https://github.com/your-username/cyber-threat-intel-analyzer.git
cd cyber-threat-intel-analyzer

# Setup venv (optional)
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt
````

---

## ๐ŸŽ›๏ธ Usage

### 1. Streamlit UI (Dashboard)

```bash
streamlit run cyber_threat_intel_analyzer.py
```

Open [http://localhost:8501](http://localhost:8501) in your browser.
Upload logs and explore results visually.

---

### 2. CLI Mode (Headless Batch Processing)

```bash
python cli_ingest.py --in samples/sample_access.log --out results/
```

Outputs:

* `normalized_events.csv` โ€“ normalized logs
* `rule_hits.csv` โ€“ rule detections
* `ml_anomalies.csv` โ€“ ML-based anomalies

---

### 3. Docker Deployment

```bash
docker build -t threat-analyzer .
docker run --rm -p 8501:8501 -v "$PWD:/data" threat-analyzer
```

---

## ๐Ÿงช Running Tests

```bash
pytest tests/
```

---

## ๐Ÿ“ Repository Structure

```
.
โ”œโ”€โ”€ cyber_threat_intel_analyzer.py # Streamlit app
โ”œโ”€โ”€ cli_ingest.py # CLI tool
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ Dockerfile
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ tests/
โ”‚ โ””โ”€โ”€ test_rules.py # Rule-based detection tests
โ””โ”€โ”€ samples/
โ””โ”€โ”€ sample_access.log # Example Apache log
```

---

## ๐Ÿ“Š Example Detection Output

From the included `samples/sample_access.log`:

* ๐Ÿšจ Brute-force login attempts (401 spam from `203.0.113.5`)
* ๐Ÿšจ Suspicious paths (`/wp-admin`, `/phpmyadmin`, `.env`)
* ๐Ÿšจ Suspicious UAs (`sqlmap`, `nmap`, `requests`)
* โš ๏ธ Request floods from aggressive scanners

---

## ๐Ÿ”ฎ Roadmap

* [ ] Add **Syslog & NGINX error log parsing**
* [ ] Geo-IP enrichment (map attacker IPs)
* [ ] Sigma rule integration
* [ ] Slack/Email alerting for rule hits

---

## ๐Ÿ“œ License

MIT License ยฉ 2025

---

### ๐Ÿ‘จโ€๐Ÿ’ป Author

Harsh Sonkar
๐Ÿš€ Data Science โ€ข Cybersecurity โ€ข Cloud Engineer

```