piątek, 19 września 2014

Java localhost port scanner

threadNetwork.java

package threads;
public class threadNetwork
{
    private static String host;
    public static void main(String[] args)
    {
        host = "localhost";
        for (int i = 22; i < 65356; i++)
        {
            portThread t = new portThread(host, i);
            t.start(); 
        }
    }
}

portThread.java

package threads;

import java.net.Socket;

public class portThread extends Thread
{
    private String host;
    private int port;
    public portThread(String host, int port)
    {
        this.host = host;
        this.port = port;
      
    }
    public void run()
    {
        try
        {
            Socket socket = new Socket(host, port);
            System.out.println("Port: "+ port + " is open...");
            socket.close()  
        }
        catch (Exception e)
        {
            //System.out.println("Port: "+ port + " is not in use");
        }
    }
}


Brak komentarzy:

Prześlij komentarz