From 15745671239f8d0a552dc30058a4f3903b71cc7e Mon Sep 17 00:00:00 2001 From: Mathias Svensson Date: Fri, 8 Jun 2018 16:43:02 +0200 Subject: [PATCH] Fix #1164 --- pwnlib/elf/elf.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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)