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

problem about using tmux while debugging #1927

Closed
chujDK opened this issue Jul 3, 2021 · 1 comment
Closed

problem about using tmux while debugging #1927

chujDK opened this issue Jul 3, 2021 · 1 comment
Labels

Comments

@chujDK
Copy link

chujDK commented Jul 3, 2021

Hello, I have been using tmux and gdb as the debugger to debug for a while. However i got error while using it now.

I wrote my exp with following method

  • fisrtly, set the terminal
    context.terminal = ["tmux", 'splitw', '-h']
  • secondly use gdb.attach to attach the program
sh = process("...")
...
gdb.attach(proc.pidof(sh)[0])

it used work, but now i get error like

[DEBUG] Launching a new terminal: ['/usr/bin/tmux', 'splitw', '-h', '/usr/bin/gdb -q  "/home/chuj/com/TCTF/LB/listbook" 19995']              
Traceback (most recent call last):                                                                                                           
  File "listbook_exp.py", line 37, in <module>                                                                                               
    gdb.attach(proc.pidof(sh)[0])                                                                                                            
  File "/home/chuj/.local/lib/python2.7/site-packages/pwnlib/context/__init__.py", line 1543, in setter                                      
    return function(*a, **kw)                                                                                                                
  File "/home/chuj/.local/lib/python2.7/site-packages/pwnlib/gdb.py", line 1051, in attach                                                   
    gdb_pid = misc.run_in_new_terminal(cmd, preexec_fn = preexec_fn)                                                                         
  File "/home/chuj/.local/lib/python2.7/site-packages/pwnlib/util/misc.py", line 297, in run_in_new_terminal                                 
    pid = int(out)                                                                                                                           
ValueError: invalid literal for int() with base 10: '' 

I found the problem is caused by int() function, so i changed site-packages/pwnlib/util/misc.py to that

     if terminal == 'tmux':                                                                                                                                                                                                                                                            
         out, _ = p.communicate()                                                                                                                                                                                                                                                               
         # pid = int(out)                                                                                                                                                                                                                                                                         
         pid = out       

and now it can work. Could you tell me what cause this problem? Is it a bug or my exp's fault?

@chujDK chujDK added the question label Jul 3, 2021
@Arusekk
Copy link
Member

Arusekk commented Jul 3, 2021

Fixed by #1902. Either update (can't remember which version, but dev certainly has it), or use a workaround mentioned here: #1874 (comment)

@Arusekk Arusekk closed this as completed Jul 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants