LoginSignup
0
0

More than 3 years have passed since last update.

netcat の代替としての StreamRelay.jar

Last updated at Posted at 2017-05-23

java.exe -Djava.security.policy=StreamRelay.policy -jar StreamRelay.jar

StreamRelay.bat


ネットワーククライアントとしてnetcatの代替

ネットワーククライアントなので、localと呼称しているストリーム側をコンソール。remoteと呼称しているストリームをネットワーク(TCP)にする
nc.exe 192.0.2.1 90

java.exe -Djava.security.policy=StreamRelay.policy -jar StreamRealy.jar -LocalPort 0 -RemoteHost 192.0.2.1 -RemotePort 90


ポートスキャンとしての netcatの代替

-z オプションは -ZeroIO
nc.exe -z 192.0.2.1 90

java.exe -Djava.security.policy=StreamRelay.policy -jar StreamRelay.jar -LocalPort 0 -RemoteHost 192.0.2.1 -RemotePort 90 -ZeroIO


ポートスキャンとしての netcatの代替(SSL対応)

-RemoteSSL で SSL ハンドシェイクまでしてくれる
java.exe -Djava.security.policy=StreamRelay.policy -jar StreamRelay.jar -LocalPort 0 -RemotePort 443 -RemoteHost www.example.com -ZeroIO -RemoteSSL
stdin/stdout => 192.0.2.1:64025 -> www.example.com:443 open (SSL open)

と、TCP ハンドシェイク→SSLハンドシェイク、どこまで成功したか分かるようになっている

java.exe -Djava.security.policy=StreamRelay.policy -jar StreamRelay.jar -LocalPort 0 -RemotePort 80 -RemoteHost www.example.com -ZeroIO -RemoteSSL
stdin/stdout => 192.0.2.1:64164 -> www.example.com:80 open (SSL failed)

これだと、TCPハンドシェイクは成功したけど、SSLハンドシェイクには失敗した。
とか分かる


ネットワークサーバとしてnetcatの代替

ネットワークサーバなので、localと呼称しているストリーム側をネットワーク(TCP)。remoteと呼称しているストリームをコンソールにする
nc.exe -l -p 90

java.exe -Djava.security.policy=StreamRelay.policy -jar StreamRelay.jar -LocalPort 90 -RemotePort 0


リバースシェルサーバのようなnetcatの代替

外部コマンドをストリームのソースにするには、ポートに-1を指定する
nc.exe -e cmd.exe 192.0.2.1 90

java.exe -Djava.security.policy=StreamRelay.policy -jar StreamRelay.jar -LocalPort -1 -LocalProgram cmd.exe -RemoteHost 192.0.2.1 -RemotePort 90


シェルサーバのようなnetcatの代替

外部コマンドをストリームのソースにするには、ポートに-1を指定する
nc.exe -e cmd.exe -l -p 90

java.exe -Djava.security.policy=StreamRelay.policy -jar StreamRelay.jar -LocalPort 90 -RemotePort -1 -RemoteProgram cmd.exe


UDP を使うnetcatの代替

基本的には「-RemoteUdp」か「-LocalUdp」でよい
nc.exe -u 192.0.2.1 90

java.exe -Djava.security.policy=StreamRelay.policy -jar StreamRelay.jar -LocalPort 0 -RemoteHost 192.0.2.1 -RemotePort 90 -RemoteUDP

とか

nc.exe -u -l -p 90

java.exe -Djava.security.policy=StreamRelay.policy -jar StreamRelay.jar -LocalPort 90 -LocalUDP -RemotePort 0


ファイルを入力源としたhttpクライアントのようなnetcatの代替

ファイル中にHTTPリクエストを記述し、それをリダイレクトする場合、StreamRelayは、基本的に双方向通信としているので、ファイル読み込み完了→レスポンス受信前にストリーム終了、となってしまうので「-AllowHalfOpen」を指定する
nc.exe 192.0.2.1 80 < httpRequest.txt

java.exe -Djava.security.policy=StreamRelay.policy -jar StreamRelay.jar -LocalPort 0 -localinputFile httpRequest.txt -RemoteHost 192.0.2.1 -RemotePort 80 -AllowHalfOpen


目次へ戻る

目次というか最初の一歩

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0