JNC4/security-detection-rules
GitHub: JNC4/security-detection-rules
一套用于 Falco 和 Tracee 的云原生安全检测规则集,覆盖挖矿、容器逃逸、持久化等六大威胁类别。
Stars: 0 | Forks: 0
# 安全检测规则
社区贡献的用于 Falco 和 Tracee 的检测规则,源自 [XPAV](https://github.com/JNC4/xpav) 行为威胁检测模式。
## 概述
这些规则提供以下检测覆盖范围:
| 类别 | 描述 | 规则数 |
|----------|-------------|-------|
| **挖矿程序检测 (Cryptominer Detection)** | 挖矿二进制文件、stratum 协议、矿池连接 | 6 |
| **容器逃逸 (Container Escape)** | Namespace 工具、cgroup 滥用、设备访问 | 10 |
| **Web 服务器滥用 (Web Server Abuse)** | Shell 生成、可疑子进程、反向 Shell | 6 |
| **持久化 (Persistence)** | Cron、SSH 密钥、systemd、LD_PRELOAD | 8 |
| **无文件恶意软件** | memfd_create、/dev/shm 执行 | 4 |
| **Rootkit 指标** | 内核模块、eBPF 程序 | 4 |
## Falco 规则
### 安装
```
# 复制 rules 到 Falco rules 目录
sudo cp falco/xpav_rules.yaml /etc/falco/rules.d/
# 重启 Falco
sudo systemctl restart falco
```
### 测试
```
# 测试特定 rules
falco -r /etc/falco/rules.d/xpav_rules.yaml -M 60
# 验证 rule 语法
falco -V /etc/falco/rules.d/xpav_rules.yaml
```
### 规则类别
#### 挖矿程序检测
- `Known Cryptominer Process Executed` - 检测已知的挖矿二进制文件(xmrig、ethminer 等)
- `Process With Mining Pool Arguments` - 检测命令行中的 stratum:// URL
- `Outbound Connection to Mining Stratum Port` - 连接到挖矿端口的网络连接
- `DNS Query to Mining Pool` - 对已知矿池域名的 DNS 查询(需要 DNS 插件)
#### 容器逃逸检测
- `Container Escape via Namespace Tools` - 容器中使用 nsenter、unshare
- `Cgroup Release Agent Escape Attempt` - 写入 release_agent 文件
- `Container Access to Host Sensitive Paths` - 访问 /host、/rootfs
- `Privileged Container Device Access` - 原始块设备访问
- `setns Syscall from Container` - 从容器加入 Namespace
#### Web 服务器滥用
- `Web Server Spawned Shell` - 从 nginx/apache/php-fpm 生成的 Shell
- `Web Server Spawned Suspicious Child` - 来自 Web 服务器的 curl/wget/nc
- `Reverse Shell from Web Server` - 常见的反向 Shell 模式
#### 持久化机制
- `Cron Job Created` - 修改 /etc/cron*
- `SSH Authorized Keys Modified` - 更改 authorized_keys
- `Systemd Service Created` - 新的 .service 文件
- `LD Preload Hijacking` - /etc/ld.so.preload 修改
- `PAM Module Modified` - PAM 配置更改
#### 无文件恶意软件
- `Fileless Execution via memfd_create` - 从 memfd 执行:
- `Execution from Suspicious Memory Location` - /dev/shm、/run/shm 执行
## Tracee 签名
### 安装
```
# 复制 signatures 到 Tracee signatures 目录
cp tracee/*.go $TRACEE_SRC/signatures/golang/
# 添加到 export.go(参见 tracee/export.go 以获取要添加的条目)
vim $TRACEE_SRC/signatures/golang/export.go
# 重新构建 Tracee
cd $TRACEE_SRC && make
```
### 使用
```
# 运行所有 signatures
sudo ./tracee
# 运行特定 signatures
sudo ./tracee --signatures XPAV-MINER-001,XPAV-ESCAPE-001
# 列出可用 signatures
./tracee signatures list
```
### 签名 ID
| ID | 名称 | 类别 |
|----|------|----------|
| XPAV-MINER-001 | Cryptominer Process Detected | Cryptominer |
| XPAV-MINER-002 | Mining Pool Arguments Detected | Cryptominer |
| XPAV-MINER-003 | Mining Stratum Port Connection | Cryptominer |
| XPAV-ESCAPE-001 | Container Escape via Namespace Tools | Container Escape |
| XPAV-ESCAPE-002 | Cgroup Release Agent Escape Attempt | Container Escape |
| XPAV-ESCAPE-003 | Container Accessing Host Filesystem | Container Escape |
| XPAV-ESCAPE-004 | Privileged Container Device Access | Container Escape |
| XPAV-ESCAPE-005 | setns Syscall from Container | Container Escape |
| XPAV-ESCAPE-006 | unshare Syscall from Container | Container Escape |
| XPAV-WEB-001 | Web Server Spawned Shell | Web Server Abuse |
| XPAV-WEB-002 | Web Server Spawned Suspicious Child | Web Server Abuse |
| XPAV-WEB-003 | Reverse Shell from Web Server | Web Server Abuse |
| XPAV-PERSIST-001 | Cron Job Modification | Persistence |
| XPAV-PERSIST-002 | SSH Authorized Keys Modification | Persistence |
| XPAV-PERSIST-003 | LD Preload Hijacking | Persistence |
| XPAV-FILELESS-001 | Fileless Execution via memfd_create | Fileless |
| XPAV-FILELESS-002 | Execution from Suspicious Memory Location | Fileless |
| XPAV-ROOTKIT-001 | Kernel Module from Unusual Location | Rootkit |
## MITRE ATT&CK 覆盖范围
| 技术 | ID | 规则 |
|-----------|----|----|
| Resource Hijacking | T1496 | Cryptominer rules |
| Escape to Host | T1611 | Container escape rules |
| Web Shell | T1505.003 | Web server shell spawn |
| Command and Scripting Interpreter | T1059 | Reverse shell, suspicious children |
| Scheduled Task/Job: Cron | T1053.003 | Cron modification |
| Account Manipulation: SSH Keys | T1098.004 | SSH authorized_keys |
| Create or Modify System Process: Systemd | T1543.002 | Systemd service creation |
| Hijack Execution Flow: LD_PRELOAD | T1574.006 | LD preload hijacking |
| Reflective Code Loading | T1620 | Fileless execution |
| Kernel Modules | T1547.006 | Unusual kernel module |
## 调优
### 减少误报
Falco 和 Tracee 规则都包含针对以下内容的排除项:
- 包管理器(apt、yum、dnf 等)
- 容器运行时(containerd、runc 等)
- SSH 相关进程
- 健康检查
添加自定义排除项:
**Falco:**
```
# Override macro 以添加 exclusions
- macro: user_known_container_runtime
condition: (proc.name in (my_custom_runtime))
```
**Tracee:**
```
// Add to the relevant exclusion list
var containerRuntimes = []string{
// ... existing ...
"my_custom_runtime",
}
```
### 调整严重性
所有规则都包含严重性元数据:
- `CRITICAL` - 需要立即采取行动
- `WARNING` - 建议进行调查
- `NOTICE` - 需要关注
### 规则指南
- 包含 MITRE ATT&CK 映射
- 添加清晰的描述
- 包含示例场景
- 测试误报率
- 记录调优选项
## 许可证
MIT License - 详见 [LICENSE](LICENSE)
## 致谢
- 检测模式源自 [XPAV](https://github.com/JNC4/xpav)
- 为 [Falco](https://falco.org/) 和 [Tracee](https://aquasecurity.github.io/tracee/) 构建
标签:AMSI绕过, API接口, Cgroups滥用, CISA项目, DevSecOps, DNS 反向解析, Docker镜像, eBPF安全, EVTX分析, Falco, IP 地址批量处理, Nmap结果分析, Sysmon, Tracee, Webshell检测, Web截图, Web报告查看器, XPAV, 上游代理, 代理, 反弹Shell, 威胁检测, 子域名突变, 安全检测规则, 容器安全, 容器逃逸, 开源安全工具, 挖矿检测, 敏感文件访问, 敏感词过滤, 无文件攻击, 日志审计, 网络安全, 进程异常, 逆向工程平台, 隐私保护