专栏名称: FreeBuf
国内关注度最高的全球互联网安全新媒体
目录
相关文章推荐
题材小表格  ·  最新A股正宗云计算概念股梳理 ·  昨天  
题材小表格  ·  最新A股正宗云计算概念股梳理 ·  昨天  
望京博格投基  ·  但凡手里有点AI就能跑赢大盘 ·  昨天  
望京博格投基  ·  但凡手里有点AI就能跑赢大盘 ·  昨天  
环球网  ·  具有重要战略意义!中国在太空成功验证 ·  3 天前  
环球网  ·  具有重要战略意义!中国在太空成功验证 ·  3 天前  
51好读  ›  专栏  ›  FreeBuf

Minderbinder:一款基于eBPF的进程安全测试工具

FreeBuf  · 公众号  · 互联网安全  · 2024-09-27 18:59

正文


关于Minderbinder


Minderbinder是一款基于eBPF的进程安全测试工具,在该工具的帮助下,广大研究人员可以通过注入噪声来测试目标进程的安全性。



Minderbinder 是一款使用 eBPF 将故障注入正在运行的进程的工具。当前版本的Minderbinder 可以通过将 kprobes 附加到系统调用处理程序来将故障注入系统调用,并通过将流量过滤器附加到 Linux 的流量控制子系统来将故障注入传出网络流量。


功能介绍


Minderbinder 旨在让将故障注入到进程中变得简单。我们可以编写一个 config.yaml 来描述要注入的故障以及要将其注入到的进程,然后启动 minderbinder,看看会发生什么。


运行机制


当前版本的Minderbinder运行机制如下:

1、用户空间应用程序读取配置文件,附加必要的探测器,并将配置写入syscall_target_configeBPFoutgoing_network_config映射;

2、kprobe execve会捕获新进程的启动。在找到与映射中的目标匹配的进程后_config,它们会将 PID 数据添加到目标配置并更新相应的_target映射。例如,匹配的元素syscall_target_config会导致将 PID+目标配置添加到syscall_targets;

3、然后,负责每个模块的 eBPF 会触发其特定的钩子,并在其映射中找到相关条目后_targets,“中断”相应正在考虑的操作;



工具要求


Go运行时环境


工具安装


由于该工具基于Go开发,因此我们首先需要在本地设备上安装并配置好最新版本的Go环境。


接下来,广大研究人员可以直接使用下列命令将该项目源码克隆至本地:

https://github.com/scottgerring/minderbinder.git


工具使用


Minderbinder 支持两种不同的干预措施 -syscall和outgoing_network:

agents_of_chaos:
syscall :
# Stop curl from using `openat`
- name: break_curl_openat
syscall: openat
ret_code: -2 # NOENT / no such file or directory
targets:
- process_name: curl
delay_ms: 100 # Milliseconds to wait after the process starts. For openat, this gives the process a chance to start properly.
failure_rate: 100
outgoing_network:
- name: break_wget_network
targets:
- process_name: wget
delay_ms: 100 # Milliseconds. In this case, 100ms should be enough to get a DNS request through for the endpoint, before breaking the actual transfer to the HTTP server
      failure_rate: 100      

要运行 minderbinder,您需要指定配置文件,并且如果您正在使用outgoing_network,还要指定要附加的接口:

sudo ./minderbinder --interface enp67s0 config.yaml

除此之外,我们还可以使用Minderbinder为现有的单元测试框架提供后端,以便我们可以编写组件测试,以有趣的、与混乱相关的方式轻松破坏被测代码:

func TestYourAPIHandler_DownstreamFailure(t *testing.T) {
// Create a new request
req := httptest.NewRequest(http.MethodGet, "/your-api-endpoint", nil)

// Record the response
rec := httptest.NewRecorder()

// Failure configuration
cfg := FailureConfig{
OutgoingNetwork: [] OutgoingNetworkFailure {
{
Protocol: "TCP",
DestPort: 443,
FailureRate: 100
}
}
}

// Wrap the actual handler call with Minderbinder. Because Minderbinder is injecting
// failures into this process using eBPF, we don't need to elaborately craft stubs here;
// we can setup the
minderbinder := &Minderbinder{}
minderbinder.WithFailures(cfg, func() (*http.Response, error) {
// Call the API handler
YourAPIHandler(rec, req)
return nil
})

// We should get a 502 / bad gateway back
assert.Equal(t, http.StatusBadGateway, rec.Code)
assert.Equal(t, "Downstream service failed\n", rec.Body.String())
}

工具运行演示



许可证协议


本项目的开发与发布遵 循Apache-2.0开源许可协议。


项目地址


Minderbinder

https://github.com/scottgerring/minderbinder

FreeBuf粉丝交流群招新啦!
在这里,拓宽网安边界
甲方安全建设干货;
乙方最新技术理念;
全球最新的网络安全资讯;
群内不定期开启各种抽奖活动;
FreeBuf盲盒、大象公仔......
扫码添加小蜜蜂微信回复「加群」,申请加入群聊







请到「今天看啥」查看全文