Jump to content

detecting ip changes


pork

Recommended Posts

EDIT 

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;

public class IPListener {

    private static final String MY_IP_URL = "http://my-ip.heroku.com/";
    private static final String BAT_TO_RUN = "run.bat";

    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(new InputStreamReader(new URL(MY_IP_URL).openConnection().getInputStream()));
        String initialIP = reader.readLine();
        reader.close();
        System.out.println("Initial IP: " + initialIP);
        System.out.println("Listening for change in IP address...");
        while (true) {
            reader = new BufferedReader(new InputStreamReader(new URL(MY_IP_URL).openConnection().getInputStream()));
            String currentIP = reader.readLine();
            reader.close();
            if (!initialIP.equals(currentIP)) {
                System.out.println("IP changed from " + initialIP + " to " + currentIP);
                Runtime.getRuntime().exec("cmd /c start " + BAT_TO_RUN);
                System.out.println(BAT_TO_RUN + " executed.");
                break;
            }
        }
    }

}

Came up with this but it spams the website every few milliseconds... they'll prob block me. The file run.bat is executed on IP change so you can put commands in there to kill java.exe or javaw.exe processes.

Edited by pork
Link to comment
Share on other sites

Code for ip changer killer

package ipchange;
import java.net.InetAddress;
import java.net.UnknownHostException;

import javax.swing.JFrame;


public class IpChange
{
	private static String ip;
	
	private static void kill(String string)
	{
	    try 
	    {
	      Runtime.getRuntime().exec("taskkill /F /IM " + string).waitFor();
	    } 
	    catch (Exception e) {}
	}
	
	public static void main(String[] args) throws UnknownHostException, InterruptedException
	{
		ip = InetAddress.getLocalHost().getHostAddress();
		JFrame frame = new JFrame();
		frame.setVisible(true);
		while(true)
		{
			System.out.println(InetAddress.getLocalHost().getHostAddress());
			if(!ip.equalsIgnoreCase(InetAddress.getLocalHost().getHostAddress()))
			{
				kill("javaw.exe");
				break;
			}
			Thread.sleep(5000);
		}
	}

}
 

 

Here is download link

 

https://www.dropbox.com/s/0w27kzkx3de417k/IpChange.jar

 

Also keep the JFRAME that it pops up open.... that is for the purpose of that it is still running

 

It will kill osbot when you disconnect from vpn 

 

Cheers smile.png

Edited by Anon
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...