From e43a96b8adabb024e7dc8b5e81fa3a9593c2edb5 Mon Sep 17 00:00:00 2001 From: AnonymousUser Date: Fri, 11 Jun 2021 12:36:30 +0800 Subject: [PATCH] Version: 2.0.1 Fixed bug --- src/main/java/burp/BurpExtender.java | 54 +++++++++++++--------- src/main/java/burp/ui/MainUI.java | 6 +-- src/main/java/burp/ui/RulePane.java | 26 ++++++----- src/main/java/burp/yaml/Rule.java | 15 ++---- src/main/java/burp/yaml/SetRuleConfig.java | 2 +- 5 files changed, 55 insertions(+), 48 deletions(-) diff --git a/src/main/java/burp/BurpExtender.java b/src/main/java/burp/BurpExtender.java index 44052a4..feeb9ba 100644 --- a/src/main/java/burp/BurpExtender.java +++ b/src/main/java/burp/BurpExtender.java @@ -33,7 +33,7 @@ public void registerExtenderCallbacks(final IBurpExtenderCallbacks callbacks) this.callbacks = callbacks; BurpExtender.helpers = callbacks.getHelpers(); - String version = "2.0"; + String version = "2.0.1"; callbacks.setExtensionName(String.format("HaE (%s) - Highlighter and Extractor", version)); // 定义输出 stdout = new PrintWriter(callbacks.getStdout(), true); @@ -133,37 +133,47 @@ public Component getUiComponent() { @Override public boolean isEnabled(byte[] content, boolean isRequest) { - try { - // 流量清洗 - String urlString = helpers.analyzeRequest(controller.getHttpService(), controller.getRequest()).getUrl().toString(); - urlString = urlString.indexOf("?") > 0 ? urlString.substring(0, urlString.indexOf("?")) : urlString; - // 正则判断 - if (mh.matchSuffix(urlString)) { + Map> obj; + + if (isRequest) { + try { + // 流量清洗 + String urlString = helpers.analyzeRequest(controller.getHttpService(), controller.getRequest()).getUrl().toString(); + urlString = urlString.indexOf("?") > 0 ? urlString.substring(0, urlString.indexOf("?")) : urlString; + // 正则判断 + if (mh.matchSuffix(urlString)) { + return false; + } + } catch (Exception e) { return false; } - } catch (Exception e) { - return false; - } - // 获取报文头 - List tmpHeaders = helpers.analyzeRequest(controller.getHttpService(), content).getHeaders(); - String headers = String.join("\n", tmpHeaders); - // 获取报文主体 - int bodyOffset = helpers.analyzeRequest(controller.getHttpService(), content).getBodyOffset(); - byte[] byteRequest = controller.getRequest(); - byte[] body = Arrays.copyOfRange(byteRequest, bodyOffset, byteRequest.length); + // 获取报文头 + List tmpHeaders = helpers.analyzeRequest(controller.getHttpService(), content).getHeaders(); + String headers = String.join("\n", tmpHeaders); + // 获取报文主体 + int bodyOffset = helpers.analyzeRequest(controller.getHttpService(), content).getBodyOffset(); + byte[] byteRequest = controller.getRequest(); + byte[] body = Arrays.copyOfRange(byteRequest, bodyOffset, byteRequest.length); - Map> obj; - if (isRequest) { obj = ec.matchRegex(content, headers, body, "request"); - if (obj.size() != 0) { + if (obj.size() > 0) { String result = da.extractString(obj); extractRequestContent = result.getBytes(); return true; } } else { - obj = ec.matchRegex(content, headers, body, "response"); - if (obj.size() != 0) { + + // 获取报文头 + List tmpHeaders1 = helpers.analyzeResponse(content).getHeaders(); + String headers1 = String.join("\n", tmpHeaders1); + // 获取报文主体 + int bodyOffset1 = helpers.analyzeResponse(content).getBodyOffset(); + byte[] byteRequest1 = controller.getResponse(); + byte[] body = Arrays.copyOfRange(byteRequest1, bodyOffset1, byteRequest1.length); + + obj = ec.matchRegex(content, headers1, body, "response"); + if (obj.size() > 0) { String result = da.extractString(obj); extractResponseContent = result.getBytes(); return true; diff --git a/src/main/java/burp/ui/MainUI.java b/src/main/java/burp/ui/MainUI.java index be154d8..b88d174 100644 --- a/src/main/java/burp/ui/MainUI.java +++ b/src/main/java/burp/ui/MainUI.java @@ -221,7 +221,7 @@ class TabTitleEditListener extends MouseAdapter implements ChangeListener, Docum protected Boolean isRenamesucc = false; protected LoadConfigFile loadfile = new LoadConfigFile(); protected LoadRule lr = new LoadRule(loadfile.getConfigPath()); - protected SetRuleConfig setruleconfig = new SetRuleConfig(); + protected SetRuleConfig setRuleConfig = new SetRuleConfig(); protected final Action startEditing = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { editingIdx = tabbedPane.getSelectedIndex(); @@ -243,7 +243,7 @@ class TabTitleEditListener extends MouseAdapter implements ChangeListener, Docum if (editingIdx >= 0 && !title.isEmpty()) { String oldname = tabbedPane.getTitleAt(editingIdx); tabbedPane.setTitleAt(editingIdx, title); - setruleconfig.rename(oldname,title); + setRuleConfig.rename(oldname,title); } cancelEditing.actionPerformed(null); } @@ -298,7 +298,7 @@ protected TabTitleEditListener(JTabbedPane tabbedPane) { } public void newTab(){ Object[][] data = new Object[][]{{false, "New Name", "(New Regex)", "gray", "any", "nfa"}}; - insertTab(tabbedPane,setruleconfig.newRules(),data); + insertTab(tabbedPane,setRuleConfig.newRules(),data); } public void insertTab(@NotNull JTabbedPane pane,String title,Object[][] data){ pane.addTab(title,new RulePane(data,pane)); diff --git a/src/main/java/burp/ui/RulePane.java b/src/main/java/burp/ui/RulePane.java index beaa567..ca196d5 100644 --- a/src/main/java/burp/ui/RulePane.java +++ b/src/main/java/burp/ui/RulePane.java @@ -27,18 +27,19 @@ private void RuleAddMouseClicked(MouseEvent e, JTabbedPane pane) { RuleSetting add = new RuleSetting(); int isOk = JOptionPane.showConfirmDialog(null,add,"RuleSetting - Add Rule",JOptionPane.OK_OPTION); if(isOk == 0){ - model.addRow(new Object[0]); - model.setValueAt(false,(model.getRowCount()-1),0); - model.setValueAt(add.Name.getText(),(model.getRowCount()-1),1); - model.setValueAt(add.Regex.getText(),(model.getRowCount()-1),2); - model.setValueAt(add.ColorSelect.getSelectedItem().toString(),(model.getRowCount()-1),3); - model.setValueAt(add.ScopeSelect.getSelectedItem().toString(),(model.getRowCount()-1),4); - model.setValueAt(add.EngineSelect.getSelectedItem().toString(),(model.getRowCount()-1),5); + Vector data = new Vector(); + data.add(false); + data.add(add.Name.getText()); + data.add(add.Regex.getText()); + data.add(add.ColorSelect.getSelectedItem().toString()); + data.add(add.ScopeSelect.getSelectedItem().toString()); + data.add(add.EngineSelect.getSelectedItem().toString()); + model.insertRow(model.getRowCount(),data); model = (DefaultTableModel) table.getModel(); - int select = table.convertRowIndexToModel(table.getSelectedRow()); - setruleconfig.add((Vector) model.getDataVector().get(select),pane.getTitleAt(pane.getSelectedIndex())); + setruleconfig.add(data,pane.getTitleAt(pane.getSelectedIndex())); } } + private void RuleEditMouseClicked(MouseEvent e,JTabbedPane pane){ if (table.getSelectedRowCount()>=1){ RuleSetting edit = new RuleSetting(); @@ -60,18 +61,19 @@ private void RuleEditMouseClicked(MouseEvent e,JTabbedPane pane){ } } } + private void RuleRemoveMouseClicked(MouseEvent e,JTabbedPane pane){ if (table.getSelectedRowCount()>=1){ int isOk = JOptionPane.showConfirmDialog(null,"Are your sure?","RuleSetting - Delete Rule",JOptionPane.OK_OPTION); if (isOk==0){ - model.removeRow(table.convertRowIndexToModel(table.getSelectedRow())); - table.remove(table.getSelectedRow()); - model = (DefaultTableModel) table.getModel(); int select = table.convertRowIndexToModel(table.getSelectedRow()); + model.removeRow(select); + model = (DefaultTableModel) table.getModel(); setruleconfig.remove(select,pane.getTitleAt(pane.getSelectedIndex())); } } } + private void RuleTableChange(TableModelEvent e,JTabbedPane pane) { if (e.getColumn()==0&&table.getSelectedRow()!=-1&&!isEdit){ model = (DefaultTableModel) table.getModel(); diff --git a/src/main/java/burp/yaml/Rule.java b/src/main/java/burp/yaml/Rule.java index ac62d03..12a3f14 100644 --- a/src/main/java/burp/yaml/Rule.java +++ b/src/main/java/burp/yaml/Rule.java @@ -14,20 +14,10 @@ public class Rule { private String Color; private String Engine; private String Scope; - private String Action; public Boolean getLoaded() { return Loaded; } - - public void setLoaded(Boolean loaded) { - this.Loaded = loaded; - } - - public String getAction() { - return Action; - } - public String getColor() { return Color; } @@ -48,6 +38,11 @@ public String getScope() { return Scope; } + public void setLoaded(Boolean loaded) { + this.Loaded = loaded; + } + + public void setColor(String color) { this.Color = color; } diff --git a/src/main/java/burp/yaml/SetRuleConfig.java b/src/main/java/burp/yaml/SetRuleConfig.java index 53f0120..3ef56f4 100644 --- a/src/main/java/burp/yaml/SetRuleConfig.java +++ b/src/main/java/burp/yaml/SetRuleConfig.java @@ -98,7 +98,7 @@ public String newRules(){ lr = new LoadRule(loadfile.getConfigPath()); config = lr.getConfig(); String name = "New "; - Object[][] data = new Object[][]{{false,"newName","newRegex","gray","any","nfa"}}; + Object[][] data = new Object[][]{{false, "New Name", "(New Regex)", "gray", "any", "nfa"}}; while (config.containsKey(name+i)){ i++; }