Created
January 17, 2020 10:00
-
-
Save hacksysteam/47d407674e9cc9101c168a94655a5ec4 to your computer and use it in GitHub Desktop.
List Imports from DLL or EXE
This file contains 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
import sys | |
import pefile | |
import glob | |
if len(sys.argv) < 2: | |
print "{0} <dll name>".format(sys.argv[0]) | |
sys.exit(-1) | |
target_dll = sys.argv[1] | |
system_path = "C:\\Windows\\System32\\*" | |
# find all the dlls | |
system_files = glob.glob(system_path) | |
# load all dlls in pefile | |
for f in system_files: | |
try: | |
pe = pefile.PE(f, fast_load=True) | |
pe.parse_data_directories() | |
for entry in pe.DIRECTORY_ENTRY_IMPORT: | |
if entry.dll.decode('utf-8') == target_dll: | |
print f, "-->", entry.dll.decode('utf-8') | |
for func in entry.imports: | |
print "\t%s" % func.name.decode('utf-8') | |
except Exception as ex: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment