Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nicer error when running tmux exploit outside tmux #2314

Merged
merged 1 commit into from Dec 6, 2023

Conversation

peace-maker
Copy link
Member

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.

from pwn import *
context.terminal = ['tmux', 'splitw', '-h']
gdb.debug('/bin/cat').interactive()
[+] Starting local process '/usr/bin/gdbserver': pid 3401
[*] running in new terminal: ['/usr/bin/gdb', '-q', '/bin/cat', '-x', '/tmp/pwni46_dcye.gdb']
Traceback (most recent call last):
  File "/home/peace/dev/pwntools/blabla.py", line 4, in <module>
    gdb.debug('/bin/cat').interactive()
  File "/home/peace/dev/pwntools/pwnlib/context/__init__.py", line 1581, in setter
    return function(*a, **kw)
  File "/home/peace/dev/pwntools/pwnlib/gdb.py", line 582, in debug
    tmp = attach((host, port), exe=exe, gdbscript=gdbscript, ssh=ssh, sysroot=sysroot, api=api)
  File "/home/peace/dev/pwntools/pwnlib/context/__init__.py", line 1581, in setter
    return function(*a, **kw)
  File "/home/peace/dev/pwntools/pwnlib/gdb.py", line 1100, in attach
    gdb_pid = misc.run_in_new_terminal(cmd, preexec_fn = preexec_fn)
  File "/home/peace/dev/pwntools/pwnlib/util/misc.py", line 413, in run_in_new_terminal
    pid = int(out)
ValueError: invalid literal for int() with base 10: b''
[*] Stopped process '/bin/cat' (pid 3404)

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.
@Arusekk Arusekk merged commit b1e2b56 into Gallopsled:dev Dec 6, 2023
10 of 11 checks passed
@peace-maker peace-maker deleted the run_tmux branch December 7, 2023 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants