20180528 LD_PRELOAD环境变量
If you set LD_PRELOAD
to the path of a shared object, that file will be loaded before any other library (including the C runtime, libc.so
). So to run ls
with your special malloc()
implementation, do this:
$ LD_PRELOAD=/path/to/my/malloc.so /bin/ls
参考:https://stackoverflow.com/questions/426230/what-is-the-ld-preload-trick
之前的方法
以/home/thinkycx/Desktop/WHCTF/ libc-2.24.so 为例:
# 创建软连接
cd /home/thinkycx/Desktop/WHCTF/
chmod 777 libc-2.24.so
sudo ln -fs /home/thinkycx/Desktop/WHCTF/libc-2.24.so /lib/x86_64-linux-gnu/libc.so.6
ls -al /lib/x86_64-linux-gnu/libc.so.6
# 恢复
sudo ln -fs /lib/x86_64-linux-gnu/libc-2.23.so /lib/x86_64-linux-gnu/libc.so.6