;.com文件加密的小工具
;pack.asm
trac MACRO
zjnt1:db 60h
pushf
sj1: push ds
push es
mov ax,3521h
int 21h
cmp bx,2701h
jnz exs1
jmp sj1 ;发现内存中有rcopy脱壳工具就死循环
exs1: cld
cli
mov si,0
mov ds,si
mov cx,10h
mov di,560h
mov es,si
rep movsb
mov di,552h
mov ax,0cfh
stosw
mov di,0ch
mov ax,552h
stosw
mov ax,0
stosw
mov ax,1000h
mov si,4647h
mov di,4a4dh
int 3 ;对付soft-ice的
mov di,550h
mov ax,'SY' ;在内存中做个记号,没有壳不能运行
STOSW
mov di,0ch
mov ax,552h
stosw ;对付debug的
mov ax,0
stosw
cli
mov di,0
mov es,di
mov cx,10h
mov si,560h
mov ds,di
rep movsb
pop es
pop ds
popf
db 61h
ENDM
mycode segment
org 100h
assume cs:mycode;ds:mycode
start:jmp begin
bf db 30h dup (36h)
fname db 30h dup(0)
fhand dw 3636h
begin:
GETFN:
push cs
POP DS
MOV SI,80H
PUSH CS
POP ES
MOV DI,OFFSET BF
MOV CX,30H
CLD
REP MOVSB
CMP BF[0],0
JNZ GFN
JMP NFN
GFN: PUSH CS
POP DS
MOV CH,0
MOV CL,BYTE PTR BF[0]
dec cl
MOV SI,OFFSET BF[2]
MOV DI,OFFSET FNAME
CLD
REP MOVSB
JMP ANF
NFN:push cs
pop ds
MOV AX,0003H
INT 10H
call nfn1
DB '.COM文件加密工具 SPACK V2.0',0DH,0AH
db '山东海化集团有限公司设计院 盛玉增 研制',0dh,0ah
DB '(C)Copyright Sheng YuZeng 1996.6.31 ',0DH,0AH
DB 'Usage: PACK',0DH,0AH
db 'File not Found!',0dh,0ah,24h
nfn1:pop dx
MOV AH,9
INT 21H
MOV AX,4C00H
INT 21H
ANF:
PUSH CS
POP DS
MOV DX,OFFSET FName
mov ax,cs
mov es,ax
mov di,dx
mov al,'.'
mov cx,30h
cld
repNE scasb
mov ax,es:[di]
cmp ax,'oc'
jz opf
cmp ax,'OC'
JZ OPF
NOPF:call nopf1
db 'This file is not a COM file!',0dh,0ah,24h
nopf1:pop dx
mov ah,09
int 21h
mov ax,4c00h
int 21h
OPF:
MOV AX,3D02H
PUSH CS
POP DS
MOV DX,OFFSET fname
INT 21H ;OPEN FILE
JNC S1
JMP error
s1:mov fhand,ax
readf:
mov ax,4202h
mov cx,0
mov dx,0
mov bx,cs:fhand
int 21h
push cs
pop es
mov di,offset fsize
stosw
mov ax,4200h
mov cx,0
mov dx,0
mov bx,cs:fhand
int 21h
push cs
pop dx
add dx,1000h
MOV ES,DX
PUSH CS
POP DS
MOV SI,OFFSET TRACE
MOV DI,100h
MOV CX,OFFSET LAST
MOV DX,SI
SUB CX,DX
PUSH CX
MOV CS:SSIZE,CX
CLD
REP MOVSB
POP CX
PUSH ES
POP DS
MOV DX,100H
ADD DX,CX
mov bx,cs:fhand
mov cx,0fe00h
mov ax,3f00h
int 21h
jnc s2
;clof
push cs
pop ds
push cs
pop es
MOV AH,3EH
MOV BX,CS:FHAND
INT 21H ;CLOSE FILE
s2 :
push cs
pop es
mov di,offset fsize
stosw
push cs
pop ds
MOV AH,3EH
MOV BX,cs:FHAND
INT 21H ;CLOSE FILE
s3: mov ax, 3c02h ;build a file
mov cx,0
push cs
pop ds
mov dx,offset fname
int 21h
jnc s4
jmp error
s4: mov cs:fhand,ax
s5: push cs
pop ax
add ax,1000h
mov ds,ax
mov es,ax
mov si,CS:SSIZE
ADD SI,100H
mov di,SI
mov dx,cs:fsize
mov cx,dx
cld
pcsec:
LODSB
xor al,cl
stosB
loop pcsec ;jia mi yuan wen jian
mov cx,cs:ssize
mov si,offset stx1
mov di,offset trace
sub si,di
sub cx,si
add si,100h
mov di,si
cld
sxx2:lodsb
xor al,cl
stosb
loop sxx2 ;jia mi
s6:
MOV AH,40H
MOV BX,cs:FHAND
MOV DX,100h
mov cx,cs:fsize
ADD CX,cs:SSIZE
INT 21H ;WRITE FILE
push cs
pop ds
push cs
pop es
MOV AH,3EH
MOV BX,CS:FHAND
INT 21H ;CLOSE FILE
push cs
pop ds
call dispok
db 'OK!',0DH,0AH,24H
DISPOK:POP DX
mov ah,9
int 21h
JMP DEN
Error: call derror
db 'ERROR! END',0DH,0AH,24H
DERROR:POP DX
PUSH CS
POP DS
MOV AH,9
INT 21H
den: Mov ax,4c00h
int 21h
TRACE:jmp usx1
ssize dw 3636h
db 0dh,'SPACK 2.0',0dh,'山东海化集团有限公司设计院 盛玉增 研制',0dh,0ah
db '欢迎联系 电话:0536-5329514(office)',0dh,0ah,1AH
usx1:push cs
pop ds
push cs
pop es
MOV WORD PTR CS:[60H],'盛'
mov cx,cs:[103h]
mov si,offset stx1
mov di,offset trace
sub si,di
sub cx,si
add si,100h
mov di,si
cld
usxx2:trac
lodsb
xor al,cl
stosb
dec cx
jcxz stx1
jmp usxx2
stx1:
USEC:
PUSH CS
pop ax
mov es,ax
mov ds,ax
mov si,offset fsize
mov di,offset trace
sub si,di
add si,100h
lodsw
push ax ;yuan file size
mov si,offset last
mov di,offset trace
sub si,di
add si,100h
push si ;yuan 100 addr
mov di,si
pop si
pop dx
push dx
push si
mov cx,dx
cld
susec: LODSB
xor aL,cl
stosB
loop susec
movad:call mova1
mova1:pop dx
mov di,offset movyf
mov si,offset mova1
sub di,si
add dx,di
mov si,dx
mov di,0c0h
push cs
pop es
mov cx,30h
cld
rep movsb
push cs
mov ax,0c0h
push ax
retf
movyf:push ds
pop es
pop si ;y100addr
pop cx ;yfsize
push cx
mov di,100h
cld
rep movsb
pop cx
mov ax,0
mov bx,ax
mov dx,ax
mov si,ax
mov di,0
mov dx,ax
push ds
mov ax,100h
push ax
mov ax,0
retf
fsize dw 3636h
LAST DB 0
mycode ends
end start
;pack.asm
trac MACRO
zjnt1:db 60h
pushf
sj1: push ds
push es
mov ax,3521h
int 21h
cmp bx,2701h
jnz exs1
jmp sj1 ;发现内存中有rcopy脱壳工具就死循环
exs1: cld
cli
mov si,0
mov ds,si
mov cx,10h
mov di,560h
mov es,si
rep movsb
mov di,552h
mov ax,0cfh
stosw
mov di,0ch
mov ax,552h
stosw
mov ax,0
stosw
mov ax,1000h
mov si,4647h
mov di,4a4dh
int 3 ;对付soft-ice的
mov di,550h
mov ax,'SY' ;在内存中做个记号,没有壳不能运行
STOSW
mov di,0ch
mov ax,552h
stosw ;对付debug的
mov ax,0
stosw
cli
mov di,0
mov es,di
mov cx,10h
mov si,560h
mov ds,di
rep movsb
pop es
pop ds
popf
db 61h
ENDM
mycode segment
org 100h
assume cs:mycode;ds:mycode
start:jmp begin
bf db 30h dup (36h)
fname db 30h dup(0)
fhand dw 3636h
begin:
GETFN:
push cs
POP DS
MOV SI,80H
PUSH CS
POP ES
MOV DI,OFFSET BF
MOV CX,30H
CLD
REP MOVSB
CMP BF[0],0
JNZ GFN
JMP NFN
GFN: PUSH CS
POP DS
MOV CH,0
MOV CL,BYTE PTR BF[0]
dec cl
MOV SI,OFFSET BF[2]
MOV DI,OFFSET FNAME
CLD
REP MOVSB
JMP ANF
NFN:push cs
pop ds
MOV AX,0003H
INT 10H
call nfn1
DB '.COM文件加密工具 SPACK V2.0',0DH,0AH
db '山东海化集团有限公司设计院 盛玉增 研制',0dh,0ah
DB '(C)Copyright Sheng YuZeng 1996.6.31 ',0DH,0AH
DB 'Usage: PACK
db 'File not Found!',0dh,0ah,24h
nfn1:pop dx
MOV AH,9
INT 21H
MOV AX,4C00H
INT 21H
ANF:
PUSH CS
POP DS
MOV DX,OFFSET FName
mov ax,cs
mov es,ax
mov di,dx
mov al,'.'
mov cx,30h
cld
repNE scasb
mov ax,es:[di]
cmp ax,'oc'
jz opf
cmp ax,'OC'
JZ OPF
NOPF:call nopf1
db 'This file is not a COM file!',0dh,0ah,24h
nopf1:pop dx
mov ah,09
int 21h
mov ax,4c00h
int 21h
OPF:
MOV AX,3D02H
PUSH CS
POP DS
MOV DX,OFFSET fname
INT 21H ;OPEN FILE
JNC S1
JMP error
s1:mov fhand,ax
readf:
mov ax,4202h
mov cx,0
mov dx,0
mov bx,cs:fhand
int 21h
push cs
pop es
mov di,offset fsize
stosw
mov ax,4200h
mov cx,0
mov dx,0
mov bx,cs:fhand
int 21h
push cs
pop dx
add dx,1000h
MOV ES,DX
PUSH CS
POP DS
MOV SI,OFFSET TRACE
MOV DI,100h
MOV CX,OFFSET LAST
MOV DX,SI
SUB CX,DX
PUSH CX
MOV CS:SSIZE,CX
CLD
REP MOVSB
POP CX
PUSH ES
POP DS
MOV DX,100H
ADD DX,CX
mov bx,cs:fhand
mov cx,0fe00h
mov ax,3f00h
int 21h
jnc s2
;clof
push cs
pop ds
push cs
pop es
MOV AH,3EH
MOV BX,CS:FHAND
INT 21H ;CLOSE FILE
s2 :
push cs
pop es
mov di,offset fsize
stosw
push cs
pop ds
MOV AH,3EH
MOV BX,cs:FHAND
INT 21H ;CLOSE FILE
s3: mov ax, 3c02h ;build a file
mov cx,0
push cs
pop ds
mov dx,offset fname
int 21h
jnc s4
jmp error
s4: mov cs:fhand,ax
s5: push cs
pop ax
add ax,1000h
mov ds,ax
mov es,ax
mov si,CS:SSIZE
ADD SI,100H
mov di,SI
mov dx,cs:fsize
mov cx,dx
cld
pcsec:
LODSB
xor al,cl
stosB
loop pcsec ;jia mi yuan wen jian
mov cx,cs:ssize
mov si,offset stx1
mov di,offset trace
sub si,di
sub cx,si
add si,100h
mov di,si
cld
sxx2:lodsb
xor al,cl
stosb
loop sxx2 ;jia mi
s6:
MOV AH,40H
MOV BX,cs:FHAND
MOV DX,100h
mov cx,cs:fsize
ADD CX,cs:SSIZE
INT 21H ;WRITE FILE
push cs
pop ds
push cs
pop es
MOV AH,3EH
MOV BX,CS:FHAND
INT 21H ;CLOSE FILE
push cs
pop ds
call dispok
db 'OK!',0DH,0AH,24H
DISPOK:POP DX
mov ah,9
int 21h
JMP DEN
Error: call derror
db 'ERROR! END',0DH,0AH,24H
DERROR:POP DX
PUSH CS
POP DS
MOV AH,9
INT 21H
den: Mov ax,4c00h
int 21h
TRACE:jmp usx1
ssize dw 3636h
db 0dh,'SPACK 2.0',0dh,'山东海化集团有限公司设计院 盛玉增 研制',0dh,0ah
db '欢迎联系 电话:0536-5329514(office)',0dh,0ah,1AH
usx1:push cs
pop ds
push cs
pop es
MOV WORD PTR CS:[60H],'盛'
mov cx,cs:[103h]
mov si,offset stx1
mov di,offset trace
sub si,di
sub cx,si
add si,100h
mov di,si
cld
usxx2:trac
lodsb
xor al,cl
stosb
dec cx
jcxz stx1
jmp usxx2
stx1:
USEC:
PUSH CS
pop ax
mov es,ax
mov ds,ax
mov si,offset fsize
mov di,offset trace
sub si,di
add si,100h
lodsw
push ax ;yuan file size
mov si,offset last
mov di,offset trace
sub si,di
add si,100h
push si ;yuan 100 addr
mov di,si
pop si
pop dx
push dx
push si
mov cx,dx
cld
susec: LODSB
xor aL,cl
stosB
loop susec
movad:call mova1
mova1:pop dx
mov di,offset movyf
mov si,offset mova1
sub di,si
add dx,di
mov si,dx
mov di,0c0h
push cs
pop es
mov cx,30h
cld
rep movsb
push cs
mov ax,0c0h
push ax
retf
movyf:push ds
pop es
pop si ;y100addr
pop cx ;yfsize
push cx
mov di,100h
cld
rep movsb
pop cx
mov ax,0
mov bx,ax
mov dx,ax
mov si,ax
mov di,0
mov dx,ax
push ds
mov ax,100h
push ax
mov ax,0
retf
fsize dw 3636h
LAST DB 0
mycode ends
end start
浙公网安备 33010602011771号