Last active
December 14, 2015 02:19
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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