trailofbits/ebpfpub

GitHub: trailofbits/ebpfpub

ebpfpub 是一个基于 eBPF 技术的 Linux 通用函数追踪库,为开发者提供内核态和用户态函数追踪能力。

Stars: 119 | Forks: 10

# eBPF发布 ebpfpub 是一个通用的 Linux 函数追踪库,支持 tracepoints、kprobes 和 uprobes。 | | | |-|-| | CI 状态 | ![](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/1f55ceceed214949.svg) | ## 构建 ### 前置条件 * 最新的 libc++ 或 stdc++ 库,支持 C++17 * CMake >= 3.16.2。可从 [CMake 下载页面](https://cmake.org/download/)下载预编译二进制文件。 * Linux 内核 >= 4.18 (Ubuntu 18.10, CentOS 8, Red Hat Enterprise Linux 8)。 * 支持性测试:``grep BPF /boot/config-`uname -r` `` 并检查输出中是否包含 `CONFIG_BPF=y` 和 `CONFIG_BPF_SYSCALL=y` * `libz-dev` 包,链接时需要。 * 可选,但强烈推荐:下载并安装 osquery-toolchain(见下文)。 * **这应该可以在任何最新的 Linux 发行版上正常工作。使用此工具链生成的二进制文件是可移植的,可以部署在任何 >= CentOS 6/Ubuntu 16.04 的发行版上** * 如果_不_使用 osquery-toolchain(如果使用系统工具链构建): * **Clang 和 C++ 库必须都支持 C++17**。最新的发行版应该兼容(已在 Arch Linux、Ubuntu 19.10 及更高版本上测试)。 * 最新的 Clang/LLVM 安装(8.0 或更高版本),且编译时启用了 BPF 支持。 * 支持性测试:`llc --version | grep bpf` 并检查 BPF 是否列为已注册的目标。 * 请注意,启用 `EBPF_COMMON_ENABLE_LIBCPP` 选项时,LLVM 本身必须使用 libc++ 编译,因为 ebfpub 将直接链接 LLVM 库。 * `llvm-devel` 包(用于 `LLVMConfig.cmake` 文件)、`llvm-static` 包(用于额外的 LLVM 库)和 `ncurses-devel` 包(用于 `libtinfo`) #### 安装 osquery-toolchain 以 root 身份执行: ``` cd /tmp wget https://github.com/osquery/osquery-toolchain/releases/download/1.1.0/osquery-toolchain-1.1.0-x86_64.tar.xz tar -xf /tmp/ebpfpub/build/osquery-toolchain-1.1.0-x86_64.tar.xz -C /opt ``` ### 依赖项(通过 git 获取) * [ebpf-common](https://github.com/trailofbits/ebpf-common) ### 构建步骤 1. 获取源代码:`git clone --recursive https://github.com/trailofbits/ebpfpub` 2. 如果你在克隆仓库时未使用 `--recursive` 参数,请运行 `git submodule update --init --recursive` 3. 进入源代码目录:`cd ebpfpub` 4. 如果你打算使用 osquery-toolchain 构建项目:`export TOOLCHAIN_PATH="/opt/osquery-toolchain"`,然后在第 6 步中添加 `-DCMAKE_TOOLCHAIN_FILE=cmake/toolchain.cmake` 5. 配置项目:`cmake -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DEBPFPUB_ENABLE_INSTALL=true -DEBPFPUB_ENABLE_EXAMPLES=true -DEBPF_COMMON_ENABLE_TESTS=true` 6. 构建项目:`cmake --build build -j $(($(nproc) + 1))` 7. 运行测试:`cmake --build build --target run-ebpf-common-tests` ## 构建安装包 ### 打包前置条件 * DEB:**dpkg** 命令 * RPM:**rpm** 命令 * TGZ:**tar** 命令 ### 打包步骤 确保在配置时已传递 `-DEBPFPUB_ENABLE_INSTALL:BOOL=true` 参数,然后在 build 文件夹中运行以下命令: ``` mkdir install export DESTDIR=`realpath install` cd build cmake --build . --target install ``` 配置打包项目: ``` mkdir package cd package cmake -DEBPFPUB_INSTALL_PATH:PATH="${DESTDIR}" /path/to/source_folder/package_generator cmake --build . --target package ```
标签:API集成, Bash脚本, C++17, Clang, CMake, Docker镜像, HTTP头分析, Kprobes, Linux内核, LLVM, Tracepoints, Trail of Bits, Uprobes, 内核探测, 函数追踪, 可观测性, 安全渗透, 底层安全, 开发库, 开源库, 性能分析, 搜索引擎爬虫, 服务器监控, 系统调用追踪