mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-19 19:13:22 +08:00
[+] added: windbg snippet displaying list of export for module
git-svn-id: https://pykd.svn.codeplex.com/svn@57286 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
69e93336d9
commit
5101d95766
55
snippets/export.py
Normal file
55
snippets/export.py
Normal file
@ -0,0 +1,55 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
import sys
|
||||
import fnmatch
|
||||
from pykd import *
|
||||
|
||||
|
||||
def export( moduleName, mask = "*" ):
|
||||
|
||||
module = loadModule( moduleName )
|
||||
dprintln( "Module: " + moduleName + " base: %x" % module.begin() + " end: %x" % module.end() )
|
||||
|
||||
dosHeader = typedVar( "nt", "_IMAGE_DOS_HEADER", module.begin() )
|
||||
|
||||
if is64bitSystem():
|
||||
ntHeader = typedVar( "nt", "_IMAGE_NT_HEADERS64", module.begin() + dosHeader.e_lfanew )
|
||||
else:
|
||||
ntHeader = typedVar( "nt", "_IMAGE_NT_HEADERS", module.begin() + dosHeader.e_lfanew )
|
||||
|
||||
|
||||
dprintln( "Export RVA: %x Size: %x" % ( ntHeader.OptionalHeader.DataDirectory[0].VirtualAddress, ntHeader.OptionalHeader.DataDirectory[0].Size ) )
|
||||
dprintln( "========================" )
|
||||
|
||||
exportDirAddr = module.begin() + ntHeader.OptionalHeader.DataDirectory[0].VirtualAddress;
|
||||
|
||||
namesCount = ptrDWord( exportDirAddr + 0x18 )
|
||||
|
||||
namesRva = module.begin() + ptrDWord( exportDirAddr + 0x20 )
|
||||
|
||||
for i in range( 0, namesCount ):
|
||||
exportName = loadCStr( module.begin() + ptrDWord( namesRva + 4 * i ) )
|
||||
if fnmatch.fnmatch( exportName, mask ):
|
||||
dprintln( exportName )
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
if not isSessionStart():
|
||||
print "script is launch out of windbg"
|
||||
quit( 0 )
|
||||
|
||||
if len( sys.argv ) == 1:
|
||||
|
||||
if sys.argv[0]=="":
|
||||
dprintln( "module name not found" )
|
||||
else:
|
||||
export( sys.argv[0] )
|
||||
|
||||
else:
|
||||
|
||||
export( sys.argv[0], sys.argv[1] )
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user