Hugal31/yara-rust
GitHub: Hugal31/yara-rust
该项目为 VirusTotal 的 Yara 库提供了安全、高性能的 Rust 语言绑定,方便开发者在 Rust 应用中集成模式匹配与威胁检测能力。
Stars: 81 | Forks: 29
# yara-rust
[](https://github.com/Hugal31/yara-rust/actions/workflows/tests.yml)
[](https://crates.io/crates/yara)
[](https://docs.rs/yara)
[VirusTotal 的 Yara 库](https://github.com/VirusTotal/yara)的绑定。
更多文档可以在 [Yara 的文档](https://yara.readthedocs.io/en/stable/index.html)中找到。
## 示例
实现灵感来源于 [yara-python](https://github.com/VirusTotal/yara-python)。
```
const RULES: &str = r#"
rule contains_rust {
strings:
$rust = "rust" nocase
condition:
$rust
}
"#;
fn main() {
let compiler = Compiler::new().unwrap();
let compiler = compiler
.add_rules_str(RULES)
.expect("Should have parsed rule");
let rules = compiler
.compile_rules()
.expect("Should have compiled rules");
let results = rules
.scan_mem("I love Rust!".as_bytes(), 5)
.expect("Should have scanned");
assert!(results.iter().any(|r| r.identifier == "contains_rust"));
}
```
## 功能特性
* 支持 Yara v4.2。
* 从字符串或文件编译规则。
* 保存和加载编译后的规则。
* 扫描字节数组(`&[u8]`)或文件。
## 特性标志与 Yara 链接。
查看 [yara-sys](yara-sys) crate 文档以获取特性标志列表
以及如何链接到你的 Yara crate。
### 待办事项
- [ ] 移除字符串转换中的一些 `unwrap`(目前此 crate 假定规则、元数据和命名空间标识符是有效的 Rust `str`)。
- [ ] 在多个函数中接受 `AsRef` 而不是 `&str`。
- [x] 实现 scanner API。
- [x] 添加进程扫描。
- [x] 向用户报告警告。
## 许可证
根据以下任一许可证授权:
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) 或 http://www.apache.org/licenses/LICENSE-2.0)
* MIT 许可证 ([LICENSE-MIT](LICENSE-MIT) 或 http://opensource.org/licenses/MIT)
可根据您的选择。
## 贡献
在向此仓库提交时,请遵循 [约定式提交][Conventional commit] 规则。
如果您添加了任何新功能,请添加相应的单元/文档测试。
标签:Ask搜索, Crates.io, DAST, DNS 反向解析, DNS解析, Rust, URL发现, VirusTotal, YARA, yara-rust, yara-sys, 云安全监控, 云计算, 云资产可视化, 代码库, 内存扫描, 可视化界面, 威胁情报, 子域名变形, 安全检测, 开发者工具, 开源项目, 恶意软件分析, 扫描器, 文件扫描, 无线安全, 模式匹配, 绑定, 网络流量审计, 网页爬虫, 自动化资产收集, 规则引擎, 进程扫描, 通知系统, 静态分析