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

Function _run

pwnlib/asm.py:421–450  ·  view source on GitHub ↗
(cmd, stdin = None)

Source from the content-addressed store, hash-verified

419 return arch
420
421def _run(cmd, stdin = None):
422 log.debug('%s', subprocess.list2cmdline(cmd))
423 try:
424 proc = subprocess.Popen(
425 cmd,
426 stdin = subprocess.PIPE,
427 stdout = subprocess.PIPE,
428 stderr = subprocess.PIPE,
429 universal_newlines = True
430 )
431 stdout, stderr = proc.communicate(stdin)
432 exitcode = proc.wait()
433 except OSError as e:
434 if e.errno == errno.ENOENT:
435 log.exception('Could not run %r the program', cmd[0])
436 else:
437 raise
438
439 if (exitcode, stderr) != (0, ''):
440 msg = 'There was an error running %r:\n'
441 args = cmd,
442 if exitcode != 0:
443 msg += 'It had the exitcode %d.\n'
444 args += exitcode,
445 if stderr != '':
446 msg += 'It had this on stdout:\n%s\n'
447 args += stderr,
448 log.error(msg, *args)
449
450 return stdout
451
452@LocalContext
453def cpp(shellcode):

Callers 5

cppFunction · 0.85
make_elfFunction · 0.85
make_machoFunction · 0.85
asmFunction · 0.85
disasmFunction · 0.85

Calls 5

communicateMethod · 0.80
exceptionMethod · 0.80
errorMethod · 0.80
debugMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected