#security #threat-detection #log-processing #signature-engine

gene

提供Rust编写的日志匹配框架的Crate

7个版本

0.2.0 2024年7月29日
0.1.5 2024年7月16日
0.1.3 2024年6月20日
0.1.2 2024年4月11日

#323 in 文本处理

Download history 10/week @ 2024-04-15 3/week @ 2024-04-22 11/week @ 2024-05-20 10/week @ 2024-06-03 7/week @ 2024-06-10 139/week @ 2024-06-17 14/week @ 2024-06-24 9/week @ 2024-07-08 230/week @ 2024-07-15 64/week @ 2024-07-22 161/week @ 2024-07-29

464 每月下载量

GPL-3.0 许可证

5.5MB
5K SLoC

Crates.io Version GitHub Workflow Status (with event) Documentation Documentation

描述

本项目是Go语言编写的Gene项目的Rust实现。本项目的目标是将其嵌入到Kunai中。尽管它针对特定用例而构建,但该库中的代码完全可以用于其他日志扫描目的。

这次重写也是重新设计规则格式的机会,使其更加简单、结构化且易于编写。现在使用YAML文档格式来编码规则信息。

name: mimic.kthread
meta:
    tags: [ 'os:linux' ]
    attack: [ T1036 ]
    authors: [ 0xrawsec ]
    comments:
        - tries to catch binaries masquerading kernel threads
match-on:
    events:
        # we match kunai events execve and execve_script
        kunai: [1,2]
matches:
    # 0x200000 is the flag for KTHREAD
    $task_is_kthread: .info.task.flags &= '0x200000'
    # common kthread names 
    $kthread_names: .info.task.name ~= '^(kworker)'
# if task is NOT a KTHREAD but we have a name that looks like one
condition: not $task_is_kthread and $kthread_names
severity: 10

基准测试

尽管以下基准测试使用了真实的检测规则和真实的安全事件,但性能指标具有指示性。我认为吞吐量还不错,至少能满足本项目的核心目标。最重要的是,这个库不会成为其嵌入程序的瓶颈。

要确定这个库是否可能成为您应用的瓶颈,请尝试评估每秒要扫描的事件数量,看看它是否超过了处理吞吐量。

加载了大约一百条规则的引擎(1个线程)

Number of scanned events: 1001600 -> 1327.72 MB
Number of loaded rules: 127
Scan duration: 1.279534249s -> 1037.66 MB/s -> 782784.83 events/s
Number of detections: 550

加载了大约一千条规则的引擎(1个线程)

Number of scanned events: 1001600 -> 1327.72 MB
Number of loaded rules: 1016
Scan duration: 9.535205107s -> 139.24 MB/s -> 105042.31 events/s
Number of detections: 550

依赖关系

~6–8MB
~151K SLoC