-
-
Save xcellerator/d3a75b0e20d7bf0cab0c521838116ac2 to your computer and use it in GitHub Desktop.
Kernel Linked List Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
obj-m += rootkit.o | |
all: | |
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules | |
clean: | |
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <linux/init.h> | |
#include <linux/module.h> | |
#include <linux/kernel.h> | |
#include <linux/list.h> | |
MODULE_LICENSE("GPL"); | |
MODULE_AUTHOR("TheXcellerator"); | |
MODULE_DESCRIPTION("Linked Lists Example"); | |
MODULE_VERSION("0.01"); | |
static int __init rootkit_init(void) | |
{ | |
printk(KERN_INFO "rootkit: Loaded >:-)\n"); | |
struct list_head *next_position = (&THIS_MODULE->list)->next; | |
struct list_head *prev_position = (&THIS_MODULE->list)->prev; | |
struct module *next_ptr = NULL; | |
struct module *prev_ptr = NULL; | |
next_ptr = list_entry( next_position, struct module, list); | |
prev_ptr = list_entry( prev_position, struct module, list); | |
printk(KERN_DEBUG "rootkit: next kernel module = %s\n", next_ptr->name); | |
printk(KERN_DEBUG "rootkit: prev kernel module = %s\n", prev_ptr->name); | |
return 0; | |
} | |
static void __exit rootkit_exit(void) | |
{ | |
printk(KERN_INFO "rootkit: Unloaded :(\n"); | |
} | |
module_init(rootkit_init); | |
module_exit(rootkit_exit); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment