Created
March 22, 2016 17:59
-
-
Save mgeeky/7a9930f8f036c889e3f5 to your computer and use it in GitHub Desktop.
Lists imported modules from all of the PE EXE/DLL files along the specified path. Helpful when looking for DLL Search-Order Hijacking weak points.
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
import sys | |
import os | |
import pefile | |
rootPath = sys.argv[1] | |
modules = set() | |
def scanFile(f): | |
try: | |
pe = pefile.PE(f) | |
for entry in pe.DIRECTORY_ENTRY_IMPORT: | |
modules.add(entry.dll) | |
except: | |
pass | |
for root, dirs, files in os.walk(rootPath): | |
path = root.split('/') | |
for file in files: | |
scanFile(root + '\\' + file) | |
for mod in modules: | |
print mod |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment