YaraMonitor is a tool to continuously ingest, analyze, and alert on malware samples given a set of yara rules. The main design philosophy behind it is that it is extendable to monitor additional sources so long as the ingestion from that source can be automated via Python.
It currently monitors:
- MalwareBazaar recent uploads
rules
= place yara rules here, do not create sub-folderssources
= python scripts to ingest data from various sources, must be called bymonitor/main.py
in therun_ingestion()
functionsamples
= scripts insources
download samples to this directory, in a subfolder for each script (created at run time)
The samples
directory will contain live malware (with executable extensions).
- Python
pip install -r requirements.txt
monitor/main.py
is intended to be ran for long periods of time, polling MalwareBazaar every hour for new uploads- It is recommended to use this within a Python venv
- By default, matches are only written to stdout. You can use
-d, --discord
to supply a Discord webhook and it will send a message with what rule and the path to the sample (it does not upload any files to Discord)
git clone https://github.com/montysecurity/yaramonitor.git
cd yaramonitor
# [Activate Python venv, optional, recommended]
python -m pip install -r requirements.txt
python main/main.py
- When running
main.py
, do it from the root folder of the repo (yaramonitor
) by runningpython monitor/main.py
(doing anything else will cause the program to not be able to find thesamples
directory)
- Removes all files from
samples
directory (optional, if-w, --wipe
is supplied) - Poll MalwareBazaar and download all samples that were uploaded in the last hour, store in
samples/MalwareBazaar
- Loop through all files just downloaded, unzip them, delete the zip file, and scan them with all yara rules in
rules
- If a sample matches a rule, send alert (print to screen and/or Discord Webhook)
- If a sample has no macthes, delete it
- Sleep for 1 minute and repeat
So long as the program is running and memory is retained, the following are true:
- Samples that have a yara match are not deleted
- The process will not re-download samples that have already been downloaded and scanned, even if they have already been deleted
- The process will not re-scan samples that have already been scanned with the yara rules