Skip to content

Commit 5cef120

Browse files
Merge pull request #9 from CompassSecurity/master
Release v2.3.0
2 parents 7efc614 + b714ca0 commit 5cef120

31 files changed

+988
-286
lines changed

BappManifest.bmf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ Uuid: c61cfa893bb14db4b01775554f7b802e
22
ExtensionType: 1
33
Name: SAML Raider
44
RepoName: saml-raider
5-
ScreenVersion: 2.1.0
6-
SerialVersion: 19
5+
ScreenVersion: 2.3.0
6+
SerialVersion: 20
77
MinPlatformVersion: 16
88
ProOnly: False
99
Author: Roland Bischofberger / Emanuel Duss / Tobias Hort-Giess
1010
ShortDescription: Provides a SAML message editor and a certificate management tool to help with testing SAML infrastructures.
11-
EntryPoint: build/libs/saml-raider-2.1.0.jar
11+
EntryPoint: build/libs/saml-raider-2.3.0.jar
1212
BuildCommand: ./gradlew jar
1313
SupportedProducts: Pro, Community

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Don't forget to rate our extension with as many stars you like :smile:.
7979
### Manual Installation
8080

8181
First, download the latest SAML Raider version:
82-
[saml-raider-2.1.0.jar](https://github.com/SAMLRaider/SAMLRaider/releases/download/v2.1.0/saml-raider-2.1.0.jar).
82+
[saml-raider-2.3.0.jar](https://github.com/SAMLRaider/SAMLRaider/releases/download/v2.3.0/saml-raider-2.3.0.jar).
8383
Then, start Burp Suite and click in the `Extensions` tab on `Add`. Choose the
8484
SAML Raider JAR file to install it and you are ready to go.
8585

@@ -149,7 +149,7 @@ SAML Raider is on the Internet :).
149149

150150
### Other
151151

152-
- SANS Burp Suite Cheat Sheet recommends SAML Raider: https://www.sans.org/security-resources/posters/pen-testing/burp-suite-cheat-sheet-280?msc=Cheat+Sheet+Blog
152+
- SANS Burp Suite Cheat Sheet recommends SAML Raider: https://www.sans.org/posters/burp-suite-cheat-sheet/
153153

154154
## Authors
155155

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ plugins {
22
id "java-library"
33
}
44

5-
version = "2.1.0"
5+
version = "2.3.0"
66

77
repositories {
88
mavenCentral()
@@ -24,6 +24,7 @@ dependencies {
2424
implementation libs.org.apache.santuario.xmlsec
2525
implementation libs.xerces.xercesimpl
2626

27+
testImplementation libs.com.formdev.flatlaf
2728
testImplementation libs.net.portswigger.burp.extensions.montoya.api
2829
testImplementation libs.org.bouncycastle.bcpkix.jdk15on
2930
testImplementation libs.org.junit.jupiter

src/main/java/application/CertificateTabController.java

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,17 @@
33
import burp.BurpExtender;
44
import gui.CertificateTab;
55
import helpers.FileHelper;
6+
import model.BurpCertificate;
7+
import model.BurpCertificateBuilder;
8+
import model.BurpCertificateExtension;
9+
import model.BurpCertificateStore;
10+
import model.ObjectIdentifier;
11+
import org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
12+
import org.bouncycastle.openssl.PEMKeyPair;
13+
import org.bouncycastle.openssl.PEMParser;
14+
import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
15+
616
import java.awt.Component;
7-
import java.io.BufferedReader;
817
import java.io.ByteArrayInputStream;
918
import java.io.DataInputStream;
1019
import java.io.File;
@@ -13,7 +22,6 @@
1322
import java.io.IOException;
1423
import java.security.InvalidKeyException;
1524
import java.security.KeyFactory;
16-
import java.security.KeyPair;
1725
import java.security.NoSuchAlgorithmException;
1826
import java.security.NoSuchProviderException;
1927
import java.security.PrivateKey;
@@ -31,14 +39,6 @@
3139
import java.util.LinkedList;
3240
import java.util.List;
3341
import java.util.Observable;
34-
import model.BurpCertificate;
35-
import model.BurpCertificateBuilder;
36-
import model.BurpCertificateExtension;
37-
import model.BurpCertificateStore;
38-
import model.ObjectIdentifier;
39-
import org.bouncycastle.openssl.PEMKeyPair;
40-
import org.bouncycastle.openssl.PEMParser;
41-
import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
4242

4343
public class CertificateTabController extends Observable {
4444

@@ -186,7 +186,7 @@ private void importExampleCertificates() {
186186
if (fileHelper.startedFromJar()) {
187187
try {
188188
BurpCertificate c1 = importCertificate(fileHelper.exportRessourceFromJar("examples/certificate.pem"));
189-
importPrivateKey(c1, fileHelper.exportRessourceFromJar("examples/private_key_rsa.pem"));
189+
importPrivateKeyPemFormat(c1, fileHelper.exportRessourceFromJar("examples/private_key_rsa.pem"));
190190
importCertificateChain(fileHelper.exportRessourceFromJar("examples/example.org_chain.pem"));
191191
setCertificateDetails(c1);
192192
} catch (IOException e) {
@@ -196,7 +196,7 @@ private void importExampleCertificates() {
196196
}
197197
} else {
198198
BurpCertificate c1 = importCertificate("src/main/resources/examples/certificate.pem");
199-
importPrivateKey(c1, "src/main/resources/examples/private_key_rsa.pem");
199+
importPrivateKeyPemFormat(c1, "src/main/resources/examples/private_key_rsa.pem");
200200
importCertificateChain("src/main/resources/examples/example.org_chain.pem");
201201
setCertificateDetails(c1);
202202
}
@@ -311,29 +311,34 @@ public List<BurpCertificate> importCertificateChain(String filename) {
311311
}
312312

313313
/**
314-
* Import a private RSA key in PEM format from a file and add it to the
314+
* Import a private key in PEM format from a file and add it to the
315315
* selected certificate.
316316
*
317317
* @param certificate which the private key is for.
318-
* @param filename of the private RSA key in PEM format
318+
* @param filename of the private key in PEM format
319319
*/
320-
public void importPrivateKey(BurpCertificate certificate, String filename) {
320+
public void importPrivateKeyPemFormat(BurpCertificate certificate, String filename) {
321321
setStatus("Importing private key...");
322-
BufferedReader br;
323-
try {
324-
br = new BufferedReader(new FileReader(filename));
325-
PEMParser pp = new PEMParser(br);
326-
PEMKeyPair pemKeyPair = (PEMKeyPair) pp.readObject();
327-
KeyPair kp = new JcaPEMKeyConverter().getKeyPair(pemKeyPair);
328-
pp.close();
322+
try (var pemParser = new PEMParser(new FileReader(filename))) {
323+
PrivateKeyInfo privateKeyInfo = null;
324+
var object = pemParser.readObject();
325+
if (object instanceof PEMKeyPair pemKeyPair) {
326+
privateKeyInfo = pemKeyPair.getPrivateKeyInfo();
327+
} else if (object instanceof PrivateKeyInfo) {
328+
privateKeyInfo = (PrivateKeyInfo) object;
329+
}
330+
if (privateKeyInfo == null) {
331+
setStatus("Error importing private key.");
332+
return;
333+
}
334+
var converter = new JcaPEMKeyConverter();
335+
var privateKey = converter.getPrivateKey(privateKeyInfo);
336+
certificate.setPrivateKey(privateKey);
329337
setCertificateTree();
330338
setStatus("Private Key imported.");
331-
certificate.setPrivateKey(kp.getPrivate());
332-
} catch (IOException e) {
333-
setStatus("Error importing private key. (" + e.getMessage() + ")");
334-
BurpExtender.api.logging().logToError(e);
335339
} catch (Exception e) {
336-
setStatus("Error (" + e.getMessage() + ")");
340+
setStatus("Error importing private Key. (" + e.getMessage() + ")");
341+
BurpExtender.api.logging().logToError(e);
337342
}
338343
}
339344

@@ -345,7 +350,7 @@ public void importPrivateKey(BurpCertificate certificate, String filename) {
345350
* <code>openssl pkcs8 -topk8 -inform PEM -outform DER -in privatekey.pem -out private_key_pkcs8.pem -nocrypt</code>
346351
* @param filename of the PKCS8 key
347352
*/
348-
public void importPKCS8(BurpCertificate certificate, String filename) {
353+
public void importPrivateKeyPkcs8DerFormat(BurpCertificate certificate, String filename) {
349354
setStatus("Importing private key...");
350355
FileInputStream fis;
351356
File file = new File(filename);
@@ -363,11 +368,9 @@ public void importPKCS8(BurpCertificate certificate, String filename) {
363368
certificate.setPrivateKey(privateKey);
364369
setCertificateTree();
365370
setStatus("Private Key imported.");
366-
} catch (IOException | NoSuchAlgorithmException | InvalidKeySpecException e) {
371+
} catch (Exception e) {
367372
setStatus("Error importing private Key. (" + e.getMessage() + ")");
368373
BurpExtender.api.logging().logToError(e);
369-
} catch (Exception e) {
370-
setStatus("Error (" + e.getMessage() + ")");
371374
}
372375
}
373376

@@ -394,12 +397,12 @@ public void exportCertificate(BurpCertificate certificate, String filename) {
394397
}
395398

396399
/**
397-
* Export Private RSA Key in PEM format.
400+
* Export private key in PEM format.
398401
*
399402
* @param certificate to export
400-
* @param filename for the exported private RSA key
403+
* @param filename for the exported private key
401404
*/
402-
public void exportPrivateKey(BurpCertificate certificate, String filename) {
405+
public void exportPrivateKeyPemFormat(BurpCertificate certificate, String filename) {
403406
setStatus("Exporting private key...");
404407
try {
405408
fileHelper.exportPEMObject(certificate.getPrivateKey(), filename);

src/main/java/application/SamlMessageDecoder.java

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,23 @@ public static DecodedSAMLMessage getDecodedSAMLMessage(String message, boolean i
3232
boolean isInflated = true;
3333
boolean isGZip = true;
3434

35-
var httpHelpers = new HTTPHelpers();
36-
37-
try {
38-
byte[] inflated = httpHelpers.decompress(base64Decoded, true);
39-
return new DecodedSAMLMessage(new String(inflated, StandardCharsets.UTF_8), isInflated, isGZip);
40-
} catch (DataFormatException e) {
41-
isGZip = false;
42-
}
43-
44-
try {
45-
byte[] inflated = httpHelpers.decompress(base64Decoded, false);
46-
return new DecodedSAMLMessage(new String(inflated, StandardCharsets.UTF_8), isInflated, isGZip);
47-
} catch (DataFormatException e) {
35+
if (base64Decoded.length == 0) {
4836
isInflated = false;
37+
isGZip = false;
38+
} else {
39+
var httpHelpers = new HTTPHelpers();
40+
try {
41+
byte[] inflated = httpHelpers.decompress(base64Decoded, true);
42+
return new DecodedSAMLMessage(new String(inflated, StandardCharsets.UTF_8), isInflated, isGZip);
43+
} catch (DataFormatException e) {
44+
isGZip = false;
45+
}
46+
try {
47+
byte[] inflated = httpHelpers.decompress(base64Decoded, false);
48+
return new DecodedSAMLMessage(new String(inflated, StandardCharsets.UTF_8), isInflated, isGZip);
49+
} catch (DataFormatException e) {
50+
isInflated = false;
51+
}
4952
}
5053

5154
return new DecodedSAMLMessage(new String(base64Decoded, StandardCharsets.UTF_8), isInflated, isGZip);

0 commit comments

Comments
 (0)