pwnlib.runner — Running Shellcode

pwnlib.runner.run_assembly(*a, **kw)[source]

Given an assembly listing, assemble and execute it.

Returns:A pwnlib.tubes.process.process tube to interact with the process.

Example

>>> p = run_assembly('mov ebx, 3; mov eax, SYS_exit; int 0x80;')
>>> p.wait_for_close()
>>> p.poll()
3
>>> p = run_assembly('mov r0, #12; mov r7, #1; svc #0', arch='arm')
>>> p.wait_for_close()
>>> p.poll()
12
pwnlib.runner.run_shellcode(*a, **kw)[source]

Given assembled machine code bytes, execute them.

Example

>>> bytes = asm('mov ebx, 3; mov eax, SYS_exit; int 0x80;')
>>> p = run_shellcode(bytes)
>>> p.wait_for_close()
>>> p.poll()
3
>>> bytes = asm('mov r0, #12; mov r7, #1; svc #0', arch='arm')
>>> p = run_shellcode(bytes, arch='arm')
>>> p.wait_for_close()
>>> p.poll()
12
pwnlib.runner.run_assembly_exitcode(*a, **kw)[source]

Given an assembly listing, assemble and execute it, and wait for the process to die.

Returns:The exit code of the process.

Example

>>> run_assembly_exitcode('mov ebx, 3; mov eax, SYS_exit; int 0x80;')
3
pwnlib.runner.run_shellcode_exitcode(*a, **kw)[source]

Given assembled machine code bytes, execute them, and wait for the process to die.

Returns:The exit code of the process.

Example

>>> bytes = asm('mov ebx, 3; mov eax, SYS_exit; int 0x80;')
>>> run_shellcode_exitcode(bytes)
3