参考了fly大侠和CCDebuger大侠的两篇文章
MoleBox 脱壳的一些总结:
http://bbs.pediy.com/showthread.php?t=42700
MoleBox捆绑文件的解包方法:
http://bbs.pediy.com/showthread.php?t=14618
特别对提取MoleBox捆绑的文件有兴趣,但屡试屡败,郁闷!在fly大侠的那篇“MoleBox捆绑文件的解包方法”中,错过了试练程序的练习,也很扼腕,所以自己就用fly大侠常用来做教程的EdrTest.exe和EdrLib.dll简单打包了一下(擅自打包这两个程序此来做练习,不敬处请多包涵)可是还是失败...
下列是我的操作过程,请各位大侠指正我操作错误的地方,谢谢!
一、捆绑的文件数与文件名
00407B23 > E8 00000000 CALL Packed.00407B28
// 设置OllyDBG忽略所有异常,加载后停在这里
00407B28 60 PUSHAD
00407B29 E8 4F000000 CALL Packed.00407B7D
00407B2E B2 93 MOV DL,93
00407B30 1B22 SBB ESP,DWORD PTR DS:[EDX]
BP GetFileTime后返回:
0040DD9A C745 AC 0000000>MOV DWORD PTR SS:[EBP-54],0
// 返回这里
0040DDA1 EB 09 JMP SHORT Packed.0040DDAC
0040DDA3 8B4D AC MOV ECX,DWORD PTR SS:[EBP-54]
0040DDA6 83C1 01 ADD ECX,1
0040DDA9 894D AC MOV DWORD PTR SS:[EBP-54],ECX
0040DDAC 8B55 AC MOV EDX,DWORD PTR SS:[EBP-54]
0040DDAF 3B55 9C CMP EDX,DWORD PTR SS:[EBP-64]
// [EBP-64]=1 捆绑的文件数
0040DDB2 0F83 E3000000 JNB Packed.0040DE9B
0040DDB8 8B45 AC MOV EAX,DWORD PTR SS:[EBP-54]
0040DDBB C1E0 04 SHL EAX,4
0040DDBE 8B4D E0 MOV ECX,DWORD PTR SS:[EBP-20]
0040DDC1 8B51 04 MOV EDX,DWORD PTR DS:[ECX+4]
0040DDC4 8B4D DC MOV ECX,DWORD PTR SS:[EBP-24]
// [EBP-24]=912350 数据窗口可见到文件名EdrLib.dll
00912350 45 64 72 4C 69 62 2E 64 6C 6C 00 00 00 00 00 04 EdrLib.dll.....
二、提取捆绑的文件EdrLib.dll
BP GetCurrentProcessId 中断后取消断点,继续下断
BP CreateFileA 中断后取消断点,继续下断
BP GetSystemTimeAsFileTime 中断后取消断点返回
将下列PE头数据保存
0040B0CF FF15 90B74100 CALL DWORD PTR DS:[41B790] ; kernel32.GetSystemTimeAsFileTime
0040B0D5 8B45 C4 MOV EAX,DWORD PTR SS:[EBP-3C]
// 返回这里 [EBP-3C]=960090
0040B0D8 8B4D F0 MOV ECX,DWORD PTR SS:[EBP-10]
00960090 4D 5A 90 00 03 00 00 00 04 00 00 00 FF FF 00 00 MZ?........
009600A0 B8 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00 ?......@.......
009600B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
009600C0 00 00 00 00 00 00 00 00 00 00 00 00 D8 00 00 00 ............?..
009600D0 0E 1F BA 0E 00 B4 09 CD 21 B8 01 4C CD 21 54 68 ?.???L?Th
009600E0 69 73 20 70 72 6F 67 72 61 6D 20 63 61 6E 6E 6F is program canno
009600F0 74 20 62 65 20 72 75 6E 20 69 6E 20 44 4F 53 20 t be run in DOS
00960100 6D 6F 64 65 2E 0D 0D 0A 24 00 00 00 00 00 00 00 mode....$.......
00960110 D4 CA 64 C8 90 AB 0A 9B 90 AB 0A 9B 90 AB 0A 9B 采d??????
00960120 78 B4 01 9B 91 AB 0A 9B 13 B7 04 9B 99 AB 0A 9B x???????
00960130 F2 B4 19 9B 95 AB 0A 9B 90 AB 0B 9B A7 AB 0A 9B 缳?????
00960140 78 B4 00 9B 87 AB 0A 9B 78 B4 0E 9B 91 AB 0A 9B x??????
00960150 52 69 63 68 90 AB 0A 9B 00 00 00 00 00 00 00 00 Rich.?.......
00960160 00 00 00 00 00 00 00 00 50 45 00 00 4C 01 04 00 ........PE..L.
00960170 47 08 C7 3D 00 00 00 00 00 00 00 00 E0 00 0E 21 G?........?!
00960180 0B 01 06 00 00 30 00 00 00 30 00 00 00 00 00 00 ..0...0......
00960190 C9 11 00 00 00 10 00 00 00 40 00 00 00 00 40 00 ?......@....@.
009601A0 00 10 00 00 00 10 00 00 04 00 00 00 00 00 00 00 .............
009601B0 04 00 00 00 00 00 00 00 00 70 00 00 00 10 00 00 ........p.....
009601C0 00 00 00 00 02 00 00 00 00 00 10 00 00 10 00 00 .............
009601D0 00 00 10 00 00 10 00 00 00 00 00 00 10 00 00 00 .............
009601E0 A0 48 00 00 6D 00 00 00 2C 44 00 00 3C 00 00 00 ..m...,D..<...
009601F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00960200 00 00 00 00 00 00 00 00 00 60 00 00 B0 03 00 00 .........`..?..
00960210 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00960220 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00960230 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00960240 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00960250 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00960260 2E 74 65 78 74 00 00 00 96 2B 00 00 00 10 00 00 .text...?.....
00960270 00 30 00 00 00 10 00 00 00 00 00 00 00 00 00 00 .0.............
00960280 00 00 00 00 20 00 00 60 2E 72 64 61 74 61 00 00 .... ..`.rdata..
00960290 0D 09 00 00 00 40 00 00 00 10 00 00 00 40 00 00 .....@......@..
009602A0 00 00 00 00 00 00 00 00 00 00 00 00 40 00 00 40 ............@..@
009602B0 2E 64 61 74 61 00 00 00 E0 08 00 00 00 50 00 00 .data...?...P..
009602C0 00 10 00 00 00 50 00 00 00 00 00 00 00 00 00 00 ....P..........
009602D0 00 00 00 00 40 00 00 C0 2E 72 65 6C 6F 63 00 00 ....@..?reloc..
009602E0 9C 04 00 00 00 60 00 00 00 10 00 00 00 60 00 00 ?...`......`..
009602F0 00 00 00 00 00 00 00 00 00 00 00 00 40 00 00 42 ............@..B
BP CreateFileA 中断后取消断点返回
00410984 8945 A8 MOV DWORD PTR SS:[EBP-58],EAX
// 返回这里
00410987 837D A8 FF CMP DWORD PTR SS:[EBP-58],-1
0041098B 75 0A JNZ SHORT Packed.00410997
0041098D B9 110000EF MOV ECX,EF000011
00410992 E8 A2140000 CALL Packed.00411E39
00410997 6A 00 PUSH 0
00410999 8D85 38FFFFFF LEA EAX,DWORD PTR SS:[EBP-C8]
0041099F 50 PUSH EAX
004109A0 FF75 CC PUSH DWORD PTR SS:[EBP-34]
004109A3 FF75 E4 PUSH DWORD PTR SS:[EBP-1C]
004109A6 FF75 A8 PUSH DWORD PTR SS:[EBP-58]
004109A9 FF15 20B84100 CALL DWORD PTR DS:[41B820] ; kernel32.WriteFile
004109AF 837D D4 00 CMP DWORD PTR SS:[EBP-2C],0
004109B3 74 18 JE SHORT Packed.004109CD
004109B5 6A 00 PUSH 0
004109B7 8D85 38FFFFFF LEA EAX,DWORD PTR SS:[EBP-C8]
004109BD 50 PUSH EAX
004109BE FF75 D0 PUSH DWORD PTR SS:[EBP-30]
004109C1 FF75 D4 PUSH DWORD PTR SS:[EBP-2C]
004109C4 FF75 A8 PUSH DWORD PTR SS:[EBP-58]
004109C7 FF15 20B84100 CALL DWORD PTR DS:[41B820] ; kernel32.WriteFile
004109CD 6A 00 PUSH 0
004109CF 8D85 38FFFFFF LEA EAX,DWORD PTR SS:[EBP-C8]
004109D5 50 PUSH EAX
004109D6 68 00020000 PUSH 200
004109DB FF75 AC PUSH DWORD PTR SS:[EBP-54]
004109DE FF75 A8 PUSH DWORD PTR SS:[EBP-58]
004109E1 FF15 20B84100 CALL DWORD PTR DS:[41B820] ; kernel32.WriteFile
004109E7 FF75 A8 PUSH DWORD PTR SS:[EBP-58]
004109EA FF15 3CB74100 CALL DWORD PTR DS:[41B73C] ; kernel32.FlushFileBuffers
004109F0 FF75 A8 PUSH DWORD PTR SS:[EBP-58]
004109F3 FF15 08B74100 CALL DWORD PTR DS:[41B708] ; kernel32.CloseHandle
004109F9 C705 94B94100 0>MOV DWORD PTR DS:[41B994],1
00410A03 FF75 D8 PUSH DWORD PTR SS:[EBP-28]
00410A06 FF15 C0B74100 CALL DWORD PTR DS:[41B7C0] ; kernel32.LoadLibraryA
// 装载DLL,此时可以见到堆栈中捆绑的文件已被创建
BP GetModuleHandleA 中断后返回
004147DD FF15 7CB74100 CALL DWORD PTR DS:[41B77C] ; kernel32.GetModuleHandleA
004147E3 8945 FC MOV DWORD PTR SS:[EBP-4],EAX ; kernel32.7C800000
// 返回这里
接着我用LordPE完全转存这个MBX@6EC@912510.###改名为EdrLib.dll,然后将之前复制下来的PE头数据贴上
跟DLL的源文件比较后,除了镜像大小和重定位有点问题不一样外,就多了附加数据,用PE Tools纠正一下镜像大小,再把附加数据去掉,剩下重定位我不知道怎么修复,DLL装载器加载不了...汗!
CCDebuger大侠在“MoleBox 脱壳的一些总结”中有提到:“只要你找好关键点,可以 dump 出来一个完整的未加壳前的程序”但我摸索了好些日子毫无所获,真是无限怅惘...
在附件中的Packed.exe是用MoleBox打包的程序,EdrLib.dll是源DLL,dump.dll是我转存出来的文件,请各位大侠指导一下如何完成捆绑文件的提取和正确的方式,感激不尽!
附件下载地址:
http://www.51files.com/?ABT0UKZIGFXF8D8QOHE3
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!