Skip to content

Commit

Permalink
添加删除缓存文件功能
Browse files Browse the repository at this point in the history
  • Loading branch information
kN6jq committed Mar 29, 2024
1 parent ae80deb commit 7dcf111
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/main/java/burp/ui/ConfigUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import burp.IBurpExtenderCallbacks;
import burp.bean.ConfigBean;
import burp.utils.Utils;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;
Expand Down Expand Up @@ -33,7 +34,7 @@ public class ConfigUI implements UIHandler {
private JLabel toolArgvLabel;
private JButton refershButton;
private JButton deleteSelectButton;
private JButton clearHostButton;
private JButton clearCacheButton;
private JTable configTable;
private JScrollPane configPanelDownJscrollPanel;
private JPanel configPanelTop;
Expand Down Expand Up @@ -85,9 +86,9 @@ private void setupUI() {
deleteSelectButton = new JButton();
deleteSelectButton.setText("删除选中");
configPanelTop.add(deleteSelectButton, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
clearHostButton = new JButton();
clearHostButton.setText("清空host过滤");
configPanelTop.add(clearHostButton, new GridConstraints(3, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
clearCacheButton = new JButton();
clearCacheButton.setText("删除req缓存文件");
configPanelTop.add(clearCacheButton, new GridConstraints(3, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
configPanelDown = new JPanel();
configPanelDown.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
configPanel.add(configPanelDown, BorderLayout.CENTER);
Expand Down Expand Up @@ -139,12 +140,17 @@ public void actionPerformed(ActionEvent e) {
}
}
});
clearHostButton.addActionListener(new AbstractAction() {
clearCacheButton.addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
// mark
// 弹出提示框
JOptionPane.showMessageDialog(null, "功能未实现", "提示", JOptionPane.INFORMATION_MESSAGE);
boolean deleteReqFile = Utils.deleteReqFile();
if (deleteReqFile){
JOptionPane.showMessageDialog(null, "删除成功", "提示", JOptionPane.INFORMATION_MESSAGE);
}else {
JOptionPane.showMessageDialog(null, "删除失败", "提示", JOptionPane.INFORMATION_MESSAGE);
}
}
});

Expand Down
18 changes: 18 additions & 0 deletions src/main/java/burp/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,25 @@ public static String writeReqFile(IHttpRequestResponse message) {
return null;
}
}
// 删除后缀为req的缓存文件
public static boolean deleteReqFile() {
File file = new File(workdir);
if (!file.exists()) {
return false;
}
File[] files = file.listFiles();
if (files == null) {
return false;
}
for (File f : files) {
if (f.getName().endsWith(".req")) {
f.delete();
}
}
return true;
}

// 获取后缀列表
public static List<String> getSuffix() {
List<String> suffix = new ArrayList<>();
suffix.add(".js");
Expand Down

0 comments on commit 7dcf111

Please sign in to comment.