Skip to content

Use lief instead of patchkit for modifying entrypoint arguments #37

@bannsec

Description

@bannsec

patchkit is still stuck on python2, which is both obsolete and actively being pushed out of major distros like ubuntu. Better path forward is to use lief to update the binary the way i want.

ls = lief.parse("./ls")

section = Section(".injected.entry", lief.ELF.SECTION_TYPES.PROGBITS)
section += lief.ELF.SECTION_FLAGS.EXECINSTR
section += lief.ELF.SECTION_FLAGS.WRITE
section.content   =  [] # int array of bytes goes here
section = ls.add(section, loaded=True)
ls.header.entrypoint = section.virtual_address + STUB.header.entrypoint

ls.write(output)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions