How To: Server Socket Hijacking in Java Как: Сервер Socket угон на Яве
Overview Обзор
Socket hijacking allows you to override a server socket opened on the same port by a different process. Socket угон позволяет переопределить сервер сокет открыт же порт на разных процесса. 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 Java поддержка сокета угон
Starting with JDK 1.4 Java supports the method ServerSocket.setReuseAddress(boolean). Начиная с JDK 1,4 Java поддерживает метод 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(); Socket sock = ssock.accept ();
// Do your thing with the accepted connection / / Делаем что с вашей принятого соединения
sock.close(); sock.close ();
Filed under Поданного в соответствии с Headline News 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 16 ноября 2007 года в 4:22 вечера
I tried this hijacking, but did not get it work. Я пробовал этот угон, но не получили его работы.
Only IP address I could bind to was localhost. Только адрес я могла бы связать локальный чтобы было.
All other IP’s throw java.net.BindException: Cannot assign requested address: JVM_Bind? Все другие IP адресов броска java.net.BindException: Can't просьбой присвоить адрес: JVM_Bind?
November 18th, 2007 at 6:54 am 18 ноября 2007 года в 6:54 утра
Does your computer (on which you are running this program) have this IP address? Ваш компьютер (на котором вы работаете в этой программе) имеют этот IP-адрес?
Can you ping it? Можете ли вы пинг-ли?