#define _GNU_SOURCE #include #include #include #include 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; }