Skip to content

Instantly share code, notes, and snippets.

@rmkanda
Created June 6, 2024 10:13
Show Gist options
  • Save rmkanda/32ca4c863af9307d900bb20daced681d to your computer and use it in GitHub Desktop.
Save rmkanda/32ca4c863af9307d900bb20daced681d to your computer and use it in GitHub Desktop.
DLL File info - pefile
import pefile
import os
def print_version_info(pe):
for fileinfo in pe.FileInfo[0]:
if fileinfo.Key.decode() == 'StringFileInfo':
for st in fileinfo.StringTable:
for entry in st.entries.items():
print(f"{entry[0].decode()}: {entry[1].decode()}")
BASE_PATH = "./test"
DLLS = [
"System.CodeDom.dll",
"System.IO.Ports.dll"
]
for dll in DLLS:
print(f"File: {dll}")
dll_file = f"{BASE_PATH}/{dll}"
if os.path.exists(dll_file):
pe = pefile.PE(dll_file)
print_version_info(pe)
print("\n\n")
pe.close()
else:
print(f"File {dll} does not exist.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment