Version: 3.0.2 Update
This commit is contained in:
@@ -8,7 +8,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
public class Config {
|
||||
public static String suffix = "3g2|3gp|7z|aac|abw|aif|aifc|aiff|apk|arc|au|avi|azw|bat|bin|bmp|bz|bz2|cmd|cmx|cod|com|csh|css|csv|dll|doc|docx|ear|eot|epub|exe|flac|flv|gif|gz|ico|ics|ief|jar|jfif|jpe|jpeg|jpg|less|m3u|mid|midi|mjs|mkv|mov|mp2|mp3|mp4|mpa|mpe|mpeg|mpg|mpkg|mpp|mpv2|odp|ods|odt|oga|ogg|ogv|ogx|otf|pbm|pdf|pgm|png|pnm|ppm|ppt|pptx|ra|ram|rar|ras|rgb|rmi|rtf|scss|sh|snd|svg|swf|tar|tif|tiff|ttf|vsd|war|wav|weba|webm|webp|wmv|woff|woff2|xbm|xls|xlsx|xpm|xul|xwd|zip";
|
||||
|
||||
public static String[] scope = new String[] {
|
||||
public static String[] scope = new String[]{
|
||||
"any",
|
||||
"any header",
|
||||
"any body",
|
||||
@@ -23,21 +23,21 @@ public class Config {
|
||||
};
|
||||
|
||||
public static String[] ruleFields = {
|
||||
"Loaded", "Name", "F-Regex", "S-Regex", "Format", "Color", "Scope", "Engine", "Sensitive"
|
||||
"Loaded", "Name", "F-Regex", "S-Regex", "Format", "Color", "Scope", "Engine", "Sensitive"
|
||||
};
|
||||
|
||||
public static Object[][] ruleTemplate = new Object[][] {
|
||||
public static Object[][] ruleTemplate = new Object[][]{
|
||||
{
|
||||
false, "New Name", "(First Regex)", "(Second Regex)", "{0}", "gray", "any", "nfa", false
|
||||
}
|
||||
};
|
||||
|
||||
public static String[] engine = new String[] {
|
||||
public static String[] engine = new String[]{
|
||||
"nfa",
|
||||
"dfa"
|
||||
};
|
||||
|
||||
public static String[] color = new String[] {
|
||||
public static String[] color = new String[]{
|
||||
"red",
|
||||
"orange",
|
||||
"yellow",
|
||||
|
||||
@@ -16,7 +16,7 @@ public class HaE implements BurpExtension {
|
||||
@Override
|
||||
public void initialize(MontoyaApi api) {
|
||||
// 设置扩展名称
|
||||
String version = "3.0.1";
|
||||
String version = "3.0.2";
|
||||
api.extension().setName(String.format("HaE (%s) - Highlighter and Extractor", version));
|
||||
|
||||
// 加载扩展后输出的项目信息
|
||||
|
||||
3
src/main/java/hae/cache/CachePool.java
vendored
3
src/main/java/hae/cache/CachePool.java
vendored
@@ -1,6 +1,7 @@
|
||||
package hae.cache;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class CachePool {
|
||||
private static final Map<String, Map<String, Map<String, Object>>> cache = new HashMap<>();
|
||||
|
||||
@@ -28,10 +28,10 @@ public class Main extends JPanel {
|
||||
|
||||
private void initComponents() {
|
||||
setLayout(new GridBagLayout());
|
||||
((GridBagLayout)getLayout()).columnWidths = new int[] {0, 0};
|
||||
((GridBagLayout)getLayout()).rowHeights = new int[] {0, 0};
|
||||
((GridBagLayout)getLayout()).columnWeights = new double[] {1.0, 1.0E-4};
|
||||
((GridBagLayout)getLayout()).rowWeights = new double[] {1.0, 1.0E-4};
|
||||
((GridBagLayout) getLayout()).columnWidths = new int[]{0, 0};
|
||||
((GridBagLayout) getLayout()).rowHeights = new int[]{0, 0};
|
||||
((GridBagLayout) getLayout()).columnWeights = new double[]{1.0, 1.0E-4};
|
||||
((GridBagLayout) getLayout()).rowWeights = new double[]{1.0, 1.0E-4};
|
||||
|
||||
JTabbedPane mainTabbedPane = new JTabbedPane();
|
||||
|
||||
|
||||
@@ -3,20 +3,21 @@ package hae.component.board;
|
||||
import burp.api.montoya.MontoyaApi;
|
||||
import hae.Config;
|
||||
import hae.component.board.message.MessageTableModel;
|
||||
import hae.utils.string.StringProcessor;
|
||||
import hae.utils.config.ConfigLoader;
|
||||
import hae.component.board.message.MessageTableModel.MessageTable;
|
||||
import hae.utils.config.ConfigLoader;
|
||||
import hae.utils.string.StringProcessor;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import javax.swing.event.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import javax.swing.table.TableColumnModel;
|
||||
import javax.swing.table.TableModel;
|
||||
import javax.swing.table.TableRowSorter;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.List;
|
||||
import javax.swing.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class Databoard extends JPanel {
|
||||
private final MontoyaApi api;
|
||||
@@ -28,8 +29,8 @@ public class Databoard extends JPanel {
|
||||
private MessageTable messageTable;
|
||||
|
||||
private static Boolean isMatchHost = false;
|
||||
private DefaultComboBoxModel comboBoxModel = new DefaultComboBoxModel();
|
||||
private JComboBox hostComboBox = new JComboBox(comboBoxModel);
|
||||
private final DefaultComboBoxModel comboBoxModel = new DefaultComboBoxModel();
|
||||
private final JComboBox hostComboBox = new JComboBox(comboBoxModel);
|
||||
|
||||
public Databoard(MontoyaApi api, ConfigLoader configLoader, MessageTableModel messageTableModel) {
|
||||
this.api = api;
|
||||
@@ -41,10 +42,10 @@ public class Databoard extends JPanel {
|
||||
|
||||
private void initComponents() {
|
||||
setLayout(new GridBagLayout());
|
||||
((GridBagLayout)getLayout()).columnWidths = new int[] {25, 0, 0, 0,20, 0};
|
||||
((GridBagLayout)getLayout()).rowHeights = new int[] {0, 65, 20, 0};
|
||||
((GridBagLayout)getLayout()).columnWeights = new double[] {0.0, 0.0, 1.0, 0.0, 0.0, 1.0E-4};
|
||||
((GridBagLayout)getLayout()).rowWeights = new double[] {0.0, 1.0, 0.0, 1.0E-4};
|
||||
((GridBagLayout) getLayout()).columnWidths = new int[]{25, 0, 0, 0, 20, 0};
|
||||
((GridBagLayout) getLayout()).rowHeights = new int[]{0, 65, 20, 0};
|
||||
((GridBagLayout) getLayout()).columnWeights = new double[]{0.0, 0.0, 1.0, 0.0, 0.0, 1.0E-4};
|
||||
((GridBagLayout) getLayout()).rowWeights = new double[]{0.0, 1.0, 0.0, 1.0E-4};
|
||||
|
||||
JLabel hostLabel = new JLabel("Host:");
|
||||
|
||||
@@ -81,7 +82,7 @@ public class Databoard extends JPanel {
|
||||
new Insets(8, 0, 5, 5), 0, 0));
|
||||
add(hostTextField, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
||||
new Insets(8, 0, 5, 5), 0, 0));
|
||||
add(actionButton, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
||||
add(actionButton, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
||||
new Insets(8, 0, 5, 5), 0, 0));
|
||||
add(splitPane, new GridBagConstraints(1, 1, 3, 3, 0.0, 0.0,
|
||||
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
||||
@@ -196,7 +197,7 @@ public class Databoard extends JPanel {
|
||||
Map<String, List<String>> selectedDataMap;
|
||||
|
||||
dataTabbedPane.removeAll();
|
||||
dataTabbedPane.setPreferredSize(new Dimension(500,0));
|
||||
dataTabbedPane.setPreferredSize(new Dimension(500, 0));
|
||||
dataTabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
|
||||
splitPane.setLeftComponent(dataTabbedPane);
|
||||
|
||||
|
||||
@@ -2,21 +2,24 @@ package hae.component.board;
|
||||
|
||||
import burp.api.montoya.MontoyaApi;
|
||||
import hae.component.board.message.MessageTableModel;
|
||||
import hae.instances.editor.RequestEditor;
|
||||
import jregex.Pattern;
|
||||
import jregex.REFlags;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import javax.swing.table.TableColumn;
|
||||
import javax.swing.table.TableRowSorter;
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.*;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import javax.swing.*;
|
||||
import java.awt.datatransfer.*;
|
||||
import javax.swing.event.*;
|
||||
import javax.swing.table.*;
|
||||
|
||||
public class Datatable extends JPanel {
|
||||
private final MontoyaApi api;
|
||||
@@ -213,7 +216,7 @@ public class Datatable extends JPanel {
|
||||
}
|
||||
|
||||
// 便于单行复制,去除最后一个换行符
|
||||
if (!selectData.isEmpty()){
|
||||
if (!selectData.isEmpty()) {
|
||||
selectData.deleteCharAt(selectData.length() - 1);
|
||||
return selectData.toString();
|
||||
} else {
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
package hae.component.board.message;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import java.awt.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
|
||||
public class MessageRenderer extends DefaultTableCellRenderer {
|
||||
|
||||
private List<MessageEntry> log;
|
||||
private Map<String, Color> colorMap = new HashMap<>();
|
||||
private JTable table; // 保存对表格的引用
|
||||
private final List<MessageEntry> log;
|
||||
private final Map<String, Color> colorMap = new HashMap<>();
|
||||
private final JTable table; // 保存对表格的引用
|
||||
|
||||
public MessageRenderer(List<MessageEntry> log, JTable table) {
|
||||
this.log = log;
|
||||
@@ -42,7 +41,7 @@ public class MessageRenderer extends DefaultTableCellRenderer {
|
||||
|
||||
if (isSelected) {
|
||||
// 通过更改RGB颜色来达成阴影效果
|
||||
component.setBackground(new Color(color.getRed()-0x20, color.getGreen()-0x20, color.getBlue()-0x20));
|
||||
component.setBackground(new Color(color.getRed() - 0x20, color.getGreen() - 0x20, color.getBlue() - 0x20));
|
||||
} else {
|
||||
// 否则使用原始颜色
|
||||
component.setBackground(color);
|
||||
|
||||
@@ -14,18 +14,14 @@ import hae.cache.CachePool;
|
||||
import hae.utils.string.HashCalculator;
|
||||
import hae.utils.string.StringProcessor;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.*;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JSplitPane;
|
||||
import javax.swing.JTabbedPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.SwingWorker;
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import javax.swing.table.TableModel;
|
||||
import javax.swing.table.TableRowSorter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -37,7 +33,7 @@ public class MessageTableModel extends AbstractTableModel {
|
||||
private final JTabbedPane messageTab;
|
||||
private final JSplitPane splitPane;
|
||||
private final List<MessageEntry> log = new ArrayList<MessageEntry>();
|
||||
private LinkedList<MessageEntry> filteredLog;
|
||||
private final LinkedList<MessageEntry> filteredLog;
|
||||
|
||||
public MessageTableModel(MontoyaApi api) {
|
||||
this.filteredLog = new LinkedList<>();
|
||||
@@ -74,6 +70,7 @@ public class MessageTableModel extends AbstractTableModel {
|
||||
int index2 = getIndex(s2);
|
||||
return Integer.compare(index1, index2);
|
||||
}
|
||||
|
||||
private int getIndex(String color) {
|
||||
for (int i = 0; i < Config.color.length; i++) {
|
||||
if (Config.color[i].equals(color)) {
|
||||
@@ -96,7 +93,7 @@ public class MessageTableModel extends AbstractTableModel {
|
||||
}
|
||||
|
||||
public void add(HttpRequestResponse messageInfo, String comment, String color) {
|
||||
synchronized(log) {
|
||||
synchronized (log) {
|
||||
HttpRequest httpRequest = messageInfo.request();
|
||||
String url = httpRequest.url();
|
||||
String method = httpRequest.method();
|
||||
@@ -120,7 +117,7 @@ public class MessageTableModel extends AbstractTableModel {
|
||||
byte[] resByteB = reqResMessage.response().toByteArray().getBytes();
|
||||
try {
|
||||
// 通过URL、请求和响应报文、匹配数据内容,多维度进行对比
|
||||
if ((entry.getUrl().toString().equals(url.toString()) || (Arrays.equals(reqByteB, reqByteA) || Arrays.equals(resByteB, resByteA))) && (areMapsEqual(getCacheData(reqByteB), getCacheData(reqByteA)) && areMapsEqual(getCacheData(resByteB), getCacheData(resByteA)))) {
|
||||
if ((entry.getUrl().equals(url) || (Arrays.equals(reqByteB, reqByteA) || Arrays.equals(resByteB, resByteA))) && (areMapsEqual(getCacheData(reqByteB), getCacheData(reqByteA)) && areMapsEqual(getCacheData(resByteB), getCacheData(resByteA)))) {
|
||||
isDuplicate = true;
|
||||
break;
|
||||
}
|
||||
@@ -243,6 +240,14 @@ public class MessageTableModel extends AbstractTableModel {
|
||||
case "response body":
|
||||
isMatch = matchingString(format, filterText, responseBody);
|
||||
break;
|
||||
case "request line":
|
||||
String requestLine = requestString.split("\\r?\\n", 2)[0];
|
||||
isMatch = matchingString(format, filterText, requestLine);
|
||||
break;
|
||||
case "response line":
|
||||
String responseLine = responseString.split("\\r?\\n", 2)[0];
|
||||
isMatch = matchingString(format, filterText, responseLine);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -334,13 +339,11 @@ public class MessageTableModel extends AbstractTableModel {
|
||||
}
|
||||
|
||||
|
||||
public JSplitPane getSplitPane()
|
||||
{
|
||||
public JSplitPane getSplitPane() {
|
||||
return splitPane;
|
||||
}
|
||||
|
||||
public MessageTable getMessageTable()
|
||||
{
|
||||
public MessageTable getMessageTable() {
|
||||
return messageTable;
|
||||
}
|
||||
|
||||
@@ -360,8 +363,7 @@ public class MessageTableModel extends AbstractTableModel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex)
|
||||
{
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
if (filteredLog.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
@@ -379,8 +381,7 @@ public class MessageTableModel extends AbstractTableModel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColumnName(int columnIndex)
|
||||
{
|
||||
public String getColumnName(int columnIndex) {
|
||||
return switch (columnIndex) {
|
||||
case 0 -> "Method";
|
||||
case 1 -> "URL";
|
||||
|
||||
@@ -23,10 +23,10 @@ public class Config extends JPanel {
|
||||
|
||||
private void initComponents() {
|
||||
setLayout(new GridBagLayout());
|
||||
((GridBagLayout) getLayout()).columnWidths = new int[] {0, 0, 0, 0, 0};
|
||||
((GridBagLayout) getLayout()).rowHeights = new int[] {0, 0, 0};
|
||||
((GridBagLayout) getLayout()).columnWeights = new double[] {0.0, 1.0, 0.0, 0.0, 1.0E-4};
|
||||
((GridBagLayout) getLayout()).rowWeights = new double[] {0.0, 0.0, 1.0E-4};
|
||||
((GridBagLayout) getLayout()).columnWidths = new int[]{0, 0, 0, 0, 0};
|
||||
((GridBagLayout) getLayout()).rowHeights = new int[]{0, 0, 0};
|
||||
((GridBagLayout) getLayout()).columnWeights = new double[]{0.0, 1.0, 0.0, 0.0, 1.0E-4};
|
||||
((GridBagLayout) getLayout()).rowWeights = new double[]{0.0, 0.0, 1.0E-4};
|
||||
|
||||
JLabel rulesFilePathLabel = new JLabel("Rules Path:");
|
||||
JTextField rulesFilePathTextField = new JTextField();
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
package hae.component.rule;
|
||||
|
||||
import burp.api.montoya.MontoyaApi;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import javax.swing.table.TableRowSorter;
|
||||
import java.util.Vector;
|
||||
|
||||
import hae.Config;
|
||||
import hae.utils.config.ConfigLoader;
|
||||
import hae.utils.rule.RuleProcessor;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import javax.swing.table.TableRowSorter;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.Vector;
|
||||
|
||||
import static javax.swing.JOptionPane.YES_OPTION;
|
||||
|
||||
public class Rule extends JPanel {
|
||||
@@ -32,10 +31,10 @@ public class Rule extends JPanel {
|
||||
|
||||
private void initComponents(Object[][] data) {
|
||||
setLayout(new GridBagLayout());
|
||||
((GridBagLayout)getLayout()).columnWidths = new int[] {0, 0, 0};
|
||||
((GridBagLayout)getLayout()).rowHeights = new int[] {0, 0, 0, 0, 0};
|
||||
((GridBagLayout)getLayout()).columnWeights = new double[] {0.0, 1.0, 1.0E-4};
|
||||
((GridBagLayout)getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 1.0, 1.0E-4};
|
||||
((GridBagLayout) getLayout()).columnWidths = new int[]{0, 0, 0};
|
||||
((GridBagLayout) getLayout()).rowHeights = new int[]{0, 0, 0, 0, 0};
|
||||
((GridBagLayout) getLayout()).columnWeights = new double[]{0.0, 1.0, 1.0E-4};
|
||||
((GridBagLayout) getLayout()).rowWeights = new double[]{0.0, 0.0, 0.0, 1.0, 1.0E-4};
|
||||
|
||||
JButton addButton = new JButton("Add");
|
||||
JButton editButton = new JButton("Edit");
|
||||
@@ -74,7 +73,7 @@ public class Rule extends JPanel {
|
||||
|
||||
model.setDataVector(data, Config.ruleFields);
|
||||
model.addTableModelListener(e -> {
|
||||
if (e.getColumn() == 0 && ruleTable.getSelectedRow() != -1){
|
||||
if (e.getColumn() == 0 && ruleTable.getSelectedRow() != -1) {
|
||||
int select = ruleTable.convertRowIndexToModel(ruleTable.getSelectedRow());
|
||||
ruleProcessor.changeRule(model.getDataVector().get(select), select, tabbedPane.getTitleAt(tabbedPane.getSelectedIndex()));
|
||||
}
|
||||
@@ -117,8 +116,8 @@ public class Rule extends JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
private void ruleEditActionPerformed(ActionEvent e, JTable ruleTable, JTabbedPane tabbedPane){
|
||||
if (ruleTable.getSelectedRowCount() >= 1){
|
||||
private void ruleEditActionPerformed(ActionEvent e, JTable ruleTable, JTabbedPane tabbedPane) {
|
||||
if (ruleTable.getSelectedRowCount() >= 1) {
|
||||
DefaultTableModel model = (DefaultTableModel) ruleTable.getModel();
|
||||
Display ruleDisplay = new Display();
|
||||
|
||||
@@ -129,12 +128,12 @@ public class Rule extends JPanel {
|
||||
ruleDisplay.colorComboBox.setSelectedItem(ruleTable.getValueAt(ruleTable.getSelectedRow(), 5).toString());
|
||||
ruleDisplay.scopeComboBox.setSelectedItem(ruleTable.getValueAt(ruleTable.getSelectedRow(), 6).toString());
|
||||
ruleDisplay.engineComboBox.setSelectedItem(ruleTable.getValueAt(ruleTable.getSelectedRow(), 7).toString());
|
||||
ruleDisplay.sensitiveComboBox.setSelectedItem(ruleTable.getValueAt(ruleTable.getSelectedRow(),8));
|
||||
ruleDisplay.sensitiveComboBox.setSelectedItem(ruleTable.getValueAt(ruleTable.getSelectedRow(), 8));
|
||||
|
||||
ruleDisplay.formatTextField.setEnabled(ruleDisplay.engineComboBox.getSelectedItem().toString().equals("nfa"));
|
||||
|
||||
int showState = JOptionPane.showConfirmDialog(null, ruleDisplay, "Edit Rule", JOptionPane.OK_OPTION);
|
||||
if (showState == 0){
|
||||
if (showState == 0) {
|
||||
int select = ruleTable.convertRowIndexToModel(ruleTable.getSelectedRow());
|
||||
model.setValueAt(ruleDisplay.ruleNameTextField.getText(), select, 1);
|
||||
model.setValueAt(ruleDisplay.firstRegexTextField.getText(), select, 2);
|
||||
@@ -150,9 +149,9 @@ public class Rule extends JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
private void ruleRemoveActionPerformed(ActionEvent e, JTable ruleTable, JTabbedPane tabbedPane){
|
||||
if (ruleTable.getSelectedRowCount() >= 1){
|
||||
if (JOptionPane.showConfirmDialog(null, "Are you sure you want to delete this rule?", "Info", JOptionPane.OK_OPTION) == 0){
|
||||
private void ruleRemoveActionPerformed(ActionEvent e, JTable ruleTable, JTabbedPane tabbedPane) {
|
||||
if (ruleTable.getSelectedRowCount() >= 1) {
|
||||
if (JOptionPane.showConfirmDialog(null, "Are you sure you want to delete this rule?", "Info", JOptionPane.OK_OPTION) == 0) {
|
||||
DefaultTableModel model = (DefaultTableModel) ruleTable.getModel();
|
||||
int select = ruleTable.convertRowIndexToModel(ruleTable.getSelectedRow());
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ public class Rules extends JTabbedPane {
|
||||
removeAll();
|
||||
|
||||
this.configLoader = new ConfigLoader(api);
|
||||
Config.globalRules.keySet().forEach(i-> addTab(i, new Rule(api, configLoader, hae.Config.globalRules.get(i), this)));
|
||||
Config.globalRules.keySet().forEach(i -> addTab(i, new Rule(api, configLoader, hae.Config.globalRules.get(i), this)));
|
||||
addTab("...", null);
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ public class Rules extends JTabbedPane {
|
||||
}
|
||||
}
|
||||
|
||||
private Action renameTitleActionPerformed = new AbstractAction() {
|
||||
private final Action renameTitleActionPerformed = new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String title = ruleGroupNameTextField.getText();
|
||||
@@ -136,7 +136,7 @@ public class Rules extends JTabbedPane {
|
||||
}
|
||||
};
|
||||
|
||||
private Action cancelActionPerformed = new AbstractAction() {
|
||||
private final Action cancelActionPerformed = new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (selectedIndex >= 0) {
|
||||
|
||||
@@ -3,12 +3,12 @@ package hae.instances.editor;
|
||||
import burp.api.montoya.MontoyaApi;
|
||||
import burp.api.montoya.core.ByteArray;
|
||||
import burp.api.montoya.core.Range;
|
||||
import burp.api.montoya.ui.editor.extension.EditorCreationContext;
|
||||
import burp.api.montoya.ui.editor.extension.ExtensionProvidedHttpRequestEditor;
|
||||
import burp.api.montoya.ui.editor.extension.HttpRequestEditorProvider;
|
||||
import burp.api.montoya.http.message.HttpRequestResponse;
|
||||
import burp.api.montoya.http.message.requests.HttpRequest;
|
||||
import burp.api.montoya.ui.Selection;
|
||||
import burp.api.montoya.ui.editor.extension.EditorCreationContext;
|
||||
import burp.api.montoya.ui.editor.extension.ExtensionProvidedHttpRequestEditor;
|
||||
import burp.api.montoya.ui.editor.extension.HttpRequestEditorProvider;
|
||||
import hae.component.board.Datatable;
|
||||
import hae.instances.http.utils.MessageProcessor;
|
||||
|
||||
@@ -36,10 +36,9 @@ public class RequestEditor implements HttpRequestEditorProvider {
|
||||
private final MessageProcessor messageProcessor;
|
||||
private HttpRequestResponse requestResponse;
|
||||
|
||||
private JTabbedPane jTabbedPane = new JTabbedPane();
|
||||
private final JTabbedPane jTabbedPane = new JTabbedPane();
|
||||
|
||||
public Editor(MontoyaApi api, EditorCreationContext creationContext)
|
||||
{
|
||||
public Editor(MontoyaApi api, EditorCreationContext creationContext) {
|
||||
this.api = api;
|
||||
this.creationContext = creationContext;
|
||||
this.messageProcessor = new MessageProcessor(api);
|
||||
@@ -103,7 +102,7 @@ public class RequestEditor implements HttpRequestEditorProvider {
|
||||
if (result != null && !result.isEmpty() && result.size() > 0) {
|
||||
Map<String, String> dataMap = result.get(0);
|
||||
if (dataMap != null && !dataMap.isEmpty() && dataMap.size() > 0) {
|
||||
dataMap.keySet().forEach(i->{
|
||||
dataMap.keySet().forEach(i -> {
|
||||
String[] extractData = dataMap.get(i).split("\n");
|
||||
Datatable dataPanel = new Datatable(api, i, Arrays.asList(extractData));
|
||||
tabbedPane.addTab(i, dataPanel);
|
||||
|
||||
@@ -5,10 +5,10 @@ import burp.api.montoya.core.ByteArray;
|
||||
import burp.api.montoya.core.Range;
|
||||
import burp.api.montoya.http.message.HttpRequestResponse;
|
||||
import burp.api.montoya.http.message.responses.HttpResponse;
|
||||
import burp.api.montoya.ui.Selection;
|
||||
import burp.api.montoya.ui.editor.extension.EditorCreationContext;
|
||||
import burp.api.montoya.ui.editor.extension.ExtensionProvidedHttpResponseEditor;
|
||||
import burp.api.montoya.ui.editor.extension.HttpResponseEditorProvider;
|
||||
import burp.api.montoya.ui.Selection;
|
||||
import hae.component.board.Datatable;
|
||||
import hae.instances.http.utils.MessageProcessor;
|
||||
|
||||
@@ -35,10 +35,9 @@ public class ResponseEditor implements HttpResponseEditorProvider {
|
||||
private final MessageProcessor messageProcessor;
|
||||
private HttpRequestResponse requestResponse;
|
||||
|
||||
private JTabbedPane jTabbedPane = new JTabbedPane();
|
||||
private final JTabbedPane jTabbedPane = new JTabbedPane();
|
||||
|
||||
public Editor(MontoyaApi api, EditorCreationContext creationContext)
|
||||
{
|
||||
public Editor(MontoyaApi api, EditorCreationContext creationContext) {
|
||||
this.api = api;
|
||||
this.creationContext = creationContext;
|
||||
this.messageProcessor = new MessageProcessor(api);
|
||||
|
||||
@@ -5,7 +5,9 @@ import burp.api.montoya.core.ByteArray;
|
||||
import burp.api.montoya.core.Range;
|
||||
import burp.api.montoya.ui.Selection;
|
||||
import burp.api.montoya.ui.contextmenu.WebSocketMessage;
|
||||
import burp.api.montoya.ui.editor.extension.*;
|
||||
import burp.api.montoya.ui.editor.extension.EditorCreationContext;
|
||||
import burp.api.montoya.ui.editor.extension.ExtensionProvidedWebSocketMessageEditor;
|
||||
import burp.api.montoya.ui.editor.extension.WebSocketMessageEditorProvider;
|
||||
import hae.component.board.Datatable;
|
||||
import hae.instances.http.utils.MessageProcessor;
|
||||
|
||||
@@ -32,7 +34,7 @@ public class WebSocketEditor implements WebSocketMessageEditorProvider {
|
||||
private final MessageProcessor messageProcessor;
|
||||
private ByteArray message;
|
||||
|
||||
private JTabbedPane jTabbedPane = new JTabbedPane();
|
||||
private final JTabbedPane jTabbedPane = new JTabbedPane();
|
||||
|
||||
public Editor(MontoyaApi api, EditorCreationContext creationContext) {
|
||||
this.api = api;
|
||||
|
||||
@@ -11,16 +11,19 @@ import hae.component.board.message.MessageTableModel;
|
||||
import hae.instances.http.utils.MessageProcessor;
|
||||
import hae.utils.string.StringProcessor;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class HttpMessageHandler implements HttpHandler {
|
||||
private final MontoyaApi api;
|
||||
private MessageTableModel messageTableModel;
|
||||
private final MessageTableModel messageTableModel;
|
||||
private final MessageProcessor messageProcessor;
|
||||
private String host;
|
||||
|
||||
// Montoya API对HTTP消息的处理分为了请求和响应,因此此处设置高亮和标记需要使用全局变量的方式,以此兼顾请求和响应
|
||||
// 同时采用 ThreadLocal 来保证多线程并发的情况下全局变量的安全性
|
||||
private final ThreadLocal<String> host = ThreadLocal.withInitial(() -> "");
|
||||
private final ThreadLocal<List<String>> colorList = ThreadLocal.withInitial(ArrayList::new);
|
||||
private final ThreadLocal<List<String>> commentList = ThreadLocal.withInitial(ArrayList::new);
|
||||
private final ThreadLocal<Boolean> matches = ThreadLocal.withInitial(() -> false);
|
||||
@@ -41,13 +44,13 @@ public class HttpMessageHandler implements HttpHandler {
|
||||
|
||||
httpRequest.set(httpRequestToBeSent);
|
||||
|
||||
host = StringProcessor.getHostByUrl(httpRequestToBeSent.url());
|
||||
host.set(StringProcessor.getHostByUrl(httpRequestToBeSent.url()));
|
||||
|
||||
List<String> suffixList = Arrays.asList(Config.suffix.split("\\|"));
|
||||
matches.set(suffixList.contains(httpRequestToBeSent.fileExtension()));
|
||||
|
||||
if (!matches.get()) {
|
||||
List<Map<String, String>> result = messageProcessor.processRequest(host, httpRequestToBeSent, true);
|
||||
List<Map<String, String>> result = messageProcessor.processRequest(host.get(), httpRequestToBeSent, true);
|
||||
setColorAndCommentList(result);
|
||||
}
|
||||
|
||||
@@ -59,7 +62,7 @@ public class HttpMessageHandler implements HttpHandler {
|
||||
Annotations annotations = httpResponseReceived.annotations();
|
||||
|
||||
if (!matches.get()) {
|
||||
List<Map<String, String>> result = messageProcessor.processResponse(host, httpResponseReceived, true);
|
||||
List<Map<String, String>> result = messageProcessor.processResponse(host.get(), httpResponseReceived, true);
|
||||
setColorAndCommentList(result);
|
||||
// 设置高亮颜色和注释
|
||||
if (!colorList.get().isEmpty() && !commentList.get().isEmpty()) {
|
||||
|
||||
@@ -24,6 +24,7 @@ public class MessageProcessor {
|
||||
|
||||
public List<Map<String, String>> processMessage(String host, String message, boolean flag) {
|
||||
Map<String, Map<String, Object>> obj = null;
|
||||
|
||||
try {
|
||||
obj = regularMatcher.match(host, "any", message, message, message);
|
||||
} catch (Exception ignored) {
|
||||
@@ -34,6 +35,7 @@ public class MessageProcessor {
|
||||
|
||||
public List<Map<String, String>> processResponse(String host, HttpResponse httpResponse, boolean flag) {
|
||||
Map<String, Map<String, Object>> obj = null;
|
||||
|
||||
try {
|
||||
String response = new String(httpResponse.toByteArray().getBytes(), StandardCharsets.UTF_8);
|
||||
String body = new String(httpResponse.body().getBytes(), StandardCharsets.UTF_8);
|
||||
@@ -57,6 +59,7 @@ public class MessageProcessor {
|
||||
String header = httpRequest.headers().stream()
|
||||
.map(HttpHeader::toString)
|
||||
.collect(Collectors.joining("\n"));
|
||||
|
||||
obj = regularMatcher.match(host, "request", request, header, body);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
@@ -99,6 +102,7 @@ public class MessageProcessor {
|
||||
String data = tempMap.get("data").toString();
|
||||
extractedData.put(key, data);
|
||||
});
|
||||
|
||||
return extractedData;
|
||||
}
|
||||
|
||||
@@ -114,10 +118,11 @@ public class MessageProcessor {
|
||||
List<List<String>> result = new ArrayList<>();
|
||||
result.add(colorList);
|
||||
result.add(commentList);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<Integer> retrieveColorIndices(List<String> colors){
|
||||
public List<Integer> retrieveColorIndices(List<String> colors) {
|
||||
List<Integer> indices = new ArrayList<>();
|
||||
String[] colorArray = Config.color;
|
||||
int size = colorArray.length;
|
||||
@@ -129,6 +134,7 @@ public class MessageProcessor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return indices;
|
||||
}
|
||||
|
||||
@@ -154,7 +160,7 @@ public class MessageProcessor {
|
||||
HashSet tmpList = new HashSet(stack);
|
||||
if (stack.size() == tmpList.size()) {
|
||||
stack.sort(Comparator.comparingInt(Integer::intValue));
|
||||
if(stack.get(0) < 0) {
|
||||
if (stack.get(0) < 0) {
|
||||
finalColor = colorArray[0];
|
||||
} else {
|
||||
finalColor = colorArray[stack.get(0)];
|
||||
|
||||
@@ -202,8 +202,8 @@ public class RegularMatcher {
|
||||
while (matcher.find()) {
|
||||
if (!matcher.group(1).isEmpty()) {
|
||||
Object[] params = indexList.stream().map(i -> {
|
||||
if (!matcher.group(i+1).isEmpty()) {
|
||||
return matcher.group(i+1);
|
||||
if (!matcher.group(i + 1).isEmpty()) {
|
||||
return matcher.group(i + 1);
|
||||
}
|
||||
return "";
|
||||
}).toArray();
|
||||
|
||||
@@ -1,15 +1,5 @@
|
||||
package hae.utils.config;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import burp.api.montoya.MontoyaApi;
|
||||
import burp.api.montoya.http.message.HttpRequestResponse;
|
||||
import burp.api.montoya.http.message.requests.HttpRequest;
|
||||
@@ -18,6 +8,12 @@ import org.yaml.snakeyaml.DumperOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.representer.Representer;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
|
||||
public class ConfigLoader {
|
||||
private final MontoyaApi api;
|
||||
private final Yaml yaml;
|
||||
@@ -32,7 +28,7 @@ public class ConfigLoader {
|
||||
this.yaml = new Yaml(representer, dop);
|
||||
|
||||
String configPath = determineConfigPath();
|
||||
this.configFilePath = String.format("%s/%s", configPath, "Config.yml");
|
||||
this.configFilePath = String.format("%s/%s", configPath, "Config.yml");
|
||||
this.rulesFilePath = String.format("%s/%s", configPath, "Rules.yml");
|
||||
|
||||
// 构造函数,初始化配置
|
||||
@@ -104,7 +100,7 @@ public class ConfigLoader {
|
||||
if (r.containsKey("excludeSuffix")) {
|
||||
return r.get("excludeSuffix").toString();
|
||||
}
|
||||
}catch (Exception ignored) {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
return Config.suffix;
|
||||
@@ -147,16 +143,16 @@ public class ConfigLoader {
|
||||
}
|
||||
|
||||
return rules;
|
||||
} catch (Exception ignored){
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
return rules;
|
||||
}
|
||||
|
||||
public void setExcludeSuffix(String excludeSuffix) {
|
||||
Map<String,Object> r = new LinkedHashMap<>();
|
||||
Map<String, Object> r = new LinkedHashMap<>();
|
||||
r.put("excludeSuffix", excludeSuffix);
|
||||
try{
|
||||
try {
|
||||
Writer ws = new OutputStreamWriter(Files.newOutputStream(Paths.get(configFilePath)), StandardCharsets.UTF_8);
|
||||
yaml.dump(r, ws);
|
||||
ws.close();
|
||||
|
||||
@@ -2,11 +2,11 @@ package hae.utils.rule;
|
||||
|
||||
import burp.api.montoya.MontoyaApi;
|
||||
import hae.Config;
|
||||
import hae.utils.config.ConfigLoader;
|
||||
import hae.utils.rule.model.Group;
|
||||
import hae.utils.rule.model.Info;
|
||||
import hae.utils.config.ConfigLoader;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.DumperOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.representer.Representer;
|
||||
|
||||
import java.io.File;
|
||||
@@ -72,13 +72,14 @@ public class RuleProcessor {
|
||||
public void addRule(Vector data, String type) {
|
||||
ArrayList<Object[]> x = new ArrayList<>(Arrays.asList(Config.globalRules.get(type)));
|
||||
x.add(data.toArray());
|
||||
Config.globalRules.put(type,x.toArray(new Object[x.size()][]));
|
||||
Config.globalRules.put(type, x.toArray(new Object[x.size()][]));
|
||||
this.rulesFormatAndSave();
|
||||
}
|
||||
public void removeRule(int select,String type) {
|
||||
|
||||
public void removeRule(int select, String type) {
|
||||
ArrayList<Object[]> x = new ArrayList<>(Arrays.asList(Config.globalRules.get(type)));
|
||||
x.remove(select);
|
||||
Config.globalRules.put(type,x.toArray(new Object[x.size()][]));
|
||||
Config.globalRules.put(type, x.toArray(new Object[x.size()][]));
|
||||
this.rulesFormatAndSave();
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package hae.utils.string;
|
||||
import java.security.MessageDigest;
|
||||
|
||||
public class HashCalculator {
|
||||
public static String calculateHash(byte[] bytes){
|
||||
public static String calculateHash(byte[] bytes) {
|
||||
MessageDigest digest;
|
||||
try {
|
||||
digest = MessageDigest.getInstance("MD5");
|
||||
|
||||
Reference in New Issue
Block a user