Operator On The Wire
Join
← Back to Knowledge Base
RED TEAM / SHELLS / UPGRADE

Linux

  1. Spawn python shell
python3 -c 'import pty; pty.spawn("/bin/bash")'

# if only Python 2:
python -c 'import pty; pty.spawn("/bin/bash")'

python -c 'import subprocess; subprocess.run(["/bin/bash"])'
  1. When you background the shell (CTRL+Z) after spawning /bin/bash, use:
stty raw -echo; fg

# if nano or other commands return "Error opening terminal: unknown":
# inside the target shell run this command:

echo $TERM        # probably will return 'dumb'

export TERM=xterm # this should fix it
  1. Now your shell is upgraded.

Script (reliable)

script -qc /bin/bash /dev/null