A Python package and command line utility for scanning emails with YARA rules
Project description
yaramail
is a Python package and command line utility for scanning emails with
YARA rules. It is Ideal for automated triage of phishing reports.
Features
- Scans all parts of an email via API or CLI
- Headers
- Removes header indents by default for consistent scanning
- Plain text and HTML body content
- Converts body content to Markdown by default for consistent scanning
- Attachments
- Raw file content
- Emails attached to emails
- PDF document text
- ZIP file contents, including nested ZIP files
- Customizable list of passwords to use when attempting to scan encrypted ZIP files
- Headers
- Provides a built-in methodology for categorizing emails
CLI
usage: A YARA scanner for emails [-h] [-V] [-v] [--output OUTPUT]
[--rules RULES] [--header-rules HEADER_RULES]
[--body-rules BODY_RULES]
[--header-body-rules HEADER_BODY_RULES]
[--attachment-rules ATTACHMENT_RULES]
[--trusted-domains TRUSTED_DOMAINS]
scan_path
positional arguments:
scan_path The file(s) to scan (wildcards allowed)
options:
-h, --help show this help message and exit
-V, --version show program's version number and exit
-v, --verbose Output the entire parsed email (default: False)
--output OUTPUT, -o OUTPUT
Redirect output to a file (default: None)
--rules RULES A path to a directory that contains YARA rules. Can be
set by the YARA_RULES_DIR environment variable.
(default: .)
--header-rules HEADER_RULES
Filename of the header rules file. Can be set by the
YARA_HEADER_RULES environment variable. (default:
header.yar)
--body-rules BODY_RULES
Filename of the body rules file. Can be set by the
YARAMAIL_BODY_RULES environment variable. (default:
body.yar)
--header-body-rules HEADER_BODY_RULES
Filename of the header_body rules file. Can be set by
the YARAMAIL_HEADER_BODY_RULES environment variable.
(default: header_body.yar)
--attachment-rules ATTACHMENT_RULES
Filename of the body rules file. Can be set by the
YARAMAIL_BODY_RULES environment variable. (default:
attachment.yar)
--trusted-domains TRUSTED_DOMAINS
A path to a file containing a list of trusted domains.
Can be set by the YARAMAIL_TRUSTED_DOMAINS environment
variable. (default: trusted_domains.txt)
Installation
It is not recommended to use `yaramail` in the same OS that is targeted by
the potential malware you are scanning. Consider using `yaramail` inside of a
container or VM for additional security.
System dependencies
Some system dependencies must be installed before installing yaramail
.
Debian, Ubuntu, and friends
sudo apt install build-essential libpoppler-cpp-dev pkg-config python3-dev
Fedora, Red Hat, and friends
sudo yum install gcc-c++ pkgconfig poppler-cpp-devel python3-devel
macOS
Install Homebrew, then run the following command in a terminal.
brew install pkg-config poppler python
Windows
- Install the Microsoft Visual Studio Build Tools
- Install Anaconda Distribution
- Use Anaconda Navigator to create a new Anaconda Environment
- Click the play button for the Anaconda Environment
- Click Open Terminal
- Run this command and leave the terminal open:
conda install -c conda-forge poppler
- Configure your Python IDE/project to use the Anaconda Environment
Install yaramail
The official name for this project, package, and module is `yaramail`.
Unfortunately, the Python Package Index (PyPI) [did not allow that name to be
used there][pypi-name-issue], so the PyPI project name for `yaramail` is
`yara-mail`.
In a terminal, run
pip3 install -U yara-mail
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
yara_mail-2.0.0.tar.gz
(14.2 kB
view details)
Built Distribution
yara_mail-2.0.0-py3-none-any.whl
(14.9 kB
view details)
File details
Details for the file yara_mail-2.0.0.tar.gz
.
File metadata
- Download URL: yara_mail-2.0.0.tar.gz
- Upload date:
- Size: 14.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.23.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1670fde9f9a4c2e2a99363056fdda5a31498f93f8274fbb2f36c3085d636e600 |
|
MD5 | c63439c465c20b5803b9cea029ed9e58 |
|
BLAKE2b-256 | e8345f4a8ab667dfcd21e339ba0ce90d2966b2e8d08b7624ba9ffe395a523ae2 |
File details
Details for the file yara_mail-2.0.0-py3-none-any.whl
.
File metadata
- Download URL: yara_mail-2.0.0-py3-none-any.whl
- Upload date:
- Size: 14.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.23.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec81aa90d87af037f90ace1bbe693300b415bc68b445ab7e4fdac9fe73ff5846 |
|
MD5 | 608ab6650273d526a02e5508778d58fe |
|
BLAKE2b-256 | 1f90bea1626d889aec4326b217d0ed4f2a34da465a29a8369f1a4624c7eb4aac |