Upgrade Shells
Sometimes getting a basic "dumb" shell just isn't enough, and you need a more ... interactive one .
The most basic technique : Python + manual commands
One can spawn a TTY (from teletypewriter) shell using python by importing the pty
library and executing its spawn
method in a neat one liner ;
python -c 'import pty; pty.spawn("/bin/bash")'
Compatible with both python and python3 ;)
Then export TERM=xterm
will make sure the TERM variable, used by the terminal, is properrly populated, thus giving us access to commands like clear
The next step would be to put the shell in the background using Ctrl+Z, then using stty raw -echo; fg
to turn off our own terminal echo, and then foregrounding the shell.
Rlwrap
The rlwrap
command in Linux is a utility that provides readline functionality for any input/output terminal application that lacks it. Readline is a library that provides advanced line editing features to interactive shells and other terminal applications. In our case, we can prefix it before our netcat command like so :
rlwrap nc -lnvp my_port
Change the terminal tty size
If we want to be able to use stuff like text editors, changing the value of our tty size is essential. We first use the stty -a
command, take note in its output of the number of rows and columns, and then change it with the stty command :
stty rows [number_of_rows] && stty cols [number_of_columns]
Last updated
Was this helpful?