* @param q search query(not encode)
* @param page page
* @return fofa search result data
* @exception Exception search Expection
*/
public FofaData getData(String q,Integer page) throws Exception {
return getData(q, page,100,"host",false);
}
/**
* get data
*
* fields default host
* full default false
*
* @param q search query(not encode)
* @param page page
* @param size page size
* @return fofa search result data
* @exception Exception search Expection
*/
public FofaData getData(String q,Integer page,Integer size) throws Exception{
return getData(q, page,size,"host",false);
}
/**
* get data
*
* full default false
*
* @param q search query(not encode)
* @param page page
* @param size page size
* @param fields fields
* @return fofa search result data
* @throws Exception search Expection
*/
public FofaData getData(String q,Integer page,Integer size,String fields)throws Exception{
return getData(q,page,size,fields,false);
}
/**
* get data
* @param q search query(not encode)
* @param page page no
* @param size page size
* @param fields fields
* @param full is full
* @return fofa search result data
*/
public FofaData getData(String q, Integer page, Integer size, String fields, Boolean full) throws Exception{
checkParam(q,size,fields);
// check page
page = page < 0 ? 1:page;
// check full is not null
full = full == null ? false:full;
String url = BASE_URL+SEARCH_URI;
Map map = new HashMap();
map.put("qbase64", encode(q));
map.put("page", page);
map.put("size", size);
map.put("fields", fields);
map.put("full",full);
map.put("key", key);
map.put("email", email);
String rsp = HttpUtils.doGet(url, map);
JsonNode node = mapper.readTree(rsp);
JsonNode errorNode = node.get("error");
if(errorNode != null && errorNode.asBoolean()){
throw new FofaException(node.get("errmsg").asText());
}
String mode = node.get("mode").asText();
String query = node.get("query").asText();
Integer rspPage = node.get("page").asInt();
Integer totalSize = node.get("size").asInt();
String results = node.get("results").toString();
Integer totalPage = totalSize%size == 0 ? totalSize/size:totalSize/size + 1;
FofaData fofaData = new FofaData();
fofaData.setMode(mode);
fofaData.setPage(rspPage);
fofaData.setSize(totalSize);
fofaData.setQuery(query);
fofaData.setTotalPage(totalPage);
List> list = mapper.readValue(results, List.class);
fofaData.setResults(list);
return fofaData;
}
/**
* check param
* @param q search query
* @param size size
* @param fields fields
* @throws FofaException
*/
public void checkParam(String q,Integer size, String fields)throws FofaException{
// check search query
if(q == null || "".equals(q)){
throw new FofaException("search query cannot be empty");
}
// check max size
if(size > MAX_SIZE){
throw new FofaException("max size "+MAX_SIZE);
}
// check fields
List splitList = Arrays.asList(fields.split(","));
splitList = new ArrayList(splitList);
splitList.removeAll(FIELDS_LIST);
if(splitList.size() > 0){
throw new FofaException(splitList+" not's fields,please delte that");
}
}
}
================================================
FILE: src/main/java/com/suyu/core/constants/FofaClientConsts.java
================================================
/*
* Copyright (c) 2019. r4v3zn.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.suyu.core.constants;
/**
* Title: FofaClientConsts
* Descrption: this is Fofo Pro Client Constants
* Date:2019-06-07 21:56
* Email:woo0nise@gmail.com
* Company:www.j2ee.app
*
* @author R4v3zn
* @version 1.0.0
*/
public class FofaClientConsts {
/**
* Base FOFA Pro Api
*/
// public static final String BASE_URL = "https://fofa.so";
public static final String BASE_URL = "https://fofa.info";
/**
* get user info uri
*/
public static final String GET_USER_INFO_URI = "/api/v1/info/my";
/**
* search uri
*/
public static final String SEARCH_URI = "/api/v1/search/all";
/**
* max size
*/
public static final Integer MAX_SIZE = 10000;
}
================================================
FILE: src/main/java/com/suyu/core/constants/FofaFieldsConsts.java
================================================
/*
* Copyright (c) 2019. r4v3zn.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.suyu.core.constants;
import java.util.Arrays;
import java.util.List;
/**
* Title: FofaFieldsConsts
* Descrption: this is FOFA Pro fields Constants
* Date:2019-06-08 18:53
* Email:woo0nise@gmail.com
* Company:www.j2ee.app
*
* @author R4v3zn
* @version 1.0.0
*/
public class FofaFieldsConsts {
/**
* FOFA Pro fields list
*/
public static final List FIELDS_LIST = Arrays.asList(new String[]{"host","title","ip","domain","port","country","province","city","country_name","header","protocol","banner","cert","isp","as_number","as_organization","latitude","longitude"});
}
================================================
FILE: src/main/java/com/suyu/core/constants/UserConsts.java
================================================
/*
* Copyright (c) 2019. r4v3zn.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.suyu.core.constants;
/**
* Title: UserConsts
* Descrption: this is User Consts
* Date:2019-06-07 20:36
* Email:woo0nise@gmail.com
* Company:www.j2ee.app
*
* @author R4v3zn
* @version 1.0.0
*/
public class UserConsts {
}
================================================
FILE: src/main/java/com/suyu/core/enmus/UserVipLevelEnum.java
================================================
/*
* Copyright (c) 2019. r4v3zn.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.suyu.core.enmus;
/**
* Title: UserVipLevelEnum
* Descrption: TODO
* Date:2019-06-07 20:45
* Email:woo0nise@gmail.com
* Company:www.j2ee.app
*
* @author R4v3zn
* @version 1.0.0
*/
public enum UserVipLevelEnum {
/**
* Senior member, Free member
*/
SVIP(2,"高级会员"),VIP(1,"普通会员");
private String levelName;
private Integer code;
UserVipLevelEnum(Integer code,String levelName){
this.code = code;
this.levelName = levelName;
}
}
================================================
FILE: src/main/java/com/suyu/core/exception/FofaException.java
================================================
/*
* Copyright (c) 2019. r4v3zn.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.suyu.core.exception;
/**
* Title: FofaException
* Descrption: FofaException
* Date:2019-06-07 16:12
* Email:woo0nise@gmail.com
* Company:www.j2ee.app
*
* @author R4v3zn
* @version 1.0.0
*/
public class FofaException extends Exception{
/**
* Constructor
* @param msg message
*/
public FofaException(String msg){
super(msg);
}
}
================================================
FILE: src/main/java/com/suyu/core/util/HttpUtils.java
================================================
/*
* Copyright (c) 2019. r4v3zn.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.suyu.core.util;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.*;
import java.util.Map;
/**
* Title: HttpUtils
* Descrption: HttpUtils
* Date:2019-06-10 19:10
* Email:woo0nise@gmail.com
* Company:www.j2ee.app
* @author R4v3zn
* @version 1.0.0
*/
public class HttpUtils {
/**
* private
*/
private HttpUtils(){}
/**
* do get
* @param url requests url
* @return response info
*/
public static String doGet(String url){
return doGet(url,null);
}
/**
* do get
* @param actionUrl requests url
* @param map requests param
* @return response info
*/
public static String doGet(String actionUrl,Map map) {
String result = "";
try {
if(map != null && map.size() > 0){
actionUrl += "?";
for (String key: map.keySet()) {
actionUrl += key + "="+URLEncoder.encode(map.get(key).toString(), "UTF-8")+"&";
}
}
URL url = new URL(actionUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
BufferedReader reader = null;
if(HttpURLConnection.HTTP_OK == connection.getResponseCode()){
reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));
}else{
reader = new BufferedReader(new InputStreamReader(connection.getErrorStream(), "utf-8"));
}
String s = "";
String temp = "";
while ((temp = reader.readLine()) != null) {
s += temp;
}
result = s;
reader.close();
} catch (ProtocolException e) {
e.printStackTrace();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
}
================================================
FILE: src/main/java/com/suyu/utils/FileTools.java
================================================
package com.suyu.utils;
import java.io.*;
public class FileTools
{
public static byte[] getBytesByFile(final String filePath) throws IOException {
final InputStream in = new FileInputStream(filePath);
final byte[] data = toByteArray(in);
in.close();
return data;
}
public static byte[] toByteArray(final InputStream in) throws IOException {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final byte[] buffer = new byte[4096];
final boolean var3 = false;
int n;
while ((n = in.read(buffer)) != -1) {
out.write(buffer, 0, n);
}
return out.toByteArray();
}
public static byte[] readToBytes(final String path) throws IOException {
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
final File ff = new File(path);
final FileInputStream fs = new FileInputStream(ff);
final byte[] temp = new byte[4096];
final boolean var5 = false;
int len;
while ((len = fs.read(temp)) != -1) {
bos.write(temp, 0, len);
}
fs.close();
final byte[] data = bos.toByteArray();
bos.close();
return data;
}
public static String readFileToString(final String path) throws IOException {
final byte[] data = readToBytes(path);
final String str = new String(data, "UTF-8");
return str;
}
public static void writeFile(final String filePath, final String content) {
try {
final OutputStreamWriter write = new OutputStreamWriter(new FileOutputStream(filePath), "utf-8");
final BufferedWriter writer = new BufferedWriter(write);
writer.write(content);
writer.close();
}
catch (IOException var4) {
var4.printStackTrace();
}
}
public static String readOneLineTxtFile(final String filePath) {
try {
final String encoding = "utf-8";
final File file = new File(filePath);
if (file.isFile() && file.exists()) {
final InputStreamReader read = new InputStreamReader(new FileInputStream(file), encoding);
final BufferedReader bufferedReader = new BufferedReader(read);
final String lineTxt = bufferedReader.readLine();
bufferedReader.close();
read.close();
}
else {
System.out.println("\u627e\u4e0d\u5230\u6307\u5b9a\u7684\u6587\u4ef6,\u67e5\u770b\u6b64\u8def\u5f84\u662f\u5426\u6b63\u786e:" + filePath);
}
}
catch (Exception var6) {
System.out.println("\u8bfb\u53d6\u6587\u4ef6\u5185\u5bb9\u51fa\u9519");
}
return "";
}
public static String readFileAllContent(final String filePath, final String encoding) {
final StringBuffer fileContent = new StringBuffer();
try {
final File file = new File(filePath);
if (file.isFile() && file.exists()) {
final InputStreamReader read = new InputStreamReader(new FileInputStream(file), encoding);
final BufferedReader bufferedReader = new BufferedReader(read);
String lineTxt = null;
while ((lineTxt = bufferedReader.readLine()) != null) {
fileContent.append(lineTxt);
fileContent.append("\n");
}
read.close();
}
else {
System.out.println("\u627e\u4e0d\u5230\u6307\u5b9a\u7684\u6587\u4ef6,\u67e5\u770b\u6b64\u8def\u5f84\u662f\u5426\u6b63\u786e:" + filePath);
}
}
catch (Exception var7) {
System.out.println("\u8bfb\u53d6\u6587\u4ef6\u5185\u5bb9\u51fa\u9519");
}
return fileContent.toString();
}
}
================================================
FILE: src/main/java/com/suyu/utils/Path.java
================================================
package com.suyu.utils;
import java.net.*;
import java.io.*;
public class Path
{
public static String getRootPath() {
final URL url = Path.class.getProtectionDomain().getCodeSource().getLocation();
String filePath = "";
try {
filePath = URLDecoder.decode(url.getPath(), "UTF-8");
}
catch (Exception ex) {}
filePath = filePath.replace("\\", "/").replace("//", "/");
if (filePath.contains(":/") && filePath.startsWith("/")) {
filePath = filePath.substring(1);
}
if (filePath.endsWith(".jar")) {
filePath = filePath.substring(0, filePath.lastIndexOf("/") + 1);
}
return filePath;
}
public static String getClassResources() {
String cpath = new Object() {
public String getPath() {
return this.getClass().getResource("").getPath();
}
}.getPath();
cpath = URLDecoder.decode(cpath.replaceAll("file:/", ""));
if (cpath.indexOf(":") != 1) {
cpath = File.separator + cpath;
}
return cpath;
}
}
================================================
FILE: src/main/java/com/suyu/utils/Tools.java
================================================
package com.suyu.utils;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Tools
{
public static String date2Str(final Date date, final String format) {
if (date != null) {
final SimpleDateFormat sdf = new SimpleDateFormat(format);
return sdf.format(date);
}
return "";
}
public static String getTimeNow() {
return date2Str(new Date(), "yyyy-MM-dd HH:mm:ss");
}
}
================================================
FILE: src/main/java/com/suyu/views/FoFa.fxml
================================================