Divine is a Rust port of malcontent, a malware detection tool that uses YARA rules to identify suspicious behaviors in files and executables.
- π Fast scanning with parallel processing using Rust's async/await and Rayon
- π― YARA rule engine for flexible pattern matching with YARA-X
- π¦ Archive support for ZIP, TAR, and compressed files
- π¨ Multiple output formats (terminal, JSON, YAML, brief)
- π Risk categorization (Low, Medium, High, Critical)
- π§ CLI interface with scan and analyze modes
- β‘ Memory efficient with streaming file processing
- π Detailed reporting with behavior categorization
- Rust 1.70 or later
- Cargo
git clone https://github.com/chainguard-dev/malcontent
cd divine
make install
cargo install --path .
make build # Debug build
make release # Release build
Scan a single file:
divine scan /path/to/suspicious/file
Scan multiple files or directories:
divine scan /path/to/dir /another/file
Scan with archive extraction:
divine scan --archives /path/to/archive.zip
Analyze a single file with full details:
divine analyze /path/to/file
Use custom rule files or directories:
divine scan --rules /path/to/custom/rules.yar /target
divine scan --rules /path/to/rules/directory/ /target
- Terminal (default): Human-readable colored output
- JSON: Machine-readable JSON format
- YAML: YAML format for configuration
- Brief: Minimal output showing only findings
divine scan --format json /target
divine scan --format yaml /target > report.yaml
divine scan --format brief /target
Filter results by minimum risk level:
divine scan --min-risk medium /target
divine scan --min-risk high /target
Save output to a file:
divine scan --output report.json --format json /target
π Scanning "suspicious_binary"
ββ π suspicious_binary [HIGH]
β β‘ networking [HIGH]
β π net/url/embedded β Hardcoded URLs detected: http://malicious-site.com
β β‘ execution [MEDIUM]
β π‘ os/terminal β Uses terminal/shell functionality
β β‘ cryptography [LOW]
β π΅ crypto/rc4 β RC4 encryption detected
β
π Divine Scan Report (1,234ms)
Files scanned: 150
Files skipped: 12
Malicious files: 3
Suspicious files: 8
βββββββββββββββββββββββββββ¬βββββββ¬ββββββββββββ¬βββββββββββ
β path β risk β behaviors β size β
βββββββββββββββββββββββββββΌβββββββΌββββββββββββΌβββββββββββ€
β malware/trojan.exe β CRIT β 15 β 2.3MB β
β scripts/backdoor.sh β HIGH β 8 β 1.2KB β
β tools/keylogger β HIGH β 12 β 856.7KB β
βββββββββββββββββββββββββββ΄βββββββ΄ββββββββββββ΄βββββββββββ
Divine uses embedded YARA rules by default, but supports custom rules:
rule suspicious_network_activity {
meta:
description = "Detects suspicious network connections"
risk = "medium"
author = "Security Team"
strings:
$http = "http://" nocase
$connect = "connect(" nocase
condition:
any of them
}
make build # Debug build
make release # Release build
make test # Run tests
make test-verbose # Run tests with output
make lint # Run linting and formatting checks
make fmt # Format code
make audit # Security audit
make doc # Generate documentation
Divine is built with the following components:
- Scanner: Core scanning engine with YARA integration
- Rules: YARA rule loader and manager
- Archive: ZIP/TAR extraction with security limits
- Report: Risk assessment and behavior categorization
- CLI: Command-line interface and output formatting
- Parallel file processing using Rayon
- Async I/O for large file operations
- Memory-mapped file reading for efficiency
- Configurable worker thread pools
Divine includes built-in YARA rules for common malware patterns:
- Networking: HTTP clients, socket operations, URL patterns
- Execution: Shell commands, process injection, code execution
- Filesystem: Directory traversal, file operations, path manipulation
- Cryptography: Encryption algorithms, hashing, key generation
- Persistence: Registry modification, service installation
- Anti-Analysis: Debug detection, VM evasion, obfuscation
- Command & Control: C2 communications, data exfiltration
- Fork the repository
- Create a feature branch
- Make changes with tests
- Run
make lint
andmake test
- Submit a pull request
Licensed under the Apache License 2.0. See LICENSE for details.
- malcontent - Original Go implementation
- YARA - Pattern matching engine
- yara-x - Rust YARA implementation