Closed Xunflash closed 1 week ago
I can't attach to gdb, details on the outputs below:
from pwn import * context.log_level='debug' # context.terminal=['cmd.exe', '/c', 'start', 'wsl.exe', '--', 'sudo', 'su', '-c'] #use this line can attach to su gdb sh = process("./challenge") gdb.attach(sh)
If this is your whole script, the problem is that your exploit script terminates and takes the target process with it before gdb has a chance to attach. Usually adding a p.interactive()
call at the end helps. Try adding a pause()
call after your gdb.attach
or use gdb.debug
instead to avoid race conditions.
A different issue appears to be the wait_for_debugger
helper failing for you.
[-] Waiting for debugger: debugger exited!
That should block execution in your exploit script until the debugger is actually attached. If you manage to fix it, please open a pull request! https://github.com/Gallopsled/pwntools/blob/d7817a7eaccb9baacb121131ec913cf0a14a1f05/pwnlib/util/proc.py#L391
If this is your whole script
Actually it's not the whole script. I omitted some code.
A different issue appears to be the
wait_for_debugger
helper failing for you.[-] Waiting for debugger: debugger exited!
That should block execution in your exploit script
I think here is the key point.(This may be caused by the ptrace error) Actually I need to add a "-- sudo" to the context.terminal so that I can temporarily attach to the gdb. But this means I need to prefix each script with context.terminal. I think it maybe a issue that associated with WSL.
I can't attach to gdb, details on the outputs below:
and I get the following output
I searched the error (ptrace: Operation not permitted.) on google and I found the following wiki: https://github.com/Microsoft/MIEngine/wiki/Troubleshoot-attaching-to-processes-using-GDB
so I exeuted the second option's command because my wsl don't support yama (it shows "no such file or directory.")
sudo setcap cap_sys_ptrace=eip /usr/bin/gdb
But still not working.