[ERROR] Could not find a terminal binary to use. Set context.terminal to your terminal.问题的解决方案

背景

使用ssh连接远程服务器做pwn题,由于服务器上没有装gnome,所以在执行gdb.attach的时候会报错:

pwnlib.exception.PwnlibException: Could not find a terminal binary to use. Set context.terminal to your terminal.

在这里插入图片描述
解决方案是在代码的gdb.attach前添加一行代码,指定使用哪个terminal。
context.terminal = ['tmux','splitw','-h']

这里选择一般都会安装好了的tmux。后面两个参数表示水平分割窗口。然后gdb.attach无需改变(比如gdb.attach(io,gdbscript=“b main”),这里的io是之前通过io = process(’./xxxx’)获取的返回值)

最后然后要先运行tmux,在tmux里运行exp的python脚本。

如果修改后又再次报错:

ValueError: invalid literal for int() with base 10: b’’

在这里插入图片描述
这是pwntools早期存在的bug导致的,更新一下pwntools即可:pwn update 查看更新信息,然后pip install -U pwntools
在这里插入图片描述
下面是官方issue:

https://github.com/Gallopsled/pwntools/issues/1898

其他

  • 2021-7-18补充:这样做实际上没有解决问题。当在pwndbg使用c继续运行程序时,程序窗口仍处于Waiting for debugger的状态,不能进行输入。估计是没有做好subprocess的通讯功能。在这种情况下,可以在运行脚本后,通过ps -aux找到运行的那个二进制文件的pid,然后在另外一个窗口用gdb -p <pid>来直接attach到这个程序。(或者在gdb里面用attach <pid>的方式也行)。当然,exp脚本跑起来的时候也会输出这个程序的pid,不用ps -aux来找的。
  • 2021-7-18补充:新版的pwntools修复了misc的问题,不用手动改源码了(博客也随之更新)

---->安利一波自己总结的pwn知识点<----

猜你喜欢

转载自blog.csdn.net/weixin_43483799/article/details/118757637