How To: Server Socket Hijacking in Javaどのように:サーバソケットをJavaでハイジャック
Overview 概要
Socket hijacking allows you to override a server socket opened on the same port by a different process.ハイジャックをオーバーライドするソケットサーバソケットを使用すると、同じポートを開いて、別のプロセスです。 There are several good uses of socket hijacking like developing aソケットを使用するのにはいくつかの良いようにハイジャックを開発する port blocker applicationアプリケーションポートを阻害薬 (poor man’s firewall) and some bad uses too. (貧乏人のファイアウォール)といくつかの悪い使用が判明しました。
Normally the operating system doesn’t allow you to open a server socket on a port which is already opened by another (or even the same) application.通常は、オペレーティングシステムはありませんを開くにはサーバソケットを使用するポートは、これはすでに開いて別の(あるいは同じ)アプリケーションを作成します。 However there is an exception and an exception to the exception.ただし、例外には例外として例外が発生します。
What and how of socket hijacking 何をどのようにソケットをハイジャック
Often a ServerSocket is opened without specifying a particular IP address to bind to. serversocketが開かれた、多くの場合、特定のIPアドレスを指定せずにバインドする。 So the socket essentially binds to all available IP address of the machine.ソケットので、本質的に結合して、マシンのIPアドレスを利用可能なすべてのです。 This is simple for the programmer.これは単純なため、プログラマです。 However it introduces a security hole.しかしセキュリティホールを導入することです。 Any application can bind to a specific IP address of the same machine and on the same port.任意のアプリケーションにバインドすること、特定のIPアドレスと同じマシン、同じポートに接続します。 The original server socket still binds on the remaining port.まだ、元のサーバソケットをバインドするための残りのポートに接続します。 In essence the port has been hijacked by the new application for a specific IP address.本質的にハイジャックされたポートされ、新しいアプリケーションは、特定のIPアドレスです。 This is socket hijacking.これは、ソケットのハイジャックです。
Java support for socket hijacking ジャワのサポートをソケットハイジャック
Starting with JDK 1.4 Java supports the method ServerSocket.setReuseAddress(boolean).ジャワで始めるとJDK 1.4のメソッドをサポートしてserversocket.setreuseaddress (ブール値)です。 It allows you to hijack a port for a particular IP address as described above.飛行機をハイジャックすることを使用すると、特定のIPアドレスのポートを前述のようにします。 Here is a sample code which allows you to hijack a server socket.次に示すのは、サンプルコードを使用して飛行機をハイジャックするサーバソケットを提供します。
Code コード
ServerSocket ssock = new ServerSocket();新しいserversocket ssock = serversocket ( ) ;
ssock.setReuseAddress(true); // The magic ssock.setreuseaddress (真の) ; / /ザマジック
ssock.bind(new InetSocketAddress(addr, i)); // addr = IP, i = port ssock.bind (新inetsocketaddress (住所、私) ) ; / /住所= IPの、私=ポート
Socket sock = ssock.accept();ソケットの靴下= ssock.accept ( ) ;
// Do your thing with the accepted connection / /行うことを利用して接続
sock.close(); sock.close ( ) ;
Filed under提出されて Headline Newsニュースの見出し , 、 How Toどのように , 、 Java Software Javaソフトウェア , 、 Tech Note技術のノート | |
| |
RSS 2.0 RSS 2.0を | |
Trackbackトラックバック this Article |この記事|
Email this Article電子メールこの記事
You may also like to readを読むようにすることも可能 |




November 16th, 2007 at 4:22 pm 2007年11月16日は4:22 pmの
I tried this hijacking, but did not get it work.このハイジャックてみましたが、仕事てくれなかったよ。
Only IP address I could bind to was localhost.私がIPアドレスのみにバインドするがlocalhostです。
All other IP’s throw java.net.BindException: Cannot assign requested address: JVM_Bind?すべての他のIPの投げjava.net.bindexception :要求された住所に割り当てることはできません: jvm_bindですか?
November 18th, 2007 at 6:54 am 2007年11月18日の午前6時54時
Does your computer (on which you are running this program) have this IP address?お使いのコンピュータは(上でこのプログラムを実行している)がこのIPアドレスですか?
Can you ping it? pingを実行することですか?