Skip to content

Commit

Permalink
将数据看板界面的复选框状态保存到配置文件;将Disable选项功能更改为Enable
Browse files Browse the repository at this point in the history
  • Loading branch information
vaycore committed May 29, 2023
1 parent caef6f1 commit 9bb45f6
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 24 deletions.
6 changes: 3 additions & 3 deletions src/main/java/burp/BurpExtender.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ private void doScan(IHttpRequestResponse httpReqResp, boolean fromProxy) {
// 收集响应包中的Json字段信息
collectJsonField(httpReqResp);
// 检测是否禁用递归扫描
if (!mDataBoardTab.hasDisableDirScan()) {
if (mDataBoardTab.hasDirScan()) {
// 一级目录一级目录递减访问
for (int i = pathDict.size() - 1; i >= 0; i--) {
String path = pathDict.get(i);
Expand Down Expand Up @@ -398,7 +398,7 @@ private void doBurpRequest(IHttpRequestResponse httpReqResp, byte[] request) {
}

private byte[] handleExcludeHeader(IHttpRequestResponse httpReqResp, byte[] request) {
boolean state = mDataBoardTab.hasEnableExcludeHeader();
boolean state = mDataBoardTab.hasExcludeHeader();
List<String> excludeHeader = WordlistManager.getExcludeHeader();
if (!state || excludeHeader.isEmpty()) {
return request;
Expand Down Expand Up @@ -434,7 +434,7 @@ private String buildRequestHeader(IHttpRequestResponse httpReqResp, String urlPa
// 请求头构造
request.append("GET ").append(urlPath).append(" HTTP/1.1").append("\r\n");
// 如果存在配置并且未禁用替换请求头,直接加载配置的值,否则使用原请求包的请求头
if (!mDataBoardTab.hasDisableHeaderReplace() && headerList.size() > 0) {
if (mDataBoardTab.hasReplaceHeader() && headerList.size() > 0) {
for (String headerItem : headerList) {
int splitIndex = headerItem.indexOf(": ");
if (splitIndex == -1) {
Expand Down
22 changes: 19 additions & 3 deletions src/main/java/burp/vaycore/onescan/common/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* Created by vaycore on 2022-08-19.
*/
public class Config {
// 配置项
public static final String KEY_VERSION = "version";
public static final String KEY_PAYLOAD_PROCESS_LIST = "payload-process-list";
public static final String KEY_QPS_LIMIT = "qps-limit";
Expand All @@ -31,6 +32,11 @@ public class Config {
public static final String KEY_HAE_PLUGIN_PATH = "hae-plugin-path";
public static final String KEY_INCLUDE_METHOD = "include-method";
public static final String KEY_WORDLIST_PATH = "dict-path";
// 首页开关配置项
public static final String KEY_ENABLE_LISTEN_PROXY = "enable-listen-proxy";
public static final String KEY_ENABLE_EXCLUDE_HEADER = "enable-exclude-header";
public static final String KEY_ENABLE_REPLACE_HEADER = "enable-replace-header";
public static final String KEY_ENABLE_DIR_SCAN = "enable-dir-scan";
private static ConfigManager sConfigManager;
private static String sConfigPath;

Expand All @@ -48,6 +54,11 @@ public static void init() {
"woff2|xbm|xls|xlsx|xpm|xul|xwd|zip|zip");
initDefaultConfig(Config.KEY_INCLUDE_METHOD, "GET|POST");
initDefaultConfig(Config.KEY_WORDLIST_PATH, getWorkDir() + "wordlist");
// 默认开关配置
initDefaultConfig(Config.KEY_ENABLE_LISTEN_PROXY, "false");
initDefaultConfig(Config.KEY_ENABLE_EXCLUDE_HEADER, "false");
initDefaultConfig(Config.KEY_ENABLE_REPLACE_HEADER, "true");
initDefaultConfig(Config.KEY_ENABLE_DIR_SCAN, "true");
// 初始化字典管理
WordlistManager.init(get(Config.KEY_WORDLIST_PATH));
// 初始化指纹管理
Expand All @@ -71,13 +82,12 @@ private static void initFpManager() {

private static void onVersionUpgrade() {
String version = getVersion();
if (!version.equals("1.0.0")) {
putVersion("1.0.0");
if (!version.equals(Constants.PLUGIN_VERSION)) {
putVersion(Constants.PLUGIN_VERSION);
upgradeDomain();
upgradeRemoveHeaderList();
upgradeWordlist();
}

}

private static void upgradeDomain() {
Expand Down Expand Up @@ -201,6 +211,12 @@ public static String get(String key) {
return sConfigManager.get(key);
}

public static boolean getBoolean(String key) {
checkInit();
String value = sConfigManager.get(key);
return "true".equals(value);
}

public static ArrayList<String> getList(String key) {
checkInit();
return sConfigManager.getList(key);
Expand Down
46 changes: 28 additions & 18 deletions src/main/java/burp/vaycore/onescan/ui/tab/DataBoardTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import burp.vaycore.common.widget.HintTextField;
import burp.vaycore.onescan.bean.FpData;
import burp.vaycore.onescan.bean.TaskData;
import burp.vaycore.onescan.common.Config;
import burp.vaycore.onescan.common.DialogCallbackAdapter;
import burp.vaycore.onescan.manager.FpManager;
import burp.vaycore.onescan.ui.base.BaseTab;
Expand All @@ -30,9 +31,9 @@ public class DataBoardTab extends BaseTab {

private TaskTable mTaskTable;
private JCheckBox mListenProxyMessage;
private JCheckBox mEnableExcludeHeader;
private JCheckBox mDisableHeaderReplace;
private JCheckBox mDisableDirScan;
private JCheckBox mExcludeHeader;
private JCheckBox mReplaceHeader;
private JCheckBox mDirScan;
private ArrayList<FilterRule> mLastFilters;
private HintTextField mFilterRuleText;

Expand Down Expand Up @@ -83,13 +84,13 @@ public void init(Component requestTextEditor, Component responseTextEditor) {
controlPanel.setLayout(new HLayout(5, true));
add(controlPanel);
// 代理监听开关
mListenProxyMessage = newJCheckBox(controlPanel, "Listen Proxy Message");
// 启用请求头排除开关
mEnableExcludeHeader = newJCheckBox(controlPanel, "Enable ExcludeHeader");
// 禁用请求头替换功能
mDisableHeaderReplace = newJCheckBox(controlPanel, "Disable HeaderReplace");
// 禁用递归扫描功能
mDisableDirScan = newJCheckBox(controlPanel, "Disable DirScan");
mListenProxyMessage = newJCheckBox(controlPanel, "Listen Proxy Message", Config.KEY_ENABLE_LISTEN_PROXY);
// 请求头排除开关
mExcludeHeader = newJCheckBox(controlPanel, "Exclude Header", Config.KEY_ENABLE_EXCLUDE_HEADER);
// 请求头替换开关
mReplaceHeader = newJCheckBox(controlPanel, "Replace Header", Config.KEY_ENABLE_REPLACE_HEADER);
// 递归扫描开关
mDirScan = newJCheckBox(controlPanel, "DirScan", Config.KEY_ENABLE_DIR_SCAN);
// 过滤设置
controlPanel.add(new JPanel(), "1w");
mFilterRuleText = new HintTextField();
Expand Down Expand Up @@ -122,11 +123,20 @@ public void init(Component requestTextEditor, Component responseTextEditor) {
add(mainSplitPanel, "100%");
}

private JCheckBox newJCheckBox(JPanel panel, String text) {
JCheckBox checkBox = new JCheckBox(text, false);
private JCheckBox newJCheckBox(JPanel panel, String text, String configKey) {
JCheckBox checkBox = new JCheckBox(text, Config.getBoolean(configKey));
checkBox.setFocusable(false);
checkBox.setMargin(new Insets(5, 5, 5, 5));
panel.add(checkBox);
checkBox.addActionListener(e -> {
boolean configSelected = Config.getBoolean(configKey);
boolean selected = checkBox.isSelected();
if (selected == configSelected) {
return;
}
// 保存配置
Config.put(configKey, String.valueOf(selected));
});
return checkBox;
}

Expand All @@ -138,16 +148,16 @@ public boolean hasListenProxyMessage() {
return mListenProxyMessage != null && mListenProxyMessage.isSelected();
}

public boolean hasEnableExcludeHeader() {
return mEnableExcludeHeader != null && mEnableExcludeHeader.isSelected();
public boolean hasExcludeHeader() {
return mExcludeHeader != null && mExcludeHeader.isSelected();
}

public boolean hasDisableHeaderReplace() {
return mDisableHeaderReplace != null && mDisableHeaderReplace.isSelected();
public boolean hasReplaceHeader() {
return mReplaceHeader != null && mReplaceHeader.isSelected();
}

public boolean hasDisableDirScan() {
return mDisableDirScan != null && mDisableDirScan.isSelected();
public boolean hasDirScan() {
return mDirScan != null && mDirScan.isSelected();
}

/**
Expand Down

0 comments on commit 9bb45f6

Please sign in to comment.