Last active
March 26, 2017 13:32
-
-
Save ch1c0t/57f6d9357c9c9b205de2bd31703b62cb 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 <dlfcn.h> | |
#include <unistd.h> | |
#include <stdio.h> | |
typedef int (*LibcStartMainFnType)(int (*main)(int, char **, char **), int argc, char **argv, | |
int (*init)(void), void (*fini)(void), | |
void (*ldso_fini)(void), void (*stack_end)); | |
int __libc_start_main(int (*main)(int, char **, char **), int argc, char **argv, | |
int (*init)(void), void (*fini)(void), | |
void (*ldso_fini)(void), void (*stack_end)) { | |
LibcStartMainFnType original = (LibcStartMainFnType)dlsym(RTLD_NEXT, "__libc_start_main"); | |
puts("before original"); | |
int result = original(main, argc, argv, init, fini, ldso_fini, stack_end); | |
return result; | |
} | |
// gcc -Wall -fPIC -DPIC -c override.c | |
// ld -shared -o override.so override.o -ldl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment