bannsec / autoPwn

Automate repetitive tasks for fuzzing
123 stars 31 forks source link

Use lief instead of patchkit for modifying entrypoint arguments #37

Open bannsec opened 4 years ago

bannsec commented 4 years ago

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)