Skip to content

Commit

Permalink
Added document import/export functionality. Fixed some file loading i…
Browse files Browse the repository at this point in the history
…ssues.
  • Loading branch information
aglane committed Feb 28, 2013
1 parent 4df1fe4 commit 47de698
Show file tree
Hide file tree
Showing 5 changed files with 269 additions and 44 deletions.
9 changes: 6 additions & 3 deletions README.md
Expand Up @@ -32,11 +32,14 @@ interface
from source, then click "Open".
5. Click "Next" to load the plugin.

Within the Notes tab, there are four options:
Within the Notes tab, you can:
- Save Notes: Save any currently open documents to a file.
- Load Notes: Load a previously saved set of notes from a file.
- Add Text: Add a tab with a new text document.
- Add Spreadsheet: Add a tab with a new spreadsheet.
- New Text: Add a tab with a new text document.
- Import Text: Load the contents of a text document.
- New Spreadsheet: Add a tab with a new spreadsheet.
- Import Spreadsheet: Load the contents of a CSV document.
- You can also export individual notes tabs to an external file.

From other tabs in Burp, right clicking in areas where a user can normally
interact with HTTP Responses and Requests, such as the Proxy History or Site Map
Expand Down
Binary file modified build/jar/BurpNotesExtension.jar
Binary file not shown.
77 changes: 57 additions & 20 deletions src/burp/BurpExtender.java
Expand Up @@ -13,6 +13,8 @@
package burp;

import java.awt.Component;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
Expand All @@ -21,6 +23,7 @@
import java.util.List;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
Expand All @@ -39,7 +42,6 @@
public class BurpExtender implements IBurpExtender, ITab, ActionListener, IExtensionStateListener, IContextMenuFactory
{
private NotesExtensionOperations ops;
private JButton btnAddText, btnAddSpreadsheet, btnLoadNotes, btnSaveNotes;

public final String TAB_NAME = "Notes";

Expand Down Expand Up @@ -70,27 +72,62 @@ public void registerExtenderCallbacks(final IBurpExtenderCallbacks Callbacks)
public void run(){
//Create our initial UI components
ops.tabbedPane = new JTabbedPane();
JPanel panel = new JPanel();
JPanel panel = new JPanel(new BorderLayout());
//Tab Management
ops.tabList = new JComboBox();
ops.tabList.addItem("Choose...");
ops.btnSaveTabAsTemplate = new JButton("Export Tab");
ops.btnSaveTabAsTemplate.setActionCommand(NotesExtensionOperations.COMMAND_SAVE_TAB_AS_TEMPLATE);
ops.btnSaveTabAsTemplate.addActionListener(BurpExtender.this);
ops.btnRemoveTab = new JButton("Remove Tab");
ops.btnRemoveTab.setActionCommand(NotesExtensionOperations.COMMAND_REMOVE_TAB);
ops.btnRemoveTab.addActionListener(BurpExtender.this);

//Add the save,load, and document buttons
btnAddText = new JButton("Add Text");
btnAddText.setActionCommand(NotesExtensionOperations.COMMAND_ADD_TEXT);
btnAddText.addActionListener(BurpExtender.this);
btnAddSpreadsheet = new JButton("Add Spreadsheet");
btnAddSpreadsheet.setActionCommand(NotesExtensionOperations.COMMAND_ADD_SPREADSHEET);
btnAddSpreadsheet.addActionListener(BurpExtender.this);
btnSaveNotes = new JButton("Save Notes");
btnSaveNotes.setActionCommand(NotesExtensionOperations.COMMAND_SAVE_NOTES);
btnSaveNotes.addActionListener(BurpExtender.this);
btnLoadNotes = new JButton("Load Notes");
btnLoadNotes.setActionCommand(NotesExtensionOperations.COMMAND_LOAD_NOTES);
btnLoadNotes.addActionListener(BurpExtender.this);
ops.btnAddText = new JButton("New Text");
ops.btnAddText.setActionCommand(NotesExtensionOperations.COMMAND_ADD_TEXT);
ops.btnAddText.addActionListener(BurpExtender.this);
ops.btnAddSpreadsheet = new JButton("New Spreadsheet");
ops.btnAddSpreadsheet.setActionCommand(NotesExtensionOperations.COMMAND_ADD_SPREADSHEET);
ops.btnAddSpreadsheet.addActionListener(BurpExtender.this);
ops.btnImportText = new JButton("Import Text");
ops.btnImportText.setActionCommand(NotesExtensionOperations.COMMAND_IMPORT_TEXT);
ops.btnImportText.addActionListener(BurpExtender.this);
ops.btnImportSpreadsheet = new JButton("Import Spreadsheet");
ops.btnImportSpreadsheet.setActionCommand(NotesExtensionOperations.COMMAND_IMPORT_SPREADSHEET);
ops.btnImportSpreadsheet.addActionListener(BurpExtender.this);
ops.btnSaveNotes = new JButton("Save Notes");
ops.btnSaveNotes.setActionCommand(NotesExtensionOperations.COMMAND_SAVE_NOTES);
ops.btnSaveNotes.addActionListener(BurpExtender.this);
ops.btnLoadNotes = new JButton("Load Notes");
ops.btnLoadNotes.setActionCommand(NotesExtensionOperations.COMMAND_LOAD_NOTES);
ops.btnLoadNotes.addActionListener(BurpExtender.this);

//Make our panel with a grid layout for arranging the buttons
panel.setLayout(new GridLayout(3, 3));
panel.add(btnSaveNotes);
panel.add(btnLoadNotes);
panel.add(btnAddText);
panel.add(btnAddSpreadsheet);
JPanel topPanel = new JPanel();
topPanel.add(ops.tabList);
topPanel.add(ops.btnSaveTabAsTemplate);
topPanel.add(ops.btnRemoveTab);
topPanel.setPreferredSize(new Dimension(500,100));
panel.add(topPanel, BorderLayout.PAGE_START);
JPanel spaceLeft = new JPanel();
spaceLeft.setPreferredSize(new Dimension(300,200));
panel.add(spaceLeft, BorderLayout.LINE_START);
JPanel buttonPanel = new JPanel(new GridLayout(3,2));
buttonPanel.add(ops.btnSaveNotes);
buttonPanel.add(ops.btnLoadNotes);
buttonPanel.add(ops.btnAddText);
buttonPanel.add(ops.btnAddSpreadsheet);
buttonPanel.add(ops.btnImportText);
buttonPanel.add(ops.btnImportSpreadsheet);
buttonPanel.setPreferredSize(new Dimension(150,150));
panel.add(buttonPanel, BorderLayout.CENTER);
JPanel spaceRight = new JPanel();
spaceRight.setPreferredSize(new Dimension(300,200));
panel.add(spaceRight, BorderLayout.LINE_END);
JPanel spaceBottom = new JPanel();
spaceBottom.setPreferredSize(new Dimension(500,250));
panel.add(spaceBottom, BorderLayout.PAGE_END);
ops.tabbedPane.addTab("Main", panel);
ops.callbacks.customizeUiComponent(ops.tabbedPane);

Expand Down Expand Up @@ -122,7 +159,7 @@ public void extensionUnloaded() {
//Unloading extension, prompt user to save data if they have any tabs
if(ops.tabbedPane.getTabCount() > 1){
Object[] options = {"Yes", "No"};
int n = JOptionPane.showOptionDialog(getUiComponent(), "Would you like to save your notes?", "Notes Tab", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
int n = JOptionPane.showOptionDialog(ops.tabbedPane, "Would you like to save your notes?", "Notes Tab", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
if(n == JOptionPane.YES_OPTION){
ops.SaveNotes();
}
Expand Down
10 changes: 4 additions & 6 deletions src/com/trustwave/burp/ButtonTabComponent.java
Expand Up @@ -50,14 +50,16 @@
@SuppressWarnings("serial")
public class ButtonTabComponent extends JPanel {
private final JTabbedPane pane;
private final NotesExtensionOperations ops;

public ButtonTabComponent(final JTabbedPane pane) {
public ButtonTabComponent(final JTabbedPane pane, final NotesExtensionOperations ops) {
//unset default FlowLayout' gaps
super(new FlowLayout(FlowLayout.LEFT, 0, 0));
if (pane == null) {
throw new NullPointerException("TabbedPane is null");
}
this.pane = pane;
this.ops = ops;
setOpaque(false);

//make JLabel read titles from JTabbedPane
Expand Down Expand Up @@ -105,11 +107,7 @@ public TabButton() {
public void actionPerformed(ActionEvent e) {
int i = pane.indexOfTabComponent(ButtonTabComponent.this);
if (i != -1) {
Object[] options = {"OK", "Cancel"};
int n = JOptionPane.showOptionDialog(pane, "If you close this tab you will lose any unsaved data.", "Notes Tab", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]);
if(n == JOptionPane.OK_OPTION){
pane.remove(i);
}
ops.RemoveTab(i);
}
}

Expand Down

0 comments on commit 47de698

Please sign in to comment.