Skip to content

Commit

Permalink
info tab todo
Browse files Browse the repository at this point in the history
  • Loading branch information
bit4woo committed May 13, 2024
1 parent 31085d3 commit 2d04acf
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 72 deletions.
3 changes: 3 additions & 0 deletions src/burp/BurpExtender.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import config.ConfigTableModel;
import config.GUI;
import knife.*;
import messageTab.Info.InfoTabFactory;
import messageTab.U2C.ChineseTabFactory;
import config.ProcessManager;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -69,11 +70,13 @@ public void registerExtenderCallbacks(IBurpExtenderCallbacks callbacks) {
showToUI(configManager);

ChineseTabFactory chntabFactory = new ChineseTabFactory(null, false, helpers, callbacks);
InfoTabFactory infotabFactory = new InfoTabFactory(null, false, helpers, callbacks);

//各项数据初始化完成后在进行这些注册操作,避免插件加载时的空指针异常
callbacks.setExtensionName(getFullExtensionName());
callbacks.registerContextMenuFactory(this);// for menus
callbacks.registerMessageEditorTabFactory(chntabFactory);// for Chinese
callbacks.registerMessageEditorTabFactory(infotabFactory);// for Chinese
callbacks.addSuiteTab(BurpExtender.this);
callbacks.registerHttpListener(this);
callbacks.registerProxyListener(this);
Expand Down
10 changes: 8 additions & 2 deletions src/config/ConfigTableModel.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package config;

import java.io.File;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -29,7 +30,8 @@ public class ConfigTableModel extends AbstractTableModel{
};

public static final String Firefox_Mac = "/Applications/Firefox.app/Contents/MacOS/firefox";
public static final String Firefox_Windows = "D:\\Program Files\\Mozilla Firefox\\firefox.exe";
public static final String Firefox_Windows_D = "D:\\Program Files\\Mozilla Firefox\\firefox.exe";
public static final String Firefox_Windows_C = "C:\\Program Files\\Mozilla Firefox\\firefox.exe";

// /usr/local/bin 本地默认可执行文件路径
public static final String SQLMap_Command = "python /usr/local/bin/sqlmap-dev/sqlmap.py -r {RequestAsFile} --force-ssl --risk=3 --level=3";
Expand All @@ -45,7 +47,11 @@ public ConfigTableModel(){
if (SystemUtils.isMac()) {
configEntries.add(new ConfigEntry("browserPath", Firefox_Mac,ConfigEntry.Config_Basic_Variable,true,false));
}else {
configEntries.add(new ConfigEntry("browserPath", Firefox_Windows,ConfigEntry.Config_Basic_Variable,true,false));
if (new File(Firefox_Windows_C).exists()){
configEntries.add(new ConfigEntry("browserPath", Firefox_Windows_C,ConfigEntry.Config_Basic_Variable,true,false));
}else {
configEntries.add(new ConfigEntry("browserPath", Firefox_Windows_D,ConfigEntry.Config_Basic_Variable,true,false));
}
}
configEntries.add(new ConfigEntry("tokenHeaders", "token,Authorization,Auth,jwt",ConfigEntry.Config_Basic_Variable,true,false));
//configEntries.add(new ConfigEntry("DismissedTargets", "{\"*.firefox.com\":\"Drop\",\"*.mozilla.com\":\"Drop\"}",ConfigEntry.Config_Basic_Variable,true,false));
Expand Down
6 changes: 6 additions & 0 deletions src/messageTab/Info/InfoEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ public class InfoEntry {
public InfoEntry() {
//to resolve "default constructor not found" error
}

public InfoEntry(String value, String type) {
this.value = value;
this.type = type;
this.enable = true;
}

public InfoEntry(String value, String type, boolean enable) {
this.value = value;
Expand Down
29 changes: 22 additions & 7 deletions src/messageTab/Info/InfoPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
Expand All @@ -18,31 +19,45 @@
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;

import com.bit4woo.utilbox.utils.SystemUtils;

import burp.BurpExtender;

public class InfoPanel extends JPanel {

private final JTextField searchField;
private final JLabel statusLabel = new JLabel(" 0 matches");
boolean isRequest;
private final JComponent parent;

InfoTable table;


public InfoTable getTable() {
return table;
}


InfoPanel(JComponent parent) {
public void setTable(InfoTable table) {
this.table = table;
}


InfoPanel(InfoTab parent) {

this.parent = parent;
setBorder(new EmptyBorder(5, 5, 5, 5));
setLayout(new BorderLayout(0, 0));

JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
add(buttonPanel, BorderLayout.NORTH);

InfoTableModel model = new InfoTableModel();
InfoTable table = new InfoTable(model);
table = new InfoTable(model);

JScrollPane scrollPane = new JScrollPane();
scrollPane.add(table);
scrollPane.setViewportView(table);
add(scrollPane, BorderLayout.CENTER);



JPanel footPanel = new JPanel(new BorderLayout());
searchField = new JTextField();
Timer searchTimer = createSearchTimer();
Expand Down
31 changes: 16 additions & 15 deletions src/messageTab/Info/InfoTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@
import java.awt.Component;

import javax.swing.JPanel;
import javax.swing.SwingWorker;
import javax.swing.border.EmptyBorder;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StringEscapeUtils;

import burp.BurpExtender;
import burp.IBurpExtenderCallbacks;
import burp.IExtensionHelpers;
import burp.IMessageEditorController;
import burp.IMessageEditorTab;
import burp.IRequestInfo;
import burp.IResponseInfo;
import messageTab.U2C.ChinesePanel;

/**
* @author bit4woo
Expand All @@ -33,22 +37,10 @@ public class InfoTab implements IMessageEditorTab{

private byte[] originContent;

private static IExtensionHelpers helpers;

public InfoTab(IMessageEditorController controller, boolean editable, IExtensionHelpers helpers, IBurpExtenderCallbacks callbacks)
{
panel = createpanel();
InfoTab.helpers = helpers;
}


public JPanel createpanel() {

JPanel contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));

return contentPane;
panel = new InfoPanel(this);
BurpExtender.getCallbacks().customizeUiComponent(panel);//尝试使用burp的font size
}

@Override
Expand All @@ -73,7 +65,16 @@ public boolean isEnabled(byte[] content, boolean isRequest)
public void setMessage(byte[] content, boolean isRequest)
{
originContent = content;

SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
originContent = content;
InfoEntry aaa = new InfoEntry("http://www.baidu.com",InfoEntry.Type_URL);
((InfoPanel)panel).getTable().getInfoTableModel().addNewInfoEntry(aaa);
return null;
}
};
worker.execute();
}


Expand Down
90 changes: 53 additions & 37 deletions src/messageTab/Info/InfoTable.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package messageTab.Info;

import burp.BurpExtender;
import com.bit4woo.utilbox.utils.SystemUtils;

import static config.ConfigTableModel.titles;

import java.awt.Color;
Expand Down Expand Up @@ -28,8 +31,8 @@ public class InfoTable extends JTable {
*
*/
private static final long serialVersionUID = 1L;
public static final String[] headers ={"value","type"};

public static final String[] headers = {"Value", "Type"};


public InfoTable(InfoTableModel tableModel) {
Expand All @@ -46,14 +49,14 @@ public InfoTable(InfoTableModel tableModel) {
//table.setupTypeColumn()//can't set here, only can after table data loaded.
//tableHeaderLengthInit();//can't set here, only can after table data loaded.
}
public static List<String> getHeaders(){
return Arrays.asList(headers);

public static List<String> getHeaders() {
return Arrays.asList(headers);
}
public InfoTableModel getInfoTableModel(){
return (InfoTableModel)this.getModel();


public InfoTableModel getInfoTableModel() {
return (InfoTableModel) this.getModel();
}


Expand Down Expand Up @@ -94,47 +97,60 @@ public void tableHeaderLengthInit() {
//this.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);//配合横向滚动条
}


//将选中的行(图形界面的行)转换为Model中的行数(数据队列中的index).因为图形界面排序等操作会导致图像和数据队列的index不是线性对应的。
public int[] SelectedRowsToModelRows(int[] SelectedRows) {

for (int i = 0; i < SelectedRows.length; i++){
SelectedRows[i] = convertRowIndexToModel(SelectedRows[i]);//转换为Model的索引,否则排序后索引不对应〿
}
Arrays.sort(SelectedRows);//升序
//将选中的行(图形界面的行)转换为Model中的行数(数据队列中的index).因为图形界面排序等操作会导致图像和数据队列的index不是线性对应的。
public int[] SelectedRowsToModelRows(int[] SelectedRows) {

return SelectedRows;
}
for (int i = 0; i < SelectedRows.length; i++) {
SelectedRows[i] = convertRowIndexToModel(SelectedRows[i]);//转换为Model的索引,否则排序后索引不对应〿
}
Arrays.sort(SelectedRows);//升序

return SelectedRows;
}

private void registerListeners() {
this.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
InfoTable target = (InfoTable) e.getSource();
InfoTable target = (InfoTable) e.getSource();
int row = target.getSelectedRow();
int column = target.getSelectedColumn();
if (titles[column].equals("Enable")) {
boolean value = (boolean) getValueAt(row, column);
setValueAt(!value, row, column);
}
//双击浏览器打开url
if (headers[column].equalsIgnoreCase("Value")) {//双击url在浏览器中打开
try {
String url = (String) getValueAt(row, column);
if (url != null && !url.toLowerCase().startsWith("http://") && !url.toLowerCase().startsWith("https://")) {
url = "http://" + url;//针对DNS记录中URL字段是host的情况
}
String browserPath = BurpExtender.getConfigTableModel().getConfigValueByKey("browserPath");
SystemUtils.browserOpen(url, browserPath);
} catch (Exception e1) {
e1.printStackTrace(BurpExtender.getStderr());
}
}
}
}

@Override//title表格中的鼠标右键菜单
public void mouseReleased( MouseEvent e ){
if ( SwingUtilities.isRightMouseButton( e )){
if (e.isPopupTrigger() && e.getComponent() instanceof InfoTable ) {
int[] rows = getSelectedRows();
int col = ((InfoTable) e.getSource()).columnAtPoint(e.getPoint()); // 获得列位置
int modelCol = InfoTable.this.convertColumnIndexToModel(col);
if (rows.length>0){
int[] modelRows = SelectedRowsToModelRows(rows);
//new ConfigTableMenu(ConfigTable.this, modelRows, modelCol).show(e.getComponent(), e.getX(), e.getY());
}
}
}
}
@Override//title表格中的鼠标右键菜单
public void mouseReleased(MouseEvent e) {
if (SwingUtilities.isRightMouseButton(e)) {
if (e.isPopupTrigger() && e.getComponent() instanceof InfoTable) {
int[] rows = getSelectedRows();
int col = ((InfoTable) e.getSource()).columnAtPoint(e.getPoint()); // 获得列位置
int modelCol = InfoTable.this.convertColumnIndexToModel(col);
if (rows.length > 0) {
int[] modelRows = SelectedRowsToModelRows(rows);
//new ConfigTableMenu(ConfigTable.this, modelRows, modelCol).show(e.getComponent(), e.getX(), e.getY());
}
}
}
}

@Override
public void mousePressed(MouseEvent e) {
Expand All @@ -144,10 +160,10 @@ public void mousePressed(MouseEvent e) {
}


/**
* 搜索功能
* @param caseSensitive
*/
/**
* 搜索功能
* @param caseSensitive
*/
/*
public void search(String Input,boolean caseSensitive) {
final RowFilter filter = new RowFilter() {
Expand Down
14 changes: 3 additions & 11 deletions src/messageTab/Info/InfoTableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,7 @@ public String getColumnName(int columnIndex) {

@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
InfoEntry entry = infoEntries.get(rowIndex);
if (!entry.isEditable()) {
if (titles[columnIndex].equals("Key")) {
return false;
}else if (titles[columnIndex].equals("Type")) {
return false;
}
}
return true;
return false;
}

@Override
Expand Down Expand Up @@ -126,8 +118,8 @@ public void addNewInfoEntry(InfoEntry lineEntry){
//fireTableRowsInserted(row, row);
//need to use row-1 when add setRowSorter to table. why??
//https://stackoverflow.com/questions/6165060/after-adding-a-tablerowsorter-adding-values-to-model-cause-java-lang-indexoutofb
//fireTableRowsInserted(row-1, row-1);
fireTableRowsInserted(row-2, row-2);
fireTableRowsInserted(row-1, row-1);
//fireTableRowsInserted(row-2, row-2);
}
}

Expand Down

0 comments on commit 2d04acf

Please sign in to comment.