Created
November 1, 2014 11:06
-
-
Save securitytube/bac5d8228b49caa5c3ee to your computer and use it in GitHub Desktop.
Export DLL Functions into a DEF file for use with Mingw32/64
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
""" | |
Author - Vivek Ramachandran | |
Learn Pentesting Online -- http://PentesterAcademy.com/topics and http://SecurityTube-Training.com | |
Free Infosec Videos -- http://SecurityTube.net | |
""" | |
import sys, pefile | |
dllName = sys.argv[1] | |
newDllName = sys.argv[2].replace(".dll", "") | |
pe = pefile.PE(dllName) | |
if not hasattr(pe, 'DIRECTORY_ENTRY_EXPORT') : | |
print "No Export table! Is this a DLL??" | |
sys.exit(-1) | |
# Lets create a DEF file for gcc/ld (mingw) | |
print "LIBRARY \"" + dllName.replace(".dll","") + "\"" | |
print "EXPORTS\n" | |
for exp in pe.DIRECTORY_ENTRY_EXPORT.symbols: | |
if exp.name : | |
print "%s=%s.%s @%d" % (exp.name, newDllName, exp.name, exp.ordinal) | |
else : | |
print "ord%d=%s.ord%d @%d NONAME" %(exp.ordinal, newDllName, exp.ordinal, exp.ordinal) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment