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

anti-ptrace.txt

anti-ptrace.txt
Posted Apr 16, 2003
Authored by netric, Sacrine | Site netric.org

Linux LKM that disables ptrace abilities in the 2.4.x kernels.

tags | kernel
systems | linux
SHA-256 | 1d8cb9eedc847c0da5391b758eba2303658fc96887860ddadb104e0b904b66df

anti-ptrace.txt

Change Mirror Download
#!/bin/sh
# MAKE ME EXECUTABLE !!!
#
# root@Hogwarts:/home/sacrine/TEST# chmod +x anti-ptrace
# root@Hogwarts:/home/sacrine/TEST# ./anti-ptrace
# [+] making anti-ptrace.c: OK
# [+] compiling the script: OK
# [+] loading the module : OK
#
#
# This is a modified version, if you have a module loaded without this line
# please /sbin/rmmod (previous anti-ptrace) and load this one
# Thanks to Alejandro Gramajo for mailing me,
# because I forgot 1 argument (eg: int action) and didn't tested it enough
# to spot this stupid error.
#


echo -n " [+] making anti-ptrace.c: "
cat > anti-ptrace.c <<NETRIC

/*
* Noodoplossing voor de ptrace race vuln
* anti-ptrace.c by sacrine
* netric.org
*/

#define __KERNEL__
#define MODULE
#define LINUX

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

#include <linux/ptrace.h>

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,9)
#ifdef MODULE_LICENSE
MODULE_LICENSE("GPL");
#endif
#endif

long (*o_ptrace) ( int action,
pid_t pid ,
void *addr,
void *data );

extern struct task_struct *current;
extern void* sys_call_table[];

long anti_ptrace (int action,
pid_t pid ,
void *addr,
void *data )
{
uid_t o_uid;

if(current->uid == 0)
{
return (o_ptrace(action, pid, addr, data));
}
printk("warning: ptrace(); violation <=> pid=[%i] uid=[%i]\n"
,current->pid
,current->uid);

console_print("warning: non-root users are not allowed to use ptrace();\n");
return EPERM;
}

int init_module(void)
{
o_ptrace=sys_call_table[SYS_ptrace];
sys_call_table[SYS_ptrace] = anti_ptrace;

printk("anti-ptrace kernel module loaded with pid=[%i]\n",
current->pid);

return(0);
}

void cleanup_module(void)
{
sys_call_table[SYS_ptrace] = o_ptrace;
printk("anti-ptrace kernel module ended with pid=[%i]\n",
current->pid);
}

NETRIC
echo "OK";
echo -n " [+] compiling the script: ";
gcc -c anti-ptrace.c -I/lib/modules/$(uname -r)/build/include
echo "OK";
echo -n " [+] loading the module : ";
/sbin/insmod anti-ptrace.o
echo "OK";

# sacrine [Netric Security]

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