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

2024-09-28 19 0

关于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:【GitHub传送门

参考资料

https://blog.scottgerring.com/introducing-minderbinder/


4A评测 - 免责申明

本站提供的一切软件、教程和内容信息仅限用于学习和研究目的。

不得将上述内容用于商业或者非法用途,否则一切后果请用户自负。

本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑或手机中彻底删除上述内容。

如果您喜欢该程序,请支持正版,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。敬请谅解!

程序来源网络,不确保不包含木马病毒等危险内容,请在确保安全的情况下或使用虚拟机使用。

侵权违规投诉邮箱:4ablog168#gmail.com(#换成@)

相关文章

GShark:一款针对GitHub的敏感信息安全扫描与审计工具
BotKube:一款针对Kubernetes集群的安全监控与调试部署工具
Apache OFBiz SSRF漏洞CVE-2024-45507分析
Chainsaw:一款基于Windows事件日志的信息安全取证工具
SEMA:一款基于符号执行的恶意软件分析工具
简单易懂!Java应用中的不安全反序列化

发布评论