Skip to content

Instantly share code, notes, and snippets.

@OALabs
Created December 1, 2019 05:12
Show Gist options
  • Save OALabs/94ff4fc02bf02d55a8161068cafd11c0 to your computer and use it in GitHub Desktop.
Save OALabs/94ff4fc02bf02d55a8161068cafd11c0 to your computer and use it in GitHub Desktop.

Revisions

  1. OALabs created this gist Dec 1, 2019.
    28 changes: 28 additions & 0 deletions dll_exports.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@

    import os
    import pefile
    import json

    INTERESTING_DLLS = [
    'kernel32.dll', 'comctl32.dll', 'advapi32.dll', 'comdlg32.dll',
    'gdi32.dll', 'msvcrt.dll', 'netapi32.dll', 'ntdll.dll',
    'ntoskrnl.exe', 'oleaut32.dll', 'psapi.dll', 'shell32.dll',
    'shlwapi.dll', 'srsvc.dll', 'urlmon.dll', 'user32.dll',
    'winhttp.dll', 'wininet.dll', 'ws2_32.dll', 'wship6.dll',
    'advpack.dll',
    ]


    exports_list = []

    for filename in os.listdir("C:\\Windows\\System32"):
    if filename.lower() in INTERESTING_DLLS:
    pe = pefile.PE("C:\\Windows\\System32\\" + filename)
    for exp in pe.DIRECTORY_ENTRY_EXPORT.symbols:
    try:
    exports_list.append(exp.name.decode('utf-8'))
    except:
    continue

    exports_json = {'exports':exports_list}
    open('exports.json','wb').write(json.dumps(exports_json))