A powerful Rust library for crafting, validating, and managing YARA rules. YARA Forge provides a comprehensive set of tools for creating sophisticated malware detection rules with an intuitive builder pattern interface.
- ποΈ Rule Builder Pattern: Intuitive interface for creating YARA rules
- π Pre-built Templates: Common templates for malware detection
- π Pattern Library: Extensive collection of malware detection patterns
- β Validation: Built-in rule validation and testing
- π Performance: Parallel scanning capabilities
- π Import/Export: Support for JSON and other formats
- π Documentation: Comprehensive documentation and examples
Add this to your Cargo.toml
:
[dependencies]
yara-forge = "0.1.0"
use yara_forge::{RuleBuilder, ValidationOptions};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a simple rule
let rule = RuleBuilder::new("detect_suspicious")
.with_metadata("author", "YARA Forge")
.with_string("$suspicious_api", "CreateRemoteThread")
.with_condition("$suspicious_api")
.build()?;
// Validate the rule
let options = ValidationOptions {
syntax_only: true,
test_against_samples: false,
max_file_size: 10 * 1024 * 1024,
timeout: 30,
};
// Save the rule
rule.save("detect_suspicious.yar")?;
Ok(())
}
use yara_forge::templates::ransomware_template;
let rule = ransomware_template("detect_ransomware")
.with_metadata("severity", "high")
.build()?;
use yara_forge::patterns::{ENCRYPTION_APIS, PROCESS_INJECTION};
let rule = RuleBuilder::new("detect_malware")
.with_patterns(ENCRYPTION_APIS)
.with_patterns(PROCESS_INJECTION)
.with_condition("2 of them")
.build()?;
use yara_forge::validation::parallel_scan;
let matches = parallel_scan("rules/malware.yar", "samples/", &options)?;
# Run tests
cargo test
# Run benchmarks
cargo bench
# Build documentation
cargo doc --no-deps --open
# Format code
cargo fmt
# Run lints
cargo clippy
Build the Docker image:
docker build -t yara-forge .
Run with Docker Compose:
docker-compose up
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
This project is licensed under the MIT License - see the LICENSE file for details.
- YARA Project: https://virustotal.github.io/yara/
- Rust Community
- All Contributors
For security issues, please open issue on GitHub.