You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
wsl1 needs sudo for gdb; using pwntools with sudo will cause wsl detection to fail. Options include:
ignoring this. Perhaps sudo should have its PATH corrected, and this is a user/wsl issue
adding sudo to the arguments passed here (security horror)
some mechanism to specifically launch only GDB as sudo
Update Pwntools First
This is a report about the latest pwntools stable release, 4.3.0, in relation to this older PR. This Issue Report is mostly smokescreen to ask why & how that PR fails to work on my machine.
GEF for linux ready, type `gef' to start, `gef config' to configure
77 commands loaded for GDB 7.12.0.20161007-git using Python engine 3.5
[*] 3 commands could not be loaded, run `gef missing` to know why.
Reading symbols from /bin/cat...(no debugging symbols found)...done.
Attaching to program: /bin/cat, process 779
ptrace: Operation not permitted.
/mnt/c/Users/A/779: No such file or directory.
gef➤
If the python script is ran with sudo, this happens:
[*] runninginnewterminal: /usr/bin/gdb-q"/bin/cat"821
[ERROR] Couldnotfindaterminalbinarytouse. Setcontext.terminaltoyourterminal.
Traceback (mostrecentcalllast):
File"<stdin>", line3, in<module>File"/usr/local/lib/python3.8/site-packages/pwnlib/context/__init__.py", line1449, insetterreturnfunction(*a, **kw)
File"/usr/local/lib/python3.8/site-packages/pwnlib/gdb.py", line791, inattachgdb_pid=misc.run_in_new_terminal(cmd)
File"/usr/local/lib/python3.8/site-packages/pwnlib/util/misc.py", line244, inrun_in_new_terminallog.error('Could not find a terminal binary to use. Set context.terminal to your terminal.')
File"/usr/local/lib/python3.8/site-packages/pwnlib/log.py", line424, inerrorraisePwnlibException(message%args)
pwnlib.exception.PwnlibException: Couldnotfindaterminalbinarytouse. Setcontext.terminaltoyourterminal.
Cause of issue
running gdb without sudo on this version of wsl will prevent ptrace from attaching. Running python with sudo will lead to the if-statement here failing, because sudo doesn't inherit PATH from the main user, and consequently fails the which(cmd.exe) check.
This can probably get solved easier after #1725. Also, why not disable YAMA? And does this work as intended if you replace r=process(...); gdb.attach(r) with r = gdb.debug(...)?
And why use M$ Windows NT as an exploitation environment in the first place? W has been getting more and more useless, pretty much since day one. Why don't you give another OS, say GNU/Linux a try? It is free of charge, safer, mature (just works™), has a sane community, if there is anything you don't like, you can just change it, you can even use Wine for running NT games/apps that happen to be misdesigned and work officially only on NT.
Pwntools will probably not support NT and/or WSL officially in any near future, but I am here to do my best anyway :)
This can probably get solved easier after #1725. Also, why not disable YAMA?
Didn't know about that! Whoops. It was set to 1 apparently.
If YAMA is meant to be disabled with pwntools, then alright.
And does this work as intended if you replace r=process(...); gdb.attach(r) with r = gdb.debug(...)?
Yes it does (with YAMA too).
And why use M$ Windows NT as an exploitation environment in the first place? W has been getting more and more useless, pretty much since day one. Why don't you give another OS, say GNU/Linux a try?
I completely agree. I'm only using Windows out of sheer inertia.
Pwntools will probably not support NT and/or WSL officially in any near future, but I am here to do my best anyway :)
Thanks for the effort. I'm going to take the hint and just close off this
TLDR
wsl1 needs sudo for gdb; using pwntools with sudo will cause wsl detection to fail. Options include:
sudo
should have its PATH corrected, and this is a user/wsl issuesudo
to the arguments passed here (security horror)Update Pwntools First
This is a report about the latest pwntools stable release, 4.3.0, in relation to this older PR. This Issue Report is mostly smokescreen to ask why & how that PR fails to work on my machine.
Debug Output
produces this output:
with this window:
If the python script is ran with sudo, this happens:
Cause of issue
running gdb without sudo on this version of wsl will prevent ptrace from attaching. Running
python
withsudo
will lead to the if-statement here failing, because sudo doesn't inheritPATH
from the main user, and consequently fails thewhich(cmd.exe)
check.Solutions
Prior to 4.3.0, I had this inside
~/.pwn.conf
:This 'solved' the issue by giving every binary root privileges.
The text was updated successfully, but these errors were encountered: