How To: Server Socket Hijacking in Java Comment: Détournement socket serveur en Java
Overview Présentation
Socket hijacking allows you to override a server socket opened on the same port by a different process. Socket détournement vous permet de l'emporter sur un serveur socket ouvert sur le même port par un procédé différent. There are several good uses of socket hijacking like developing a Il ya plusieurs bons usages de prise en développement comme le détournement d'un port blocker application Port bloquant l'application (poor man’s firewall) and some bad uses too. (pauvre du pare-feu) et d'autres mauvais usages.
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. Normalement, le système d'exploitation ne vous permet pas d'ouvrir un serveur socket sur un port qui est déjà ouvert par un autre (ou même identiques). However there is an exception and an exception to the exception. Toutefois, il est une exception et une exception à l'exception.
What and how of socket hijacking Quoi et comment le détournement de socket
Often a ServerSocket is opened without specifying a particular IP address to bind to. Souvent, un ServerSocket est ouvert sans spécifier une adresse IP à lier. So the socket essentially binds to all available IP address of the machine. Ainsi, la prise essentiellement lie à toutes les adresse IP de la machine. This is simple for the programmer. C'est simple pour le programmeur. However it introduces a security hole. Cependant, il introduit une faille de sécurité. Any application can bind to a specific IP address of the same machine and on the same port. Toute demande peut se lier à une adresse IP spécifique de la même machine et sur le même port. The original server socket still binds on the remaining port. Le serveur d'origine lie encore prise sur les autres ports. In essence the port has been hijacked by the new application for a specific IP address. En essence, le port a été détourné par la nouvelle demande pour une adresse IP spécifique. This is socket hijacking. Ce détournement est prise.
Java support for socket hijacking Le support Java prise pour détournement
Starting with JDK 1.4 Java supports the method ServerSocket.setReuseAddress(boolean). À partir de 1,4 JDK Java soutient la méthode ServerSocket.setReuseAddress (booléen). It allows you to hijack a port for a particular IP address as described above. Il vous permet de détourner un port pour une adresse IP comme décrit ci-dessus. Here is a sample code which allows you to hijack a server socket. Voici un exemple de code qui vous permet de détourner un serveur socket.
Code Code
ServerSocket ssock = new ServerSocket(); ServerSocket ssock = new ServerSocket ();
ssock.setReuseAddress(true); // The magic ssock.setReuseAddress (true); / / La magie
ssock.bind(new InetSocketAddress(addr, i)); // addr = IP, i = port ssock.bind (nouveau InetSocketAddress (addr, i)) / / = adr IP, i = port
Socket sock = ssock.accept(); Sock = socket ssock.accept ();
// Do your thing with the accepted connection / / Est-ce que vos chose avec la connexion acceptée
sock.close(); sock.close ();
Filed under Classé sous Headline News Headline News , How To Comment , Java Software Logiciel de Java , Tech Note Note technique | |
| |
RSS 2.0 RSS 2,0 | |
Trackback this Article | cet article |
Email this Article Envoyer cet article
You may also like to read Vous mai également à lire |




November 16th, 2007 at 4:22 pm Novembre 16th, 2007 at 4:22 pm
I tried this hijacking, but did not get it work. J'ai essayé ce détournement, mais il n'a pas que ça fonctionne.
Only IP address I could bind to was localhost. Adresse IP je pourrais lier était localhost.
All other IP’s throw java.net.BindException: Cannot assign requested address: JVM_Bind? Tous les autres IP jeter java.net.BindException: Impossible d'attribuer adresse demandée: JVM_Bind?
November 18th, 2007 at 6:54 am Novembre 18th, 2007 at 6:54 am
Does your computer (on which you are running this program) have this IP address? Votre ordinateur (sur lequel vous exécutez ce programme) ont cette adresse IP?
Can you ping it? Pouvez-vous Ping?