Skip to content

Instantly share code, notes, and snippets.

@arcatdmz
Last active December 14, 2015 02:19
Show Gist options
  • Save arcatdmz/5012993 to your computer and use it in GitHub Desktop.
Save arcatdmz/5012993 to your computer and use it in GitHub Desktop.
Scan TCP 80 port and test if the destination IPs are HTTP-reachable or not.
import java.net.Socket;
public class HttpPortScan {
public static void main(String[] args) {
final String prefix = "192.168.1.";
for (int i = 1; i < 256; i ++) {
final int ip = i;
new Thread(new Runnable() {
public void run() {
try {
new Socket(prefix + ip, 80);
} catch (Exception e) {
return;
}
System.out.println("connection succeeded: " + prefix + ip);
}
}).start();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment