Brought to you by:
Suppliers of:
Credit:
The information has been provided by Mariusz Woloszyn and Wojtek Kaniewski .
The following tool will disable ptrace for non-root users. Even though it doesn't prevent exploitation of the ptrace vulnerability (PTrace Improved Exploit Code Released (Race condition) ), it will stop it from running successfully.
Tool:
/* no ptrace module
fast prevention for kernel bug
(c) 2001 a Lam3rZ oddysey
*/
#define MODULE
#define __KERNEL__
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/unistd.h>
#include <sys/syscall.h>
#ifndef KERNEL_VERSION
#define KERNEL_VERSION(a,b,c) ((a)*65536+(b)*256+(c))
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
#include <asm/unistd.h>
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,14)
#include <bits/syscall.h>
#endif
extern void *sys_call_table[];
int (*orig_ptrace)(int, int, int, int);
int no_ptrace (int request, int pid, int addr, int data) {
if (current->euid ==0 ) {
return (orig_ptrace)(request, pid, addr, data);
} else
return -1;
}
int init_module(void) {
orig_ptrace = sys_call_table[__NR_ptrace];
sys_call_table[__NR_ptrace]=no_ptrace;
return 0;
}
void cleanup_module(void) {
sys_call_table[__NR_ptrace]=orig_ptrace;
}
Tool add-up:
Adding something like:
printk("ptrace(): uid=%d, comm=%s\n", current->uid, current->comm);
Before ,,return'' helps spot potential abusers.
Please enable JavaScript to view the comments powered by Disqus.
blog comments powered by