能力值:
( LV9,RANK:550 )
|
-
-
10 楼
给菜鸟看的详细过程,我是学了很久才会的,希望给我等菜鸟一点帮助
一、寻找OEP+解码Dump
利用用AvAtAr//TEAM RESURREC提供的Armadillo Process Detach v1.3 Final,也非常简单的dump。
选择CopyMem-II选项,把目标拖进去,成功后提示:
Filename: notepad
Parent process iD: [00000424]
Processing...
[PROTECTiON SYSTEM]
Professional Edition
[PROTECTiON OPTiONS]
Debug-Blocker protection detected
CopyMem-II protection detected
Memory-Patching Protections enabled
[CHiLD iNFO]
Crypto call found: [0043721B]
Child process iD: [00000700]
Entry point: [004010CC]
Original bytes: [558BEC83]
Detached successfully :)
此时打开OD,附加428的notepad,F9,F12来到被修改了的OEP处,将前面四个字节558BEC83,然后利用LordPE
Dump Full,这样就完成了Dump的任务。
二、修复IAT
利用OD加载没有脱壳的程序,BP DebugActiveProcess,Shift+F9,运行,程序中断下来,查看堆栈如下:
0013DDAC 00434864 /CALL 到 DebugActiveProcess 来自 notepad.0043485E
0013DDB0 0000014C \ProcessId = 14C
然后新开一个OD,然后附加14C的程序,F9,F12来到被修改了的OEP处,将前面两个字节修改为E8 E3(未脱壳程序中的OEP),
然后利用“转单进程脚本”
msg "请忽略所有异常,并添加忽略C000001E异常,然后运行本脚本!"
gpa "OpenMutexA","kernel32.dll"
bp $RESULT
esto
exec
pushad
pushfd
push edx
xor eax,eax
push eax
push eax
call kernel32.CreateMutexA
popfd
popad
jmp kernel32.OpenMutexA
ende
bc eip
msg "现已转换成单进程!"
ret
将程序转换为单进程,程序中断在下面地方,
7C80EC1B kernel32.Op> 8BFF mov edi,edi
7C80EC1D 55 push ebp
7C80EC1E 8BEC mov ebp,esp
堆栈显示:
0013F720 004314DA /CALL 到 OpenMutexA 来自 notepad.004314D4
0013F724 001F0001 |Access = 1F0001
0013F728 00000000 |Inheritable = FALSE
0013F72C 0013FD7C \MutexName = "2D4::DA5004986C"
然后BP GetModuleHandleA+5,Shift+F9,注意看堆栈,当堆栈如下变化时:
00139478 |00D05205 返回到 00D05205 来自 kernel32.GetModuleHandleA
0013947C |00D30B98 ASCII "kernel32.dll"
00139480 |00D31A64 ASCII "VirtualAlloc"
00139478 |00D05223 返回到 00D05223 来自 kernel32.GetModuleHandleA
0013947C |00D30B98 ASCII "kernel32.dll"
00139480 |00D31A58 ASCII "VirtualFree"
001391C4 |00CE7E44 返回到 00CE7E44 来自 kernel32.GetModuleHandleA
001391C8 |00139340 ASCII "kernel32.dll"
取消断点,Alt+F9返回,
00CE7E44 8B55 F4 mov edx,dword ptr ss:[ebp-C] ; 返回这里
00CE7E47 8B0D 4CDFD300 mov ecx,dword ptr ds:[D3DF4C]
00CE7E4D 890491 mov dword ptr ds:[ecx+edx*4],eax
00CE7E50 8B55 F4 mov edx,dword ptr ss:[ebp-C]
00CE7E53 A1 4CDFD300 mov eax,dword ptr ds:[D3DF4C]
00CE7E58 833C90 00 cmp dword ptr ds:[eax+edx*4],0
00CE7E5C 75 5C jnz short 00CE7EBA
00CE7E5E 8B4D F8 mov ecx,dword ptr ss:[ebp-8]
00CE7E61 8B51 08 mov edx,dword ptr ds:[ecx+8]
00CE7E64 83E2 02 and edx,2
00CE7E67 74 38 je short 00CE7EA1
00CE7E69 B8 17000000 mov eax,17
00CE7E6E C1E0 02 shl eax,2
00CE7E71 8B0D 04BBD300 mov ecx,dword ptr ds:[D3BB04] ; notepad.0046D378
00CE7E77 8B15 04BBD300 mov edx,dword ptr ds:[D3BB04] ; notepad.0046D378
00CE7E7D 8B35 04BBD300 mov esi,dword ptr ds:[D3BB04] ; notepad.0046D378
00CE7E83 8B5E 08 mov ebx,dword ptr ds:[esi+8]
00CE7E86 335A 64 xor ebx,dword ptr ds:[edx+64]
00CE7E89 331C01 xor ebx,dword ptr ds:[ecx+eax]
00CE7E8C 83E3 10 and ebx,10
00CE7E8F F7DB neg ebx
00CE7E91 1BDB sbb ebx,ebx
00CE7E93 F7DB neg ebx
00CE7E95 0FB6C3 movzx eax,bl
00CE7E98 85C0 test eax,eax
00CE7E9A 75 05 jnz short 00CE7EA1
00CE7E9C ^ E9 1BFFFFFF jmp 00CE7DBC
00CE7EA1 8D8D C8FEFFFF lea ecx,dword ptr ss:[ebp-138]
00CE7EA7 51 push ecx
00CE7EA8 FF15 D4E1D200 call dword ptr ds:[D2E1D4] ; kernel32.LoadLibraryA
00CE7EAE 8B55 F4 mov edx,dword ptr ss:[ebp-C]
00CE7EB1 8B0D 4CDFD300 mov ecx,dword ptr ds:[D3DF4C]
00CE7EB7 890491 mov dword ptr ds:[ecx+edx*4],eax
00CE7EBA 8B55 F4 mov edx,dword ptr ss:[ebp-C]
00CE7EBD A1 4CDFD300 mov eax,dword ptr ds:[D3DF4C]
00CE7EC2 833C90 00 cmp dword ptr ds:[eax+edx*4],0
00CE7EC6 75 05 jnz short 00CE7ECD ; Magic Jmp,NOP掉
00CE7EC8 ^ E9 EFFEFFFF jmp 00CE7DBC
00CE7ECD C785 BCFEFFFF 00000>mov dword ptr ss:[ebp-144],0
00CE7ED7 C785 C0FEFFFF 00000>mov dword ptr ss:[ebp-140],0
00CE7EE1 8B4D F8 mov ecx,dword ptr ss:[ebp-8]
00CE7EE4 8B51 04 mov edx,dword ptr ds:[ecx+4]
00CE7EE7 8995 C4FEFFFF mov dword ptr ss:[ebp-13C],edx
00CE7EED EB 0F jmp short 00CE7EFE
00CE7EEF 8B85 C4FEFFFF mov eax,dword ptr ss:[ebp-13C]
00CE7EF5 83C0 0C add eax,0C
00CE7EF8 8985 C4FEFFFF mov dword ptr ss:[ebp-13C],eax
00CE7EFE 8B8D C4FEFFFF mov ecx,dword ptr ss:[ebp-13C]
00CE7F04 8339 00 cmp dword ptr ds:[ecx],0
00CE7F07 74 11 je short 00CE7F1A
00CE7F09 8B95 C0FEFFFF mov edx,dword ptr ss:[ebp-140]
00CE7F0F 83C2 01 add edx,1
00CE7F12 8995 C0FEFFFF mov dword ptr ss:[ebp-140],edx
00CE7F18 ^ EB D5 jmp short 00CE7EEF
00CE7F1A 33C9 xor ecx,ecx
00CE7F1C 8B85 C0FEFFFF mov eax,dword ptr ss:[ebp-140]
00CE7F22 BA 04000000 mov edx,4
00CE7F27 F7E2 mul edx
00CE7F29 0F90C1 seto cl
00CE7F2C F7D9 neg ecx
00CE7F2E 0BC8 or ecx,eax
00CE7F30 51 push ecx
00CE7F31 E8 19FE0200 call 00D17D4F
00CE7F36 83C4 04 add esp,4
00CE7F39 8985 7CFDFFFF mov dword ptr ss:[ebp-284],eax
00CE7F3F 8B45 F4 mov eax,dword ptr ss:[ebp-C]
00CE7F42 8B0D 44DFD300 mov ecx,dword ptr ds:[D3DF44]
00CE7F48 8B95 7CFDFFFF mov edx,dword ptr ss:[ebp-284]
00CE7F4E 891481 mov dword ptr ds:[ecx+eax*4],edx
00CE7F51 33C9 xor ecx,ecx
00CE7F53 8B85 C0FEFFFF mov eax,dword ptr ss:[ebp-140]
00CE7F59 BA 04000000 mov edx,4
00CE7F5E F7E2 mul edx
00CE7F60 0F90C1 seto cl
00CE7F63 F7D9 neg ecx
00CE7F65 0BC8 or ecx,eax
00CE7F67 51 push ecx
00CE7F68 E8 E2FD0200 call 00D17D4F
00CE7F6D 83C4 04 add esp,4
00CE7F70 8985 78FDFFFF mov dword ptr ss:[ebp-288],eax
00CE7F76 8B45 F4 mov eax,dword ptr ss:[ebp-C]
00CE7F79 8B0D 48DFD300 mov ecx,dword ptr ds:[D3DF48]
00CE7F7F 8B95 78FDFFFF mov edx,dword ptr ss:[ebp-288]
00CE7F85 891481 mov dword ptr ds:[ecx+eax*4],edx
00CE7F88 8B45 F8 mov eax,dword ptr ss:[ebp-8]
00CE7F8B 8B48 04 mov ecx,dword ptr ds:[eax+4]
00CE7F8E 898D C4FEFFFF mov dword ptr ss:[ebp-13C],ecx
00CE7F94 EB 1E jmp short 00CE7FB4
00CE7F96 8B95 C4FEFFFF mov edx,dword ptr ss:[ebp-13C]
00CE7F9C 83C2 0C add edx,0C
00CE7F9F 8995 C4FEFFFF mov dword ptr ss:[ebp-13C],edx
00CE7FA5 8B85 BCFEFFFF mov eax,dword ptr ss:[ebp-144]
00CE7FAB 83C0 01 add eax,1
00CE7FAE 8985 BCFEFFFF mov dword ptr ss:[ebp-144],eax
00CE7FB4 8B8D C4FEFFFF mov ecx,dword ptr ss:[ebp-13C]
00CE7FBA 8339 00 cmp dword ptr ds:[ecx],0
00CE7FBD 0F84 47010000 je 00CE810A
00CE7FC3 68 00010000 push 100
00CE7FC8 8D95 B8FDFFFF lea edx,dword ptr ss:[ebp-248]
00CE7FCE 52 push edx
00CE7FCF 8B85 C4FEFFFF mov eax,dword ptr ss:[ebp-13C]
00CE7FD5 8B08 mov ecx,dword ptr ds:[eax]
00CE7FD7 51 push ecx
00CE7FD8 E8 03ABFDFF call 00CC2AE0
00CE7FDD 83C4 0C add esp,0C
00CE7FE0 8B15 04BBD300 mov edx,dword ptr ds:[D3BB04] ; notepad.0046D378
00CE7FE6 A1 04BBD300 mov eax,dword ptr ds:[D3BB04]
00CE7FEB 8B4A 60 mov ecx,dword ptr ds:[edx+60]
00CE7FEE 3348 08 xor ecx,dword ptr ds:[eax+8]
00CE7FF1 8B15 04BBD300 mov edx,dword ptr ds:[D3BB04] ; notepad.0046D378
00CE7FF7 334A 64 xor ecx,dword ptr ds:[edx+64]
00CE7FFA A1 04BBD300 mov eax,dword ptr ds:[D3BB04]
00CE7FFF 3348 68 xor ecx,dword ptr ds:[eax+68]
00CE8002 898D 6CFDFFFF mov dword ptr ss:[ebp-294],ecx
00CE8008 8D8D B8FDFFFF lea ecx,dword ptr ss:[ebp-248]
00CE800E 51 push ecx
00CE800F 8B55 F4 mov edx,dword ptr ss:[ebp-C]
00CE8012 A1 4CDFD300 mov eax,dword ptr ds:[D3DF4C]
00CE8017 8B0C90 mov ecx,dword ptr ds:[eax+edx*4]
00CE801A 51 push ecx
00CE801B FF15 04E3D200 call dword ptr ds:[D2E304] ; kernel32.GetProcAddress
00CE8021 3385 6CFDFFFF xor eax,dword ptr ss:[ebp-294]
00CE8027 8B55 F4 mov edx,dword ptr ss:[ebp-C]
00CE802A 8B0D 44DFD300 mov ecx,dword ptr ds:[D3DF44]
00CE8030 8B1491 mov edx,dword ptr ds:[ecx+edx*4]
00CE8033 8B8D BCFEFFFF mov ecx,dword ptr ss:[ebp-144]
00CE8039 89048A mov dword ptr ds:[edx+ecx*4],eax
00CE803C 6A 01 push 1
00CE803E 8D95 B8FDFFFF lea edx,dword ptr ss:[ebp-248]
00CE8044 52 push edx
00CE8045 8B45 F4 mov eax,dword ptr ss:[ebp-C]
00CE8048 8B0D 4CDFD300 mov ecx,dword ptr ds:[D3DF4C]
00CE804E 8B1481 mov edx,dword ptr ds:[ecx+eax*4]
00CE8051 52 push edx
00CE8052 E8 D9090000 call 00CE8A30
00CE8057 83C4 0C add esp,0C
00CE805A 8B4D F4 mov ecx,dword ptr ss:[ebp-C]
00CE805D 8B15 48DFD300 mov edx,dword ptr ds:[D3DF48]
00CE8063 8B0C8A mov ecx,dword ptr ds:[edx+ecx*4]
00CE8066 8B95 BCFEFFFF mov edx,dword ptr ss:[ebp-144]
00CE806C 890491 mov dword ptr ds:[ecx+edx*4],eax
00CE806F 8B45 F4 mov eax,dword ptr ss:[ebp-C]
00CE8072 8B0D 48DFD300 mov ecx,dword ptr ds:[D3DF48]
00CE8078 8B1481 mov edx,dword ptr ds:[ecx+eax*4]
00CE807B 8B85 BCFEFFFF mov eax,dword ptr ss:[ebp-144]
00CE8081 833C82 00 cmp dword ptr ds:[edx+eax*4],0
00CE8085 75 32 jnz short 00CE80B9
00CE8087 6A 00 push 0
00CE8089 8D8D B8FDFFFF lea ecx,dword ptr ss:[ebp-248]
00CE808F 51 push ecx
00CE8090 8B55 F4 mov edx,dword ptr ss:[ebp-C]
00CE8093 A1 4CDFD300 mov eax,dword ptr ds:[D3DF4C]
00CE8098 8B0C90 mov ecx,dword ptr ds:[eax+edx*4]
00CE809B 51 push ecx
00CE809C E8 8F090000 call 00CE8A30
00CE80A1 83C4 0C add esp,0C
00CE80A4 8B55 F4 mov edx,dword ptr ss:[ebp-C]
00CE80A7 8B0D 48DFD300 mov ecx,dword ptr ds:[D3DF48]
00CE80AD 8B1491 mov edx,dword ptr ds:[ecx+edx*4]
00CE80B0 8B8D BCFEFFFF mov ecx,dword ptr ss:[ebp-144]
00CE80B6 89048A mov dword ptr ds:[edx+ecx*4],eax
00CE80B9 8B55 F4 mov edx,dword ptr ss:[ebp-C]
00CE80BC A1 48DFD300 mov eax,dword ptr ds:[D3DF48]
00CE80C1 8B0C90 mov ecx,dword ptr ds:[eax+edx*4]
00CE80C4 8B15 04BBD300 mov edx,dword ptr ds:[D3BB04] ; notepad.0046D378
00CE80CA A1 04BBD300 mov eax,dword ptr ds:[D3BB04]
00CE80CF 8B35 04BBD300 mov esi,dword ptr ds:[D3BB04] ; notepad.0046D378
00CE80D5 8B3D 04BBD300 mov edi,dword ptr ds:[D3BB04] ; notepad.0046D378
00CE80DB 8B7F 60 mov edi,dword ptr ds:[edi+60]
00CE80DE 337E 08 xor edi,dword ptr ds:[esi+8]
00CE80E1 3378 64 xor edi,dword ptr ds:[eax+64]
00CE80E4 337A 68 xor edi,dword ptr ds:[edx+68]
00CE80E7 8B95 BCFEFFFF mov edx,dword ptr ss:[ebp-144]
00CE80ED 333C91 xor edi,dword ptr ds:[ecx+edx*4]
00CE80F0 8B45 F4 mov eax,dword ptr ss:[ebp-C]
00CE80F3 8B0D 48DFD300 mov ecx,dword ptr ds:[D3DF48]
00CE80F9 8B1481 mov edx,dword ptr ds:[ecx+eax*4]
00CE80FC 8B85 BCFEFFFF mov eax,dword ptr ss:[ebp-144]
00CE8102 893C82 mov dword ptr ds:[edx+eax*4],edi
00CE8105 ^ E9 8CFEFFFF jmp 00CE7F96
00CE810A 8B0D 04BBD300 mov ecx,dword ptr ds:[D3BB04] ; notepad.0046D378
00CE8110 8B15 04BBD300 mov edx,dword ptr ds:[D3BB04] ; notepad.0046D378
00CE8116 A1 04BBD300 mov eax,dword ptr ds:[D3BB04]
00CE811B 8B35 04BBD300 mov esi,dword ptr ds:[D3BB04] ; notepad.0046D378
00CE8121 8B36 mov esi,dword ptr ds:[esi]
00CE8123 3370 64 xor esi,dword ptr ds:[eax+64]
00CE8126 3372 3C xor esi,dword ptr ds:[edx+3C]
00CE8129 3371 34 xor esi,dword ptr ds:[ecx+34]
00CE812C 8B4D F4 mov ecx,dword ptr ss:[ebp-C]
00CE812F 8B15 4CDFD300 mov edx,dword ptr ds:[D3DF4C]
00CE8135 33348A xor esi,dword ptr ds:[edx+ecx*4]
00CE8138 8B45 F4 mov eax,dword ptr ss:[ebp-C]
00CE813B 8B0D 4CDFD300 mov ecx,dword ptr ds:[D3DF4C]
00CE8141 893481 mov dword ptr ds:[ecx+eax*4],esi
00CE8144 ^ E9 73FCFFFF jmp 00CE7DBC
00CE8149 EB 03 jmp short 00CE814E
00CE814B D6 salc
00CE814C D6 salc
将00CE7EC6 75 05 jnz short 00CE7ECD代码NOP掉,然后在00CE8149处F2下断点,F9运行下来后取消断点,并撤消
00CE7EC6处的选择。
这个东东在处理输入表的时候还有时间校验,不处理的话会导致某些函数被加密
下断:BP GetTickCount 中断后
7C8092B1 8B02 mov eax,dword ptr ds:[edx]
7C8092B3 F762 04 mul dword ptr ds:[edx+4]
7C8092B6 0FACD0 18 shrd eax,edx,18
7C8092BA C3 retn
取消断点返回
00D0A78F FF15 44E3D200 call dword ptr ds:[D2E344] ; kernel32.GetTickCount
00D0A795 8985 94D4FFFF mov dword ptr ss:[ebp-2B6C],eax ; 返回这里
00D0A79B B9 01000000 mov ecx,1
00D0A7A0 85C9 test ecx,ecx
00D0A7A2 0F84 C4030000 je 00D0AB6C
00D0A7A8 8B95 90D9FFFF mov edx,dword ptr ss:[ebp-2670]
下面还有一处GetTickCount取时间
00D0AB4A 8B85 4CD8FFFF mov eax,dword ptr ss:[ebp-27B4] ; 此处EAX中能够看到IAT中的一个单元地址的地方,这里为4063F8
00D0AB50 8B8D 54CAFFFF mov ecx,dword ptr ss:[ebp-35AC]
00D0AB56 8908 mov dword ptr ds:[eax],ecx
00D0AB58 8B95 4CD8FFFF mov edx,dword ptr ss:[ebp-27B4]
00D0AB5E 83C2 04 add edx,4
00D0AB61 8995 4CD8FFFF mov dword ptr ss:[ebp-27B4],edx
00D0AB67 ^ E9 2FFCFFFF jmp 00D0A79B
00D0AB6C FF15 44E3D200 call dword ptr ds:[D2E344] ; kernel32.GetTickCount
00D0AB72 2B85 94D4FFFF sub eax,dword ptr ss:[ebp-2B6C]
00D0AB78 8B8D A4D4FFFF mov ecx,dword ptr ss:[ebp-2B5C]
00D0AB7E 6BC9 32 imul ecx,ecx,32
00D0AB81 81C1 D0070000 add ecx,7D0
00D0AB87 3BC1 cmp eax,ecx
00D0AB89 76 07 jbe short 00D0AB92 ; 将起修改为jmp short 00D0AB92
然后在红色代码下方的:
00D0AD60 /EB 03 jmp short 00D0AD65
00D0AD62 |D6 salc
00D0AD63 |D6 salc
00D0AD60处下断点,F9运行下来,此时得到的IAT就是正确的IAT了。通过在数据窗口滚动可以知道IAT为4062E4-406524
最后运行ImportREC,选择这个进程。填入RVA=0062E4、Size=00000240,Get Import剪切掉无效函数,修改OEP RVA=0010CC,FixDump,正常运行!
|