1
2
3
4
5
6
7
8
9
import pefile

pe = pefile.PE("sample.exe")

# Print imported DLLs and functions
for entry in pe.DIRECTORY_ENTRY_IMPORT:
    print(f"[*] {entry.dll.decode()}")
    for imp in entry.imports:
        print(f"\t{hex(imp.address)}: {imp.name}")