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:

April 2024

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close