Skip to content

Commit 9b805b5

Browse files
committed
better error message when process creation fails in ssh.process
1 parent d9b3e17 commit 9b805b5

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

pwnlib/tubes/ssh.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -947,17 +947,19 @@ def process(self, argv=None, executable=None, tty=True, cwd=None, env=None, igno
947947
python = ssh_process(self, script, tty=True, cwd=cwd, raw=True, level=self.level, timeout=timeout)
948948

949949
try:
950-
python.recvline_contains(b'PWNTOOLS') # Magic flag so that any sh/bash initialization errors are swallowed
951-
python.recvline() # Python interpreter that was selected
950+
python.recvline_contains(b'PWNTOOLS') # Magic flag so that any sh/bash initialization errors are swallowed
951+
if not b'python' in python.recvline(): # Python interpreter that was selected
952+
self.warn_once('Could not find a Python interpreter on %s\n' % self.host
953+
+ "Use ssh.system() instead of ssh.process()\n")
954+
h.failure("Process creation failed")
955+
return None
956+
952957
result = safeeval.const(python.recvline()) # Status flag from the Python script
953958
except (EOFError, ValueError):
954959
h.failure("Process creation failed")
955-
self.warn_once('Could not find a Python interpreter on %s\n' % self.host
956-
+ "Use ssh.run() instead of ssh.process()\n"
957-
"The original error message:\n"
958-
+ python.recvall().decode())
959960
return None
960961

962+
961963
# If an error occurred, try to grab as much output
962964
# as we can.
963965
if result != 1:

0 commit comments

Comments
 (0)