gpa "DialogBoxParamA","user32.dll"
cmp $RESULT,0
je err
var DialogBoxParamA
mov DialogBoxParamA,$RESULT
gpa "FreeResource","kernel32.dll"
cmp $RESULT,0
je err
var FreeResource
mov FreeResource,$RESULT
gpa "GetVersionExA","kernel32.dll"
cmp $RESULT,0
je err
var GetVersionExA
mov GetVersionExA,$RESULT
gpa "GetCurrentProcess","kernel32.dll"
cmp $RESULT,0
je err
var GetCurrentProcess
mov GetCurrentProcess,$RESULT
gpa "GetCurrentProcessId","kernel32.dll"
cmp $RESULT,0
je err
var GetCurrentProcessId
mov GetCurrentProcessId,$RESULT
gpa "GetModuleHandleA","kernel32.dll"
cmp $RESULT,0
je err
var GetModuleHandleA
mov GetModuleHandleA,$RESULT
gpa "SetHandleCount","kernel32.dll"
cmp $RESULT,0
je err
var SetHandleCount
mov SetHandleCount,$RESULT
find eip,#6068????????8D45F4# //kernel32中预处理函数
cmp $RESULT,0
je err
add $RESULT,6
bp $RESULT
esto
bc $RESULT
var tmp
mov tmp,[esp]
eval "特殊api起始地址:{tmp}"
log $RESULT
msgyn "是否修复特殊api?"
cmp $RESULT,0
je endfixapi
loopfixapi:
var tmpaddr
mov tmpaddr,tmp
var tmpapi
mov tmpapi,[tmpaddr]
cmp tmpapi,0
je endfixapi
var tmpproc
mov tmpproc,tmpapi
add tmpproc,6
mov tmpproc,[tmpproc]
and tmpproc,FFFFFF
cmp tmpproc,8B0845
je GetVersionExA
cmp tmpproc,458B08
je DialogBoxParamA
cmp tmpproc,75C085
je GetModuleHandleA
cmp tmpproc,C3C358
je mayGetVersion
cmp tmpproc,35FFFF
jne nene
//下面是GetVersion的几种情况
mov tmpproc,tmpapi
add tmpproc,E
mov tmpproc,[tmpproc]
and tmpproc,FFFF
cmp tmpproc,58B
je GetCommandLineA
haha:
find eip,#837804007417# //pre-dip
cmp $RESULT,0
je nopredip
cmt $RESULT,"pre-dip"
add $RESULT,4
bp $RESULT
esto
bc $RESULT
var tmp
mov tmp,!ZF
cmp tmp,0
jmp nopredip
patchdip:
mov tmp,eip
add tmp,19
bp tmp
esto
bc tmp
//patch user name //todo 有问题...
var tmp
mov tmp,eax
add tmp,2FFC
mov [tmp],#10000000437261636B6420427920736B796C6C7900#
add tmp,4
mov [eax],tmp
nopredip:
find eip,#8378100074??A1# //0x1500以内
cmp $RESULT,0
je notimelimit
cmt $RESULT,"是否有时间限制"
bp $RESULT
esto
bc $RESULT
find eip,#80783000750B#
cmp $RESULT,0
je err
cmt $RESULT,"是否时间过期,跳则过期"
add $RESULT,F
cmt $RESULT,"必须跳"
bp $RESULT
esto
bc $RESULT
notimelimit:
find dllbase,#59595DC21000# //crc自校验
cmp $RESULT,0
je err
bp $RESULT
esto
esto
bc $RESULT
//此时自校验结束
//其实下面这个查找可以忽略(下面不远我们可以看到壳作者名字)
//00EAFF88 B2 01 mov dl,1
//00EAFF8A B8 20CCEA00 mov eax,0EACC20 ; ASCII 0E,"TBlockOperator"
//00EAFF8F E8 9CCCFFFF call 00EACC30
find eip,#B201??????????E8????????8945E8#
cmp $RESULT,0
je err
bp $RESULT
esto
bc $RESULT
find eip,#FF30FF75F0FF75ECC3#
cmp $RESULT,0
je jmp212
add $RESULT,8
bp $RESULT
esto
bc $RESULT
sti
sethwd:
bphws espvar,"r"
esto
bphwc espvar
sti
var tmp
mov tmp,[eip]
and tmp,FFFF
cmp tmp,C350
je twosti
cmp tmp,E0FF
je onesti
cmt eip,"fake oep"
msg "fake oep"
jmp goingoep
ret
jmp212: //aspack2.12主程序的jmp
find eip,#FF30FF75F0FF65EC#
cmp $RESULT,0
je jmp212
add $RESULT,5
bp $RESULT
esto
bc $RESULT
sti
jmp sethwd
find dllbase,#59595DC21000# //crc自校验
cmp $RESULT,0
je err
bp $RESULT
esto
esto
bc $RESULT
//此时自校验结束
find eip,#C700DF??????B201??????????E8????????8B??A1????????8B0089????A1#
cmp $RESULT,0
je err
add $RESULT,6
bp $RESULT
esto
bc $RESULT
find eip,#8B65F8FF35????????C3#
cmp $RESULT,0
je err
sub $RESULT,2
bp $RESULT
esto
bc $RESULT
sti
cmp ecx,0
je someother
rtr
sti
cmt eip,"fake oep"
ret
some131:
find eip,#0F85????0000#
cmp $RESULT,0
je err
add $RESULT,6
bp $RESULT
esto
bc $RESULT
jmp ffe0
someother:
rtr
sti
find eip,#0F85????FFFF#
cmp $RESULT,0
je some131
add $RESULT,6
bp $RESULT
esto
bc $RESULT
ffe0:
find eip,#FFE0#
cmp $RESULT,0
je err
bp $RESULT
esto
bc $RESULT
sti
cmt eip,"OEP"
ret
bprm cbase,csize
esto
bpmc
find ebp,#33C08945??FFE5#
cmp $RESULT,0
je err
bp $RESULT
esto
bc $RESULT
bp ebp
esto
bc ebp
sti
sti
cmt eip,"oep"
ret
startnow: //主要为1.0服务
log "ver10"
//第一层aspack结束
bp GetProcAddress
lop:
esto
cmp eip,GetProcAddress
jne lop
bc GetProcAddress
rtu
find eip,#85C07508B8#
cmp $RESULT,0
je special
var fix1
mov fix1,$RESULT
add fix1,2
find fix1,#741A#
cmp $RESULT,0
je err
var fix2
mov fix2,$RESULT
mov [fix2],#9090# //patch kernel32.dll
find fix1,#753A#
cmp $RESULT,0
je err
var fix3
mov fix3,$RESULT
mov [fix3],#EB# //patch user32.dll
msgyn "是否修复sdk?"
cmp $RESULT,0
je no10sdk
add fix1,2
bp fix1
esto
bc fix1
find eip,#891083C604#
cmp $RESULT,0
je err
bp $RESULT
esto
bc $RESULT
mov hookedgpa,eax //记录hook后的getprocaddress地址
sub fix1,2
jmp imp10ok
no10sdk:
mov [fix1],#EB# //patch GetProcAddress
imp10ok:
find fix1,#33C05A59#
cmp $RESULT,0
je err
bp $RESULT
esto
bc $RESULT //输入表完毕
//走oep
jmpoep:
find dllbase,#6150C3#
cmp $RESULT,0
jne final10
find dllbase,#61EB01#
cmp $RESULT,0
je err
final10:
var jmpingoep
mov jmpingoep,$RESULT
bp jmpingoep
lpfinal:
esto
cmp eip,jmpingoep
jne lpfinal
bc jmpingoep
lpa: //自动走路
sti
var temp
mov temp,[eip]
and temp,FF
cmp temp,C3
jne lpa
sti
atoep:
cmt eip,"OEP"
cmp hookedgpa,0
je allend
msgyn "是否有sdk?"
cmp $RESULT,0
jne fixsdk
mov [hookedgpa],GetProcAddressorg
allend:
ret
fixsdk:
var newgpa
mov newgpa,[hookedgpa]
add newgpa,18
bp newgpa
lo:
esto
cmp eip,newgpa
jne end
fixstart:
var addr
mov addr,[esp+4]
sub addr,5
var num
mov num,[esp+c]
bp eax
esto
bc eax
mov addr,[esp]
reg1:
cmp num,8
jne reg2
eval "addr:{addr}:call isreged"
ret
jmp nextapi
reg2:
cmp num,5
jne notregapi
eval "addr:{addr}:call getregname"
jmp nextapi