PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : [JAVA]Einfacher Portscanner beispiel



Hassia
05.05.2009, 17:03
Nur ein kleines beispiel. Man könnte das ganze nun ausbauen mit gui, threads etc. aber dazu hatte ich gerade kein bock^^
Code:
/*
www.bifrostworld.org
*/
import java.io.*;
import java.net.*;

public class CPortScanner{
public static void main(String [] args){
int port=0;
String host="localhost";
for ( port = 1; port < 65000; port++) {
try {
Socket s = new Socket(host,port);
System.out.println("Server is listening on port " + port+ " of " + host);
s.close();
}
catch (IOException ex) {
System.out.println("Server is not listening on port " + port);

}
}

}
}