Skip to content

Instantly share code, notes, and snippets.

@hartwork
Forked from spookyahell/exe2version_info.py
Created November 3, 2023 15:17
Show Gist options
  • Save hartwork/1160bd55544670e39eae7915f5bbf6d7 to your computer and use it in GitHub Desktop.
Save hartwork/1160bd55544670e39eae7915f5bbf6d7 to your computer and use it in GitHub Desktop.
Using the python pefile lib to extract version information from an exe file
'''Licensed under the MIT License :)'''
import pefile
import pprint
pe = pefile.PE('example.exe')
string_version_info = {}
for fileinfo in pe.FileInfo[0]:
if fileinfo.Key.decode() == 'StringFileInfo':
for st in fileinfo.StringTable:
for entry in st.entries.items():
string_version_info[entry[0].decode()] = entry[1].decode()
pprint.pprint(string_version_info)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment