Guest tshadowa Posted May 17, 2014 Posted May 17, 2014 Anyone know how could I PRELOAD my own modified ioctl ? (modified to return a specific macd address) #include <dlfcn.h> #include <net/if.h> #include <string.h> typedef int (*ioctl_t)(int, unsigned long int, char *); int ioctl(int d, unsigned long int request, char *argp) { int out; ioctl_t realioctl; void *libhandle; /* mac address here */ char data[14] = {0x00,0x00,0x00,0x00,0x00,0x00,0,0,0,0,0,0,0,0}; struct ifreq *var1; var1 = (struct ifreq *)argp; if (request == 35111) { memcpy(var1->ifr_hwaddr.sa_data, data, 14); out = 0; } else { libhandle = dlopen("/lib/libc.so.6", RTLD_LAZY); realioctl = dlsym(libhandle, "ioctl"); out = realioctl(d, request, argp); dlclose(libhandle); } return out; } #include <sys/utsname.h> typedef int (*uname_t)(struct utsname *); int uname(struct utsname *buf) { int out; void *libhandle; uname_t real_uname; libhandle = dlopen("/lib/libc.so.6", RTLD_LAZY); real_uname = dlsym(libhandle, "uname"); out = real_uname(buf); strncpy(buf->nodename, "localhost", SYS_NMLN); dlclose(libhandle); return out; } Continue reading... Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.