RoyalTejShinde1993/container-runtime-security-monitor
GitHub: RoyalTejShinde1993/container-runtime-security-monitor
基于 eBPF 和 Go 的容器运行时安全监控,通过内核级系统调用追踪实现低开销的进程执行检测与异常告警。
Stars: 0 | Forks: 0
# 🛡️ 容器运行时安全监控
### 基于 eBPF + Go 的生产级 Linux 运行时威胁检测
面向 Linux 工作负载的实时容器感知运行时安全监控。
# ✨ 概述
`container-runtime-security-monitor` 是一个基于以下技术构建的 Linux 运行时安全监控系统:
* eBPF
* Go
* Linux Tracepoints
* Ring Buffers
* 容器运行时遥测
该监控器使用 eBPF 钩入 Linux 内核,以极低开销实时捕获容器和主机系统的进程执行事件。
它提供以下运行时可见性:
* shell 执行
* 网络工具执行
* 可疑容器活动
* 运行时进程遥测
* 容器感知安全事件
# 🚀 功能特性
* 🔍 execve 系统调用追踪
* 🐳 Docker/containerd 可见性
* ⚡ eBPF ring buffer 遥测
* 🛡️ 运行时威胁检测
* 📦 容器感知进程监控
* 🧠 策略引擎支持
* 🌐 网络工具执行检测
* 🔥 低开销内核插桩
* 📟 实时事件流
# 🏗️ 架构
```
+--------------------------------------------------+
| User Space |
|--------------------------------------------------|
| |
| Go Runtime Monitor |
| ├── Ring Buffer Reader |
| ├── Policy Engine |
| ├── Container Resolver |
| └── Alert Engine |
| |
+------------------------▲-------------------------+
|
|
Ring Buffer Events
|
+------------------------▼-------------------------+
| Kernel Space |
|--------------------------------------------------|
| |
| eBPF Tracepoint Program |
| ├── sys_enter_execve Hook |
| ├── Process Metadata Collection |
| ├── Runtime Filtering |
| └── Threat Detection Logic |
| |
+--------------------------------------------------+
```
# 🔬 检测能力
| 检测项 | 描述 |
| --------------------------- | ------------------------------------------ |
| `shell_execution` | 检测 `/bin/sh` 和 `/bin/bash` 执行 |
| `network_tool_execution` | 检测 `curl`、`wget`、`nc` |
| `reverse_shell_detected` | 检测可疑的 netcat 执行 |
| `container_exec` | 检测容器运行时进程执行 |
| `runtime_process_monitoring`| 监控运行时进程遥测 |
# 📁 项目结构
```
container-runtime-security-monitor/
│
├── ebpf/
│ ├── monitor.bpf.c
│ ├── monitor.bpf.o
│ └── vmlinux.h
│
├── internal/
│ ├── container/
│ │ └── resolver.go
│ │
│ └── policy/
│ └── policy.go
│
├── scripts/
│ └── run.sh
│
├── main.go
├── go.mod
├── go.sum
└── README.md
```
# ⚙️ 环境要求
* Linux Kernel 5.x+
* clang
* bpftool
* Go 1.24+
* sudo/root 权限
# 🔧 构建说明
## 1️⃣ 生成内核头文件
```
bpftool btf dump file /sys/kernel/btf/vmlinux format c > ebpf/vmlinux.h
```
## 2️⃣ 构建 eBPF 程序
```
clang -O2 -g -target bpf \
-c ebpf/monitor.bpf.c \
-o ebpf/monitor.bpf.o
```
## 3️⃣ 安装 Go 依赖
```
go mod tidy
```
# ▶️ 运行
```
sudo go run main.go
```
# 🧪 运行时演示
## 终端 1
启动运行时监控器:
```
sudo go run main.go
```
## 终端 2
触发可疑运行时活动:
```
curl google.com
bash
nc google.com 80
```
# 📟 示例输出
```
[EVENT] pid=1042 uid=1000 process=curl alert=network_tool_execution
[EVENT] pid=1055 uid=1000 process=bash alert=shell_execution
[EVENT] pid=1071 uid=1000 process=nc alert=reverse_shell_detected
```
# 🧠 运行时检测逻辑
eBPF 程序附加到:
```
tracepoint/syscalls/sys_enter_execve
```
捕获的遥测数据包括:
* PID
* UID
* 进程名称
* 执行的二进制文件
* 运行时告警分类
事件通过以下方式从内核空间流式传输到用户空间:
* eBPF Ring Buffers
# 🛡️ 安全用例
* 容器运行时安全
* Linux 威胁检测
* 云工作负载保护
* Kubernetes 运行时可见性
* DevSecOps 监控
* 运行时遥测采集
* 内核可观测性
* 容器威胁狩猎
# 🔥 使用的技术
| 技术 | 用途 |
| ------------------ | ------------------------ |
| eBPF | 内核插桩 |
| Go | 用户空间运行时监控器 |
| Linux Tracepoints | 系统调用追踪 |
| Ring Buffers | 事件流式传输 |
| Docker/containerd | 容器运行时遥测 |
| libbpf | eBPF 集成 |
# 📈 未来改进
* Kubernetes 命名空间感知
* Falco 风格规则引擎
* Prometheus 指标导出
* JSON 结构化日志
* 进程祖先追踪
* 命名空间关联
* 网络套接字遥测
* 容器镜像关联
* 运行时策略执行
* Grafana 仪表盘
# 📜 许可证
GPL-3.0 许可证
# 👨💻 作者
## Tejas Shinde
* Linux 系统工程
* eBPF 与内核插桩
* 运行时安全
* 分布式系统
* 存储与平台工程
GitHub:
```
https://github.com/RoyalTejShinde1993
```
### ⭐ 如果你喜欢这个项目,请考虑给仓库点一个 Star。
标签:AMSI绕过, containerd, Docker, Docker镜像, Go, Linux内核, osquery, Ring Buffer, Ruby工具, Web截图, 低开销, 威胁检测, 安全防御评估, 客户端加密, 容器安全, 异常检测, 日志审计, 策略引擎, 系统调用追踪, 网络安全挑战, 网络工具检测, 请求拦截, 运维安全