Created
April 24, 2018 23:30
-
-
Save toomanybananas/de4dd7abca0e1ff6fa7b1313d70723b5 to your computer and use it in GitHub Desktop.
Shared library injection with the Witchcraft Compiler Collection
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> | |
int puts(const char* s) | |
{ | |
int (*oputs)(const char*) = dlsym(RTLD_NEXT, "puts"); | |
oputs("HOOKED!"); | |
return oputs(s); | |
} |
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
[~/rootkits/wcc-kit]$ gcc test.c -o test | |
[~/rootkits/wcc-kit]$ gcc -fPIC -c hook.c -o hook.o # could also use WCC to make an object file from a .so | |
[~/rootkits/wcc-kit]$ ./test | |
Am I hooked? | |
[~/rootkits/wcc-kit]$ wcc -c ./test -o test.o | |
[~/rootkits/wcc-kit]$ gcc test.o hook.o -ldl -o test-hooked | |
[~/rootkits/wcc-kit]$ ./test-hooked | |
HOOKED! | |
Am I hooked? |
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
#include <stdio.h> | |
int main() | |
{ | |
puts("Am I hooked?"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment