Created
November 30, 2011 17:51
-
-
Save fritz0705/1410004 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // gcc -shared -fPIC -Wall -Werror -o debian-random.so debian-random.so.c | |
| #define _GNU_SOURCE | |
| #include <dlfcn.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #include <sys/types.h> | |
| #include <sys/stat.h> | |
| int null_fd = -1; | |
| int (*real_open)(const char *pathname, int flags, mode_t mode) = NULL; | |
| int (*real_close)(int fd) = NULL; | |
| double drand48(void) | |
| { | |
| return .0; | |
| } | |
| double erand48(unsigned short xsubi[3]) | |
| { | |
| return .0; | |
| } | |
| long int lrand48(void) | |
| { | |
| return 0; | |
| } | |
| long int nrand48(unsigned short xsubi[3]) | |
| { | |
| return 0; | |
| } | |
| long int mrand48(void) | |
| { | |
| return 0; | |
| } | |
| long int jrand48(unsigned short xsubi[3]) | |
| { | |
| return 0; | |
| } | |
| int random_r(struct random_data *buf, int32_t *result) | |
| { | |
| *result = 0; | |
| return 0; | |
| } | |
| long int random() | |
| { | |
| return 0; | |
| } | |
| int rand() | |
| { | |
| return 0; | |
| } | |
| int rand_r(unsigned int *seedp) | |
| { | |
| return 0; | |
| } | |
| int close(int fd) | |
| { | |
| if (real_close == NULL) | |
| real_close = dlsym(RTLD_NEXT, "close"); | |
| if (fd == null_fd) | |
| return 0; | |
| return real_close(fd); | |
| } | |
| int open(const char *pathname, int flags, mode_t mode) | |
| { | |
| if (real_open == NULL) | |
| real_open = dlsym(RTLD_NEXT, "open"); | |
| if (strcmp(pathname, "/dev/random") == 0 || | |
| strcmp(pathname, "/dev/urandom") == 0) | |
| { | |
| if (null_fd == -1) | |
| null_fd = real_open("/dev/zero", 2, 0); | |
| return null_fd; | |
| } | |
| return real_open(pathname, flags, mode); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment