(Python) DLL Proxying by Sh0ckFR

Created the Monday 25 July 2022. Updated 2 weeks, 4 days ago.

Description:

Basic python script to extract all exported functions of a targeted DLL, here DNSAPI.dll used by nslookup.exe.

Code

            import pefile

exported_functions = []
pe = pefile.PE('C:\\windows\\system32\\DNSAPI.dll')
for entry in pe.DIRECTORY_ENTRY_EXPORT.symbols:
    func = entry.name.decode('utf-8')
    exported_functions.append(f'#pragma comment(linker,"/export:{func}=proxy.{func},@{entry.ordinal}")')

exported_functions = '\n'.join(exported_functions)
print(exported_functions)