Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bit4woo committed Apr 7, 2024
1 parent fd5a2a8 commit 897d614
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 79 deletions.
3 changes: 1 addition & 2 deletions src/GUI/GUIMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ public GUIMain(IBurpExtender burp) {//构造函数

public void renewConfigPanel() {
tabbedWrapper.remove(configPanel);
new ConfigPanel(this);
tabbedWrapper.addTab("Config", null,configPanel,null);
tabbedWrapper.addTab("Config", null,new ConfigPanel(this),null);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/InternetSearch/APISearchAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -58,8 +59,7 @@ public APISearchAction(AbstractTableModel lineModel, int[] modelRows, int column
}

public APISearchAction(AbstractTableModel lineModel, int[] modelRows, int columnIndex, String engine,boolean autoAddToTarget, boolean showInGUI) {
this(lineModel, modelRows, columnIndex,new ArrayList<>(), autoAddToTarget, showInGUI);
engineList.add(engine);
this(lineModel, modelRows, columnIndex,new ArrayList<>(Collections.singletonList(engine)), autoAddToTarget, showInGUI);
}

public APISearchAction(AbstractTableModel lineModel, int[] modelRows, int columnIndex, String engine) {
Expand Down
3 changes: 3 additions & 0 deletions src/base/Stack.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public boolean contains(String t) {
return stack.contains(t);
}

public List<String> getItemList(){
return new ArrayList<>(stack);
}

public static void main(String[] args) {
Stack stack = new Stack();
Expand Down
12 changes: 12 additions & 0 deletions src/burp/ProjectMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ public void actionPerformed(ActionEvent actionEvent) {
openMenu.setToolTipText("Open Domain Hunter Project File(DB File)");
this.add(openMenu);

JMenu openRecentMenu = new JMenu("Open Recent");
gui.getDataLoadManager().createRecentOpenItem(openRecentMenu);
openMenu.setToolTipText("Open Recent Domain Hunter Project File(DB File)");
this.add(openRecentMenu);

JMenuItem renameMenu = new JMenuItem(new AbstractAction("Rename(Save As)")
{
Expand Down Expand Up @@ -194,6 +198,14 @@ public void openDb() {
}
}


public void openRecentDb() {
File file = gui.dbfc.dialog(true,".db");
if (null != file) {
gui.getDataLoadManager().loadDbfileToHunter(file.toString());
}
}

public void Add() {
int count = 500;
JMenuBar menuBar = getBurpFrame().getJMenuBar();
Expand Down
172 changes: 104 additions & 68 deletions src/config/ConfigManager.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package config;

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.io.FileUtils;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

Expand Down Expand Up @@ -33,15 +36,15 @@ public class ConfigManager {
public static final String defaultDirSearch = "python3 dirsearch.py -t 8 --proxy=127.0.0.1:8080 "
+ "--random-agent -e * -f -x 400,404,500,502,503,514,550,564 -u {url}";
public static final String macDefaultBrowserPath = "/Applications/Firefox.app/Contents/MacOS/firefox";
public static final String defaultDirDictPath ="D:\\github\\webdirscan\\dict\\dict.txt";
public static final String defaultDirDictPath ="D:\\github\\webdirscan\\dict\\dict.txt";

private GUIMain gui;

ConfigManager(){
//to resolve "default constructor not found" error
}

public String getBrowserPath() {
public static String getBrowserPath() {
if (Commons.isMac()) {
return macDefaultBrowserPath;
}else {
Expand All @@ -62,40 +65,74 @@ public static void setConfigList(List<ConfigEntry> configList) {
ConfigManager.configList = configList;
}

public ConfigManager(String Name){
this.configManagerName = Name;
configList.add(new ConfigEntry(ConfigName.BrowserPath,getBrowserPath(),"",true,true));
configList.add(new ConfigEntry(ConfigName.PortScanCmd,defaultNmap,"",true,true));
configList.add(new ConfigEntry(ConfigName.DirBruteCmd,defaultDirSearch,"",true,true));
configList.add(new ConfigEntry(ConfigName.DirDictPath,"","",true,true));
configList.add(new ConfigEntry(ConfigName.ElasticURL,"http://10.12.72.55:9200/","",true,true));
configList.add(new ConfigEntry(ConfigName.ElasticUserPass,"elastic:changeme","username and password of elastic API",true,true));

configList.add(new ConfigEntry(ConfigName.UploadApiURL,"","",true,true));
configList.add(new ConfigEntry(ConfigName.UploadApiToken,"","",true,true));

configList.add(new ConfigEntry(ConfigName.FofaEmail,"","",true,true));
configList.add(new ConfigEntry(ConfigName.FofaKey,"","",true,true));

configList.add(new ConfigEntry(ConfigName.Quake360APIKey,"","",true,true));
configList.add(new ConfigEntry(ConfigName.Ti360APIKey,"","",true,true));
configList.add(new ConfigEntry(ConfigName.QianxinHunterAPIKey,"","",true,true));
configList.add(new ConfigEntry(ConfigName.QianxinTiAPIKey,"","",true,true));
configList.add(new ConfigEntry(ConfigName.ZoomEyeAPIKey,"","",true,true));
configList.add(new ConfigEntry(ConfigName.ShodanAPIKey,"","",true,true));

configList.add(new ConfigEntry(ConfigName.ProxyForGetCert,"127.0.0.1:7890","",true,true));


configList.add(new ConfigEntry(ConfigName.showBurpMenu,"true","",true,true));
configList.add(new ConfigEntry(ConfigName.showMenuItemsInOne,"true","",true,true));
configList.add(new ConfigEntry(ConfigName.ignoreHTTPS,"false","",true,true));
configList.add(new ConfigEntry(ConfigName.ignoreHTTP,"true","",true,true));
configList.add(new ConfigEntry(ConfigName.ignoreHTTPStaus500,"true","",true,true));
configList.add(new ConfigEntry(ConfigName.ignoreHTTPStaus400,"true","",true,true));
configList.add(new ConfigEntry(ConfigName.ignoreWrongCAHost,"false","",true,true));
configList.add(new ConfigEntry(ConfigName.removeItemIfIgnored,"true","",true,true));
configList.add(new ConfigEntry(ConfigName.SaveTrafficToElastic,"false","",true,true));
public static void init(String configManagerFile) {
if (initFromFile(configManagerFile) && configList.size() >0) {
return;
}
initDefault();
}

/**
* 从文件中初始化ConfigManager对象
* @param configManagerFile
* @return
*/
private static boolean initFromFile(String configManagerFile) {
if (configManagerFile != null){
try {
File localFile = new File(configManagerFile);
if (localFile.exists()) {
String jsonstr = FileUtils.readFileToString(localFile,"UTF-8");
FromJson(jsonstr);
return true;
}
} catch (IOException e) {
e.printStackTrace();
e.printStackTrace(BurpExtender.getStderr());
}
}
return false;
}

private static boolean initDefault(){
try {
configList.add(new ConfigEntry(ConfigName.BrowserPath,getBrowserPath(),"",true,true));
configList.add(new ConfigEntry(ConfigName.PortScanCmd,defaultNmap,"",true,true));
configList.add(new ConfigEntry(ConfigName.DirBruteCmd,defaultDirSearch,"",true,true));
configList.add(new ConfigEntry(ConfigName.DirDictPath,defaultDirDictPath,"",true,true));
configList.add(new ConfigEntry(ConfigName.ElasticURL,"http://10.12.72.55:9200/","",true,true));
configList.add(new ConfigEntry(ConfigName.ElasticUserPass,"elastic:changeme","username and password of elastic API",true,true));

configList.add(new ConfigEntry(ConfigName.UploadApiURL,"","",true,true));
configList.add(new ConfigEntry(ConfigName.UploadApiToken,"","",true,true));

configList.add(new ConfigEntry(ConfigName.FofaEmail,"","",true,true));
configList.add(new ConfigEntry(ConfigName.FofaKey,"","",true,true));

configList.add(new ConfigEntry(ConfigName.Quake360APIKey,"","",true,true));
configList.add(new ConfigEntry(ConfigName.Ti360APIKey,"","",true,true));
configList.add(new ConfigEntry(ConfigName.QianxinHunterAPIKey,"","",true,true));
configList.add(new ConfigEntry(ConfigName.QianxinTiAPIKey,"","",true,true));
configList.add(new ConfigEntry(ConfigName.ZoomEyeAPIKey,"","",true,true));
configList.add(new ConfigEntry(ConfigName.ShodanAPIKey,"","",true,true));

configList.add(new ConfigEntry(ConfigName.ProxyForGetCert,"127.0.0.1:7890","",true,true));


configList.add(new ConfigEntry(ConfigName.showBurpMenu,"true","",true,true));
configList.add(new ConfigEntry(ConfigName.showMenuItemsInOne,"true","",true,true));
configList.add(new ConfigEntry(ConfigName.ignoreHTTPS,"false","",true,true));
configList.add(new ConfigEntry(ConfigName.ignoreHTTP,"true","",true,true));
configList.add(new ConfigEntry(ConfigName.ignoreHTTPStaus500,"true","",true,true));
configList.add(new ConfigEntry(ConfigName.ignoreHTTPStaus400,"true","",true,true));
configList.add(new ConfigEntry(ConfigName.ignoreWrongCAHost,"false","",true,true));
configList.add(new ConfigEntry(ConfigName.removeItemIfIgnored,"true","",true,true));
configList.add(new ConfigEntry(ConfigName.SaveTrafficToElastic,"false","",true,true));
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}

public String getConfigManagerName() {
Expand All @@ -115,34 +152,34 @@ public String ToJsonDeprecated(){//注意函数名称,如果是get set开头
public static ConfigManager FromJsonDeprecated(String json){//注意函数名称,如果是get set开头,会被认为是Getter和Setter函数,会在序列化过程中被调用。
return new Gson().fromJson(json, ConfigManager.class);
}


public static String ToJson(){//注意函数名称,如果是get set开头,会被认为是Getter和Setter函数,会在序列化过程中被调用。
return configListToJson();
}

public static void FromJson(String json){//注意函数名称,如果是get set开头,会被认为是Getter和Setter函数,会在序列化过程中被调用。
configList = configListFromJson(json);
}

public static String configListToJson(){
return new Gson().toJson(configList);
}

public static List<ConfigEntry> configListFromJson(String json){
// 创建一个Gson对象
Gson gson = new Gson();
// 使用TypeToken来获取List<ConfigEntry>的Type
java.lang.reflect.Type listType = new TypeToken<List<ConfigEntry>>(){}.getType();
Gson gson = new Gson();
// 使用TypeToken来获取List<ConfigEntry>的Type
java.lang.reflect.Type listType = new TypeToken<List<ConfigEntry>>(){}.getType();

// 使用fromJson方法将JSON字符串反序列化为List<ConfigEntry>对象
List<ConfigEntry> configList = gson.fromJson(json, listType);
return configList;
// 使用fromJson方法将JSON字符串反序列化为List<ConfigEntry>对象
List<ConfigEntry> configList = gson.fromJson(json, listType);
return configList;
}



// 现在你可以使用configList了,它是一个List<ConfigEntry>对象

// 现在你可以使用configList了,它是一个List<ConfigEntry>对象

public static String getStringConfigByKey(String configKey) {
if(ConfigName.getAllConfigNames().contains(configKey)) {
Expand All @@ -159,22 +196,22 @@ public static String getStringConfigByKey(String configKey) {

public static boolean getBooleanConfigByKey(String configKey){
if(ConfigName.getAllConfigNames().contains(configKey)) {
for (ConfigEntry entry : configList) {
if (entry.getKey().equalsIgnoreCase(configKey)) {
try {
return Boolean.parseBoolean(entry.getValue());
} catch (IllegalArgumentException e) {
BurpExtender.getStderr().println("Invalid boolean value for config key: " + configKey);
}
}
}
}else {
for (ConfigEntry entry : configList) {
if (entry.getKey().equalsIgnoreCase(configKey)) {
try {
return Boolean.parseBoolean(entry.getValue());
} catch (IllegalArgumentException e) {
BurpExtender.getStderr().println("Invalid boolean value for config key: " + configKey);
}
}
}
}else {
BurpExtender.getStderr().println("Config key not found: " + configKey);
}
return false;
}


public static void setConfigValue(String configKey,String configValue) {
if(ConfigName.getAllConfigNames().contains(configKey)) {
for (ConfigEntry entry:configList) {
Expand All @@ -189,19 +226,19 @@ public static void setConfigValue(String configKey,String configValue) {

public static boolean setConfigValue(String configKey,boolean configValue){
if(ConfigName.getAllConfigNames().contains(configKey)) {
for (ConfigEntry entry : configList) {
if (entry.getKey().equalsIgnoreCase(configKey)) {
if (entry.getKey().equalsIgnoreCase(configKey)) {
for (ConfigEntry entry : configList) {
if (entry.getKey().equalsIgnoreCase(configKey)) {
if (entry.getKey().equalsIgnoreCase(configKey)) {
entry.setValue(configValue+"");
}
}
}
}else {
}
}
}else {
BurpExtender.getStderr().println("Config key not found: " + configKey);
}
return false;
}


/**
* 当从文件恢复出当前对象后,需要通过setter来设置gui
Expand All @@ -212,10 +249,9 @@ public void setGui(GUIMain gui) {
}

public static void main(String[] args) {
System.out.println(new ConfigManager("test").ToJson());
System.out.println(new ConfigManager().ToJson());
}


/**
*是否是从http跳转到相同URL的https
**/
Expand Down
8 changes: 4 additions & 4 deletions src/config/ConfigPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void actionPerformed(ActionEvent e) {

add(radioButton, new MyGridBagLayout(++rowIndex,2));
}else {
JLabel label = new JLabel(config.getKey());
JLabel label = new JLabel(config.getKey()+":");

JTextField textField = new JTextField();
textField.setText(config.getValue());
Expand Down Expand Up @@ -100,7 +100,7 @@ public void changedUpdate(DocumentEvent e) {
});

// 添加到界面
add(label, new MyGridBagLayout(++rowIndex,1));
add(label, new MyGridBagLayout(rowIndex,1));
add(textField, new MyGridBagLayout(rowIndex,2));
}
}
Expand All @@ -114,9 +114,9 @@ public ConfigPanel(GUIMain gui) {
for (JButton button:creatControlButtons()) {
add(button, new MyGridBagLayout(++rowIndex,1));
}

//需要提取初始化ConfigManager
for (ConfigEntry config:ConfigManager.getConfigList()) {
addConfigItem(config,rowIndex);
addConfigItem(config,++rowIndex);
}
}

Expand Down
Loading

0 comments on commit 897d614

Please sign in to comment.