def debug_shellcode(data, gdbscript=None, vma=None): r"""debug_shellcode(data, gdbscript=None, vma=None) -> tube Creates an ELF file, and launches it under a debugger. Arguments: data(str): Assembled shellcode bytes gdbscript(str): Script to run in GDB vma(int): Base address to load the shellcode at \**kwargs: Override any :obj:`pwnlib.context.context` values. Returns: :class:`.process` Example: >>> assembly = shellcraft.echo("Hello world!\n") >>> shellcode = asm(assembly) >>> io = gdb.debug_shellcode(shellcode) >>> io.recvline() b'Hello world!\n' """ if isinstance(data, six.text_type): log.error( "Shellcode is cannot be unicode. Did you mean debug_assembly?") tmp_elf = make_elf(data, extract=False, vma=vma) os.chmod(tmp_elf, 0o777) atexit.register(lambda: os.unlink(tmp_elf)) if context.os == 'android': android_path = '/data/data/%s' % os.path.basename(tmp_elf) adb.push(tmp_elf, android_path) tmp_elf = android_path return debug(tmp_elf, gdbscript=gdbscript, arch=context.arch)
def debug_shellcode(data, gdbscript=None, vma=None): """ Creates an ELF file, and launches it under a debugger. Arguments: data(str): Assembled shellcode bytes gdbscript(str): Script to run in GDB vma(int): Base address to load the shellcode at **kwargs: Override any :obj:`.context` values. Returns: :class:`.process` """ if isinstance(data, unicode): log.error( "Shellcode is cannot be unicode. Did you mean debug_assembly?") tmp_elf = make_elf(data, extract=False, vma=vma) os.chmod(tmp_elf, 0777) atexit.register(lambda: os.unlink(tmp_elf)) if context.os == 'android': android_path = '/data/data/%s' % os.path.basename(tmp_elf) adb.push(tmp_elf, android_path) tmp_elf = android_path return debug(tmp_elf, gdbscript=gdbscript, arch=context.arch)
def debug_assembly(asm, gdbscript=None, vma=None): """debug_assembly(asm, gdbscript=None, vma=None) -> tube Creates an ELF file, and launches it under a debugger. This is identical to debug_shellcode, except that any defined symbols are available in GDB, and it saves you the explicit call to asm(). Arguments: asm(str): Assembly code to debug gdbscript(str): Script to run in GDB vma(int): Base address to load the shellcode at **kwargs: Override any :obj:`.context` values. Returns: :class:`.process` """ tmp_elf = make_elf_from_assembly(asm, vma=vma, extract=False) os.chmod(tmp_elf, 0777) atexit.register(lambda: os.unlink(tmp_elf)) if context.os == 'android': android_path = '/data/data/%s' % os.path.basename(tmp_elf) adb.push(tmp_elf, android_path) tmp_elf = android_path return debug(tmp_elf, gdbscript=gdbscript, arch=context.arch)
def debug_shellcode(data, gdbscript=None, vma=None): """ Creates an ELF file, and launches it under a debugger. Arguments: data(str): Assembled shellcode bytes gdbscript(str): Script to run in GDB vma(int): Base address to load the shellcode at **kwargs: Override any :obj:`.context` values. Returns: :class:`.process` """ if isinstance(data, unicode): log.error("Shellcode is cannot be unicode. Did you mean debug_assembly?") tmp_elf = make_elf(data, extract=False, vma=vma) os.chmod(tmp_elf, 0777) atexit.register(lambda: os.unlink(tmp_elf)) if context.os == 'android': android_path = '/data/data/%s' % os.path.basename(tmp_elf) adb.push(tmp_elf, android_path) tmp_elf = android_path return debug(tmp_elf, gdbscript=gdbscript, arch=context.arch)
def debug_assembly(asm, gdbscript=None, vma=None, api=False): r"""debug_assembly(asm, gdbscript=None, vma=None, api=False) -> tube Creates an ELF file, and launches it under a debugger. This is identical to debug_shellcode, except that any defined symbols are available in GDB, and it saves you the explicit call to asm(). Arguments: asm(str): Assembly code to debug gdbscript(str): Script to run in GDB vma(int): Base address to load the shellcode at api(bool): Enable access to GDB Python API \**kwargs: Override any :obj:`pwnlib.context.context` values. Returns: :class:`.process` Example: >>> assembly = shellcraft.echo("Hello world!\n") >>> io = gdb.debug_assembly(assembly) >>> io.recvline() b'Hello world!\n' """ tmp_elf = make_elf_from_assembly(asm, vma=vma, extract=False) os.chmod(tmp_elf, 0o777) atexit.register(lambda: os.unlink(tmp_elf)) if context.os == 'android': android_path = '/data/data/%s' % os.path.basename(tmp_elf) adb.push(tmp_elf, android_path) tmp_elf = android_path return debug(tmp_elf, gdbscript=gdbscript, arch=context.arch, api=api)