Howto: Stabilizing and upgrading Linux shells
By SecBurg
When you manage to get access to a system by the means of a reverse shell, chances are that you want to stabilize your new shell to have a real terminal (tty).
Otherwise you may not be able to do things like using tab completion, use programs like su, etc.
Since this is a process, which requires multiple steps, I’ll note it down here. :)
- use Python to spawn a new shell:
python3 -c 'import pty;pty.spawn("/bin/bash")'
- suspend the newly spawned shell by pressing:
CTRL + Z
- back on your local box, type:
stty size
stty raw -echo; fg
Note down the two numbers (cols and rows) which you got from stty size.
- on the attacked boy, finally enter:
stty cols NUMBER_OF_COLS rows NUMBER_OF_ROWS
export TERM=xterm-256color
Now you’ve upgraded your shell to a fully interactive TTY!
There are of course many more ways to stabilize a Linux shell, but this works for me. :-)