I recently have been doing some hack the box boxes and kept getting a shell via nc or meterpreter or whatever, but they were not full shells and I thought, there must be good ways to do this.
To find out what your current shell is do:
echo $0
So here is a list.
If python is installed, this works really well!
python -c 'import pty;pty.spawn("/bin/bash")'
Once you have a shell, you can upgrade it to get tab autocomplete etc by doing:
Ctrl + z
This puts the netcat session into the background
stty raw -echo
It won’t look like anything changed, but go with it.
Then do 2x:
fg
You are now back into your shell with direction keys and tab autocomplete.
To then gain access to things like clear to clear the screen do:
Path=usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/rvm/binĀ
Thanks to ippsec video’s for these tips!