pwntools中使用tmux和gdb attach时Waiting for debugger无限等待的解决方案
First Post: Last Update: Word Count:
266
Read Time:
1 min
pwntools中使用tmux和gdb attach时Waiting for debugger无限等待的解决方案
解决方案 那么稍微修改一下源码即可。即找到了tracer就不用在while了,直接退出循环就完事了~ vim /usr/local/lib/python3.6/dist-packages/pwnlib/util/proc.py,然后把wait_for_debugger函数换成下面这个。(其实只改动了一小点,所以手动修改两三行就行)
Sleeps until the process with PID `pid` is being traced. If debugger_pid is set and debugger exits, raises an error. Arguments: pid (int): PID of the process. Returns: None """ t = Timeout() with t.countdown(timeout=15): with log.waitfor('Waiting for debugger') as l: while debugger_pid: debugger = psutil.Process(debugger_pid) #while t.timeout and tracer(pid) is None: # 新增加 if tracer(pid) isnotNone: break try: debugger.wait(0.01) except psutil.TimeoutExpired: pass else: debugger_pid = 0 else: while t.timeout and tracer(pid) isNone: time.sleep(0.01)
if tracer(pid): l.success() elif debugger_pid == 0: l.failure("debugger exited! (maybe check /proc/sys/kernel/yama/ptrace_scope)") else: l.failure('Debugger did not attach to pid %d within 15 seconds', pid)