Gallopsled / pwntools

CTF framework and exploit development library
http://pwntools.com
Other
11.74k stars 1.67k forks source link

fix: x-terminal does not work properly gdb.attach #2359

Closed cnitlrt closed 4 months ago

cnitlrt commented 4 months ago

env

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.6 LTS
Release:    20.04
Codename:   focal
python --version                                                                                                                                                      130 ↵
Python 3.8.10

When I tried to use attach in x-terminal, I found that I could not attach normally. After attaching, it always ran the script directly. Through tracing, I found that run_in_new_terminal returned the wrong gdb_pid.

//gcc test.c -o 1
#include <stdio.h>
int main(){
    puts("hello world");
    char buf[0x20] = {0};
    read(0,buf,0x20);
    puts("hello world");
    read(0,buf,0x20);
}

test.py

from pwn import*
context.log_level = "debug"
# context.terminal = ["tmux","split","-h"]
p = process('./1')
p.send("bbbb")
attach(p)
p.send("aaaa")
p.interactive()

image