Back to Projects

ai-security-log-analyzer

AI-powered Security Log Analyzer using Python and Ollama for Windows Event Logs and Linux auth logs with MITRE ATT&CK mapping and incident summaries.

artificial-intelligenceblue-teamcybersecuritydigital-forensicsincident-responselinux-securityllmlog-analysismitre-attackollamaopen-sourcepythonsecuritysecurity-monitoringsecurity-toolssiemsocsoc-analystthreat-detectionwindows-event-log
0
Stars
0
Forks
0
Watchers
0
Open Issues

README.md

# AI Security Log Analyzer ๐Ÿ›ก๏ธ

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
[![Ollama](https://img.shields.io/badge/Ollama-LLM-green.svg)](https://ollama.ai/)

**Author:** Abdul Muqeet Tabraiz  
**LinkedIn:** [Connect with me](https://www.linkedin.com/in/abdul-muqeet-tabraiz/)  
**GitHub:** [@JuttSahib1999](https://github.com/JuttSahib1999)

## ๐Ÿš€ Overview

AI Security Log Analyzer is a comprehensive security analysis tool that ingests Windows Event Logs and Linux authentication logs, detects suspicious activities using both rule-based detection and local LLM (Ollama Llama/Mistral), and generates actionable security incident reports with MITRE ATT&CK mappings.

## โœจ Features

- **Multi-platform Log Ingestion**: Windows Event Logs (EVTX) and Linux authentication logs
- **Dual Detection Engine**: Rule-based + AI-powered detection using local LLM
- **MITRE ATT&CK Mapping**: Automatic mapping of detected threats to MITRE framework
- **Severity Classification**: Automated severity scoring (Critical, High, Medium, Low, Info)
- **Incident Summaries**: Human-readable incident reports with recommended actions
- **Dual Interface**: CLI tool + Web Dashboard
- **Zero Cost**: Completely free, no API keys required
- **Privacy-First**: All processing happens locally

## ๐Ÿ“‹ Prerequisites

- Python 3.8 or higher
- Ollama installed locally with Llama 2 or Mistral models
- For Windows: Python-evtx library
- For Linux: Standard syslog access

## ๐Ÿ”ง Installation

### 1. Clone the Repository
```bash
git clone https://github.com/JuttSahib1999/ai-security-log-analyzer.git
cd ai-security-log-analyzer

```

### 2. Install Dependencies

```bash
pip install -r requirements.txt

```

### 3. Install and Configure Ollama

```bash
# Install Ollama (Linux/macOS)
curl -fsSL https://ollama.ai/install.sh | sh

# Pull a model (Llama 2 or Mistral)
ollama pull llama2
# or
ollama pull mistral

```

### 4. Configure the Tool

```bash
cp config/settings.example.py config/settings.py
# Edit config/settings.py with your preferences

```

## ๐ŸŽฎ Usage

### Command Line Interface

#### Analyze a Windows Event Log

```bash
python -m src.cli analyze --source windows --file path/to/eventlog.evtx --output report.json

```

#### Analyze Linux Authentication Logs

```bash
python -m src.cli analyze --source linux --file /var/log/auth.log --output report.json

```

#### Real-time Monitoring

```bash
python -m src.cli monitor --source linux --interval 60

```

### Web Dashboard

```bash
python -m src.web_app

```

Access the dashboard at: `http://localhost:5000`

### Docker Deployment

```bash
docker-compose up -d

```

## ๐Ÿ“Š Output Example

```json
{
  "incident": {
    "id": "INC-2026-001",
    "timestamp": "2026-07-02T14:32:18Z",
    "severity": "HIGH",
    "source": "Windows",
    "category": "Privilege Escalation",
    "description": "Multiple failed logon attempts followed by successful admin login",
    "mitre_mappings": [
      "TA0004 - Privilege Escalation",
      "T1078 - Valid Accounts",
      "T1110 - Brute Force"
    ],
    "recommended_actions": [
      "Reset affected user credentials immediately",
      "Enable MFA for administrative accounts",
      "Review user permissions",
      "Check for lateral movement attempts"
    ],
    "detection_source": "Rule-based + LLM"
  }
}

```

## ๐Ÿ—๏ธ Architecture

```text
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    User Interface Layer                     โ”‚
โ”‚           โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”            โ”‚
โ”‚           โ”‚   CLI Tool   โ”‚      โ”‚ Web Dashboardโ”‚            โ”‚
โ”‚           โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                             โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    Core Analysis Engine                     โ”‚
โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”โ”‚
โ”‚   โ”‚ Rule-Based      โ”‚   โ”‚   LLM-Based     โ”‚   โ”‚  Combined  โ”‚โ”‚
โ”‚   โ”‚ Analyzer        โ”‚   โ”‚   Analyzer      โ”‚   โ”‚  Analyzer  โ”‚โ”‚
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                             โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      Log Ingestors                          โ”‚
โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                 โ”‚
โ”‚   โ”‚  Windows EVTX   โ”‚   โ”‚ Linux Auth Log  โ”‚                 โ”‚
โ”‚   โ”‚    Ingestor     โ”‚   โ”‚    Ingestor     โ”‚                 โ”‚
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

```

## ๐Ÿงช Testing

```bash
pytest tests/

```

## ๐Ÿ“ Configuration

Edit `config/settings.py` to customize:

* Detection thresholds
* Severity levels
* MITRE framework mapping
* LLM model selection
* Log retention policies

## ๐Ÿค Contributing

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

## ๐Ÿ“„ License

Distributed under the MIT License. See LICENSE for more information.

## โญ Support

If you find this project useful, please give it a โญ on GitHub!

## ๐Ÿ”’ Security Considerations

* All processing occurs locally - no data sent to external services
* Log data is stored securely with encryption
* Access controls implemented for web dashboard
* Regular security updates and patches

## ๐Ÿ“ž Contact

**Abdul Muqeet Tabraiz**

* LinkedIn: [AbdulMuqeetTabraiz](https://www.linkedin.com/in/abdul-muqeet-tabraiz/)
* GitHub: [JuttSahib1999](https://github.com/JuttSahib1999)

## ๐Ÿ™ Acknowledgments

* MITRE Corporation for the ATT&CK framework
* Ollama team for the excellent local LLM platform
* Python community for the amazing libraries