Back to Projects

AI-DNS-Analyzer

A completely offline AI-based DNS Analyzer built in Python to detect DNS tunneling, DGA domains, and suspicious queries with automated threat explanations.

ai-securitycybersecuritydga-detectiondns-tunnelingmachine-learningoffline-analyzerpythonscikit-learnthreat-hunting
0
Stars
0
Forks
0
Watchers
0
Open Issues

README.md

# AI DNS Analyzer

An offline, machine-learning-based tool designed to analyze DNS queries and detect network anomalies such as DNS Tunneling and Domain Generation Algorithms (DGA).

This tool is completely free, standalone, and provides human-readable AI threat explanations.

---

## ✨ Features

* **DGA Detection:** Uses Shannon entropy and character ratios to spot random, machine-generated domains.
* **DNS Tunneling Detection:** Identifies excessively long, encoded subdomain payloads used for data exfiltration.
* **AI Threat Explanations:** Dynamically generates reasoning for *why* a domain was flagged based on feature weights.
* **Offline First:** Built on scikit-learn utilizing a local Random Forest classifier. No API keys required.

---

## Screenshots

<p align="center">
  <img src="./screenshots/google.png" alt="Benign Google Query" width="48%" />
  <img src="./screenshots/malicious.png" alt="Malicious DNS Query" width="48%" />
</p>

---

## 🚀 Installation & Setup

### Environment Setup (Windows)

If you have multiple versions of Python installed (e.g., Python 3.13 and Python 3.14), use the explicit Python launcher (`py`) to target Python 3.13 to avoid C++ build/compilation errors.

Run the following commands in your Command Prompt or VS Code Terminal:

```cmd
:: 1. Deactivate current venv (if active)
deactivate

:: 2. Delete the virtual environment folder if corrupt or on an incompatible Python version
rmdir /s /q venv

:: 3. Create a new virtual environment explicitly with Python 3.13
py -3.13 -m venv venv

:: 4. Activate the new environment
.\venv\Scripts\activate

:: 5. Upgrade pip
python -m pip install --upgrade pip

:: 6. Install the requirements
pip install -r requirements.txt

```

---

## 💻 How to Run

1. **Train / Compile the Local ML Model:**
```dos
python src/train_model.py

```


2. **Launch the Analyzer:**
```dos
python src/main.py

```



---

## 👨‍💻 Author

Created by **Abdul Muqeet Tabraiz**

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