forked from jvns/kernel-module-fun
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexcited_virus.c
More file actions
53 lines (42 loc) · 1.59 KB
/
Copy pathexcited_virus.c
File metadata and controls
53 lines (42 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <linux/module.h> // included for all kernel modules
#include <linux/kernel.h> // included for KERN_INFO
#include <linux/init.h> // included for __init and __exit macros
#include <linux/fcntl.h> // included for O_RDONLY
#include <linux/fs.h> // included for filp_open
#define MODULE_NAME "rootkit"
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Julia Evans");
MODULE_DESCRIPTION("Makes your keyboard WAY MORE EXCITED");
static struct file_operations handler_fops;
const struct file_operations *handler_original = 0;
static ssize_t (*old_tty_read)(struct file * file, char * buf, size_t count,
loff_t *ppos) = NULL;
static ssize_t excited_tty_read(struct file * file, char * buf, size_t count,
loff_t *ppos) {
printk("hacking ur readz\n");
return old_tty_read(file, buf, count, ppos);
}
static int __init excited_init(void)
{
struct file* file = filp_open("/dev/tty0", O_RDONLY, 0);
if (file != NULL) {
old_tty_read = file->f_op->read;
handler_original = file->f_op;
handler_fops = *handler_original;
handler_fops.read = excited_tty_read;
file->f_op = &handler_fops;
printk(KERN_INFO "Starting excited time!\n");
filp_close(file, NULL);
} else {
printk("OH NO FAILED!\n");
};
return 0; // Non-zero return means that the module couldn't be loaded.
}
static void __exit excited_cleanup(void)
{
struct file* file = filp_open("/dev/tty0", O_RDONLY, 0);
file->f_op = handler_original;
printk(KERN_INFO "Excited time is over =(\n");
}
module_init(excited_init);
module_exit(excited_cleanup);