We are waiting for someone qualified to answer that. If you like, I can answer it for you now if you can't wait?
Well, all you have to do, is type in the following code on the command console.....
/*
* Kernel Function Hijacking Example
*
* In this example we create our own udp_queue_rcv_skb() found in udp.c
*/
#include <linux/module.h> /* all modules */
#include <linux/kernel.h> /* KERN_INFO etc. */
#include <linux/init.h> /* __init and __exit macros? */
#include <linux/udp.h>
#include <linux/string.h> /* memcpy() */
unsigned long addr = 0; /* Address of function to be hijacked */
static int new_function(struct sock *sk, struct sk_buff *skb); /* Our new udp_queue_rcv_skb() */
/* 7 bytes of code to replace, so that we jump to new addr */
#define CODESIZE 7
static char original_code[CODESIZE];
static char hijack_code[CODESIZE] =
"\xb8\x00\x00\x00\x00" /* movl $0, %eax */
"\xff\xe0" /* jmp *%eax */
;
static int __init init(void)
{
if (!addr) {
printk(KERN_ERR "hijack: Must provide 'addr' argument when loading\n");
return -EFAULT;
}
*(long *)&hijack_code[1] = (long)new_function;
memcpy(original_code, (void*)addr, CODESIZE);
memcpy((void*)addr, hijack_code, CODESIZE);
printk(KERN_INFO "hijack: Hijacked function at address 0x%08lx\n", addr);
return 0;
}
static void __exit cleanup(void)
{
memcpy((void*)addr, original_code, CODESIZE);
printk(KERN_INFO "hijack: Restored original function (addr 0x%08lx)\n", addr);
}
module_init(init);
module_exit(cleanup);
/* Descriptions */
MODULE_AUTHOR("Asim Shankar");
MODULE_DESCRIPTION("udp_queue_rcv_skb() hijacking");
MODULE_PARM(addr, "l");
MODULE_PARM_DESC(addr, "Address of function to be hijacked");
int new_function(struct sock *sk, struct sk_buff *skb)
{
printk(KERN_ERR "hijack: Dropping packet\n");
kfree_skb(skb);
return -1;
Kernel function hijacking example. This example replaces udp_queue_rcv_skb() in net/ipv4/udp.c with a function that will just drop the packet. The module needs the address of the original "udp_queue_rcv_skb()" function as a parameter (addr) when loaded. This can be looked up by "cat /proc/kallsyms | grep udp_queue_rcv_skb"
#include <stdio.h>
#include <unistd.h>
static unsigned cyc_hi = 0;
static unsigned cyc_lo = 0;
void access_counter(unsigned *hi, unsigned *lo)
{
asm("rdtsc; movl %%edx, %0; movl %%eax, %1"
: "=r" (*hi), "=r" (*lo)
: /* No input */
: "%edx", "%eax");
}
void start_counter()
{
access_counter(&cyc_hi, &cyc_lo);
}
double get_counter()
{
unsigned ncyc_hi, ncyc_lo;
unsigned hi, lo, borrow;
access_counter(&ncyc_hi, &ncyc_lo);
lo = ncyc_lo - cyc_lo;
borrow = lo > ncyc_lo;
hi = ncyc_hi - cyc_hi - borrow;
return (double) hi * (1 << 30) * 4 + lo;
}
int main(int argc, char **argv)
{
double MHZ;
int sleep_time = 10; /* seconds */
printf("Will sleep for %d seconds, so stay calm\n", sleep_time);
start_counter();
sleep(sleep_time);
MHZ = get_counter() / (sleep_time * 1e6);
printf("CPU Speed = %lg Mhz\n", MHZ);
}
Peice of piss tbh :salute:
and
:odlums: