Comments (9)
This is due to fish forking multiple times when running fish -c somescript
and we're returning the pid of the original fish process instead of the forked one which actually runs the script.
I don't use fish, so you're welcome to propose a pull request for the misc.run_in_new_terminal
function to return the correct pid around:
Line 305 in 75cc3c3
from pwntools.
This is due to fish forking multiple times when running
fish -c somescript
and we're returning the pid of the original fish process instead of the forked one which actually runs the script.
I only see one process here.
from pwntools.
But your screenshot shows 3 processes?
When I run fish -c "sleep 999"
I see the fish process staying alive instead of being replaced by the sleep binary
# fish -c "sleep 999"
# other terminal:
pstree -p `whoami` | grep sleep
zsh(367594)---fish(368747)---sleep(368753)
compared to bash or zsh:
# bash -c "sleep 999"
# other terminal:
pstree -p `whoami` | grep sleep
zsh(367594)---sleep(368783)
I've asked about this in fish's matrix channel and it's expected behavior - BUT I've confused myself with terminal emulators and shells. This issue isn't in pwntools since we don't run shell -c command
at all but an instance of #2321 which boils down to a bug in gdbserver. pwntools 4.13.0 would print a more helpful error message suggesting you to set the SHELL environment variable to some other shell than fish like bash.
So try doing p = gdb.debug(['./start'], env={"SHELL": "/bin/bash"})
instead.
from pwntools.
Looking a bit more: gdbserver supports a --no-startup-with-shell
argument which might help too.
--startup-with-shell
Start PROG using a shell. I.e., execs a shell that
then execs PROG. (default)
--no-startup-with-shell
Exec PROG directly instead of using a shell.
Disables argument globbing and variable substitution
on UNIX-like systems.
@Arusekk can you think of why we don't start the program directly but have it go through a shell in gdb.debug? We don't do that when starting directly using process()
and I don't think we support the shell=True
argument when debugging?
@iacore @k4lizen can you test if adding that flag fixes your issue please? in gdb.py in _gdbserver_args(), can you add the argument?
Change that line to
gdbserver_args = [gdbserver, '--multi', '--no-startup-with-shell']
in your /home/maker/.local/lib/python3.11/site-packages/pwnlib/gdb.py
from pwntools.
So try doing p = gdb.debug(['./start'], env={"SHELL": "/bin/bash"}) instead.
This does seem to work.
gdbserver_args = [gdbserver, '--multi', '--no-startup-with-shell']
This also seems to work.
A bit off topic but im seeing some weird behaviour with the SHELL
env variable, like doing fish; bash; fish;
points to bash sometimes. Or setting the variable to fish and going into zsh still has it pointing to fish.
But anyways yeah, the proposed fixes seem good (and works with my template script with tmux settings etc).
from pwntools.
But your screenshot shows 3 processes?
I run fish -c xxx
in fish shell (I use fish already).
When I run
fish -c "sleep 999"
I see the fish process staying alive instead of being replaced by the sleep binary
This is expected. -c runs the script in script mode, not execv. You are likely looking for fish -c 'exec sleep 999'
, which calls execv.
compared to bash or zsh:
...
It's not mentioned in sh, so I guess it's not even part of POSIX. fish is also not a POSIX-compliant shell, so..
from pwntools.
Yes, faho mentioned this too and it seems the other shells are doing it wrong, but as I said, this is out of our control and done inside gdbserver.
from pwntools.
from pwntools.
We're passing --no-startup-with-shell
now, but the --wrapper
argument appears to require a shell. So it's only passed when env
is None and argv0 is unchanged. This will make debugging with a forking shell work most of the time, hopefully.
from pwntools.
Related Issues (20)
- Test windows-only features in CI
- SSHException("No authentication methods available") HOT 3
- DynELF._lookup returns GOT entry instead of PLT entry
- amd64 considered native architecture on i386 HOT 1
- `Context.log_file` does not allow bytes type HOT 2
- `BitPolynom.__init__` does not allow bytes type
- `CorefileFinder.read` returns bytes instead of str type HOT 1
- `xor` function raises `TypeError: pop expected at least 1 argument, got 0` HOT 2
- Add the ability to specify custom shellcraft templates HOT 2
- Inconsistency detected by ld.so HOT 2
- can't find write-what-where gadgets HOT 2
- [docs bug] Beginning of documentation cuts off for some things (due to "}")
- [docs bug] Many "links to the source" in the docs just link to the file (and not the line)
- [Bug?] FileStructure.struntil one byte shorter for no apparent reason?
- [Windows] Using "Process" raises "AttributeError: module 'os' has no attribute 'getuid'" HOT 2
- context.cyclic_size doesn't update when using context.binary = ELF('./prog') HOT 3
- Pwntools setup on Mac OS HOT 1
- ROP.call execve syscall ignores parameter HOT 5
- execve bug HOT 1
- libcdb print redundant information
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pwntools.