首页
社区
课程
招聘
关于 ImportREC v1.7a 中的修正
发表于: 2008-2-29 18:23 7824

关于 ImportREC v1.7a 中的修正

2008-2-29 18:23
7824
抽空看了一下 ImportREC 1.6 中 MaRKuS_TH-DJM 和 jstorme 的补丁代码,发现所谓的新版 ImportREC v1.7a 中,因为 jstorme 的补丁代码,在 Win98 下会有问题,就是补丁过的 ImportREC 无法正常获取 user32.dll 的输入表,而以前 MaRKuS_TH-DJM 的补丁没这个问题。但 jstorme 的补丁代码在 XP 等 NT 系统下没问题,而这部分代码应该是 jstorme 用来修正 Vista64 下出错的 bug 的,可惜在98下有问题。我是把原版的 ImportREC v1.6 final 脱壳后,再抽出 MaRKuS_TH-DJM 和 jstorme 的补丁代码来测试的,下面列出 MaRKuS_TH-DJM 和 jstorme 的补丁代码(OD 插件 SkyPatch 的补丁脚本):

MaRKuS_TH-DJM:


;Fixed RestoreLastError API set to SetLastError
;for WinXP/Vista compatibility (MaRKuS_TH-DJM)

@0x409296:
jmp
@start
nop
;@$backinit:

;some strings to be used

@0x448880: ;Fixed RestoreLastError API set to SetLastError

$str1 "RestoreLastError"
$str #00#
$str2
"SetLastError"
$strr #00#
$str3
"user32.dll"
@$:

;fix code

@start=@$+0x8:
pushad
push
edi
push $str1 ; ASCII "RestoreLastError"
call dword ptr [0044D1A8] ; kernel32.lstrcmpA
test eax,eax
jnz @case1
popad
mov
edi,$str2 ; ASCII "SetLastError"
jmp @case2

@case1
:

popad

@case2:

repne scas byte ptr
es:[edi]
not
ecx
sub edi,ecx
jmp 0040929C ;@$backinit

;user32.dll is always read from the system,
;prevents a crash from corrupted PE of user32.dll (MaRKuS_TH-DJM)

@0x429296:

call
004488DE ;original is call dword ptr ds:[44D238] ; kernel32.ReadProcessMemory
nop

@0x4488DE:

pushad
push
$str3 ; ASCII "user32.dll"
call dword ptr [0044D234] ; kernel32.GetModuleHandleA
cmp eax, [esp+00000004]
je
@loop1
jmp 00448905 ;@loop2
@loop1:
popad
call
0044890F ;@loop3
mov eax, 00000001
add esp, 00000018
jmp dword ptr [esp-00000018] ;this code can't be asm correctly in OD, you must input it in OD manual

@0x448905: ;@loop2:
popad
pop
edi
call dword ptr [0044D238] ; kernel32.ReadProcessMemory
push edi
ret
;@loop3:
pushad
mov
eax,dword ptr [esp+00000004]
mov
ecx,dword ptr [esp+00000018]
mov
ebx,dword ptr [esp+00000014]
@loop4:
mov
dl,byte ptr [eax]
mov byte ptr [
ebx], dl
inc eax
inc ebx
dec ecx
jnz @loop4
popad
ret


jstorme modified:


;Fixed RestoreLastError API set to SetLastError
;for WinXP/Vista compatibility (MaRKuS_TH-DJM)

@0x409296:
jmp
@start
nop
;@$backinit:

;some strings to be used

@0x448880: ;Fixed RestoreLastError API set to SetLastError

$str1 "RestoreLastError"
$str #00#
$str2
"SetLastError"
$strr #00#
$str3
"user32.dll"
@$:

;fix code

@start=@$+0x8:
pushad
push
edi
push $str1 ; ASCII "RestoreLastError"
call dword ptr [0044D1A8] ; kernel32.lstrcmpA
test eax,eax
jnz @case1
popad
mov
edi,$str2 ; ASCII "SetLastError"
jmp @case2

@case1
:

popad

@case2:

repne scas byte ptr
es:[edi]
not
ecx
sub edi,ecx
jmp 0040929C ;@$backinit

;user32.dll is always read from the system,
;prevents a crash from corrupted PE of user32.dll

@0x429296:

call
004488DE ;original is call dword ptr ds:[44D238] ; kernel32.ReadProcessMemory
nop

@0x4488DE:

pushad
push
$str3 ; ASCII "user32.dll"
call dword ptr [0044D234] ; kernel32.GetModuleHandleA
cmp eax,dword ptr ss:[esp+4]
je
@user1
jmp @user2

@user1
:

mov dword ptr
ss:[esp+024h],-1

@user2:

popad
pop
edi
call 0044890b
push edi
ret

;Fixed Vista64 crash bug (jstorme)
@0x44890b:

push
ebp
mov ebp, esp
add esp, 0ffffffd8
push edi
push esi
push ebx
mov esi, [ebp+0000000c]
mov
edi, [ebp+00000010]
mov
ebx, [ebp+0000000c]
add
ebx, [ebp+00000014]
mov dword ptr [
ebp-00000020], 00000000
@loop1:
push
0000001c
lea eax, [ebp-0000001c]
push
eax
push esi
push dword ptr [ebp+00000008]
call dword ptr [
0044D208] ;kernel32.VirtualQueryEx
cmp eax, 0000001c
je @loop2
jmp @loop6
@loop2
:
mov
ecx, [ebp-0000001c]
add
ecx, [ebp-00000010]
cmp
ebx, ecx
jbe @loop3
sub ecx, esi
jmp @loop4
@loop3
:
mov
ecx, ebx
sub ecx, esi
@loop4:
mov [
ebp-00000028], ecx
cmp dword ptr [ebp-0000000c], 00001000
jnz @loop5
lea eax, [ebp-00000028]
push
eax
push ecx
push edi
push esi
push dword ptr [ebp+00000008]
call dword ptr [
0044D238] ; kernel32.ReadProcessMemory
or eax, eax
jnz @loop5
jmp @loop6
@loop5
:
add
esi, [ebp-00000028]
add
edi, [ebp-00000028]
cmp
esi, ebx
jnz @loop1
mov dword ptr [ebp-00000020], 00000001
mov ecx, [ebp+00000018]
or
ecx, ecx
je @loop6
push dword ptr [ebp+00000014]
pop dword ptr [
ecx]
@loop6:
mov
eax, [ebp-00000020]
pop
ebx
pop esi
pop edi
leave
ret
0014


我把我脱壳后的原始 ImportREC v1.6 final 和根据上面的两位的补丁代码用 dup 做的补丁都作为附件发上来,各位可以自己选择用哪个补丁来进行 patch。另外附上汉化补丁,打上就是汉化版本。下面是文件列表:

ImportREC.exe
脱壳后的原始 ImportREC v1.6 final 文件.

importrec.1.6.final.for.98_NT-patch.exe
1. Fixed RestoreLastError API set to SetLastError for WinXP/Vista compatibility (by MaRKuS_TH-DJM)
2. user32.dll is always read from the system, prevents a crash from corrupted PE of user32.dll (by MaRKuS_TH-DJM)

注意:如果你用这个补丁的话,ImportREC 可以在 98/2000/XP 下正常工作,不过可能在 Vista64 下可能有问题(没条件装 Vista64,没法测试)。

importrec.1.6.final.for.NT-patch.exe
1. Fixed RestoreLastError API set to SetLastError for WinXP/Vista compatibility (by MaRKuS_TH-DJM)
2. user32.dll is always read from the system, prevents a crash from corrupted PE of user32.dll (by MaRKuS_TH-DJM)
3. Fixed Vista64 crash bug (by jstorme)

注意:如果你用这个补丁的话,ImportREC 在 NT 系统(如2000/XP等)下应该工作正常,不过Win98 下无法正确获取 user32.dll 中的 API。

importrec.1.6.final.汉化补丁.exe
这个汉化补丁是用于我脱壳的原始 ImportREC 1.6 final 版本的,打上这个补丁后就是汉化版。

更新:通过在 t4u(snd) 论坛与 jstorme 交流,他已经修改了他的补丁代码,现在可以在 Win98 下正常使用了。以下是修改的部分:


@user1:

;原来这里的代码是这个: mov dword ptr ss:[esp+024h],-1
;现在改成调用 GetCurrentProcess 来判断

call dword ptr ds:[0044D10C] ; kernel32.GetCurrentProcess
mov dword ptr ss:[esp+024h],eax

@user2:

同时更新一下补丁,打上这个补丁就可以在 98、XP 等下面正常运行了。原来压缩包中的文件 importrec.1.6.final.for.NT-patch.exe 可以删掉。本来是打算重新打包的,不过不想让大家重复下载,提供一个最新的补丁(importrec.1.6.final-patch.rar),可以用于我前面发的那个压缩包中的原始脱壳文件。

[课程]Android-CTF解题方法汇总!

上传的附件:
收藏
免费 0
支持
分享
最新回复 (17)
雪    币: 93908
活跃值: (200199)
能力值: (RANK:10 )
在线值:
发帖
回帖
粉丝
2
GOOD,THANKS CC.
2008-2-29 18:38
0
雪    币: 609
活跃值: (237)
能力值: ( LV12,RANK:441 )
在线值:
发帖
回帖
粉丝
3
Thx for share.....
另……200帖留影

yangjt
普通会员
资 料:
Join Date: Sep 2007
Posts: 200
精华: 2
Reputation: 11
2008-2-29 18:55
0
雪    币: 136
活跃值: (105)
能力值: ( LV9,RANK:140 )
在线值:
发帖
回帖
粉丝
4
太强了 呵呵 分析的好 学习
2008-2-29 22:33
0
雪    币: 203
活跃值: (209)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
Good,好久没看见CC了!
2008-2-29 23:16
0
雪    币: 254
活跃值: (126)
能力值: ( LV8,RANK:130 )
在线值:
发帖
回帖
粉丝
6
jmp    dword ptr [esp-00000018]    ;this code can't be asm correctly in OD, you must input it in OD manual
没懂这句的意思
2008-2-29 23:32
0
雪    币: 234
活跃值: (10)
能力值: ( LV3,RANK:30 )
在线值:
发帖
回帖
粉丝
7
注意:如果你用这个补丁的话,ImportREC 可以在 98/2000/XP 下正常工作,不过可能在 Vista64 下可能有问题(没条件装 Vista64,没法测试)。

谁有安装Vista64
测试看看反馈一下
不知能否正常WORK
2008-2-29 23:32
0
雪    币: 2506
活跃值: (1000)
能力值: (RANK:990 )
在线值:
发帖
回帖
粉丝
8
[QUOTE=heXer;422557]jmp    dword ptr [esp-00000018]    ;this code can't be asm correctly in OD, you must input it in OD manual
没懂这句的意思[/QUOTE]
这句用插件编译后在OD中是 jmp 00000000,要自己在OD中手工输入 jmp  dword ptr [esp-00000018]
2008-3-1 00:34
0
雪    币: 261
活跃值: (75)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
9
谢谢CC大哥,下载了!
2008-3-1 07:51
0
雪    币: 206
活跃值: (17)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
10
谢谢大哥了啊
2008-3-1 09:53
0
雪    币: 2506
活跃值: (1000)
能力值: (RANK:990 )
在线值:
发帖
回帖
粉丝
11
通过在 t4u 论坛与 jstorme 交流,他修改了他原来的代码,现在可以在 Win98 下正常使用了。已上传更新后的补丁(importrec.1.6.final-patch.rar),可用于我上个压缩包中的原始脱壳文件,原来压缩包中的补丁文件(importrec.1.6.final.for.NT-patch.exe)可以删掉。
2008-3-1 11:20
0
雪    币: 93908
活跃值: (200199)
能力值: (RANK:10 )
在线值:
发帖
回帖
粉丝
12
CC辛苦
2008-3-1 12:05
0
雪    币: 224
活跃值: (14)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
13
偶像 ccdebuger
2008-3-1 12:16
0
雪    币: 134
活跃值: (84)
能力值: ( LV5,RANK:60 )
在线值:
发帖
回帖
粉丝
14
不知道,补丁后稳定性如何。都是jmp补丁,怕哦。呵呵
2008-3-1 17:02
0
雪    币: 200
活跃值: (158)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
shs
15
强悍无比啊!!佩服.
2008-3-1 20:20
0
雪    币: 301
活跃值: (300)
能力值: ( LV9,RANK:290 )
在线值:
发帖
回帖
粉丝
16
谢谢牛人的辛苦劳动
2008-3-1 21:04
0
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
17
顶~~~~
2008-4-13 11:18
0
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
18
强人,支持你~~~~~
2008-4-16 18:51
0
游客
登录 | 注册 方可回帖
返回
//