A Python-based email header analysis tool designed to detect phishing attempts by examining email headers. HdrX helps identify suspicious patterns and anomalies in email headers to protect against phishing attacks.
HdrX is a command-line tool that provides a comprehensive analysis of email headers, which is a vital step in detecting phishing attacks and email spoofing. By analyzing key header fields, it can identify suspicious patterns that indicate a malicious intent. This tool is designed for both individuals and organizations seeking to enhance their email security posture.
- Header Extraction: Extracts email headers from raw email content.
- Header Parsing: Parses and prints the email headers.
- From Header Analysis: Checks the
Fromheader for spoofing. - Received Header Analysis: Analyzes the
Receivedheaders for suspicious hostnames. - Reply-To Analysis: Checks the
Reply-Toheader for inconsistencies. - SPF, DKIM, and DMARC checks: Verifies SPF, DKIM, and DMARC records for domain authentication.
- Keyword Analysis: Uses a dynamic list of keywords and regexes to identify suspicious content.
- Customizable Keyword Lists: Uses an external JSON file, allowing for easy updates to the keywords.
- Clear output: Present parsed headers and analysis results, with a phishing risk score.
- Comprehensive Error Handling: Includes try-except blocks and clear log messages.
- Modularity: The code is structured into abstract classes, to make it easier to maintain and to add new functionalities.
To use HdrX locally, follow these steps:
git clone https://github.com/CodeByKalvin/HdrX.git
cd HdrXMake sure you have Python 3.6 or higher installed. Install the required dependencies using pip:
pip install -r requirements.txtThe requirements.txt should contain the following:
requests
dmarcOnce installed, you can run the application from the command line using:
python email_analyzer.pyTo analyze email headers, you can either pass an email file path or pipe the email content to the script:
-
From File:
python email_analyzer.py -f email.txt
-
From Standard Input (Piped):
cat email.txt | python email_analyzer.pyOr copy and paste directly to the terminal.
The tool will output the email headers, the analysis results with a score, and if the score is high, a warning message.
- Keyword List: The tool uses an external file
keywords.jsonthat should be created in the same directory. - Modify keywords: Modify this file to add or change the keywords and regexes used in the application.
- Structure: The
keywords.jsonfile is a JSON object with the following categories:general: A list of generic keywords.personal: A list of keywords related to personal information.company: Keywords related to company departments, that might be used in internal phishing attacksurl: List of regexes for detecting suspicious URLs.financial: Keywords related to financial actions.email_specific: Keywords related to problems sending or receiving emails.
- Structure: The
hdrx/
│
├── email_analyzer.py # Main Python script for running the CLI app
├── README.md # This README file
├── requirements.txt # List of dependencies
└── keywords.json # File for storing keywords and regexes
- Python 3.6 or higher
- Pip to install dependencies
- Required Python libraries (in
requirements.txt):requests: For HTTP calls to webhooks and push notifications.dmarc: For validating SPF, DKIM and DMARC records.
To install the dependencies:
pip install -r requirements.txtContributions are welcome! Feel free to submit pull requests or create an issue to report a bug or request new features.
- Fork the repository.
- Create a new branch for your feature (
git checkout -b feature-name). - Make your changes.
- Test your changes.
- Commit your changes (
git commit -m 'Add some feature'). - Push to your branch (
git push origin feature-name). - Create a pull request.
This project is open-source and available under the MIT License.
- Implement more advanced techniques to detect spoofed emails.
- Incorporate machine learning for dynamic and adaptive detection patterns.
- Integrate with external threat intelligence services.
- Develop a GUI for better user interaction.
- CodeByKalvin - Initial work - GitHub Profile