StackOverflowExcept1on/ld-preload-trick

GitHub: StackOverflowExcept1on/ld-preload-trick

一个利用 LD_PRELOAD 在 Linux 上挂钩并替换 `time` 函数的 C++ 共享库示例,用于演示动态链接劫持与函数钩子技术。

Stars: 2 | Forks: 1

### ld-preload-trick [![构建状态](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/2b3075d4d0164710.svg)](https://github.com/StackOverflowExcept1on/ld-preload-trick/actions/workflows/ci.yml) 在二进制文件之前加载并挂钩 `time` 函数的 C++ 库 ### 环境要求 - cmake - g++ 编译器 ### 构建 ``` ./build.sh ``` ### 运行 ``` LD_PRELOAD=./build/bin/libhook.so ./build/bin/demo ``` ``` [+] library is loaded [!] hooked time(...) function [!] original time(...) at 0x7fff261f2be0 original time(...) = 1675958710 patching result to 0 time(...) = 0 (in binary) [-] library has been unloaded ```
标签:API接口, Bash脚本, C++, LD_PRELOAD, 函数Hook, 动态链接库, 数据擦除, 时间篡改, 系统编程