Reverse Shell to fully interactive

echo os.system('/bin/bash')
/bin/sh -i
# Enter while in reverse shell
$ python -c 'import pty; pty.spawn("/bin/bash")'
Ctrl-Z
# In Kali
$ stty raw -echo
$ fg
# In reverse shell
$ reset
$ export SHELL=bash
$ export TERM=xterm-256color
$ stty rows <num> columns <cols>
python -c "import pty; pty.spawn('/bin/bash')"

stty raw -echo
fg

stty size

This should return two numbers, which are the number of rows and columns in your terminal. For example’s sake let’s say this command returned 48 120 Head on back to your victim box’s shell and run the following.

stty -rows 48 -columns 120
$ export SHELL=bash
$ export TERM=xterm-256color
$ stty rows <num> columns <cols>