'search(needle, writable = False) -> generator
Search the ELF\'s virtual address space for the specified string.
Notes:
Does not search empty space between segments, or uninitialized
data.  This will only return data that actually exists in the
ELF file.  Searching for a long string of NULL bytes probably
won\'t work.
Arguments:
needle(str): String to search for.
writable(bool): Search only writable sections.
Yields:
An iterator for each virtual address that matches.
Examples:
An ELF header starts with the bytes ``\x7fELF``, so we
sould be able to find it easily.
>>> bash = ELF(\'/bin/bash\')
>>> bash.address + 1 == next(bash.search(\'ELF\'))
True
We can also search for string the binary.
>>> len(list(bash.search(\'GNU bash\'))) > 0
True'

def search(self, needle, writable=False):

    load_address_fixup = (self.address - self.load_addr)
    if writable:
        segments = self.writable_segments
    else:
        segments = self.segments
    for seg in segments:
        addr = seg.header.p_vaddr
        memsz = seg.header.p_memsz
        zeroed = (memsz - seg.header.p_filesz)
        offset = seg.header.p_offset
        data = self.mmap[offset:(offset + memsz)]
        data += ('\x00' * zeroed)
        offset = 0
        while True:
            offset = data.find(needle, offset)
            if (offset == (-1)):
                break
            (yield ((addr + offset) + load_address_fixup))
            offset += 1
