From 638e021d5e1acae7a435cc8b15e5fa6afcdce041 Mon Sep 17 00:00:00 2001 From: Flangvik Date: Fri, 30 Jul 2021 23:02:51 +0200 Subject: [PATCH] When reading a PKCS12 certificate file (/certificate:C:\bla\bla), check if the content is base64 encoded. Super handy with all this hot AD CS relaying --- Rubeus/lib/Ask.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Rubeus/lib/Ask.cs b/Rubeus/lib/Ask.cs index 28cb07e3..e0946c1d 100755 --- a/Rubeus/lib/Ask.cs +++ b/Rubeus/lib/Ask.cs @@ -102,8 +102,17 @@ public class Ask // with private key otherwise use users certificate store along with any smartcard that maybe present. public static X509Certificate2 FindCertificate(string certificate, string storePassword) { - if (File.Exists(certificate)) { + if (File.Exists(certificate)) + { + + string certificateData = File.ReadAllText(certificate); + + //Check if the file content is actually base64 encoded + if (Helpers.IsBase64String(certificateData)) + return new X509Certificate2(Convert.FromBase64String(certificateData), storePassword); + return new X509Certificate2(certificate, storePassword); + } else { X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);