Created
July 24, 2014 19:09
-
-
Save ValdikSS/ae5c4b9296543b7054ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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