exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

toby.c

toby.c
Posted Jan 9, 2003
Authored by Sacrine | Site netric.org

Toby.c is a Linux LKM which intercepts, logs, and stops the setuid, setreuid, and setresuid syscalls from users.

systems | linux
SHA-256 | abccb26dad5380a8b6ef2fd08effd7aae5a0b9280b0fcbfe852cb6040c092a00

toby.c

Change Mirror Download
/* Woef Waf Waf - Toby the barking Kernel Module
* (LINUX) NETRIC SECURITY 2003 @
* Netric [dot] org
*
* written by sacrine
* sacrine@netric.org
*
* Intercept setuid,setreuid,setresuid SYS_CALL from
* normal user.
* !! This is a modified version of an earlier written LKM "suidshow.c" !!
* Credits are also for: CyberPsychotic from K.A.L.U.G.
* I hacked in a setresuid function and some other changes.
*
* compile:
* gcc -c toby.c -I/lib/modules/$(uname -r)/build/include
* then /sbin/insmod toby.o
*
* If everything went right you'll get something like this
* in your /var/log/messages:
* Jan 7 12:23:25 voldemort kernel: Toby_sec 0.1 kernel module started [pid=766]
*/


#define MODULE
#define LINUX
#define __KERNEL__

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/dirent.h>
#include <linux/sched.h>
#include <linux/types.h>
#include <linux/slab.h>
#include <linux/fs.h>
#include <linux/tty.h>
#include <sys/syscall.h>

#define VERSION "0.1"

int (*o_setuid) (uid_t); // 23 SYS_setuid
int (*o_setreuid) (uid_t ruid, uid_t euid); // 70 SYS_setreuid
int (*o_setresuid)(uid_t ruid, uid_t euid, uid_t suid); // 164 SYS_setresuid

extern void* sys_call_table[];

int toby_setuid(uid_t uid)
{
uid_t o_uid;
int it;

if (current -> uid && ! uid)
{
printk("Warning: SETUID SYS_CALL tried\n"
"pid=%i current uid=(%i) -> uid=(%i)\n",
current->pid,
current->uid,
uid);
o_uid=current->uid;
it=(* o_setuid)(uid);
if (o_uid && ! uid)
{
printk("%i\n",it);
}
console_print("You are not allowed to perform a SETUID SYS_CALL\n");
return(0);
}
}
int toby_setreuid(uid_t ruid, uid_t euid)
{
uid_t o_uid;
int it;

if (current->uid && ! ruid || ! euid)
{
printk("Warning: SETEUID SYS_CALL tried\n"
"pid=%i current uid=(%i) -> ruid=(%i)\n",
current->pid,
current->uid,
ruid);
o_uid=current->uid;
it=(* o_setreuid)(ruid,euid);
if (o_uid && ! ruid || ! euid)
{
printk("%i\n",it);
}
console_print("You are not allowed to perform a SETREUID SYS_CALL\n");
return(0);
}
}
int toby_setresuid(uid_t ruid, uid_t euid, uid_t suid)
{
uid_t o_uid;
int it;

if (current->uid && ! ruid || ! suid || ! euid)
{
printk("Warning: SETRESUID SYS_CALL tried\n"
"pid=%i current uid=(%i) -> suid=(%i)\n",
current->pid,
current->uid,
suid);
o_uid=current->uid;
it=(* o_setresuid)(ruid,euid,suid);
if (o_uid && ! ruid || ! suid || ! euid)
{
printk("%i\n",it);
}
console_print("You are not allowed to perform a SETRESUID SYS_CALL\n");
return(0);
}
}
int init_module(void)
{
o_setuid=sys_call_table[SYS_setuid];
sys_call_table[SYS_setuid]=toby_setuid;

o_setreuid=sys_call_table[SYS_setreuid];
sys_call_table[SYS_setreuid]=toby_setreuid;

o_setresuid=sys_call_table[SYS_setresuid];
sys_call_table[SYS_setresuid]=toby_setresuid;

printk("Toby_sec %s kernel module started [pid=%i]\n"
,VERSION
,current->pid);
return(0);
}
void cleanup_module(void)
{
sys_call_table[SYS_setuid]=o_setuid;
sys_call_table[SYS_setreuid]=o_setreuid;
sys_call_table[SYS_setresuid]=o_setresuid;

printk("Toby_sec %s kernel module ended [pid=%i]\n"
,VERSION
,current->pid);
}


Login or Register to add favorites

File Archive:

September 2024

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close