-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed static methods for getting ExtensionHelpers and Callbacks to make code more clear about dependencies.
- Loading branch information
Showing
11 changed files
with
141 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,18 +14,23 @@ | |
* @author Joaquin R. Martinez <[email protected]> | ||
*/ | ||
public class AjaxPoc implements IPoc { | ||
|
||
private IExtensionHelpers helpers; | ||
|
||
public AjaxPoc(IExtensionHelpers helpers) { | ||
this.helpers = helpers; | ||
} | ||
|
||
@Override | ||
public byte[] getPoc(final IHttpRequestResponse request) { | ||
IExtensionHelpers iexHelpers = BurpExtender.getBurpExtenderCallbacks().getHelpers(); | ||
String lineSeparator = System.lineSeparator(); | ||
StringBuilder pocString = new StringBuilder(); | ||
pocString.append("<!DOCTYPE html>").append(lineSeparator); | ||
pocString.append("<html>").append(lineSeparator).append(" <!-- CSRF PoC - generated by Burp Suite plugin -->").append(lineSeparator); | ||
pocString.append("<body>").append(lineSeparator).append(" <script>\n function submitRequest()").append(lineSeparator); | ||
pocString.append(" {").append(lineSeparator).append(" var xhr = new XMLHttpRequest();").append(lineSeparator); | ||
String method; | ||
IRequestInfo requestInfo = iexHelpers.analyzeRequest(request); | ||
IRequestInfo requestInfo = helpers.analyzeRequest(request); | ||
method = requestInfo.getMethod(); | ||
pocString.append(" xhr.open(\"").append(method).append("\", \""); | ||
|
||
|
@@ -34,7 +39,7 @@ public byte[] getPoc(final IHttpRequestResponse request) { | |
pocString.append(" xhr.send();\n"); | ||
} else { | ||
pocString.append(requestInfo.getUrl().toString()).append("\", true);").append(lineSeparator); | ||
String body = iexHelpers.bytesToString(request.getRequest()).substring(requestInfo.getBodyOffset()); | ||
String body = helpers.bytesToString(request.getRequest()).substring(requestInfo.getBodyOffset()); | ||
body = Util.escape(body); | ||
String accept = "*/*"; | ||
String content = "text/plain"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,22 +6,24 @@ | |
import java.util.Iterator; | ||
import java.util.Map; | ||
|
||
import burp.IExtensionHelpers; | ||
|
||
/** | ||
* Contains all types of PoC's supported by this plugin. | ||
* | ||
* @author Joaquin R. Martinez <[email protected]> | ||
*/ | ||
public class Pocs { | ||
|
||
private static final Map<String, IPoc> POCS = new HashMap<>(); | ||
static Pocs poc = new Pocs(); | ||
private final Map<String, IPoc> pocs; | ||
|
||
/** | ||
* Inaccesible constructor. | ||
*/ | ||
private Pocs() { | ||
Pocs.POCS.put("Ajax", new AjaxPoc()); | ||
Pocs.POCS.put("HTML", new HtmlPoc()); | ||
public Pocs(IExtensionHelpers helpers) { | ||
this.pocs = new HashMap<>(); | ||
this.pocs.put("Ajax", new AjaxPoc(helpers)); | ||
this.pocs.put("HTML", new HtmlPoc(helpers)); | ||
// Add more kind of PoC's | ||
} | ||
|
||
|
@@ -31,17 +33,17 @@ private Pocs() { | |
* @param key the key of the {@link IPoc}. | ||
* @return the {@link IPoc} object. | ||
*/ | ||
public static IPoc getPoc(String key) { | ||
return Pocs.POCS.get(key); | ||
public IPoc getPoc(String key) { | ||
return pocs.get(key); | ||
} | ||
|
||
/** | ||
* Get the {@link IPoc} as a {@link Enumeration}. | ||
* | ||
* @return an {@link Iterator} with the keys of all {@link IPoc} objects. | ||
*/ | ||
public static Iterator<String> getPocKeys() { | ||
return Pocs.POCS.keySet().iterator(); | ||
public Iterator<String> getPocKeys() { | ||
return this.pocs.keySet().iterator(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.