java扫描局域网的端口
直接上代码:
import java.net.Socket;
import java.text.SimpleDateFormat;
import java.util.Date;
public class PortScanner 判消袭extends Thread {
private int[] p;
Socket ss = null;
public PortScanner(int[] p) {
this.p = p;
}
public static void main(String[] args) {
for (int i = 0; i 65535; i = i + 100) {
new PortScanner(new int[] { i + 1, i 掘兄+ 100 }).start();
}
}
@Override
public void run() {
for (int i = p[0]; i p[1]; i++) {
try {
ss = new Socket("8.8.8.8", 桥仔i);
System.out.println("扫描到端口: " + i);
} catch (Exception e) {
// System.out.println("关闭端口: " + i);
}
}
}
}
0条大神的评论