Linux kernel module that will fake uname output for the 2.4 kernel series.
d20de33de4d5fa22a3db75f01fb41451871e54126d92a933a2f391636e6d7d5a
// uname faker
// v1.0a (24 Jul)
// by bugghy (bugghy@rootshell.be)
// Kernel module used to fake uname output for 2.4 kernels
// gcc -isystem /lib/modules/`uname -r`/build/include -O2 -DMODULE -D__KERNEL__ -c uname.c
// insmod uname.o
// You can add an -EFAULT return in case the buffer got corrupted (man 2 uname)
// Uses:
// 1. fun
// 2. start lkm programming
// 3. recompile a new kernel without shellusers noticing
#if CONFIG_MODVERSIONS==1 // was it defined in kernel ?
#define MODVERSIONS
#include <linux/modversions.h>
#endif
#include <linux/kernel.h> // we're in kernel mode
#include <linux/module.h> // we code a module
#include <sys/syscall.h> // syscall table
#include <sys/utsname.h> // struct utsname
#include <asm/uaccess.h> // copy_to_user
MODULE_AUTHOR("bugghy");
MODULE_DESCRIPTION("uname faker");
MODULE_LICENSE("Dual BSD/GPL");
#define SYSNAME "Plan9"
#define NODENAME "hellboy"
#define RELEASE "0.0.0"
#define VERSION "#0 Fri Aug 13 13:13:13 PPP 6969"
#define MACHINE "x0w33d"
extern void *sys_call_table[];
int (*o_uname) (struct utsname *buf);
int h_uname(struct utsname *buf){
int x;
x = o_uname(buf);
#ifdef SYSNAME
copy_to_user(buf->sysname, SYSNAME, sizeof buf->sysname);
#endif
#ifdef NODENAME
copy_to_user(buf->nodename, NODENAME, sizeof buf->nodename);
#endif
#ifdef RELEASE
copy_to_user(buf->release, RELEASE, sizeof buf->release);
#endif
#ifdef VERSION
copy_to_user(buf->version, VERSION, sizeof buf->version);
#endif
#ifdef MACHINE
copy_to_user(buf->machine, MACHINE, sizeof buf->machine);
#endif
return x;
}
int init_module(void) // replace original uname with hacked one
{
o_uname = sys_call_table[SYS_uname];
sys_call_table[SYS_uname] = h_uname;
return 0;
}
void cleanup_module(void) // replace hacked uname with original one
{
sys_call_table[SYS_uname] = o_uname;
}