Giter Club home page Giter Club logo

Comments (4)

Vccxx avatar Vccxx commented on July 18, 2024

It seems that it's not the problem of gdb , because I can attach the process outside the python script (using the gdb shell command).

It looks like the problem lies in the pwntools python lib, since I have found some issue about this problem in their repo:
pwntools issue

I have checked two elf files , one is 32 Bits ELF and another is 64 Bits ELF, and both of them can be debugged in the gdb in bash. The same error occur in both of them. So I believe it's not the problem of ELF file to be debug.

I still can't fix the gdb.attach problem in the py script. Hope an elegant way can be found to solve it .

from pwndocker.

skysider avatar skysider commented on July 18, 2024

@Vccxx , I test with latest docker environment and it seems that it reports the same problem but the debugger works.
I compile a test program in my docker environment and it suceeds:
test.c

#include <stdio.h>
int main()
{
    puts("test");
   getchar();
   puts("done");
}

and I run docker run -it --privileged skysider/pwndocker/ /bin/bash, and it works.
test

from pwndocker.

Vccxx avatar Vccxx commented on July 18, 2024

I have test your test program on my docker and it doesn't work , here is how I did:
Firstly I start the docker with command :
sudo docker run -it --privileged skysider/pwndocker /bin/bash
Secondly I compile the test.c file with gcc test.c -o test, which contains the following code:

#include <stdio.h>
int main()
{
    puts("test");
   getchar();
   puts("done");
}

Thirdly I write the exp.py:

from pwn import *
context.log_level = "debug"
context.terminal = ["tmux","splitw","-h"]
io = process("./test")
io.send("1")
gdb.attach(io)
io.interactive()

and then I run the exp.py , get stuck here:

root@d3f8a524e41e:/ctf/work# python3 test_exp.py 
[+] Starting local process './test' argv=[b'./test'] : pid 38
[DEBUG] Sent 0x1 bytes:
    49 * 0x1
[*] running in new terminal: /usr/bin/gdb -q  "./test" 38
[DEBUG] Launching a new terminal: ['/usr/bin/tmux', 'splitw', '-h', '/usr/bin/gdb -q  "./test" 38']
[-] Waiting for debugger: debugger exited! (maybe check /proc/sys/kernel/yama/ptrace_scope)

and after about 1 minute, the program just exit without debugger attached:

root@d3f8a524e41e:/ctf/work# python3 test_exp.py 
[+] Starting local process './test' argv=[b'./test'] : pid 38
[DEBUG] Sent 0x1 bytes:
    49 * 0x1
[*] running in new terminal: /usr/bin/gdb -q  "./test" 38
[DEBUG] Launching a new terminal: ['/usr/bin/tmux', 'splitw', '-h', '/usr/bin/gdb -q  "./test" 38']
[-] Waiting for debugger: debugger exited! (maybe check /proc/sys/kernel/yama/ptrace_scope)
[*] Switching to interactive mode
[*] Process './test' stopped with exit code 0 (pid 38)
[DEBUG] Received 0xa bytes:
    b'test\n'
    b'done\n'
test
done
[*] Got EOF while reading in interactive
$ 
[DEBUG] Sent 0x1 bytes:
    10 * 0x1
[*] Got EOF while sending in interactive

Would you please show me your exp.py? I think there maybe some coding problem.

from pwndocker.

Vccxx avatar Vccxx commented on July 18, 2024

OK, It turns out that I didn't run exp.py in a tmux terminal but in a bash terminal......

the debugger works fine in tmux terminal.

Thank you for your time.

from pwndocker.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.