Stealing Certificates with Apostille
At Def Con 26, @singe and @_cablethief gave a talk on enterprise wireless attacks. When it’s video is released you should check it out.
During that talk, they quickly touched on a tool written by Rogan Dawes another @Sensepost-er’s tool called “Apostille”. It is esentially a certificate stealing (cloning? faking? doppelganger-ing?) tool. However, that over simplifies what it does.
To be more accurate, Apostille generates a clone of the certificate chain, identical in as many details as possible, apart from the actual key values. One thing this could be useful for is bypassing naive cert pinning if the validation is based on details of the signing certs.
— @RoganDawes@infosec.exchange (@RoganDawes) August 26, 2018
Copying a certificate’s common name, email, or other fields that are inputted during creation is a relatively easy way to copy certificates, and they can look relatively good at first glance. However, this simple copy leads to many tell-tail signs that it’s fake. For instance lets say I create a certificate like so:
|
|
If I host it out, here are the results side by side with Google.com:
The Vaild From
, the Issued By
, and most of the other certificate information helps this certificate to stand out as fraudulent. Also, doing this by hand is a PITA.
Enter Apostille.
It’s pretty straight forward to get it going, but you do need both Java’s JDK and Maven to compile it first:
|
|
(I’m doing this on a fresh box so it needed git as well)
Step 2, git clone
the repo, and compile with Maven:
|
|
Step 3, Clone your first certificate:
java -jar target/apostille-1.0-SNAPSHOT.jar google.com:443 tempkeystore.jks ASDqwe123 ASDqwe123
google.com:443
is the endpoint that will serve a certificate chain back, this isn’t regulated to only HTTPS, but any TLS endpoint.tempkeystore.jks
is the Java Keystore file that we will putting the certificate chain into.ASDqwe123
is thekspassword
and then thekeypassword
(Keystore and certificate password) - I just made them the same as this is an example and I won’t be using the keystore for anything but to export the certificates later.
In order to get the certificates out of the keystore and into a PEM format that I can use for testing, I used the following:
Source: https://www.calazan.com/how-to-convert-a-java-keystore-jks-to-pem-format/
|
|
(The passwords will not show up, but I put them in there so you can see what I’m inputting. Again I chose a simple password because I’m converting it one more time)
Then finally to a PEM like so:
|
|
To test out how it looks I’ll reference AKB’s Quick Web Servers list
|
|
And the result is:
A much more believable certificate, even to the discerning eye.
Again, thanks to @RoganDawes for this amazing tool.