Skip to content

Commit

Permalink
Zoomeye API 实现
Browse files Browse the repository at this point in the history
  • Loading branch information
bit4woo committed Apr 7, 2024
1 parent 897d614 commit 65582fa
Show file tree
Hide file tree
Showing 6 changed files with 223 additions and 26 deletions.
56 changes: 37 additions & 19 deletions src/InternetSearch/Client/ZoomEyeClient.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package InternetSearch.Client;

import java.io.File;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.io.FileUtils;
import org.json.JSONArray;
import org.json.JSONObject;

Expand All @@ -13,7 +16,6 @@
import burp.BurpExtender;
import config.ConfigManager;
import config.ConfigName;
import config.ConfigPanel;

public class ZoomEyeClient extends BaseClient {

Expand All @@ -27,20 +29,27 @@ public List<SearchResultEntry> parseResp(String respbody) {
List<SearchResultEntry> result = new ArrayList<SearchResultEntry>();
try {
JSONObject obj = new JSONObject(respbody);
Boolean error = (Boolean) obj.get("error");
if (!error) {
JSONArray results = (JSONArray) obj.get("results");
int status = obj.getInt("status");
if (status ==200) {
JSONArray results = obj.getJSONArray("matches");
for (Object item : results) {
JSONArray parts = (JSONArray) item;
// host,ip,domain,port,protocol,server
// ["www.xxx.com","11.11.11.11","xxx.com","80","http","nginx/1.20.1"]

JSONObject entryitem = (JSONObject) item;

SearchResultEntry entry = new SearchResultEntry();
entry.setHost(parts.getString(0));
entry.getIPSet().add(parts.getString(1));
entry.setRootDomain(parts.getString(2));
entry.setPort(Integer.parseInt(parts.getString(3)));
entry.setProtocol(parts.getString(4));
entry.setWebcontainer(parts.getString(5));

entry.getIPSet().add(entryitem.getString("ip"));
entry.setHost(entryitem.getString("rdns"));

int port = entryitem.getJSONObject("portinfo").getInt("port");
entry.setPort(port);

String serviceName = entryitem.getJSONObject("portinfo").getString("service");
String title = entryitem.getJSONObject("portinfo").get("title").toString();

entry.setProtocol(serviceName);
entry.setTitle(title);

entry.setSource(getEngineName());
result.add(entry);
}
Expand All @@ -55,12 +64,13 @@ public List<SearchResultEntry> parseResp(String respbody) {
public boolean hasNextPage(String respbody,int currentPage) {
// "size":83,"page":1,
try {
ArrayList<String> result = JSONHandler.grepValueFromJson(respbody, "size");
if (result.size() >= 1) {
int total = Integer.parseInt(result.get(0));
if (total > currentPage * 2000) {//size=2000
int pageSize = 10;
ArrayList<String> tmp_result = JSONHandler.grepValueFromJson(respbody, "total");
if (tmp_result.size() >= 1) {
int total = Integer.parseInt(tmp_result.get(0));
if (total > currentPage * pageSize) {
return true;
}
}
}
} catch (Exception e) {
e.printStackTrace(BurpExtender.getStderr());
Expand Down Expand Up @@ -95,13 +105,21 @@ public byte[] buildRawData(String searchContent, int page) {
+ "Connection: close\r\n"
+ "\r\n"
+ "";

searchContent = URLEncoder.encode(searchContent);
String key = ConfigManager.getStringConfigByKey(ConfigName.ZoomEyeAPIKey);
if (key.equals("")) {
BurpExtender.getStderr().println("zoomeye key not configurated!");
return null;
}
int size = 500;
int start = size*(page-1);
raw = String.format(raw,searchContent,page,key);
return raw.getBytes();
}

public static void main(String[] args) throws IOException {
String aaa = FileUtils.readFileToString(new File("G:/github/domain_hunter_pro/src/InternetSearch/Client/example_data_ZoomEye.txt"),"UTF-8");
System.out.println(new ZoomEyeClient().parseResp(aaa));
}
}
149 changes: 149 additions & 0 deletions src/InternetSearch/Client/example_data_ZoomEye.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
{
"status": 200,
"matches": [
{
"rdns": "example.com",
"jarm": "",
"ico": "https://zoomeye-icon-1305897987.cos.ap-guangzhou.myqcloud.com/cee18e28257988b40028043e65a6c2a3",
"txtfile": {},
"ip": "92.223.90.167",
"portinfo": {
"product": "Apache httpd",
"hostname": "",
"os": "",
"port": 6779,
"service": "http",
"transport": "tcp",
"title": null,
"extrainfo": ""
},
"timestamp": "2024-04-07 15:12",
"geoinfo": {
"country": {
"code": "CN",
"names": {
"en": "China",
"cn": "中国"
}
},
"base_station": "",
"city": {
"names": {
"en": "Hong Kong",
"cn": "香港"
}
},
"district": {
"names": {
"en": "",
"cn": null
}
},
"organization": "G-Core Labs S.A.",
"idc": "",
"asn": "202422",
"subdivisions": {
"names": {
"en": "Hong Kong",
"cn": "香港"
}
}
},
"type": "host",
"mapping_type": "xmap",
"token": "215cf11527eea7c9258fbf784c559c81",
"scanning": false,
"scannable": true,
"os": "",
"honeypot": null,
"qid": "eG1hcC12My0xOXw5Mi4yMjMuOTAuMTY3XzY3NzlfdGNw",
"sensitive_data": false
},
{
"rdns": "bimcom6.example.com",
"jarm": "",
"txtfile": {},
"ip": "185.154.20.88",
"portinfo": {
"product": "",
"hostname": "",
"os": "",
"port": 33890,
"service": "http-proxy",
"transport": "tcp",
"title": [
"502 Bad Gateway"
],
"extrainfo": "bad gateway"
},
"timestamp": "2024-04-07 15:09",
"geoinfo": {
"country": {
"code": "RU",
"names": {
"en": "Russia",
"cn": "俄罗斯"
}
},
"base_station": "",
"city": {
"names": {
"en": "Moscow",
"cn": "莫斯科"
}
},
"district": {
"names": {
"en": "",
"cn": null
}
},
"organization": "Kontel LLC",
"idc": "",
"asn": "204490",
"subdivisions": {
"names": {
"en": "Moscow",
"cn": "莫斯科"
}
}
},
"type": "host",
"mapping_type": "xmap",
"token": "06b849b0c70eeeb23cc0c8525be6cb2a",
"scanning": false,
"scannable": true,
"os": "",
"honeypot": null,
"qid": "eG1hcC12My0xMXwxODUuMTU0LjIwLjg4XzMzODkwX3RjcA==",
"sensitive_data": false
}
],
"total": 476527,
"took": 641,
"labels": [
"site:\"example.com\""
],
"api_dic": {
"web": "curl -X GET 'https://api.zoomeye.hk/web/search?query=site%3A%22example.com%22&page=1' -H \"API-KEY:please login\"",
"host": "curl -X GET 'https://api.zoomeye.hk/host/search?query=site%3A%22example.com%22&page=1' -H \"API-KEY:please login\""
},
"pageSize": 10,
"ipip_match": {},
"ips": [
"92.223.90.167",
"5.8.71.61",
"46.173.211.214",
"62.173.138.99",
"46.173.211.77",
"46.173.211.183",
"45.133.216.116",
"45.143.138.83",
"46.173.211.93",
"185.154.20.88"
],
"site_match": "",
"aggs": "a6775613d75bc14efd919d2b2ab575cd",
"max": 10,
"file_id": ""
}
6 changes: 6 additions & 0 deletions src/InternetSearch/SearchEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ public static List<String> getCommonSearchEngineList(){
result.add(GITHUB);
return result;
}

public static String buildSearchDork(String content,String type){
//TODO
return "";
}



public static void AddSearchMenuItems(JPopupMenu parentMenu,AbstractTableModel tableModel,int[] modelRows,int columnIndex) {
Expand Down
11 changes: 11 additions & 0 deletions src/InternetSearch/SearchType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package InternetSearch;

public class SearchType {

public static final String Host = "Host";
public static final String IP = "IP";
public static final String Subnet = "Subnet";
public static final String Domain = "Domain";
public static final String title = "title";
public static final String IconHash = "IconHash";
}
6 changes: 2 additions & 4 deletions src/config/ConfigName.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import java.util.ArrayList;
import java.util.List;

import InternetSearch.SearchEngine;

public class ConfigName {
//boolean config
public static final String showBurpMenu = "Display context menu of burp";
Expand Down Expand Up @@ -46,12 +44,12 @@ public class ConfigName {

public static List<String> getAllConfigNames(){
List<String> result = new ArrayList<String>();
Field[] fields = SearchEngine.class.getDeclaredFields();
Field[] fields = ConfigName.class.getDeclaredFields();
for (Field field : fields) {
//String varName = field.getName();// 对于每个属性,获取属性名
if (field.getGenericType().toString().equals("class java.lang.String")) {// 如果type是类类型,则前面包含"class ",后面跟类名
try {
String value = (String) field.get(SearchEngine.class);//获取属性值
String value = (String) field.get(ConfigName.class);//获取属性值
result.add(value);
} catch (IllegalArgumentException e) {
e.printStackTrace();
Expand Down
21 changes: 18 additions & 3 deletions src/domain/target/TargetTableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,26 @@ public String getValueForSearch(int rowIndex, int columnIndex,String engine) {
if (engine.equalsIgnoreCase(SearchEngine.GOOGLE)) {
value = "site:"+value;
}
if (engine.equalsIgnoreCase(SearchEngine.QIANXIN_HUNTER)) {
else if (engine.equalsIgnoreCase(SearchEngine.FOFA)) {
value = "domain=\""+value+"\"";
}
if (engine.equalsIgnoreCase(SearchEngine.ZOOMEYE)) {
value = "hostname:"+value;
else if (engine.equalsIgnoreCase(SearchEngine.ZOOMEYE)) {
value = "site:\""+value+"\"";
}
else if (engine.equalsIgnoreCase(SearchEngine.SHODAN)) {

}
else if (engine.equalsIgnoreCase(SearchEngine.QIANXIN_HUNTER)) {
value = "domain=\""+value+"\"";
}
else if (engine.equalsIgnoreCase(SearchEngine.QIANXIN_TI)) {

}
else if (engine.equalsIgnoreCase(SearchEngine.TI_360)) {

}
else if (engine.equalsIgnoreCase(SearchEngine.QUAKE_360)) {

}
}else if (columnName.equalsIgnoreCase("Comments")){

Expand Down

0 comments on commit 65582fa

Please sign in to comment.