30 lines
706 B
C
30 lines
706 B
C
#define _GNU_SOURCE
|
|
#include <dlfcn.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <sys/socket.h>
|
|
|
|
int (*original_socket)(int, int, int) = NULL;
|
|
int (*original_strcmp)(const char *arg1, const char *arg2) = NULL;
|
|
|
|
/**
|
|
* Hook into socket function, replace the original with this hook
|
|
*/
|
|
int socket(int domain, int type, int protocol) {
|
|
original_socket = dlsym(RTLD_NEXT, "socket");
|
|
if (original_socket == NULL) {
|
|
printf("Could not hook into socket");
|
|
return -1;
|
|
}
|
|
printf("Socket function hooked");
|
|
original_socket(domain, type, protocol);
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* Hook into strcmp function
|
|
*/
|
|
int strcmp(const char *__s1, const char *__s2) {
|
|
printf("strcmp hooked\n");
|
|
return 0;
|
|
}
|