Back to Projects

AI-Phishing-Email-Analyzer

AI-powered phishing email analyzer for .eml files - Detect phishing attempts, analyze headers, URLs, attachments, and get AI-powered risk assessments

aicyber-securitycybersecurityemail-analyzeremail-securityeml-analyzerinformation-securitymachine-learningphishingphishing-detectionpythonsecurity-analysissecurity-researchsecurity-toolsthreat-detection
0
Stars
0
Forks
0
Watchers
0
Open Issues

README.md

# AI Phishing Email Analyzer

[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![Python](https://img.shields.io/badge/python-3.8+-green.svg)](https://www.python.org/)
[![Version](https://img.shields.io/badge/version-1.0.0-orange.svg)](https://github.com/JuttSahib1999/AI-Phishing-Email-Analyzer)

## ๐Ÿšจ Overview

**AI Phishing Email Analyzer** is a powerful, free, and open-source tool designed to analyze `.eml` email files for phishing indicators using AI-powered analysis. It provides comprehensive security assessments, risk scores, and actionable recommendations.

### Key Features

- ๐Ÿ“ง **Email Parsing**: Extract headers, body, attachments, and URLs from `.eml` files
- ๐ŸŽฏ **Header Analysis**: Check SPF, DKIM, DMARC, and identify suspicious headers
- ๐Ÿ”— **URL Analysis**: Detect malicious URLs, check redirects, and domain reputation
- ๐Ÿ“Ž **Attachment Analysis**: Identify suspicious file types, malware indicators, and extract hashes
- ๐Ÿค– **AI-Powered Analysis**: Generate risk scores, phishing probabilities, and reasoning
- ๐Ÿ›ก๏ธ **Sender Reputation**: Check domain age, DNS records, and blacklist status
- ๐Ÿ“Š **Comprehensive Reports**: Generate detailed JSON and HTML reports
- ๐Ÿ” **Indicators of Compromise**: Extract and list all potential IOCs
- ๐Ÿ“ **Actionable Recommendations**: Get clear guidance on handling suspicious emails

## ๐Ÿš€ Quick Start

### Installation

1. **Clone the repository**
   ```bash
   git clone https://github.com/JuttSahib1999/AI-Phishing-Email-Analyzer.git
   cd AI-Phishing-Email-Analyzer

   ```

2. **Install dependencies**
```bash
pip install -r requirements.txt

```


3. **Run the analyzer**
```bash
python src/main.py path/to/suspicious_email.eml

```



### Windows 10 Setup

1. Download and install Python 3.8+ from [python.org](https://www.python.org)
2. Open Command Prompt as Administrator
3. Navigate to the project directory
4. Run the setup script:
```cmd
run.bat

```



### ๐Ÿ“‹ Usage Examples

**Basic Usage**

```bash
python src/main.py sample_phishing.eml

```

**Advanced Options**

```bash
python src/main.py suspicious_email.eml --output ./reports --verbose

```

**Example Output**

```text
============================================================
ANALYSIS SUMMARY
============================================================
Subject: Urgent: Account Security Alert
Sender: security@fake-bank.com
Risk Score: 85/100
Risk Level: High
Phishing Probability: 92%
------------------------------------------------------------
Indicators of Compromise:
  โ€ข Suspicious URL: [http://fake-bank-verify.com/login](http://fake-bank-verify.com/login)
  โ€ข Suspicious attachment: invoice_123.exe
  โ€ข Suspicious domain: fake-bank.com
------------------------------------------------------------
Recommendations:
  โ€ข HIGH RISK: Do NOT open any attachments or click any links
  โ€ข Delete this email immediately
  โ€ข Report as phishing to your IT security team
============================================================
Full report saved to: output/phishing_report_20260704_120000.json

```

### ๐Ÿ“Š Report Example

The tool generates comprehensive reports in JSON format:

```json
{
  "report_metadata": {
    "generated_at": "2026-07-04T12:00:00.123456",
    "analyzer_version": "1.0.0",
    "analyzer_author": "Abdul Muqeet Tabraiz"
  },
  "risk_assessment": {
    "overall_risk_score": 85,
    "risk_level": "High",
    "phishing_probability": 92,
    "ai_reasoning": "Contains 2 suspicious URL(s) | SPF check failed | High risk: Multiple phishing indicators detected"
  }
}

```

### ๐Ÿ—๏ธ Architecture

```text
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    Email Parser                     โ”‚
โ”‚                     (.eml file)                     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                         โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                Analysis Components                  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  โ€ข Header Analyzer    โ€ข URL Analyzer                โ”‚
โ”‚  โ€ข Attachment Analyzer โ€ข Reputation Checker         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                         โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                     AI Analyzer                     โ”‚
โ”‚            (Risk Scoring & Reasoning)               โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                         โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                 Report Generator                    โ”‚
โ”‚                (JSON & HTML Reports)                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

```

### ๐Ÿ”ง Dependencies

* Python 3.8+
* `requests`: HTTP requests for URL checks
* `python-magic`: File type detection
* `dnspython`: DNS record queries
* `python-whois`: Domain registration information
* `scikit-learn`: Machine learning for enhanced detection

### ๐Ÿงช Testing

#### Test on Windows 10

1. **Create a test email file:**
* Open Notepad
* Copy and paste a phishing email sample
* Save as `test_sample.eml`


2. **Run the test:**
```bash
python src/main.py test_sample.eml --output ./test_results

```


3. **Verify results:**
* Check the output directory for JSON reports
* Review the analysis summary in the console



#### Sample Test Email

```text
From: security@fake-bank.com
To: user@example.com
Subject: Urgent: Account Security Alert

Dear valued customer,

We have detected unusual activity in your account. 
Please verify your identity immediately:

[http://fake-bank-verify.com/account](http://fake-bank-verify.com/account)

If you do not respond within 24 hours, your account will be suspended.

Sincerely,
Security Team

```

### ๐Ÿ› ๏ธ Development

#### Project Structure

```text
AI-Phishing-Email-Analyzer/
โ”œโ”€โ”€ src/                    # Source code
โ”‚   โ”œโ”€โ”€ main.py            # Main application
โ”‚   โ”œโ”€โ”€ email_parser.py    # Email parsing
โ”‚   โ”œโ”€โ”€ header_analyzer.py # Header analysis
โ”‚   โ”œโ”€โ”€ url_analyzer.py    # URL analysis
โ”‚   โ”œโ”€โ”€ attachment_analyzer.py # Attachment analysis
โ”‚   โ”œโ”€โ”€ ai_analyzer.py     # AI analysis
โ”‚   โ”œโ”€โ”€ reputation_checker.py # Sender reputation
โ”‚   โ””โ”€โ”€ report_generator.py # Report generation
โ”œโ”€โ”€ tests/                  # Test files
โ”œโ”€โ”€ output/                 # Generated reports
โ””โ”€โ”€ requirements.txt        # Dependencies

```

#### Running Tests

```bash
pytest tests/

```

#### Code Style

```bash
black src/
flake8 src/
mypy src/

```

### ๐Ÿ”’ Security Considerations

* **No External APIs:** All analysis is performed locally
* **No Data Storage:** Email content is not stored permanently
* **No Network Calls:** Optional, configurable for enhanced security
* **Open Source:** Full transparency in security analysis

### License

This project is licensed under the MIT License - see the LICENSE file for details.

### Author

**Abdul Muqeet Tabraiz**

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

### ๐Ÿค Contributing

Contributions are welcome! Please read CONTRIBUTING.md for details.

### โญ Support

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

### ๐Ÿ“ Changelog

See CHANGELOG.md for version history.

### ๐Ÿ”— Links

* [GitHub Repository](https://github.com/JuttSahib1999/AI-Phishing-Email-Analyzer)
* [Documentation](https://github.com/JuttSahib1999/AI-Phishing-Email-Analyzer/wiki)
* [Issue Tracker](https://github.com/JuttSahib1999/AI-Phishing-Email-Analyzer/issues)

```

```