Skip to content

Commit

Permalink
删除请求中的email字段,只用key请求api
Browse files Browse the repository at this point in the history
针对不同会员级别设配的查询字段不同进行修正
更新readme
  • Loading branch information
f1ashine committed Jun 11, 2024
1 parent 14dbfff commit 8ca1471
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 59 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ VIP说明:https://fofa.info/vip
4. IP和端口两个一起排序?
先点击IP或者端口这一列的header进行排序,然后按住shift点击另一列就可以一起排序了。

5. 为什么显示“访问权限不足”?
**product****lastupdatetime** 两个参数需要“专业版及以上”才能使用,**fid**则需要企业版才能使用,个人版和注册用户无法使用该字段进行查询,查询时需要注意勾选。

## :rocket: 二次开发
```
git clone https://github.com/wgpsec/fofa_viewer.git
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/fofaviewer/bean/ExcelBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class ExcelBean extends BaseBean {
private Integer port;
private String protocol;
private String server;
@Setter
private String lastupdatetime;
@Setter
private String fid;
Expand All @@ -29,15 +30,14 @@ public class ExcelBean extends BaseBean {
@Setter
private String certs_subject_cn;

public ExcelBean(String host, String title, String ip, String domain, Integer port, String protocol, String server, String lastupdatetime) {
public ExcelBean(String host, String title, String ip, String domain, Integer port, String protocol, String server) {
this.host = host;
this.title = title;
this.ip = ip;
this.domain = domain;
this.port = port;
this.protocol = protocol;
this.server = server;
this.lastupdatetime = lastupdatetime;
}

@Override
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/org/fofaviewer/bean/TableBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class TableBean extends BaseBean{
@Getter
public SimpleStringProperty status = new SimpleStringProperty();

public TableBean(int num, String host, String title, String ip, String domain, int port, String protocol, String server, String lastupdatetime) {
public TableBean(int num, String host, String title, String ip, String domain, int port, String protocol, String server) {
this.num.set(num);
this.host.set(host);
this.title.set(title);
Expand All @@ -49,7 +49,6 @@ public TableBean(int num, String host, String title, String ip, String domain, i
this.port.set(port);
this.protocol.set(protocol);
this.server.set(server);
this.lastupdatetime.set(lastupdatetime);
}

public void setFid(String fid) {
Expand Down Expand Up @@ -80,11 +79,16 @@ public void setDomain(String value){
this.domain = new SimpleStringProperty(value);
}

public void setLastUpdateTime(String lastupdatetime) {
this.lastupdatetime = new SimpleStringProperty(lastupdatetime);
}

public int getIntNum(){
return num.intValue();
}



@Override
public boolean equals(Object obj) {
if (!(obj instanceof TableBean))
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/org/fofaviewer/controllers/MainController.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ public class MainController {
@FXML
private CheckBox certs_subject_org;
@FXML
private CheckBox lastUpdateTime;
@FXML
private CheckBox isAll;
@FXML
private CloseableTabPane tabPane;
Expand All @@ -122,6 +124,7 @@ private void initialize() {
keyMap.put(product, "product");
keyMap.put(certs_subject_cn, "certs_subject_cn");
keyMap.put(certs_subject_org,"certs_subject_org");
keyMap.put(lastUpdateTime, "lastupdatetime");
projectInfo = new HashMap<>();
projectInfo.put("status", Boolean.FALSE);
projectInfo.put("name", "");
Expand All @@ -131,6 +134,7 @@ private void initialize() {
icp.setText("icp");
product.setText(resourceBundle.getString("PRODUCT_FINGER"));
certs_subject_org.setText(resourceBundle.getString("CERT_ORG"));
lastUpdateTime.setText(resourceBundle.getString("LAST_UPDATE_TIME"));
about.setText(resourceBundle.getString("ABOUT"));
help.setText(resourceBundle.getString("HELP"));
project.setText(resourceBundle.getString("PROJECT"));
Expand Down Expand Up @@ -539,8 +543,9 @@ protected Void call() {
for(TableBean i : tableView.getItems()){
ExcelBean data = new ExcelBean(
i.host.getValue(), i.title.getValue(), i.ip.getValue(), i.domain.getValue(),
i.port.getValue(), i.protocol.getValue(), i.server.getValue(), i.lastupdatetime.getValue()
i.port.getValue(), i.protocol.getValue(), i.server.getValue()
);
data.setLastupdatetime(i.lastupdatetime.getValue());
data.setFid(i.fid.getValue());
data.setProduct(i.product.getValue());
data.setOs(i.os.getValue());
Expand Down Expand Up @@ -691,7 +696,7 @@ protected Void call() {
Label countLabel = (Label) statusBar.getRightItems().get(1);
Platform.runLater(() -> countLabel.setText(String.valueOf(Integer.parseInt(countLabel.getText()) + obj.getJSONArray("results").size())));
if(client.getCheckStatus()){
result = helper.getLeftAmount(String.format(client.personalInfoAPI, client.getEmail(), client.getKey()), 120000, 120000);
result = helper.getLeftAmount(String.format(client.personalInfoAPI, client.getKey()), 120000, 120000);
if (result.get("code").equals("200")) {
Label infoLabel = (Label)statusBar.getLeftItems().get(0);
String msg = result.get("msg");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ public class SetConfigDialogController {
@FXML
private Label label_fofa_api;
@FXML
private Label label_fofa_email;
@FXML
private Label label_fofa_key;
@FXML
private Label label_fofa_max_size;
Expand All @@ -44,8 +42,6 @@ public class SetConfigDialogController {
@FXML
private TextField fofa_api;
@FXML
private TextField fofa_email;
@FXML
private TextField fofa_key;
@FXML
private TextField fofa_max_size;
Expand Down Expand Up @@ -80,7 +76,6 @@ private void initialize(){
disableCheck.setText(bundle.getString("DISABLE_RADIO"));
disable.setText(bundle.getString("DISABLE_RADIO"));
label_fofa_api.setText(bundle.getString("FOFA_API"));
label_fofa_email.setText(bundle.getString("FOFA_EMAIL"));
label_fofa_key.setText(bundle.getString("FOFA_KEY"));
label_fofa_max_size.setText(bundle.getString("FOFA_MAX_SIZE"));
label_proxy_ip.setText(bundle.getString("PROXY_IP_ADDRESS"));
Expand All @@ -90,7 +85,6 @@ private void initialize(){
labelCombo.setText(bundle.getString("PROXY_TYPE"));
propertiesMap = new HashMap<TextField, String>(){{
put(fofa_api, "api");
put(fofa_email, "email");
put(fofa_key, "key");
put(fofa_max_size, "max_size");
put(proxy_ip, "proxy_ip");
Expand All @@ -117,13 +111,12 @@ private void initialize(){
public void setAction(DialogPane dialogPane){
dialogPane.lookupButton(ButtonType.OK).addEventFilter(ActionEvent.ACTION, e -> {
createConfigFile();
if(enable.isSelected() && (proxy_ip.getText().equals("") || proxy_port.getText().equals(""))){
if(enable.isSelected() && (proxy_ip.getText().isEmpty() || proxy_port.getText().isEmpty())){
DataUtil.showAlert(Alert.AlertType.WARNING, null, bundle.getString("PROXY_SET_ERROR")).showAndWait();
e.consume();
}else{
Properties properties = new Properties();
try {
fofaConfig.setEmail(fofa_email.getText());
fofaConfig.API = fofa_api.getText();
fofaConfig.setSize(fofa_max_size.getText());
fofaConfig.setKey(fofa_key.getText());
Expand Down Expand Up @@ -168,7 +161,6 @@ private void createConfigFile(){

private void loadConfigFile(){
this.fofa_api.setText(fofaConfig.API);
this.fofa_email.setText(fofaConfig.getEmail());
this.fofa_key.setText(fofaConfig.getKey());
this.fofa_max_size.setText(fofaConfig.getSize());
if(proxyConfig.getStatus()){
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/fofaviewer/controls/MyTableView.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public MyTableView(TableView<TableBean> view, MainControllerCallback mainControl
case "os" : os.setVisible(false);break;
case "icp" : icp.setVisible(false);break;
case "product" : product.setVisible(false);break;
case "lastupdatetime" : lastupdatetime.setVisible(false);break;
case "certs_subject_org" : certOrg.setVisible(false);break;
case "certs_subject_cn" : certCN.setVisible(false);break;
}
Expand Down
19 changes: 4 additions & 15 deletions src/main/java/org/fofaviewer/main/FofaConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,19 @@ public class FofaConfig {
private static FofaConfig config = null;
@Setter
private boolean checkStatus;
private String email;
private String key;
private final String page = "1";
// private final String page = "1";
public final int max = 10000;
private String size = "1000";
public String API = "https://fofa.info";
public String personalInfoAPI = "https://fofa.info/api/v1/info/my?email=%s&key=%s";
public String personalInfoAPI = "https://fofa.info/api/v1/info/my?key=%s";
// 改用连续翻页接口
public final String path = "/api/v1/search/next";
public static final String TIP_API = "https://api.fofa.info/v1/search/tip?q=";
private final String[] fields = new String[]{"host","title","ip","domain","port","protocol","server","lastupdatetime","link"};
private final String[] fields = new String[]{"host","title","ip","domain","port","protocol","server","link"};
public ArrayList<String> additionalField;

private FofaConfig(){
this.email = "";
this.key = "";
}

Expand All @@ -32,18 +30,10 @@ public static FofaConfig getInstance(){
return config;
}

public String getEmail() {
return email;
}

public String getKey() {
return key;
}

public void setEmail(String email) {
this.email = email;
}

public void setKey(String key) {
this.key = key;
}
Expand All @@ -61,8 +51,7 @@ public void setSize(String size){
}

public String getParam(boolean isAll) {
return API + path + "?email=" + email + "&key=" + key + (isAll ? "&full=true" : "") + "&page=" +
this.page + "&size=" + size + "&fields=" + getFields() + "&qbase64=";
return API + path + "?key=" + key + (isAll ? "&full=true" : "") + "&size=" + size + "&fields=" + getFields() + "&qbase64=";
}

public String getFields(){
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/fofaviewer/main/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.fofaviewer.controllers.MainController;

public class MainApp extends Application {
private final String version = "1.1.14";
private final String version = "1.1.15";

@Override
public void start(Stage stage) throws Exception {
Expand Down
25 changes: 14 additions & 11 deletions src/main/java/org/fofaviewer/utils/DataUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ public static void exportToExcel(String fileName, String tabTitle, List<ExcelBea
excelWriter.addHeaderAlias("port", "端口");
excelWriter.addHeaderAlias("protocol", "协议");
excelWriter.addHeaderAlias("server", "server指纹");
excelWriter.addHeaderAlias("lastupdatetime", "最近更新时间");
if(config.additionalField.contains("lastupdatetime")){
excelWriter.addHeaderAlias("lastupdatetime", "最近更新时间");
}
if (config.additionalField.contains("os")) {
excelWriter.addHeaderAlias("os", "操作系统");
}
Expand Down Expand Up @@ -94,10 +96,11 @@ public static void exportToExcel(String fileName, String tabTitle, List<ExcelBea
headerStyle.setFont(headerFont);
excelWriter.setStyleSet(style);

excelWriter.merge(7 + config.additionalField.size(), tabTitle, true);
excelWriter.merge(6 + config.additionalField.size(), tabTitle, true);
excelWriter.write(totalData, true);
excelWriter.setSheet("urls");
excelWriter.write(urls);
excelWriter.setColumnWidth(0, 40);
if(errorPage.length() == 0){
showAlert(Alert.AlertType.INFORMATION, null, resourceBundle.getString("EXPORT_MESSAGE1") + fileName).showAndWait();
}else{
Expand Down Expand Up @@ -134,18 +137,18 @@ public static List<? extends BaseBean> loadJsonData(TabDataBean bean,
continue;
}
String server = _array.getString(6);
String lastupdatetime = _array.getString(7);
String link = _array.getString(8);
String link = _array.getString(7);
HashMap<String, String> map = new HashMap<String, String>(){{
put("fid","");put("os","");put("icp", "");put("product","");put("certs_subject_cn","");put("certs_subject_org","");
put("fid","");put("os","");put("icp", "");put("product","");put("certs_subject_cn","");put("certs_subject_org","");put("lastupdatetime","");
}};
for(String item : map.keySet()){
if(fileds.contains(item)){
map.put(item, _array.getString(9+fileds.indexOf(item)));
map.put(item, _array.getString(8+fileds.indexOf(item)));
}
}
if(isExport){ // 是否为导出数据
ExcelBean d = new ExcelBean(host, title, ip, domain, port, protocol, server, lastupdatetime);
ExcelBean d = new ExcelBean(host, title, ip, domain, port, protocol, server);
d.setLastupdatetime(map.get("lastupdatetime"));
d.setFid(map.get("fid"));
d.setOs(map.get("os"));
d.setProduct(map.get("product"));
Expand All @@ -165,7 +168,7 @@ public static List<? extends BaseBean> loadJsonData(TabDataBean bean,
}
}
if(d2.getHost().equals(d.getHost())){
if(!d2.getTitle().equals("")){
if(!d2.getTitle().isEmpty()){
continue;
}else {
excelData.remove(d2);
Expand All @@ -176,13 +179,14 @@ public static List<? extends BaseBean> loadJsonData(TabDataBean bean,
if(!link.isEmpty())
urlList.add(link);
}else{ // table 页更新数据
TableBean b = new TableBean(0, host, title, ip, domain, port, protocol, server, lastupdatetime);
TableBean b = new TableBean(0, host, title, ip, domain, port, protocol, server);
b.setFid(map.get("fid"));
b.setIcp(map.get("icp"));
b.setOs(map.get("os"));
b.setCertCN(map.get("certs_subject_cn"));
b.setProduct(map.get("product"));
b.setCertOrg(map.get("certs_subject_org"));
b.setLastUpdateTime(map.get("lastupdatetime"));
if(list.contains(b)){
TableBean b2 = list.get(list.indexOf(b));
if(port == 443 || port == 80){
Expand All @@ -196,7 +200,7 @@ public static List<? extends BaseBean> loadJsonData(TabDataBean bean,
}
// host 相同时 去掉不带title的
if(b2.host.getValue().equals(b.host.getValue())){
if(!b2.title.getValue().equals("")){
if(!b2.title.getValue().isEmpty()){
continue;
}else{
b.num = b2.num;
Expand Down Expand Up @@ -260,7 +264,6 @@ public static FofaConfig loadConfigure(){
try {
properties.load(new FileReader(SQLiteUtils.getPath() + "config.properties"));
client = FofaConfig.getInstance();
client.setEmail(properties.getProperty("email").trim());
client.setKey(properties.getProperty("key").trim());
client.setAPI(properties.getProperty("api").trim());
client.setSize(properties.getProperty("max_size"));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/fofaviewer/utils/RequestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public HashMap<String, String> getHTML(String url, int connectTimeout, int socks
String body = response.readToText(); // 默认使用utf-8编码
result.put("msg", body);
} else if (code == 401) {
result.put("msg", "请求错误状态码401,可能是没有在config中配置有效的email和key,或者您的账号权限不足无法使用api进行查询。");
result.put("msg", "请求错误状态码401,可能是没有在config中配置有效的key,或者您的账号权限不足无法使用api进行查询。");
} else if (code == 502) {
result.put("msg", "请求错误状态码502,可能是账号限制了每次请求的最大数量,建议尝试修改config中的maxSize为100");
} else {
Expand Down
14 changes: 6 additions & 8 deletions src/main/resources/fxml/SetConfigDialog.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@
<padding><Insets right="10.0D" left="10.0D"/></padding>
<Label fx:id="label_fofa_api" GridPane.columnIndex="0" GridPane.rowIndex="0"/>
<TextField fx:id="fofa_api" GridPane.columnIndex="1" GridPane.rowIndex="0" prefWidth="250"/>
<Label fx:id="label_fofa_email" GridPane.columnIndex="0" GridPane.rowIndex="1"/>
<TextField fx:id="fofa_email" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
<Label fx:id="label_fofa_key" GridPane.columnIndex="0" GridPane.rowIndex="2"/>
<TextField fx:id="fofa_key" GridPane.columnIndex="1" GridPane.rowIndex="2"/>
<Label fx:id="label_fofa_max_size" GridPane.columnIndex="0" GridPane.rowIndex="3"/>
<TextField fx:id="fofa_max_size" GridPane.columnIndex="1" GridPane.rowIndex="3"/>
<Label fx:id="checkLeftAmount" GridPane.columnIndex="0" GridPane.rowIndex="4"/>
<HBox spacing="10.0D" GridPane.columnIndex="1" GridPane.rowIndex="4">
<Label fx:id="label_fofa_key" GridPane.columnIndex="0" GridPane.rowIndex="1"/>
<TextField fx:id="fofa_key" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
<Label fx:id="label_fofa_max_size" GridPane.columnIndex="0" GridPane.rowIndex="2"/>
<TextField fx:id="fofa_max_size" GridPane.columnIndex="1" GridPane.rowIndex="2"/>
<Label fx:id="checkLeftAmount" GridPane.columnIndex="0" GridPane.rowIndex="3"/>
<HBox spacing="10.0D" GridPane.columnIndex="1" GridPane.rowIndex="3">
<RadioButton fx:id="enableCheck" />
<RadioButton fx:id="disableCheck" />
</HBox>
Expand Down
9 changes: 6 additions & 3 deletions src/main/resources/fxml/fofa_viewer.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,16 @@
<CheckBox fx:id="withFid" mnemonicParsing="false">
<HBox.margin><Insets top="4"/></HBox.margin>
</CheckBox>
<CheckBox fx:id="os" mnemonicParsing="false">
<CheckBox fx:id="lastUpdateTime" mnemonicParsing="false">
<HBox.margin><Insets top="4"/></HBox.margin>
</CheckBox>
<CheckBox fx:id="icp" mnemonicParsing="false">
<CheckBox fx:id="product" mnemonicParsing="false">
<HBox.margin><Insets top="4"/></HBox.margin>
</CheckBox>
<CheckBox fx:id="product" mnemonicParsing="false">
<CheckBox fx:id="os" mnemonicParsing="false">
<HBox.margin><Insets top="4"/></HBox.margin>
</CheckBox>
<CheckBox fx:id="icp" mnemonicParsing="false">
<HBox.margin><Insets top="4"/></HBox.margin>
</CheckBox>
<CheckBox fx:id="certs_subject_cn" mnemonicParsing="false" selected="true">
Expand Down
Loading

0 comments on commit 8ca1471

Please sign in to comment.