Created
January 26, 2020 10:30
-
-
Save Barakat/e20ec993748c6ab382d727f08eaa523e to your computer and use it in GitHub Desktop.
Locating PDB file URL in Microsoft Symbol Server
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
#!python3 | |
import pefile | |
SYMBOLS_SERVER = 'https://msdl.microsoft.com/download/symbols' | |
def main(): | |
pe = pefile.PE('C:/Windows/System32/kernel32.dll', fast_load=True) | |
pe.parse_data_directories() | |
for directory in pe.DIRECTORY_ENTRY_DEBUG: | |
debug_entry = directory.entry | |
if hasattr(debug_entry, 'PdbFileName'): | |
pdb_file = debug_entry.PdbFileName[:-1].decode('ascii') | |
guid = f'{debug_entry.Signature_Data1:08x}' | |
guid += f'{debug_entry.Signature_Data2:04x}' | |
guid += f'{debug_entry.Signature_Data3:04x}' | |
guid += f'{int.from_bytes(debug_entry.Signature_Data4, byteorder="big"):016x}' | |
guid = guid.upper() | |
url = f'{SYMBOLS_SERVER}/{pdb_file}/{guid}{debug_entry.Age:x}/{pdb_file}' | |
print(url) | |
if __name__ == '__main__': | |
main() | |
# https://msdl.microsoft.com/download/symbols/kernel32.pdb/5A77DE8CE8D58731F0EA38F1C92F48D81/kernel32.pdb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment