Пример #1
0
    def __init__(self, binary: ELF, command=None):
        default_command = "/bin/touch /tmp/foobar-" + "".join(
            random.sample(string.ascii_letters, 5))

        self._chain = None
        self._offsets = None
        self._command = command or default_command

        with context.local():
            context.log_level = "WARNING"  # Suppress ELF metadata print from pwntools
            if isinstance(binary, str):
                if os.path.isfile(binary):
                    self.binary = binary = ELF(binary)
            if not isinstance(binary, ELF):
                self.binary = binary = ELF.from_bytes(b"\x90" * 262144,
                                                      vma=0x8048000)
                self.rop = ROP([binary])
            else:
                self.binary = binary
                context.binary = self.binary.path
                self.rop = ROP([binary])
                context.arch = _bfdarch_patch()
                self.context = context

                self.build_offsets()