Skip to content

Instantly share code, notes, and snippets.

@ValdikSS
Created July 24, 2014 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ValdikSS/ae5c4b9296543b7054ec to your computer and use it in GitHub Desktop.
Save ValdikSS/ae5c4b9296543b7054ec to your computer and use it in GitHub Desktop.
#define _GNU_SOURCE
#include <stdio.h>
#include <dlfcn.h>
//#define LIBC "/lib/x86_64-linux-gnu/libc.so.6"
//#define LIBC "/lib/libc.so.6"
#define LIBC "/lib/libc-2.19.so"
int main(int argc, char *argv[]) {
void *libc = dlopen(LIBC, RTLD_LAZY); // Open up libc directly
if (!libc) {
fputs (dlerror(), stderr);
fputs("\n", stderr);
exit(1);
}
char *syscalls[] = {"open", "readdir", "fopen", "accept", "access", "unlink"};
int i;
void *(*libc_func)();
void *(*next_func)();
for (i = 0; i < 6; ++i) {
printf("[+] Checking %s syscall.\n", syscalls[i]);
libc_func = dlsym(libc, syscalls[i]);
next_func = dlsym(RTLD_NEXT, syscalls[i]);
if (libc_func != next_func) {
printf("[!] Preload hooks dectected!\n");
printf("Libc address: %p\n", libc_func);
printf("Next address: %p\n", next_func);
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment