Skip to content

Commit

Permalink
Implements the changing of DB file during a Burp working session #11
Browse files Browse the repository at this point in the history
  • Loading branch information
righettod committed Aug 31, 2019
1 parent 7110871 commit ef29d4e
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 13 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,28 @@ There is an option to exclude the logging of the requests that target images (ch

The list of supported file extensions is [here](resources/settings.properties).

## Pause the logging

There is an option to pause the logging (re-click on the menu to resume the logging):

![Pause Option Menu](example6a.png)

When the logging is paused then when Burp is restarted, it keep in mind that the logging was previously paused and then reflect the state in the menu:

![Pause Option Menu](example6c.png)

Otherwise, when Burp is started and logging was not previously paused then the following options are proposed:

![Pause Option Menu](example6b.png)

## Change the DB file

:warning: This option require that the logging was paused.

There is an option to change the DB file during a Burp working session:

![ChangeDB Option Menu](example7.png)

## Statistics

There is an option to obtain statistics about the information logged in the database:
Expand Down
Binary file modified example3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified example4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified example5a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example6a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example6b.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example6c.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 14 additions & 4 deletions src/burp/ActivityLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,21 @@ class ActivityLogger implements IExtensionStateListener {
//Affect the properties
this.callbacks = callbacks;
this.trace = trace;
updateStoreLocation(storeName);
}

/**
* Change the location where DB is stored.
*
* @param storeName Name of the storage that will be created (file path).
* @throws Exception If connection with the DB cannot be opened or if the DB cannot be created or if the JDBC driver cannot be loaded.
*/
void updateStoreLocation(String storeName) throws Exception {
String newUrl = "jdbc:sqlite:" + storeName;
this.url = newUrl;
//Open the connection to the DB
this.trace.writeLog("Activity information will be stored in database file '" + storeName + "'.");
url = "jdbc:sqlite:" + storeName;
this.storageConnection = DriverManager.getConnection(url);
this.storageConnection = DriverManager.getConnection(newUrl);
this.storageConnection.setAutoCommit(true);
this.trace.writeLog("Open new connection to the storage.");
//Create the table
Expand All @@ -79,7 +90,6 @@ class ActivityLogger implements IExtensionStateListener {
}
}


/**
* Save an activity event into the storage.
*
Expand Down Expand Up @@ -128,7 +138,7 @@ DBStats getEventsStats() throws Exception {
long totalAmountDataSent = 0;
long biggestRequestAmountDataSent = 0;
long maxHitsBySecond = 0;
if(recordsCount > 0){
if (recordsCount > 0) {
//Get the total amount of data sent, we assume here that 1 character = 1 byte
try (PreparedStatement stmt = this.storageConnection.prepareStatement(SQL_TOTAL_AMOUNT_DATA_SENT)) {
try (ResultSet rst = stmt.executeQuery()) {
Expand Down
10 changes: 1 addition & 9 deletions src/burp/BurpExtender.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,7 @@ public void registerExtenderCallbacks(IBurpExtenderCallbacks callbacks) {
}
//Case for the NO => Change DB file
if (loggingQuestionReply == JOptionPane.NO_OPTION) {
JFileChooser customStoreFileNameFileChooser = new JFileChooser();
customStoreFileNameFileChooser.setDialogTitle(extensionName + " - Select the DB file to use...");
customStoreFileNameFileChooser.setCurrentDirectory(new File(System.getProperty("user.home")));
customStoreFileNameFileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
customStoreFileNameFileChooser.setDragEnabled(false);
customStoreFileNameFileChooser.setMultiSelectionEnabled(false);
customStoreFileNameFileChooser.setAcceptAllFileFilterUsed(false);
customStoreFileNameFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
customStoreFileNameFileChooser.setFileHidingEnabled(true);
JFileChooser customStoreFileNameFileChooser = Utilities.createDBFileChooser();
int dbFileSelectionReply = customStoreFileNameFileChooser.showDialog(burpFrame, "Use");
if (dbFileSelectionReply == JFileChooser.APPROVE_OPTION) {
customStoreFileName = customStoreFileNameFileChooser.getSelectedFile().getAbsolutePath().replaceAll("\\\\", "/");
Expand Down
31 changes: 31 additions & 0 deletions src/burp/ConfigMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import javax.swing.AbstractAction;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
Expand Down Expand Up @@ -168,6 +169,36 @@ public void actionPerformed(ActionEvent e) {
}
});
this.cfgMenu.add(subMenuPauseTheLogging);
//Add the menu to change the DB file
menuText = "Change the DB file";
final JMenuItem subMenuDBFileLocationMenuItem = new JMenuItem(menuText);
subMenuDBFileLocationMenuItem.addActionListener(
new AbstractAction(menuText) {
public void actionPerformed(ActionEvent e) {
try {
String title = "Change the DB file";
if (!ConfigMenu.IS_LOGGING_PAUSED) {
JOptionPane.showMessageDialog(ConfigMenu.getBurpFrame(), "Logging must be paused prior to update the DB file location!", title, JOptionPane.WARNING_MESSAGE);
} else {
String customStoreFileName = callbacks.loadExtensionSetting(ConfigMenu.DB_FILE_CUSTOM_LOCATION_CFG_KEY);
JFileChooser customStoreFileNameFileChooser = Utilities.createDBFileChooser();
int dbFileSelectionReply = customStoreFileNameFileChooser.showDialog(getBurpFrame(), "Use");
if (dbFileSelectionReply == JFileChooser.APPROVE_OPTION) {
customStoreFileName = customStoreFileNameFileChooser.getSelectedFile().getAbsolutePath().replaceAll("\\\\", "/");
activityLogger.updateStoreLocation(customStoreFileName);
callbacks.saveExtensionSetting(ConfigMenu.DB_FILE_CUSTOM_LOCATION_CFG_KEY, customStoreFileName);
JOptionPane.showMessageDialog(getBurpFrame(), "DB file updated to use:\n\r" + customStoreFileName, title, JOptionPane.INFORMATION_MESSAGE);
} else {
JOptionPane.showMessageDialog(getBurpFrame(), "The following database file will continue to be used:\n\r" + customStoreFileName, title, JOptionPane.INFORMATION_MESSAGE);
}
}
} catch (Exception exp) {
ConfigMenu.this.trace.writeLog("Cannot update DB file location: " + exp.getMessage());
}
}
}
);
this.cfgMenu.add(subMenuDBFileLocationMenuItem);
//Add the sub menu to get statistics about the DB.
menuText = "Get statistics about the logged events";
final JMenuItem subMenuDBStatsMenuItem = new JMenuItem(menuText);
Expand Down
27 changes: 27 additions & 0 deletions src/burp/Utilities.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package burp;

import javax.swing.JFileChooser;
import java.io.File;

/**
* Contains utilities methods.
*/
class Utilities {

/**
* Create and configure a UI to select a DB file
* @return a instance of a JFileChooser ready to use
*/
static JFileChooser createDBFileChooser() {
JFileChooser customStoreFileNameFileChooser = new JFileChooser();
customStoreFileNameFileChooser.setDialogTitle("Select the DB file to use...");
customStoreFileNameFileChooser.setCurrentDirectory(new File(System.getProperty("user.home")));
customStoreFileNameFileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
customStoreFileNameFileChooser.setDragEnabled(false);
customStoreFileNameFileChooser.setMultiSelectionEnabled(false);
customStoreFileNameFileChooser.setAcceptAllFileFilterUsed(false);
customStoreFileNameFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
customStoreFileNameFileChooser.setFileHidingEnabled(true);
return customStoreFileNameFileChooser;
}
}

0 comments on commit ef29d4e

Please sign in to comment.