Skip to content

Commit

Permalink
Restructure based on gradle, fixes #1, #2, #4
Browse files Browse the repository at this point in the history
  • Loading branch information
honoki committed Nov 7, 2021
1 parent 632a091 commit 8418a7f
Show file tree
Hide file tree
Showing 49 changed files with 82 additions and 3,957 deletions.
26 changes: 5 additions & 21 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
*target*
*.jar
*.war
*.ear
*.class

# eclipse specific git ignore
*.pydevproject
.project
.metadata
bin/**
tmp/**
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
# Ignore Gradle project-specific cache directory
.gradle

# Ignore Gradle build output directory
build
Binary file removed BBRF.jar
Binary file not shown.
33 changes: 33 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// copied from https://parsiya.net/blog/2019-12-02-developing-and-debugging-java-burp-extensions-with-visual-studio-code/#creating-a-skeleton-extension

apply plugin: 'java'
sourceCompatibility = 11
targetCompatibility = 11

repositories {
mavenCentral()
}

dependencies {
implementation 'net.portswigger.burp.extender:burp-extender-api:2.1'
implementation 'com.google.code.gson:gson:2.8.9'
}

sourceSets {
main {
java {
srcDir 'src'
}
}
}

configurations {
customConfig.extendsFrom implementation
}

task bigJar(type: Jar) {
baseName = project.name + '-all'
duplicatesStrategy = 'include'
from { configurations.customConfig.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
File renamed without changes
File renamed without changes
10 changes: 10 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* This file was generated by the Gradle 'init' task.
*
* The settings file is used to specify which projects to include in your build.
*
* Detailed information about configuring a multi-project build in Gradle can be found
* in the user manual at https://docs.gradle.org/7.2/userguide/multi_project_builds.html
*/

rootProject.name = 'bbrf-burp-plugin'
17 changes: 8 additions & 9 deletions src/burp/BBRFTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import javax.swing.JCheckBox;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.net.URL;
import java.awt.event.ActionEvent;
import javax.swing.JTextPane;

Expand All @@ -36,7 +35,6 @@ public void actionPerformed(ActionEvent e) {
burp.program_name = textField_1.getText();

burp.saveSettings();

}
});

Expand All @@ -60,16 +58,17 @@ public void actionPerformed(ActionEvent e) {
String out_scope = burp.bbrf("scope out -p "+textField_1.getText());

burp.generateScope(in_scope.split("\n"), out_scope.split("\n"));
//textPane.setText(result);
}
});

GroupLayout groupLayout = new GroupLayout(this);
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addGap(45)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addComponent(textPane, GroupLayout.PREFERRED_SIZE, 615, GroupLayout.PREFERRED_SIZE)
.addComponent(btnSave)
.addGroup(groupLayout.createSequentialGroup()
.addComponent(lblBbrfProgram)
.addGap(43)
Expand All @@ -78,9 +77,8 @@ public void actionPerformed(ActionEvent e) {
.addComponent(btnLoad)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(btnCopyScope))
.addComponent(chckbxParseDomains, GroupLayout.PREFERRED_SIZE, 342, GroupLayout.PREFERRED_SIZE)
.addComponent(btnSave))
.addContainerGap(27, Short.MAX_VALUE))
.addComponent(chckbxParseDomains, GroupLayout.PREFERRED_SIZE, 342, GroupLayout.PREFERRED_SIZE))
.addContainerGap(20, Short.MAX_VALUE))
);
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
Expand All @@ -96,11 +94,12 @@ public void actionPerformed(ActionEvent e) {
.addComponent(btnCopyScope)))
.addGap(18)
.addComponent(chckbxParseDomains)
.addGap(18)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addGap(37)
.addComponent(btnSave)
.addGap(18)
.addComponent(textPane, GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE)
.addGap(84))
.addComponent(textPane, GroupLayout.DEFAULT_SIZE, 49, Short.MAX_VALUE)
.addGap(38))
);
setLayout(groupLayout);

Expand Down
30 changes: 26 additions & 4 deletions src/burp/BurpExtender.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class BurpExtender implements IExtensionStateListener, IScannerCheck, ITa
private IExtensionHelpers helpers;
private ArrayList<String> all_domains = new ArrayList<>();
private PrintWriter stdout;
private PrintWriter stderr;

protected String program_name;

Expand All @@ -55,6 +56,9 @@ public void registerExtenderCallbacks (IBurpExtenderCallbacks callbacks){
callbacks.setExtensionName ("BBRF for Burp");
this.helpers = callbacks.getHelpers();
this.stdout = new PrintWriter(callbacks.getStdout(), true);
this.stderr = new PrintWriter(callbacks.getStderr(), true);

logger("BBRF for Burp initialized.");
this.callbacks = callbacks;

// store project settings in site map
Expand Down Expand Up @@ -140,12 +144,30 @@ public byte[] call() throws Exception {

protected String bbrf(String cmd) {

stdout.println(program_name);
stdout.println(cmd);

String[] split_program = cmd.split(" -p ");

// Address issue #2 if program names contain spaces
if(split_program[1].contains(" ")) {
cmd = split_program[0];
}

ArrayList<String> command = new ArrayList<String>();
command.add("bbrf");
for(String c : cmd.split(" ")) {
command.add(c);
}

// Address issue #2 if program names contain spaces
if(split_program[1].contains(" ")) {
command.add("-p");
command.add(split_program[1]);
}

stdout.println(command);

ProcessBuilder processBuilder = new ProcessBuilder(command);
processBuilder.redirectErrorStream(true);

Expand Down Expand Up @@ -183,7 +205,7 @@ protected void saveSettings() {
// callbacks.saveExtensionSetting("api-gateway-url", bbrf_gateway_url);
// callbacks.saveExtensionSetting("program-name", program_name);
// callbacks.saveExtensionSetting("client-location", bbrf_py);

logger("Saving settings...");
settings.saveProjectSetting("program-name", program_name);
}

Expand Down Expand Up @@ -251,7 +273,7 @@ public int consolidateDuplicateIssues(IScanIssue existingIssue, IScanIssue newIs
}

// Logging helper functions
private void logger(String out) {
void logger(String out) {
stdout.println(out);
}

Expand Down Expand Up @@ -286,7 +308,7 @@ public void actionPerformed(ActionEvent e) {
if(!domains.contains(domain)) domains.add(domain);
}

if(domains.size() > 0) logger(bbrf("domain add "+String.join(" ", domains)+ " -s burp"));
if(domains.size() > 0) logger(bbrf("domain add "+String.join(" ", domains)+ " -s burp -p "+program_name));

}
});
Expand All @@ -302,7 +324,7 @@ public void actionPerformed(ActionEvent e) {
if(!urls.contains(url)) urls.add(helpers.analyzeRequest(req).getUrl().toString());
}

if(urls.size() > 0) logger(bbrf("url add "+String.join(" ", urls)+ " -s burp"));
if(urls.size() > 0) logger(bbrf("url add "+String.join(" ", urls)+ " -s burp -p "+program_name));

}
});
Expand Down
97 changes: 0 additions & 97 deletions src/burp/IBurpCollaboratorClientContext.java

This file was deleted.

41 changes: 0 additions & 41 deletions src/burp/IBurpCollaboratorInteraction.java

This file was deleted.

31 changes: 0 additions & 31 deletions src/burp/IBurpExtender.java

This file was deleted.

0 comments on commit 8418a7f

Please sign in to comment.