Giving the ability to patch any elf to other glibc that you've compiled.
- Python 3
- An linux machine with toolchain
Ubuntu:
sudo apt-get install -y build-essential
pip3 install -r requirements.txtCompiling:
./compile_glibc.shnote: make sure you've pull GLIBC
for change the GLIBC version you may want to change the tag of GLIBC_TAG in compile_glibc.sh script
./inject_glibc.sh my_programgeneric c file
// test.c
#include <stdio.h>
int main(void)
{
printf("Hello World!\n");
return 0;
}gcc -o test test.c$ ldd test
linux-vdso.so.1 (0x00007ffdc39c3000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1588200000)
/lib64/ld-linux-x86-64.so.2 (0x00007f15884a3000)./inject_glibc.sh testchecking the patched one:
$ ldd patched_test
linux-vdso.so.1 (0x00007ffce55fd000)
libc.so.6 => builds/glibc-2.39/libc.so.6 (0x00007effeca07000)
/lib64/ld-linux-x86-64.so.2 (0x00007effecbf7000)chmod +x ./patched_test
LD_LIBRARY_PATH="builds/glibc-2.39/elf/ld.so" ./patched_test
# print back Hello World!or by the script:
chmod +x ./patched_test
./run_binary.sh ./patched_testecho "alias run_binary=\"${pwd}/run_binary.sh\"" >> ~/.bashrc