diff --git a/pwnlib/elf/elf.py b/pwnlib/elf/elf.py index 42d2dff35..8c931be6c 100644 --- a/pwnlib/elf/elf.py +++ b/pwnlib/elf/elf.py @@ -926,10 +926,12 @@ def search(self, needle, writable = False): for seg in segments: addr = seg.header.p_vaddr memsz = seg.header.p_memsz - zeroed = memsz - seg.header.p_filesz + filesz = seg.header.p_filesz + zeroed = memsz - filesz offset = seg.header.p_offset - data = self.mmap[offset:offset+memsz] + data = self.mmap[offset:offset+filesz] data += '\x00' * zeroed + assert len(data) == memsz offset = 0 while True: offset = data.find(needle, offset)