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

Function cpp

pwnlib/asm.py:453–492  ·  view source on GitHub ↗

r"""cpp(shellcode, ...) -> str Runs CPP over the given shellcode. The output will always contain exactly one newline at the end. Arguments: shellcode(str): Shellcode to preprocess Kwargs: Any arguments/properties that can be set on ``context`` Examples:

(shellcode)

Source from the content-addressed store, hash-verified

451
452@LocalContext
453def cpp(shellcode):
454 r"""cpp(shellcode, ...) -> str
455
456 Runs CPP over the given shellcode.
457
458 The output will always contain exactly one newline at the end.
459
460 Arguments:
461 shellcode(str): Shellcode to preprocess
462
463 Kwargs:
464 Any arguments/properties that can be set on ``context``
465
466 Examples:
467
468 >>> cpp("mov al, SYS_setresuid", arch = "i386", os = "linux")
469 'mov al, 164\n'
470 >>> cpp("weee SYS_setresuid", arch = "arm", os = "linux")
471 'weee (0+164)\n'
472 >>> cpp("SYS_setresuid", arch = "thumb", os = "linux")
473 '(0+164)\n'
474 >>> cpp("SYS_setresuid", os = "freebsd")
475 '311\n'
476 """
477 if platform.system() == 'Windows':
478 cpp = which_binutils('cpp')
479 else:
480 cpp = 'cpp'
481
482 code = _include_header() + shellcode
483 cmd = [
484 cpp,
485 '-Wno-unused-command-line-argument',
486 '-C',
487 '-nostdinc',
488 '-undef',
489 '-P',
490 '-I' + _incdir,
491 ]
492 return _run(cmd, code).strip('\n').rstrip() + '\n'
493
494
495@LocalContext

Callers 4

make_machoFunction · 0.85
asmFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 4

which_binutilsFunction · 0.85
_include_headerFunction · 0.85
_runFunction · 0.85
systemMethod · 0.80

Tested by

no test coverage detected