Jump to content

Recommended Posts

Guest tshadowa
Posted

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...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...