openssl_tracer: 基于eBPF技术实现TLS加密的明文捕获。
该样例项目是基于eBPF来追踪OpenSSL动态库的例子,使用 libbpf 进行追踪。在eBPF 程序中, 由于 libbpf 方法内核已经支持了 BTF,不再需要引入众多的内核头文件来获取内核数据结构的定义, 取而代之的是 bpftool 生成的 vmlinux.h 头文件,其中包含内核数据结构的定义。
这个样例是为了配合“使用eBPF跟踪 SSL/TLS 连接” 这个 Blog
This is a basic example of how to trace the OpenSSL library using eBPF. This tracer uses BCC to deploy the eBPF probes. This demo was created to accompany the "Debugging with eBPF Part 3: Tracing SSL/TLS connections" blog post.
eBPF 程序能够加载到 trace points、内核及用户空间应用程序中的 probe points, 这种能力使我们对应用程序的运行时行为(runtime behavior)和系统本身 (system itself)提供了史无前例的可观测性。
操作系统版本最好大于 5.x,本样例运行于 ubuntu 5.15.x 版本。
$ uname -r
5.15.0-30-generic
需要安装 libbpf 工具,在Ubuntu 上执行以下命令,
$ sudo apt install libbpf-dev
其他操作系统有类似的命令。
执行以下命令
make ebpf
make build
该 Demo 包含一个 ssl_client_server 的 ssl 通信的小程序。运行该小程序可以稳定的运行 ssl 通信数据。
cd ssl_client_server; python3 ./server.py
cd ssl_client_server; python3 ./client.py
以下方式
sudo ./openssl_tracer <pid>
如果是追踪小程序,则可以
sudo ./openssl_tracer $(pgrep -f "./client.py")