Skip to content

Commit

Permalink
Version: 3.0.2 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
gh0stkey committed May 12, 2024
1 parent 3363ca2 commit 4da3d3f
Show file tree
Hide file tree
Showing 20 changed files with 137 additions and 127 deletions.
10 changes: 5 additions & 5 deletions src/main/java/hae/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
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",
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/hae/HaE.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));

// 加载扩展后输出的项目信息
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/hae/cache/CachePool.java
Original file line number Diff line number Diff line change
@@ -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<>();
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/hae/component/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ public Main(MontoyaApi api, ConfigLoader configLoader, MessageTableModel message

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();

Expand Down
29 changes: 15 additions & 14 deletions src/main/java/hae/component/board/Databoard.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@
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;
Expand All @@ -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;
Expand All @@ -41,10 +42,10 @@ public Databoard(MontoyaApi api, ConfigLoader configLoader, MessageTableModel me

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:");

Expand Down Expand Up @@ -81,7 +82,7 @@ public void componentResized(ComponentEvent e) {
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,
Expand Down Expand Up @@ -196,7 +197,7 @@ private void populateTabbedPaneByHost(String selectedHost) {
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);

Expand Down
17 changes: 10 additions & 7 deletions src/main/java/hae/component/board/Datatable.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@

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;
Expand Down Expand Up @@ -213,7 +216,7 @@ public String getSelectedDataAtTable(JTable table) {
}

// 便于单行复制,去除最后一个换行符
if (!selectData.isEmpty()){
if (!selectData.isEmpty()) {
selectData.deleteCharAt(selectData.length() - 1);
return selectData.toString();
} else {
Expand Down
15 changes: 7 additions & 8 deletions src/main/java/hae/component/board/message/MessageRenderer.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -42,7 +41,7 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole

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);
Expand Down
39 changes: 20 additions & 19 deletions src/main/java/hae/component/board/message/MessageTableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,14 @@
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;

Expand All @@ -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<>();
Expand Down Expand Up @@ -74,6 +70,7 @@ public int compare(String s1, String s2) {
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)) {
Expand All @@ -96,7 +93,7 @@ private int getIndex(String color) {
}

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();
Expand All @@ -120,7 +117,7 @@ public void add(HttpRequestResponse messageInfo, String comment, String color) {
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;
}
Expand Down Expand Up @@ -243,6 +240,14 @@ public void applyMessageFilter(String tableName, String filterText) {
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;
}
Expand Down Expand Up @@ -334,13 +339,11 @@ private boolean areInnerMapsEqual(Map<String, Object> innerMap1, Map<String, Obj
}


public JSplitPane getSplitPane()
{
public JSplitPane getSplitPane() {
return splitPane;
}

public MessageTable getMessageTable()
{
public MessageTable getMessageTable() {
return messageTable;
}

Expand All @@ -360,8 +363,7 @@ public int getColumnCount() {
}

@Override
public Object getValueAt(int rowIndex, int columnIndex)
{
public Object getValueAt(int rowIndex, int columnIndex) {
if (filteredLog.isEmpty()) {
return "";
}
Expand All @@ -379,8 +381,7 @@ public Object getValueAt(int rowIndex, int columnIndex)
}

@Override
public String getColumnName(int columnIndex)
{
public String getColumnName(int columnIndex) {
return switch (columnIndex) {
case 0 -> "Method";
case 1 -> "URL";
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/hae/component/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public Config(MontoyaApi api, ConfigLoader configLoader, Rules rules) {

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();
Expand Down
Loading

0 comments on commit 4da3d3f

Please sign in to comment.