Skip to content

Instantly share code, notes, and snippets.

@kohnakagawa
Created May 30, 2020 07:00
Show Gist options
  • Save kohnakagawa/136d395db998b8544e504874074b8ba8 to your computer and use it in GitHub Desktop.
Save kohnakagawa/136d395db998b8544e504874074b8ba8 to your computer and use it in GitHub Desktop.
LIEF rebuild PE
import lief
lief.Logger.set_level(lief.LOGGING_LEVEL.DEBUG)
fileParsed = lief.parse("calc.exe")
builder = lief.PE.Builder(fileParsed)
# Configure it to rebuild and patch the imports
builder.build_imports(True).patch_imports(True)
# builder.build_imports(False).patch_imports(False)
# Build !
builder.build()
# Save the result
builder.write("calc_patched.exe")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment