Skip to content

Commit

Permalink
Version: 2.0.1 Fixed bug
Browse files Browse the repository at this point in the history
  • Loading branch information
AnonymousUser committed Jun 11, 2021
1 parent a7112ad commit e43a96b
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 48 deletions.
54 changes: 32 additions & 22 deletions src/main/java/burp/BurpExtender.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<String, Map<String, Object>> 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<String> 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<String> 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<String, Map<String, Object>> 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<String> 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;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/burp/ui/MainUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
}
Expand Down Expand Up @@ -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));
Expand Down
26 changes: 14 additions & 12 deletions src/main/java/burp/ui/RulePane.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
15 changes: 5 additions & 10 deletions src/main/java/burp/yaml/Rule.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/burp/yaml/SetRuleConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand Down

0 comments on commit e43a96b

Please sign in to comment.