新手学习 PracticalMalwareAnalysis lab18-2
# 静态数据* md5
```
md5,9C5C27494C28ED0B14853B346B113145
sha1,290AB6F431F46547DB2628C494CE615D6061CEB8
sha256,7983A582939924C70E3DA2DA80FD3352EBC90DE7B8C4C427D484FF4F050F0AEC
```
* 有壳
```
signature,FSG 1.00 (Eng) -> dulek/xt
```
# 脱壳
## 寻找OEP
* 发现导入表里面有GetProcAddress,下断点,运行后发现这段代码:
```
004050C4 47 inc edi
004050C5 8B37 mov esi, dword ptr
004050C7 AF scas dword ptr es:
004050C8 57 push edi
004050C9 FF13 call dword ptr
004050CB 95 xchg eax, ebp
004050CC 33C0 xor eax, eax
004050CE AE scas byte ptr es:
004050CF^ 75 FD jnz short 004050CE
004050D1 FE0F dec byte ptr
004050D3^ 74 EF je short 004050C4
004050D5 FE0F dec byte ptr
004050D7 75 06 jnz short 004050DF
004050D9 47 inc edi
004050DA FF37 push dword ptr
004050DC AF scas dword ptr es:
004050DD EB 09 jmp short 004050E8
004050DF FE0F dec byte ptr
004050E1 >- 0F84 A9BFFFFF je 00401090
004050E7 57 push edi
004050E8 55 push ebp
004050E9 FF53 04 call dword ptr ; GetProcAddress
004050EC 0906 or dword ptr , eax ; ole32.OleInitialize
004050EE AD lods dword ptr
004050EF^ 75 DB jnz short 004050CC
```
* 发现这是一个循环,猜测是建立导入表,接着观察几个jmp jz jnz je跳转指令,发现下面的je最像tail jump
```
004050E1 >- 0F84 A9BFFFFF je 00401090
```
* 执行到疑似OEP(00401090),发现OD还没分析,选择analyze->analyze code,发现如下代码,应该就是OEP了:
```
00401090/.55 push ebp ;msvcrt.77650000
00401091|.8BEC mov ebp, esp
00401093|.6A FF push -1
00401095|.68 78204000 push 00402078
0040109A|.68 D0114000 push 004011D0 ;jmp to msvcrt._except_handler3; SE handler installation
0040109F|.64:A1 0000000>mov eax, dword ptr fs:
004010A5|.50 push eax
004010A6|.64:8925 00000>mov dword ptr fs:, esp
004010AD|.83EC 20 sub esp, 20
```
* dump进程。
## 重建输入表
* 试了一下工具imprec,不行,只能手工重建了。
* 用OD打开原程序,在GetProcAddress上下断点,再用IDA打开脱壳后的程序,找到函数地址表。
* 运行OD,在IDA的每个函数地址上对应写入OD里面的函数名,完成后差不多这样:
```
seg000:004011DC 00 00 00 00 00 00 00 00+ align 1000h
seg000:00402000 ; int _getmainargs
seg000:00402000 50 5C 68 77 __getmainargs dd 77685C50h ; DATA XREF: start+B5↑r
seg000:00402004 ; unsigned int controlfp
seg000:00402004 C0 9F 6E 77 _controlfp dd 776E9FC0h ; DATA XREF: j__controlfp↑r
seg000:00402008 E4 81 6A 77 _except_handler3 dd 776A81E4h ; DATA XREF: j__except_handler3↑r
seg000:0040200C 00 76 6A 77 __set_app_typedd 776A7600h ; DATA XREF: start+2C↑r
seg000:00402010 B0 5D 68 77 __p__fmode dd 77685DB0h ; DATA XREF: start+41↑r
seg000:00402014 60 5D 68 77 __p__commode dd 77685D60h ; DATA XREF: start+4F↑r
seg000:00402018 ; void __cdecl __noreturn exit(int)
seg000:00402018 10 61 6B 77 _exit dd 776B6110h ; DATA XREF: start+10A↑r
seg000:0040201C 40 4C 6A 77 _XcptFilter dd 776A4C40h ; DATA XREF: j__XcptFilter↑r
seg000:00402020 F0 66 6B 77 exit dd 776B66F0h ; DATA XREF: start+EA↑r
seg000:00402024 D0 5C 68 77 __p__initenv dd 77685CD0h ; DATA XREF: start+CA↑r
seg000:00402028 C0 64 6B 77 _initterm dd 776B64C0h ; DATA XREF: j__initterm↑r
seg000:0040202C 40 85 6E 77 __setusermatherr dd 776E8540h ; DATA XREF: start+7C↑r
seg000:00402030 E4 6B 70 77 _adjust_fdiv dd 77706BE4h ; DATA XREF: start+5D↑r
seg000:00402034 00 00 00 00 align 8
seg000:00402038 70 41 D4 76 dword_402038 dd 76D44170h ; DATA XREF: _main+36↑r
seg000:0040203C ; BSTR __stdcall SysAllocString(const OLECHAR *)
seg000:0040203C 10 E2 D4 76 SysAllocStringdd 76D4E210h ; DATA XREF: _main+50↑r
seg000:00402040 ; void __stdcall SysFreeString(BSTR)
seg000:00402040 80 E8 D4 76 SysFreeString dd 76D4E880h ; DATA XREF: _main+78↑r
seg000:00402044 00 00 00 00 align 8
seg000:00402048 ; HRESULT __stdcall OleInitialize(LPVOID pvReserved)
seg000:00402048 40 2E FA 74 OleInitialize dd 74FA2E40h ; DATA XREF: _main+5↑r
seg000:0040204C ; HRESULT __stdcall CoCreateInstance(const CLSID *const rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, const IID *const riid, LPVOID *ppv)
seg000:0040204C 70 30 A1 74 CoCreateInstance dd 74A13070h ; DATA XREF: _main+22↑r
seg000:00402050 ; void __stdcall OleUninitialize()
seg000:00402050 60 33 FA 74 OleUninitialize dd 74FA3360h ; DATA XREF: _main:loc_40107F↑r
seg000:00402054 00 00 00 00 align 8
```
* 这个过程很慢且麻烦,但我没想到其他更好的办法。。。
# IDA 分析
* 脱壳后很简单了,从main进去,发现用的COM:
```
lea eax,
push eax
push offset riid_IWebBrowser2
push 4 ; CLSCTX_LOCAL_SERVER = 0x4
push 0
push offset clsid_ie ; 2DF01h
call CoCreateInstance
```
* 逐条分析发现其会使用Navigate函数通过IE打开指定链接:
```
lea ecx,
push esi
push ecx
call dword_402038
push offset aHttpWwwMalware ; "http://www.malwareanalysisbook.com/ad.h"...
mov , 3
mov , 1
call SysAllocString
lea ecx,
mov esi, eax ; esi = newString
mov eax,
push ecx
lea ecx,
mov edx,
push ecx
lea ecx,
push ecx
lea ecx,
push ecx
push esi
push eax
call dword ptr ; Navigate
push esi
call SysFreeString
pop esi
```
# 总 结
这个lab的整个过程中,重建输入表比较麻烦,不知道有没有更好的方法。
该程序行为很简单,就是打开了指定的网页。 谢谢分享 感谢分享 谢谢大佬的分享,非常感谢 感谢分享 感谢大佬分享,佩服
感谢分享 感谢分分享~ 学习了。多来点素材 感谢分享
页:
[1]
2