-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from CompassSecurity/thort/issue78
Thort/issue78
- Loading branch information
Showing
6 changed files
with
256 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ plugins { | |
id "java-library" | ||
} | ||
|
||
version = "2.0.2" | ||
version = "2.0.3" | ||
|
||
repositories { | ||
mavenCentral() | ||
|
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 |
---|---|---|
@@ -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%2BPC9zYW1scDpTdGF0dXM%2BPEFzc2VydGlvbiBJRD0iX2YyN2Q2NDAzLTMyZjMtNDVlYy04YjI0LThiMm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m46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6YXR0cm5hbWUtZm9ybWF0OnVyaSI%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); | ||
} | ||
} | ||
} |
Oops, something went wrong.