For Linux victim machine

Steps for stabilising the shell.

Step 1: Find out which Python version is installed

# Check for python and python3
which python || which python3

Step 2: Load the bash shell.

# According to Python version present run the below command:
python -c 'import pty; pty.spawn("/bin/bash");'
python3 -c 'import pty; pty.spawn("/bin/bash");'

You can try a one-liner that first prints the Python version it is using, followed by obtaining a stable shell. If this does not work, consider trying the other methods listed below.

(command -v python && python -c 'import pty; pty.spawn("/bin/bash");') || (command -v python3 && python3 -c 'import pty; pty.spawn("/bin/bash");')

Step 3: Stabilize for tab completion.

# Press CTRL + Z
# Then run below command:
stty raw -echo ; fg

Other way:

We can also run reverse shell commands related to bash and catch it with the listener for getting a shell.

Step 1: Start the listener

Step 2: Run the below command in an unstable shell.

Last updated