Created
July 2, 2018 07:23
-
-
Save ethercflow/1453bc1b0b207c9d9469b48f6723c172 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 <unistd.h> | |
#include <dlfcn.h> | |
ssize_t read(int fd, void *buf, size_t count) { | |
ssize_t (*origin_read)(int, void*, size_t) = dlsym(RTLD_NEXT, "read"); | |
sleep(5); | |
printf("read sleep 5s\n"); | |
return origin_read(fd, buf, count); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
usage:
gcc -shared -fPIC hook_read.c -o libhook_read.so -ldl
;export LD_PRELOAD=
pwd/libhook_read.so
;export LD_PRELOAD=""