好友
阅读权限25
听众
最后登录1970-1-1
|
GCCG
发表于 2010-8-10 18:22
本帖最后由 GCCG 于 2010-8-12 16:35 编辑
【文章标题】: Armadillo 7.0 DLL 脱壳
【文章作者】: GCCG
【软件名称】: 一个DLL
【软件大小】: 2.52 MB
【下载地址】: 自己搜索下载
【加壳方式】: Armadillo 7.0
【保护方式】: Armadillo 7.0加壳
【编写语言】: VC++ 8.0
【使用工具】: OD、LoadPE、ImpRec
【操作平台】: Windows
【软件介绍】: 一个虚拟打印机的DLL
【作者声明】: 只是感兴趣,没有其他目的。失误之处敬请诸位大侠赐教!
--------------------------------------------------------------------------------
【详细过程】
碰到个Armadillo 7.0 加壳的DLL,搞了一天终于搞定,参考了众多大牛文章,在此表示感谢!
1.Exeinfo PE 查壳:Armadillo x.x ~ 7.0 32bit [ DLL ] - www.siliconrealms.com
Arma Find Protect 1.9 检测为:
Protected Armadillo
Protection system (Professional)
2 找 Magic JMP
OD 载入...
00AC5D95 > 837C24 08 01 cmp dword ptr [esp+0x8], 0x1
00AC5D9A 75 05 jnz short 00AC5DA1
00AC5D9C E8 F28C0000 call 00ACEA93
00AC5DA1 FF7424 04 push dword ptr [esp+0x4]
00AC5DA5 8B4C24 10 mov ecx, dword ptr [esp+0x10]
下断 bp GetModuleHandleA+9 F9运行并观察堆栈:
00129008 /0012E8CC
0012900C |00F43A9D RETURN to 00F43A9D from kernel32.GetModuleHandleA
00129010 |00F87B64 ASCII "kernel32.dll"
00129014 |00F89BD8 ASCII "VirtualAlloc"
00129008 /0012E8CC
0012900C |00F43ABB RETURN to 00F43ABB from kernel32.GetModuleHandleA
00129010 |00F87B64 ASCII "kernel32.dll"
00129014 |00F89BCC ASCII "VirtualFree"
00129018 |292D004D
00128D54 /0012900C
00128D58 |00F10041 RETURN to 00F10041 from kernel32.GetModuleHandleA
00128D5C |00128ED4 ASCII "kernel32.dll"
00128D60 |00000000
到达返回时机,取消断点,Alt+F9返回,返回到:
00F10041 8B55 F4 mov edx, dword ptr [ebp-0xC] ; 返回到这里
00F10044 8B0D FC5CFA00 mov ecx, dword ptr [0xFA5CFC]
00F1004A 890491 mov dword ptr [ecx+edx*4], eax
00F1004D 8B55 F4 mov edx, dword ptr [ebp-0xC]
00F10050 A1 FC5CFA00 mov eax, dword ptr [0xFA5CFC]
00F10055 833C90 00 cmp dword ptr [eax+edx*4], 0x0
00F10059 75 5C jnz short 00F100B7
00F1005B 8B4D F8 mov ecx, dword ptr [ebp-0x8]
00F1005E 8B51 08 mov edx, dword ptr [ecx+0x8]
00F10061 83E2 02 and edx, 0x2
00F10064 74 38 je short 00F1009E
00F10066 B8 13000000 mov eax, 0x13
00F1006B C1E0 02 shl eax, 0x2
00F1006E 8B0D 7433FA00 mov ecx, dword ptr [0xFA3374] ; Print2Fl.00AFE7B0
00F10074 8B15 7433FA00 mov edx, dword ptr [0xFA3374] ; Print2Fl.00AFE7B0
00F1007A 8B35 7433FA00 mov esi, dword ptr [0xFA3374] ; Print2Fl.00AFE7B0
00F10080 8B5E 08 mov ebx, dword ptr [esi+0x8]
00F10083 335A 60 xor ebx, dword ptr [edx+0x60]
00F10086 331C01 xor ebx, dword ptr [ecx+eax]
00F10089 83E3 10 and ebx, 0x10
00F1008C F7DB neg ebx
00F1008E 1BDB sbb ebx, ebx
00F10090 F7DB neg ebx
00F10092 0FB6C3 movzx eax, bl
00F10095 85C0 test eax, eax
00F10097 75 05 jnz short 00F1009E
00F10099 ^ E9 1BFFFFFF jmp 00F0FFB9
00F1009E 8D8D C8FEFFFF lea ecx, dword ptr [ebp-0x138]
00F100A4 51 push ecx
00F100A5 FF15 A430F800 call dword ptr [0xF830A4] ; kernel32.LoadLibraryA
00F100AB 8B55 F4 mov edx, dword ptr [ebp-0xC]
00F100AE 8B0D FC5CFA00 mov ecx, dword ptr [0xFA5CFC]
00F100B4 890491 mov dword ptr [ecx+edx*4], eax
00F100B7 8B55 F4 mov edx, dword ptr [ebp-0xC]
00F100BA A1 FC5CFA00 mov eax, dword ptr [0xFA5CFC]
00F100BF 833C90 00 cmp dword ptr [eax+edx*4], 0x0
00F100C3 75 05 jnz short 00F100CA ; Magic Jmp 这里Nop掉
00F100C5 ^ E9 EFFEFFFF jmp 00F0FFB9
00F100CA C785 BCFEFFFF 0>mov dword ptr [ebp-0x144], 0x0
00F100D4 C785 C0FEFFFF 0>mov dword ptr [ebp-0x140], 0x0
00F100DE 8B4D F8 mov ecx, dword ptr [ebp-0x8]
nop掉00F100C3 ,向下拉,来到:
00F10342 893481 mov dword ptr [ecx+eax*4], esi
00F10345 ^ E9 6FFCFFFF jmp 00F0FFB9
00F1034A EB 03 jmp short 00F1034F
00F1034C D6 salc
00F1034D D6 salc
直接F4到00F1034A,然后把刚才Nop掉的代码恢复,以防止Arm检测。
下面一步比较关键,参考牛人的文章要么下断 bp CreateThread ,要么打开内存在.text断下F2断点,或者bp GetCurrentProcessId
但以上方法对这个7.0的DLL都没用,郁闷了半天,于是用旧版DLL调试发现CreateThread函数上面有个CreateEventA,
于是 对于7.0的DLL,在此处下断 bp CreateEventA
7C830885 > 8BFF mov edi, edi ; 断在这里
7C830887 55 push ebp
7C830888 8BEC mov ebp, esp
7C83088A 51 push ecx
7C83088B 51 push ecx
7C83088C 56 push esi
取消断点,返回
00F1BD6A A3 607FFA00 mov dword ptr [0xFA7F60], eax ; 返回到这里
00F1BD6F 8B45 08 mov eax, dword ptr [ebp+0x8]
00F1BD72 A3 6C7FFA00 mov dword ptr [0xFA7F6C], eax
00F1BD77 E8 14010000 call 00F1BE90
00F1BD7C B9 12000000 mov ecx, 0x12
00F1BD81 C1E1 02 shl ecx, 0x2
00F1BD84 8B15 7433FA00 mov edx, dword ptr [0xFA3374] ; Print2Fl.00AFE7B0
00F1BD8A A1 7433FA00 mov eax, dword ptr [0xFA3374]
00F1BD8F 8B35 7433FA00 mov esi, dword ptr [0xFA3374] ; Print2Fl.00AFE7B0
00F1BD95 8B5E 08 mov ebx, dword ptr [esi+0x8]
00F1BD98 3358 60 xor ebx, dword ptr [eax+0x60]
00F1BD9B 331C0A xor ebx, dword ptr [edx+ecx]
00F1BD9E 81E3 80000000 and ebx, 0x80
00F1BDA4 F7DB neg ebx
00F1BDA6 1BDB sbb ebx, ebx
00F1BDA8 F7DB neg ebx
00F1BDAA 0FB6CB movzx ecx, bl
00F1BDAD 85C9 test ecx, ecx
00F1BDAF 74 6F je short 00F1BE20
00F1BDB1 BA 12000000 mov edx, 0x12
00F1BDB6 C1E2 02 shl edx, 0x2
00F1BDB9 A1 7433FA00 mov eax, dword ptr [0xFA3374]
00F1BDBE 8B0D 7433FA00 mov ecx, dword ptr [0xFA3374] ; Print2Fl.00AFE7B0
00F1BDC4 8B35 7433FA00 mov esi, dword ptr [0xFA3374] ; Print2Fl.00AFE7B0
00F1BDCA 8B5E 08 mov ebx, dword ptr [esi+0x8]
00F1BDCD 3359 60 xor ebx, dword ptr [ecx+0x60]
00F1BDD0 331C10 xor ebx, dword ptr [eax+edx]
00F1BDD3 81E3 00200000 and ebx, 0x2000
00F1BDD9 F7DB neg ebx
00F1BDDB 1BDB sbb ebx, ebx
00F1BDDD F7DB neg ebx
00F1BDDF 0FB6D3 movzx edx, bl
00F1BDE2 85D2 test edx, edx
00F1BDE4 74 05 je short 00F1BDEB ; 这个没跳,下面的CreateThread被跳过了
00F1BDE6 E9 98000000 jmp 00F1BE83
00F1BDEB 6A 00 push 0x0
00F1BDED 68 0488F800 push 0xF88804 ; ASCII "ArmServerInfo"
00F1BDF2 FF15 2C33F800 call dword ptr [0xF8332C] ; kernel32.SetEnvironmentVariableA
00F1BDF8 8D45 FC lea eax, dword ptr [ebp-0x4]
00F1BDFB 50 push eax
00F1BDFC 6A 00 push 0x0
00F1BDFE 6A 00 push 0x0
00F1BE00 68 A0C4F100 push 0xF1C4A0
00F1BE05 6A 00 push 0x0
00F1BE07 6A 00 push 0x0
00F1BE09 FF15 EC30F800 call dword ptr [0xF830EC] ; kernel32.CreateThread
00F1BE0F 50 push eax
00F1BE10 FF15 6033F800 call dword ptr [0xF83360] ; kernel32.CloseHandle
00F1BE16 6A 0A push 0xA
00F1BE18 FF15 3C33F800 call dword ptr [0xF8333C] ; kernel32.Sleep
00F1BE1E EB 63 jmp short 00F1BE83
再次返回:
00F4EF75 83C4 04 add esp, 0x4 ; 返回到这里
00F4EF78 B9 282DFA00 mov ecx, 0xFA2D28
00F4EF7D E8 2EDDF7FF call 00ECCCB0
00F4EF82 0FB6C0 movzx eax, al
00F4EF85 85C0 test eax, eax
00F4EF87 74 0C je short 00F4EF95
00F4EF89 6A 01 push 0x1
00F4EF8B B9 282DFA00 mov ecx, 0xFA2D28
00F4EF90 E8 DBF4F8FF call 00EDE470
00F4EF95 B9 5C1DFA00 mov ecx, 0xFA1D5C
00F4EF9A E8 C1BEFBFF call 00F0AE60
00F4EF9F E9 26010000 jmp 00F4F0CA ; 这个不能跳,向上找跳过该Jmp的JNZ
向上找,来到
00F4EEDA /0F85 C4000000 jnz 00F4EFA4 ; Arm检测,记下这个地址,改为Jmp
00F4EEE0 |BA 05000000 mov edx, 0x5
00F4EEE5 |C1E2 02 shl edx, 0x2
00F4EEE8 |A1 7433FA00 mov eax, dword ptr [0xFA3374]
00F4EEED |8B0D 7433FA00 mov ecx, dword ptr [0xFA3374] ; Print2Fl.00AFE7B0
00F4EEF3 |8B35 7433FA00 mov esi, dword ptr [0xFA3374] ; Print2Fl.00AFE7B0
00F4EEF9 |8B76 30 mov esi, dword ptr [esi+0x30]
00F4EEFC |3371 60 xor esi, dword ptr [ecx+0x60]
00F4EEFF |333410 xor esi, dword ptr [eax+edx]
3.搞定重定位
Ctrl+F2 重新来过
bp GetModuleHandleA+9 按以上找到Magic Jmp,修改好,并恢复Magic Jmp代码
下断 bp GetTickCount
7C80934A > BA 0000FE7F mov edx, 0x7FFE0000 ; 断在这里
7C80934F 8B02 mov eax, dword ptr [edx]
7C809351 F762 04 mul dword ptr [edx+0x4]
7C809354 0FACD0 18 shrd eax, edx, 0x18
7C809358 C3 retn
取消断点并返回: 00F49435 8985 80D4FFFF mov dword ptr [ebp-0x2B80], eax ; 返回到这里
00F4943B BA 01000000 mov edx, 0x1
00F49440 85D2 test edx, edx
00F49442 0F84 C6030000 je 00F4980E
00F49448 8B85 84D9FFFF mov eax, dword ptr [ebp-0x267C]
00F4944E 66:8B08 mov cx, word ptr [eax]
00F49451 66:898D 48D2FFF>mov word ptr [ebp-0x2DB8], cx
00F49458 8B95 84D9FFFF mov edx, dword ptr [ebp-0x267C]
00F4945E 83C2 02 add edx, 0x2
Ctrl+S 搜索一下特征(7.0 DLL的特征,自己找的)
push ebx
xchg dx, dx
pop ebx
00F4A384 898D A0B0FFFF mov dword ptr [ebp-0x4F60], ecx
00F4A38A ^ EB CA jmp short 00F4A356
00F4A38C 53 push ebx ; 找到这里
00F4A38D 66:87D2 xchg dx, dx
00F4A390 5B pop ebx
00F4A391 44 inc esp
00F4A392 93 xchg eax, ebx
在00F4A38C 处F2下断,F9运行,断下
00F4A38C 53 push ebx ; 找到这里
00F4A38D 66:87D2 xchg dx, dx
00F4A390 5B pop ebx
00F4A391 C705 74EAF900 7>mov dword ptr [0xF9EA74], 0xF89874 ; 此处代码开始出现红色代码
00F4A39B 8B15 70D5FA00 mov edx, dword ptr [0xFAD570] ; Print2Fl.00C0BFAE
00F4A3A1 8B02 mov eax, dword ptr [edx] ; 重定位地址 ds:[00C0BFA6]=00144000
00F4A3A3 8985 C0D7FFFF mov dword ptr [ebp-0x2840], eax
00F4A3A9 8B0D 70D5FA00 mov ecx, dword ptr [0xFAD570] ; Print2Fl.00C0BFAE
00F4A3AF 83C1 04 add ecx, 0x4
00F4A3B2 890D 70D5FA00 mov dword ptr [0xFAD570], ecx
00F4A3B8 8B15 70D5FA00 mov edx, dword ptr [0xFAD570] ; Print2Fl.00C0BFAE
00F4A3BE 8B02 mov eax, dword ptr [edx] ; 重定位大小ds:[00C0BFAA]=00007BB4
00F4A3C0 8985 B0D7FFFF mov dword ptr [ebp-0x2850], eax
00F4A3C6 8B0D 70D5FA00 mov ecx, dword ptr [0xFAD570] ; Print2Fl.00C0BFAE
00F4A3CC 83C1 04 add ecx, 0x4
00F4A3CF 890D 70D5FA00 mov dword ptr [0xFAD570], ecx
00F4A3D5 83BD C0D7FFFF 0>cmp dword ptr [ebp-0x2840], 0x0 ; 重定位地址是否为0
00F4A3DC 74 74 je short 00F4A452 ; 为0则处理重定位
00F4A3DE 83BD B0D7FFFF 0>cmp dword ptr [ebp-0x2850], 0x0 ; 重定位大小是否为0
00F4A3E5 74 6B je short 00F4A452 ; 为0则处理重定位
00F4A3E7 8B95 38D8FFFF mov edx, dword ptr [ebp-0x27C8]
00F4A3ED 8B85 68D8FFFF mov eax, dword ptr [ebp-0x2798] ; 重定位后基址Stack ss:[0012C134]=00910000
00F4A3F3 3B42 34 cmp eax, dword ptr [edx+0x34] ; 重定位基址与DLL基址是否相等,DLL基址是00400000
00F4A3F6 EB 5A jmp short 00F4A452 ; 不等则处理重定位,这里要改为Jmp强行跳过重定位处理
00F4A3F8 8B8D B0D7FFFF mov ecx, dword ptr [ebp-0x2850]
00F4A3FE 51 push ecx
00F4A3FF 8B95 68D8FFFF mov edx, dword ptr [ebp-0x2798]
00F4A405 0395 C0D7FFFF add edx, dword ptr [ebp-0x2840]
00F4A40B 52 push edx
00F4A40C 8B85 38D8FFFF mov eax, dword ptr [ebp-0x27C8]
00F4A412 8B48 34 mov ecx, dword ptr [eax+0x34]
00F4A415 51 push ecx
00F4A416 8B95 68D8FFFF mov edx, dword ptr [ebp-0x2798]
00F4A41C 52 push edx
00F4A41D E8 EE320000 call 00F4D710 ; 重定位处理Call
00F4A422 83C4 10 add esp, 0x10
00F4A425 0FB6C0 movzx eax, al
00F4A428 85C0 test eax, eax
00F4A42A 75 26 jnz short 00F4A452
00F4A42C 8B4D 08 mov ecx, dword ptr [ebp+0x8]
00F4A42F 8B11 mov edx, dword ptr [ecx]
00F4A431 C702 07000000 mov dword ptr [edx], 0x7
00F4A437 68 6498F800 push 0xF89864 ; ASCII "Location CPG"
00F4A43C 8B45 08 mov eax, dword ptr [ebp+0x8]
Ctrl+G 来到刚才记下的Arm检测出,即00F4EEDA,F2下断,F9运行
00F4EED7 8339 02 cmp dword ptr [ecx], 0x2
00F4EEDA 0F85 C4000000 jnz 00F4EFA4 ; 断在此处,Arm检测,改为Jmp
00F4EEE0 BA 05000000 mov edx, 0x5
00F4EEE5 C1E2 02 shl edx, 0x2
00F4EEE8 A1 7433FA00 mov eax, dword ptr [0xFA3374]
下断 bp CreateEventA,F9运行 7C830885 > 8BFF mov edi, edi
7C830887 55 push ebp
7C830888 8BEC mov ebp, esp
7C83088A 51 push ecx
7C83088B 51 push ecx
7C83088C 56 push esi
取消断点返回2次来到
00F4EFBF 83C4 04 add esp, 0x4 ; 来到这里,快到OEP了,呵呵呵
00F4EFC2 B9 282DFA00 mov ecx, 0xFA2D28
00F4EFC7 E8 E4DCF7FF call 00ECCCB0
00F4EFCC 0FB6C8 movzx ecx, al
00F4EFCF 85C9 test ecx, ecx
00F4EFD1 74 0C je short 00F4EFDF
F8单步走...........
00F4F086 8339 01 cmp dword ptr [ecx], 0x1
00F4F089 75 3F jnz short 00F4F0CA ; 这里Nop掉
00F4F08B 8B15 7433FA00 mov edx, dword ptr [0xFA3374] ; Print2Fl.00AFE7B0
00F4F091 A1 7433FA00 mov eax, dword ptr [0xFA3374]
00F4F096 8B4A 10 mov ecx, dword ptr [edx+0x10]
00F4F099 3348 60 xor ecx, dword ptr [eax+0x60]
00F4F09C 8B15 7433FA00 mov edx, dword ptr [0xFA3374] ; Print2Fl.00AFE7B0
00F4F0A2 334A 04 xor ecx, dword ptr [edx+0x4]
00F4F0A5 894D DC mov dword ptr [ebp-0x24], ecx
00F4F0A8 8B45 08 mov eax, dword ptr [ebp+0x8]
00F4F0AB 8B48 04 mov ecx, dword ptr [eax+0x4]
00F4F0AE 51 push ecx
00F4F0AF 8B55 08 mov edx, dword ptr [ebp+0x8]
00F4F0B2 8B42 08 mov eax, dword ptr [edx+0x8]
00F4F0B5 50 push eax
00F4F0B6 6A 00 push 0x0
00F4F0B8 8B4D 08 mov ecx, dword ptr [ebp+0x8]
00F4F0BB 8B51 0C mov edx, dword ptr [ecx+0xC]
00F4F0BE 52 push edx
00F4F0BF 8B45 F4 mov eax, dword ptr [ebp-0xC]
00F4F0C2 2B45 DC sub eax, dword ptr [ebp-0x24]
00F4F0C5 FFD0 call eax ; F7进去就是OEP
00F4F0C7 8945 FC mov dword ptr [ebp-0x4], eax
00F4F0CA 8B45 FC mov eax, dword ptr [ebp-0x4]
00F4F0CD 5E pop esi
00F4F0CE 8BE5 mov esp, ebp
00F4F0D0 5D pop ebp
00F4F0D1 C3 retn
0098286C 55 push ebp ; OEP
0098286D 8BEC mov ebp, esp
0098286F 53 push ebx
00982870 8B5D 08 mov ebx, dword ptr [ebp+0x8]
00982873 56 push esi
00982874 8B75 0C mov esi, dword ptr [ebp+0xC]
00982877 85F6 test esi, esi
00982879 57 push edi
0098287A 8B7D 10 mov edi, dword ptr [ebp+0x10]
打开LoadPE,Dump此DLL,并用LoadPE的PE编辑器打开Dumped.DLL,打开目录,修改重定位为刚才找到的
重定位地址 = 00144000
重定位大小 = 00007BB4
打开ImpREC,选择Loaddll.exe,选取其中的DLL
OEP:7286C
RVA:1000
Size:3B8
剪掉无效指针,修复,注意ImpRec要去掉“使用来自磁盘的 PE 文件头”。
脱壳成功,优化下就OK了。
--------------------------------------------------------------------------------
【版权声明】: 本文原创于吾爱破解论坛, 转载请注明作者并保持文章的完整, 谢谢!
2010年08月10日 18:27:21
相关脱壳文件:
Armadillo 7.0 DLL.rar
(1.31 MB, 下载次数: 272)
|
免费评分
-
查看全部评分
|