From b1e2b56445f7b100ab448f834de8027e5f597e23 Mon Sep 17 00:00:00 2001 From: peace-maker Date: Wed, 6 Dec 2023 23:48:33 +0100 Subject: [PATCH] Nicer error when running tmux exploit outside tmux (#2314) When you set the `context.terminal` to be tmux related but then try to run the exploit outside a tmux session, you'd get a cryptic ValueError while trying to parse the pid of the new pane in tmux. Print a nicer reminder to start tmux first. --- pwnlib/util/misc.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pwnlib/util/misc.py b/pwnlib/util/misc.py index f0ee62d96b..7977f7a776 100644 --- a/pwnlib/util/misc.py +++ b/pwnlib/util/misc.py @@ -410,7 +410,12 @@ def run_in_new_terminal(command, terminal=None, args=None, kill_at_exit=True, pr if terminal == 'tmux': out, _ = p.communicate() - pid = int(out) + try: + pid = int(out) + except ValueError: + pid = None + if pid is None: + log.error("Could not parse PID from tmux output (%r). Start tmux first.", out) elif terminal == 'qdbus': with subprocess.Popen((qdbus, konsole_dbus_service, '/Sessions/{}'.format(last_konsole_session), 'org.kde.konsole.Session.processId'), stdout=subprocess.PIPE) as proc: