How To: Server Socket Hijacking in Java Como a: Servidor Socket seqüestro em Java
Overview Visão geral
Socket hijacking allows you to override a server socket opened on the same port by a different process. Socket seqüestro lhe permite sobrescrever um servidor socket aberto sobre o mesmo porto por um processo diferente. There are several good uses of socket hijacking like developing a Há vários bons usos do socket como o desenvolvimento de um seqüestro port blocker application Port bloqueador candidatura (poor man’s firewall) and some bad uses too. (pobre do homem firewall) e também algumas más utilizações.
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. Normalmente o sistema operacional não permite que você abra um servidor socket em uma porta que já está aberto por outro (ou até mesmo a) requerimento. However there is an exception and an exception to the exception. No entanto, há uma exceção e uma excepção à excepção.
What and how of socket hijacking O que e como seqüestro de soquete
Often a ServerSocket is opened without specifying a particular IP address to bind to. Muitas vezes um ServerSocket é aberta sem especificar um endereço IP especial para o efeito de vincular. So the socket essentially binds to all available IP address of the machine. Portanto, o soquete liga essencialmente disponível para todos os endereços IP da máquina. This is simple for the programmer. Isto é simples para o programador. However it introduces a security hole. No entanto, introduz-se uma falha de segurança. Any application can bind to a specific IP address of the same machine and on the same port. Qualquer aplicação pode vincular a um determinado endereço IP da máquina, e mesmo sobre o mesmo porto. The original server socket still binds on the remaining port. O original server socket liga ainda sobre as restantes portos. In essence the port has been hijacked by the new application for a specific IP address. Na sua essência o porto tem sido invadida pelo novo pedido de um endereço IP específico. This is socket hijacking. Esta é socket seqüestro.
Java support for socket hijacking Java suporte para socket seqüestro
Starting with JDK 1.4 Java supports the method ServerSocket.setReuseAddress(boolean). Começando com JDK 1,4 Java apoia o método ServerSocket.setReuseAddress (boolean). It allows you to hijack a port for a particular IP address as described above. Ela permite que você roubar uma porta para um determinado endereço IP, como descrito acima. Here is a sample code which allows you to hijack a server socket. Aqui está uma amostra código que permite a adulteração um servidor socket.
Code Código
ServerSocket ssock = new ServerSocket(); ServerSocket ssock = new ServerSocket ();
ssock.setReuseAddress(true); // The magic ssock.setReuseAddress (true); / / O mágico
ssock.bind(new InetSocketAddress(addr, i)); // addr = IP, i = port ssock.bind (novo InetSocketAddress (addr, i)) / / addr = IP, i = porto
Socket sock = ssock.accept(); Socket palmilha ssock.accept = ();
// Do your thing with the accepted connection / / Do seu coisa com o aceite conexão
sock.close(); sock.close ();
Filed under Arquivado em Headline News Headline News , De How To How To , De Java Software Java Software , De Tech Note Nota Tech | |
| |
RSS 2.0 RSS 2,0 | |
Trackback this Article | este artigo |
Email this Article E-mail este artigo
You may also like to read Você pode também gosta de ler |




November 16th, 2007 at 4:22 pm 16 de novembro de 2007 em 4:22 pm
I tried this hijacking, but did not get it work. Eu tentei este seqüestro, mas não recebi-lo funcionar.
Only IP address I could bind to was localhost. Apenas o endereço IP eu poderia vincular a era localhost.
All other IP’s throw java.net.BindException: Cannot assign requested address: JVM_Bind? Todos os outros IP's throw java.net.BindException: Não é possível atribuir endereço solicitado: JVM_Bind?
November 18th, 2007 at 6:54 am 18 de novembro de 2007 em 6:54 am
Does your computer (on which you are running this program) have this IP address? Será que o seu computador (no qual você está executando o programa) tem este endereço IP?
Can you ping it? Vocês podem ping-lo?