MCPcopy Index your code
hub / github.com/10cks/fofaEX / getAllJsonResult

Method getAllJsonResult

src/main/java/FofaAPI.java:52–87  ·  view source on GitHub ↗
(String fofaDomain, String email, String key, String qbase64, String fieldsInput, int size, int page ,boolean full)

Source from the content-addressed store, hash-verified

50 }
51
52 public static JSONObject getAllJsonResult(String fofaDomain, String email, String key, String qbase64, String fieldsInput, int size, int page ,boolean full) throws Exception {
53
54 String base64Url = "qbase64=";
55 String fieldsUrl = "/api/v1/search/all?";
56
57 if (!(fieldsInput == null)) {
58 String encodedFieldsInput = URLEncoder.encode("host,ip,port" + fieldsInput, StandardCharsets.UTF_8);
59 fieldsUrl = "/api/v1/search/all?fields=" + encodedFieldsInput + "&";
60 }
61
62 String apiUrl = fofaDomain + fieldsUrl + base64Url + Base64.getEncoder().encodeToString(qbase64.getBytes()) + "&email=" + email + "&key=" + key + "&size=" + size + "&page=" + page + "&full=" + full;
63 URL url = new URL(apiUrl);
64
65 System.out.println("Query: " + url);
66
67 HttpURLConnection connection = (HttpURLConnection) url.openConnection();
68 connection.setRequestMethod("GET");
69 connection.setRequestProperty("Accept", "application/json");
70
71 if (connection.getResponseCode() != 200) {
72 throw new RuntimeException("Failed: HTTP error code : " + connection.getResponseCode());
73 }
74
75 BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
76 String output;
77 StringBuilder responseBuilder = new StringBuilder();
78 while ((output = br.readLine()) != null) {
79 responseBuilder.append(output);
80 }
81
82 connection.disconnect();
83 // 将response字符串转换为JSON对象
84 final String response = responseBuilder.toString();
85
86 return new JSONObject(response);
87 }
88
89 public static Object getValueFromJson(JSONObject json, String key) {
90

Callers 1

doInBackgroundMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected