主机检测
Search.java
package com.java; import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; import javax.utils.HttpUtils; import org.apache.commons.io.FileUtils; import org.jsoup.Connection.Response; public class Search { private static final int start = 1; private static final int end = 255; private static final int OK_CODE = 200; private static final String text = "%s %s\n"; private static final String url = "http://%s:8080/getHostMessage"; public static void main(String[] args) { try { String format = "192.%s.%s.%s"; String ip = null; for (int i = start; i < end; i++) { for (int j = start; j < end; j++) { for (int k = start; k < end; k++) { ip = String.format(format, i, j, k); detectHost(ip); } System.out.println(ip); } } } catch (Exception e) { e.printStackTrace(); } System.out.println("执行完成!"); } public static void write(String text) throws IOException { FileUtils.writeStringToFile(new File("IP.txt"), text, StandardCharsets.UTF_8, true); } public static void detectHost(String ip) { try { Response response = HttpUtils.get(String.format(url, ip)); if (OK_CODE == response.statusCode()) { write(String.format(text, ip, response.body())); } } catch (Exception e) { e.printStackTrace(); } } }
.
                    
                
                
            
        
浙公网安备 33010602011771号