BinaryAlert - Serverless, Real-time & Retroactive Malware Detection
BinaryAlert is an open-source serverless AWS pipeline where any file uploaded to an S3 bucket is immediately scanned with a configurable set of YARA rules. An alert will fire as soon as any match is found, giving an incident response team the ability to quickly contain the threat before it spreads.
Features
- Built with Amazon Web Services (AWS): An AWS account is all you need to deploy BinaryAlert.
- Broad YARA Support: Add your own YARA rules and/or automatically clone them from third-party repos. Both the
PE
andmath
modules are supported. - Real-Time: Files uploaded to BinaryAlert (S3 bucket) are immediately queued for analysis.
- Serverless: All computation is handled by Lambda functions. No servers to manage means stronger security and automatic scaling!
- Infrastructure-as-Code: The entire infrastructure is described with Terraform configuration files, enabling anyone to deploy BinaryAlert in a matter of minutes with a single command.
- Retroactive Analysis: After updating the YARA ruleset, BinaryAlert will retroactively scan the entire file corpus to find any new matches.
- Easily Configurable: BinaryAlert configuration is managed in a single Terraform variables file.
- Quality Code: Written in Python3 with unit tests and linting to ensure a clean and reliable codebase.
- Low Cost: The AWS bill is based only on how many files are analyzed.
Quick Start
- Install dependencies
- Install Python3, pip3, virtualenv, and Terraform.
- Create a virtual environment:
virtualenv -p python3 venv
- Activate the virtual env:
source venv/bin/activate
- Install third-party libraries:
pip3 install -r requirements.txt
- If the installation encounters problems finding
openssl.h
, tryexport CFLAGS='-I/usr/local/opt/openssl/include'
before the install.
- If the installation encounters problems finding
- Configure settings
- Set your AWS credentials using any method supported by Terraform. The two simplest options are to run
aws configure
(saves~/.aws/credentials
file) or
export AWS_DEFAULT_REGION="region-name"
export AWS_ACCESS_KEY_ID="access-key"
export AWS_SECRET_ACCESS_KEY="secret-key"- Fill out the base configuration options in
terraform.tfvars
- Set your AWS credentials using any method supported by Terraform. The two simplest options are to run
- Deploy:
python3 manage.py deploy
- In order to receive YARA match alerts, you must manually subscribe to the generated SNS topics. Go to the SNS console and add a subscription to the
*_binaryalert_yara_match_alerts
topic (which receives YARA match alerts) and the*_binaryalert_metric_alarms
topic (which receives CloudWatch alerts if the service is down). SNS supports a variety of subscription endpoints, including email and SMS. SNS subscriptions must be confirmed by the destination, which is why this step can't be automated by Terraform.
CLI Tool:
manage.py
For simplicity, BinaryAlert management commands are bundled together in
manage.py
.Usage:
python3 manage.py [--help] [command]
YARA Rules
YARA rules are stored in the rules/ folder. See rules/README.md for more information about adding and updating YARA rules.
Architecture
- The organization collects files and delivers them to their BinaryAlert S3 bucket. Files of interest could include executable binaries, email attachments, documents, etc.
- Every file uploaded to the S3 bucket is immediately queued for analysis.
- A dispatching Lambda function runs every minute, grouping files into batches and invoking up to dozens of analyzers in parallel.
- Each analyzer scans its files using a list of pre-compiled YARA rules.
- YARA matches are saved to DynamoDB and an alert is sent to an SNS topic. We use StreamAlert to dispatch these alerts, but other organizations can instead consume the alerts via email or any other supported SNS subscription.
- For retroactive analysis, a batching Lambda function enqueues the entire S3 bucket to be re-analyzed.
- Configurable CloudWatch alarms will trigger if any BinaryAlert component is behaving abnormally. This will notify a different SNS topic than the one used for YARA match alerts.
Updating Pip Packages
The exact
pip3
package versions used are frozen in requirements.txt
. However, to make upgrading packages easier, requirements_top_level.txt
contains only the top-level packages required by BinaryAlert. To upgrade the package requirements,pip3 install -r requirements_top_level.txt --upgrade
pip3 freeze > requirements.txt
Directory Overview
lambda_functions
: Source code for each BinaryAlert Lambda function.rules
: Collection of public and private YARA rules.terraform
: AWS infrastructure represented as Terraform configuration files.tests
: Unit tests amd mocks.
Via: www.kitploit.com
BinaryAlert - Serverless, Real-time & Retroactive Malware Detection
Reviewed by Zion3R
on
11:41
Rating: