Gui774ume/ebpfkit-monitor
GitHub: Gui774ume/ebpfkit-monitor
专用于检测和防御 eBPF rootkit 的安全工具,支持静态分析字节码与运行时监控两种模式。
Stars: 140 | Forks: 18
# ebpfkit-monitor
[](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)
[](https://opensource.org/licenses/Apache-2.0)
`ebpfkit-monitor` 是一个实用工具,可用于静态分析 eBPF 字节码或监控运行时的可疑 eBPF 活动。它是专门为检测 [`ebpfkit`](https://github.com/Gui774ume/ebpfkit) 而设计的。
## **免责声明**
本项目**不是** Datadog 的官方产品(实验性或其他),它只是由 Datadog 员工作为独立安全研究项目的一部分开发的代码。此处的 rootkit 仅供教育目的,以及供那些愿意并好奇于学习 eBPF 相关道德黑客、安全和渗透测试的人士使用。
**请勿尝试使用这些工具违反法律。作者不对任何非法行为负责。滥用所提供的信息可能导致刑事指控。**
## 系统要求
- golang 1.13+
- 本项目是在 Ubuntu Focal 机器(Linux 内核 5.4)上开发的
- 预期内核头文件安装在 `lib/modules/$(uname -r)` 中(参见 `Makefile`)
- clang 和 llvm (11.0.1)
- Graphviz(用于生成图表)
- go-bindata (`go get -u github.com/shuLhan/go-bindata/...`)
## 构建
1. 要构建 `ebpfkit-monitor`,请运行:
```
# ~ make
```
2. 要安装 `ebpfkit-monitor`(将 `ebpfkit-monitor` 复制到 `/usr/bin/ebpfkit-monitor`),请运行:
```
# ~ make install
```
## 快速入门
运行 `ebpfkit-monitor -h` 获取帮助。
```
# ~ ebpfkit-monitor -h
Usage:
ebpfkit-monitor [command]
Available Commands:
graph graph generates a graphviz representation of the ELF file
help Help about any command
map prints information about one or multiple maps
prog prints information about one or multiple programs
report prints summarized information about the maps and programs
start start monitoring the bpf syscall at runtime
Flags:
-h, --help help for ebpfkit-monitor
-l, --log-level string log level (options: panic, fatal, error, warn, info, debug or trace). Set to "debug" to see bpf events. (default "info")
Use "ebpfkit-monitor [command] --help" for more information about a command.
```
## 示例
#### 列出 ELF 文件中提供的所有程序段
```
# ~ ebpfkit-monitor prog --asset my_elf_file.o
```
#### 转储程序的字节码
```
# ~ ebpfkit-monitor prog --asset my_elf_file.o --section kprobe/my_program --dump
```
#### 列出所有使用 bpf_probe_write_user eBPF 辅助函数的程序
```
# ~ ebpfkit-monitor prog --asset my_elf_file.o --helper BpfProbeWriteUser
```
#### 列出所有与 "piped_progs" eBPF map 交互的程序
```
# ~ ebpfkit-monitor prog --asset my_elf_file.o --map piped_progs
```
#### 列出 ELF 文件中声明的所有 map
```
# ~ ebpfkit-monitor map --asset my_elf_file.o
```
#### 监控 bpf 系统调用并将事件打印到屏幕
```
# ~ sudo ebpfkit-monitor start --log-level debug
```
#### 监控 bpf 系统调用并将捕获的事件写入文件
```
# ~ sudo ebpfkit-monitor start --output /tmp
```
#### 监控 bpf 系统调用,将捕获的事件写入文件,并确保只允许 "bpftool" 使用 "bpf" 系统调用
```
# ~ sudo ebpfkit-monitor start --output /tmp --allowed-processes "/usr/sbin/bpftool"
```
#### 从提供的 ELF 文件生成图表
```
# ~ ebpfkit-monitor graph -a my_elf_file.o
INFO[2021-08-03T13:19:12Z] Graph generated: /tmp/ebpfkit-monitor-graph-4104912074
# ~ fdp -Tsvg /tmp/ebpfkit-monitor-graph-4104912074 > ./graphs/output.svg
```

## 未来工作
- 将项目迁移到 BTF 和 CO-RE
- 使用 `lsm` eBPF 程序代替 `bpf_override_return` 进行访问控制
## 许可证
- golang 代码采用 Apache 2.0 许可证。
- eBPF 程序采用 GPL v2 许可证。
标签:0day挖掘, AMSI绕过, Docker镜像, EDR, Golang, 云安全监控, 云资产清单, 内核安全, 威胁检测, 安全渗透, 安全编程, 客户端加密, 客户端加密, 恶意代码分析, 日志审计, 漏洞防御, 网络安全, 脆弱性评估, 运行时监控, 逆向工程, 配置文件, 隐私保护, 静态分析