MCPcopy
hub / github.com/Gallopsled/pwntools / run_shellcode

Function run_shellcode

pwnlib/runner.py:46–71  ·  view source on GitHub ↗

Given assembled machine code bytes, execute them. Example: >>> insn_bytes = asm('mov ebx, 3; mov eax, SYS_exit; int 0x80;') >>> p = run_shellcode(insn_bytes) >>> p.wait_for_close() >>> p.poll() 3 >>> insn_bytes = asm('mov r0, #12; mov r7, #1; sv

(bytes, **kw)

Source from the content-addressed store, hash-verified

44
45@LocalContext
46def run_shellcode(bytes, **kw):
47 """Given assembled machine code bytes, execute them.
48
49 Example:
50
51 >>> insn_bytes = asm('mov ebx, 3; mov eax, SYS_exit; int 0x80;')
52 >>> p = run_shellcode(insn_bytes)
53 >>> p.wait_for_close()
54 >>> p.poll()
55 3
56
57 >>> insn_bytes = asm('mov r0, #12; mov r7, #1; svc #0', arch='arm')
58 >>> p = run_shellcode(insn_bytes, arch='arm')
59 >>> p.wait_for_close()
60 >>> p.poll()
61 12
62 """
63 if context.os == 'darwin':
64 if sys.platform != 'darwin':
65 raise ValueError('Running Mach-O only supported on Darwin machines. Please use:\n'
66 '- https://github.com/MatthewCroughan/NixThePlanet\n'
67 '- https://github.com/sickcodes/Docker-OSX')
68 from pwnlib.asm import make_macho
69 return process(make_macho(bytes))
70
71 return ELF.from_bytes(bytes, **kw).process()
72
73@LocalContext
74def run_assembly_exitcode(assembly):

Callers 3

run_shellcode_exitcodeFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 4

processClass · 0.90
make_machoFunction · 0.90
from_bytesMethod · 0.80
processMethod · 0.45

Tested by

no test coverage detected