Skip to content

Commit

Permalink
Changed build to maven
Browse files Browse the repository at this point in the history
  • Loading branch information
rammarj committed May 21, 2022
1 parent b550641 commit cb1dd2d
Show file tree
Hide file tree
Showing 16 changed files with 1,003 additions and 1,003 deletions.
13 changes: 10 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
nbproject/*
build/*
dist/lib/*
dist/README.TXT
dist/*
manifest.mf
build.xml
/dist/
/dist/
/bin/
/target/

## maven ##
.classpath
.project
.settings/
mvn*
Binary file removed dist/csrf-poc-creator.jar
Binary file not shown.
34 changes: 34 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>csrf-poc-creator</groupId>
<artifactId>csrf-poc-creator</artifactId>
<version>0.0.1</version>
<name>csrf-poc-creator</name>
<description>Burp Suite Free extension for CSRF Proof Of Concepts</description>

<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
<!-- https://mvnrepository.com/artifact/net.portswigger.burp.extender/burp-extender-api -->
<dependency>
<groupId>net.portswigger.burp.extender</groupId>
<artifactId>burp-extender-api</artifactId>
<version>2.3</version>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
</plugins>
</build>
</project>
203 changes: 100 additions & 103 deletions src/burp/BurpExtender.java → src/main/java/burp/BurpExtender.java
Original file line number Diff line number Diff line change
@@ -1,103 +1,100 @@
package burp;

import burp.burptab.ITabImpl;
import burp.burptab.PocCreatorTab;
import burp.burptab.PocTabManager;
import burp.pocs.Pocs;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import burp.pocs.IPoc;

/**
* CSRF POC Creator extension for Burp Suite
*
* @author Joaquin R. Martinez <[email protected]>
*/
public class BurpExtender implements IBurpExtender, IContextMenuFactory, ActionListener {

private static IBurpExtenderCallbacks burpExtenderCallbacks;
private PocTabManager pocTabManager;
private IContextMenuInvocation icMenuInvocation;
private final JMenu sendMenu;
private int tabCount;
private final LinkedList<JMenuItem> menuItems;

/**Initialize all variables needed*/
public BurpExtender() {
this.menuItems = new LinkedList<>();
this.sendMenu = new JMenu("send to CSRF PoC Creator");
this.tabCount = 1;
}

@Override
public void registerExtenderCallbacks(IBurpExtenderCallbacks ibec) {
BurpExtender.burpExtenderCallbacks = ibec;
this.pocTabManager = new PocTabManager();
ibec.registerContextMenuFactory(this);
ibec.setExtensionName("CSRF PoC Creator");
BurpExtender.burpExtenderCallbacks.addSuiteTab(new ITabImpl("CSRF PoC", this.pocTabManager));
Pocs.initialize();
// add menus
Iterator<String> pocKeys = Pocs.getPocKeys();
while (pocKeys.hasNext()) {
String key = pocKeys.next();
JMenuItem item = new JMenuItem(key);
item.addActionListener(BurpExtender.this);
this.sendMenu.add(item);
}
this.menuItems.add(this.sendMenu);
BurpExtender.burpExtenderCallbacks.printOutput("Burp csrf-poc-creator plugin for Burp Suite Free loaded!");
BurpExtender.burpExtenderCallbacks.printOutput("Created by @rammarj");
}
/**
* Creates the menu items shown in burp suite
* @param icmi the context menu invocation
* @return List of menu items
*/
@Override
public List<JMenuItem> createMenuItems(IContextMenuInvocation icmi) {
this.icMenuInvocation = icmi;
byte invocation_context = icmi.getInvocationContext();
if (invocation_context == IContextMenuInvocation.CONTEXT_MESSAGE_VIEWER_REQUEST
|| invocation_context == IContextMenuInvocation.CONTEXT_PROXY_HISTORY
|| invocation_context == IContextMenuInvocation.CONTEXT_MESSAGE_EDITOR_REQUEST) {
return menuItems;
}
return null;
}

/**This method is executed when the "send to csrf ..." was clicked
* @param e event argument
*/
@Override
public void actionPerformed(ActionEvent e) {
IHttpRequestResponse[] selectedMessages = this.icMenuInvocation.getSelectedMessages();
for (IHttpRequestResponse ihrr : selectedMessages) {
try {
String actionCommand = e.getActionCommand();
IPoc poc = Pocs.getPoc(actionCommand);
byte[] pocContent = poc.getPoc(ihrr);
PocCreatorTab pocCreatorTab = new PocCreatorTab(ihrr, pocContent);
pocCreatorTab.setSelectedItem(actionCommand);
this.pocTabManager.addTab(String.valueOf((this.tabCount++)), pocCreatorTab);
} catch (Exception ex) {
JOptionPane.showMessageDialog(this.pocTabManager, ex.getMessage());
}
}
}

/**
* Get the extender callback for this plugin
* @return the extender callbacks
*/
public static IBurpExtenderCallbacks getBurpExtenderCallbacks() {
return burpExtenderCallbacks;
}

}
package burp;

import burp.burptab.ITabImpl;
import burp.burptab.PocCreatorTab;
import burp.burptab.PocTabManager;
import burp.pocs.Pocs;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import burp.pocs.IPoc;

/**
* CSRF POC Creator extension for Burp Suite
*
* @author Joaquin R. Martinez <[email protected]>
*/
public class BurpExtender implements IBurpExtender, IContextMenuFactory, ActionListener {

private static IBurpExtenderCallbacks burpExtenderCallbacks;
private PocTabManager pocTabManager;
private IContextMenuInvocation icMenuInvocation;
private int tabCount;
private final LinkedList<JMenuItem> menuItems;

/**Initialize all variables needed*/
public BurpExtender() {
this.menuItems = new LinkedList<>();
this.tabCount = 1;
}

@Override
public void registerExtenderCallbacks(IBurpExtenderCallbacks ibec) {
BurpExtender.burpExtenderCallbacks = ibec;
this.pocTabManager = new PocTabManager();
ibec.registerContextMenuFactory(this);
ibec.setExtensionName("CSRF PoC Creator");
BurpExtender.burpExtenderCallbacks.addSuiteTab(new ITabImpl("CSRF PoC", this.pocTabManager));
Pocs.initialize();
// add menus
Iterator<String> pocKeys = Pocs.getPocKeys();
while (pocKeys.hasNext()) {
String key = pocKeys.next();
JMenuItem item = new JMenuItem(key);
item.addActionListener(BurpExtender.this);
this.menuItems.add(item);
}
BurpExtender.burpExtenderCallbacks.printOutput("Burp csrf-poc-creator plugin for Burp Suite Free loaded!");
BurpExtender.burpExtenderCallbacks.printOutput("Created by @rammarj");
}
/**
* Creates the menu items shown in burp suite
* @param icmi the context menu invocation
* @return List of menu items
*/
@Override
public List<JMenuItem> createMenuItems(IContextMenuInvocation icmi) {
this.icMenuInvocation = icmi;
byte invocation_context = icmi.getInvocationContext();
if (invocation_context == IContextMenuInvocation.CONTEXT_MESSAGE_VIEWER_REQUEST
|| invocation_context == IContextMenuInvocation.CONTEXT_PROXY_HISTORY
|| invocation_context == IContextMenuInvocation.CONTEXT_MESSAGE_EDITOR_REQUEST) {
return menuItems;
}
return null;
}

/**This method is executed when the "send to csrf ..." was clicked
* @param e event argument
*/
@Override
public void actionPerformed(ActionEvent e) {
IHttpRequestResponse[] selectedMessages = this.icMenuInvocation.getSelectedMessages();
for (IHttpRequestResponse ihrr : selectedMessages) {
try {
String actionCommand = e.getActionCommand();
IPoc poc = Pocs.getPoc(actionCommand);
byte[] pocContent = poc.getPoc(ihrr);

PocCreatorTab pocCreatorTab = new PocCreatorTab(ihrr, pocContent);
pocCreatorTab.setSelectedItem(actionCommand);
this.pocTabManager.addTab(String.valueOf((this.tabCount++)), pocCreatorTab);
} catch (Exception ex) {
JOptionPane.showMessageDialog(this.pocTabManager, ex.getMessage());
}
}
}

/**
* Get the extender callback for this plugin
* @return the extender callbacks
*/
public static IBurpExtenderCallbacks getBurpExtenderCallbacks() {
return burpExtenderCallbacks;
}

}
82 changes: 41 additions & 41 deletions src/burp/Header.java → src/main/java/burp/Header.java
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@

package burp;

/**
*
* @author Joaquin R. Martinez <[email protected]>
*/
public class Header extends Parameter{

/**
* Creates a new header object with the specified name and value
* @param name the header name
* @param value the header value
*/
public Header(String name, String value) {
super(name, value, Type.PARAM_HEADER);
}
/**
* Creates a new header object with empty name and value
*/
public Header() {
this("", "");
}

/**
* Creates a new header object with the given strin
* @param header the string to parse (name:value)
* @return The header object created
*/
public static Header build(String header){
if(header == null)
throw new NullPointerException("header is null");
String[] split = header.split(":");
String name = split[0].trim(), value="";
if (split.length>1) {
value = split[1].trim();
}
return new Header(name, value);
}

}

package burp;

/**
*
* @author Joaquin R. Martinez <[email protected]>
*/
public class Header extends Parameter{

/**
* Creates a new header object with the specified name and value
* @param name the header name
* @param value the header value
*/
public Header(String name, String value) {
super(name, value, Type.PARAM_HEADER);
}
/**
* Creates a new header object with empty name and value
*/
public Header() {
this("", "");
}

/**
* Creates a new header object with the given strin
* @param header the string to parse (name:value)
* @return The header object created
*/
public static Header build(String header){
if(header == null)
throw new NullPointerException("header is null");
String[] split = header.split(":");
String name = split[0].trim(), value="";
if (split.length>1) {
value = split[1].trim();
}
return new Header(name, value);
}

}
Loading

0 comments on commit cb1dd2d

Please sign in to comment.