使用WinDbg分析PE文件

参考:http://www.cnblogs.com/kekec/archive/2012/12/02/2798020.html

 

1. 设置符号路径

首先创建文件夹“C:/symbols”,在File->Symbol File Path打开的窗口中输入:

SRV*C:\symbols*http://msdl.microsoft.com/download/symbols

勾选“reload”,应用。

 

然后打开目标PE文件,在命令窗口中输入:

.reload /f

当然要保证联网,这时到刚刚创建的文件夹中查看,会发现正在从网络上不断地拖符号文件下来。

0:000> lm
start    end        module name
00400000 00880000   image00400000 C (no symbols)           
41d50000 41d95000   iertutil   (pdb symbols)          c:\symbols\iertutil.pdb\2EAE9E11BD4F4427A6788C8EE6511EBE2\iertutil.pdb
420b0000 421d7000   URLMON     (pdb symbols)          c:\symbols\urlmon.pdb\9EFDA53CEB064F81B2385593CCEA67C32\urlmon.pdb
72f70000 72f96000   winspool   (pdb symbols)          c:\symbols\winspool.pdb\97A6ECC94EA7450CA7D375BD9DFFCA5E2\winspool.pdb
762f0000 762f5000   msimg32    (pdb symbols)          c:\symbols\msimg32.pdb\E28D4258D66B428EB5D74279EB57A08F2\msimg32.pdb
76750000 76759000   SHFolder   (pdb symbols)          c:\symbols\shfolder.pdb\E263EAC1C88E4A3FA4F533C546F6043C2\shfolder.pdb
76990000 76acd000   ole32      (pdb symbols)          c:\symbols\ole32.pdb\49AF042E8EC54047B6159C917F0DE6B42\ole32.pdb
770f0000 7717b000   oleaut32   (pdb symbols)          c:\symbols\oleaut32.pdb\802CBE0411A943A489A734B989E3EC502\oleaut32.pdb
77180000 77283000   comctl32   (pdb symbols)          c:\symbols\MicrosoftWindowsCommon-Controls-6.0.2600.2982-comctl32.pdb\C0A72EE9578847AAB7770CF02FFED0941\MicrosoftWindowsCommon-Controls-6.0.2600.2982-comctl32.pdb
77bd0000 77bd8000   version    (pdb symbols)          c:\symbols\version.pdb\180A90C40384463E82DDC45B2C8AB76E2\version.pdb
77be0000 77c38000   msvcrt     (pdb symbols)          c:\symbols\msvcrt.pdb\A678F3C30DED426B839032B996987E381\msvcrt.pdb
77d10000 77da0000   USER32     (pdb symbols)          c:\symbols\user32.pdb\F049F32D0C8948C0B48F7A065FC5C1B12\user32.pdb
77da0000 77e49000   ADVAPI32   (pdb symbols)          c:\symbols\advapi32.pdb\455D6C5F184D45BBB5C5F30F829751142\advapi32.pdb
77e50000 77ee1000   RPCRT4     (pdb symbols)          c:\symbols\rpcrt4.pdb\436F11D9044249B8AB818CAD4D9079E72\rpcrt4.pdb
77ef0000 77f37000   GDI32      (pdb symbols)          c:\symbols\gdi32.pdb\E146EA5033F543F1881E37D6702DFF892\gdi32.pdb
77f40000 77fb6000   SHLWAPI    (pdb symbols)          c:\symbols\shlwapi.pdb\658B2B7C863842A0BE311E436027F6E32\shlwapi.pdb
7c800000 7c91d000   kernel32   (pdb symbols)          c:\symbols\kernel32.pdb\006D2240474D414087FF801C64935DDD2\kernel32.pdb
7c920000 7c9b4000   ntdll      (pdb symbols)          c:\symbols\ntdll.pdb\36515FB5D04345E491F672FA2E2878C02\ntdll.pdb
7d590000 7dd84000   shell32    (pdb symbols)          c:\symbols\shell32.pdb\9A8D69139E21498F9FFDA33E5E27AE622\shell32.pdb

如果不执行.reload命令,那么大部分module的符号都处于“(Deffered)”的状态。

接下来,我们可以查看这些符号文件中都有哪些符号了:

x URLMON!*

会输出一大摊结果,很难找到我们感兴趣的符号,因此可以先使用CFF Explorer(http://www.ntcore.com/exsuite.php)查找一下目标PE文件的导入表,再找到我们关心的符号:

0:000> x URLMON!URLDownloadToFileW
42137840          URLMON!URLDownloadToFileW = <no type information>
0:000> bp URLMON!URLDownloadToFileW
0:000> bl
 0 e 42137840     0001 (0001)  0:**** URLMON!URLDownloadToFileW

我们可以Ctrl+Break键,将正在运行的目标程序断下来,然后查看线程的栈,可以使用~[thread index]来指定查看哪个线程的栈,*代表所有线程。

0:001> ~* kv
 
   0  Id: 6c4.564 Suspend: 1 Teb: 7ffde000 Unfrozen
ChildEBP RetAddr  Args to Child              
0012ff1c 77d19408 005833d6 0012ff7c 005833f1 ntdll!KiFastSystemCallRet (FPO: [0,0,0])
0012ff50 005825fc 001c0266 00000113 00000001 USER32!NtUserWaitMessage+0xc
WARNING: Stack unwind information not available. Following frames may be wrong.
0012ffa4 007d397e 7ffdf000 0012ffe0 00407f1c image00400000+0x1825fc
0012ffc0 7c816ff7 00fff600 00fff5dc 7ffdf000 image00400000+0x3d397e
0012fff0 00000000 007d3924 00000000 78746341 kernel32!BaseProcessStart+0x23 (FPO: [Non-Fpo])
 
#  1  Id: 6c4.654 Suspend: 1 Teb: 7ffdd000 Unfrozen
ChildEBP RetAddr  Args to Child              
014affc8 7c9707a8 00000005 00000004 00000001 ntdll!DbgBreakPoint (FPO: [0,0,0])
014afff4 00000000 00000000 00000000 00000000 ntdll!DbgUiRemoteBreakin+0x2d (FPO: [Non-Fpo])
0:001> ~0 kv
ChildEBP RetAddr  Args to Child              
0012ff1c 77d19408 005833d6 0012ff7c 005833f1 ntdll!KiFastSystemCallRet (FPO: [0,0,0])
0012ff50 005825fc 001c0266 00000113 00000001 USER32!NtUserWaitMessage+0xc
WARNING: Stack unwind information not available. Following frames may be wrong.
0012ffa4 007d397e 7ffdf000 0012ffe0 00407f1c image00400000+0x1825fc
0012ffc0 7c816ff7 00fff600 00fff5dc 7ffdf000 image00400000+0x3d397e
0012fff0 00000000 007d3924 00000000 78746341 kernel32!BaseProcessStart+0x23 (FPO: [Non-Fpo])
0:001> ~1 kv
ChildEBP RetAddr  Args to Child              
014affc8 7c9707a8 00000005 00000004 00000001 ntdll!DbgBreakPoint (FPO: [0,0,0])
014afff4 00000000 00000000 00000000 00000000 ntdll!DbgUiRemoteBreakin+0x2d (FPO: [Non-Fpo])

使用WinDbg分析PE文件,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。