1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
import lief
from lief import Logger
Logger.set_level(lief.LOGGING_LEVEL.DEBUG)
from lief.ELF import Section
ls = lief.parse("/home/romain/dev/LIEF/lief-samples/ELF/ELF64_x86-64_binary_static-binary.bin")
stub = lief.parse("hello_lief.bin")
#section = Section()
#section.name = "test"
#section.type = lief.ELF.SECTION_TYPES.PROGBITS
#section.content = stub.segments[0].content # First LOAD segment which holds payload (bytes)
#section = ls.add(section, loaded=True)
#ls.header.entrypoint = section.virtual_address + stub.header.entrypoint
#
#ep = ls.header.entrypoint
for i in range(10):
segment = stub.segments[0]
original_va = segment.virtual_address
segment.virtual_address = 0
segment = ls.add(segment)
new_ep = (stub.header.entrypoint - original_va) + segment.virtual_address
ls.header.entrypoint = new_ep
ls.write("lst.section")
#print(hex(ep))
|