Okay. I am with the Packet Hacking Village, and this particular speaker is being sponsored by us. And we are delighted to present Brandon Colley, who is going to obviously talk to you about Active Directory. He has been... he'll tell a little bit about himself, but he works for Trimark Security, and I'm also proud to call him friend. Take it away. Thank you, Kathy. Friend Kathy. Investigator chick, everybody. All right. Can you guys hear me okay in the back? Awesome. Let's do this. So title, as you all know, is Winning the Game of Active Directory. So a little bit about myself is I served in an operations role, managed Active Directory for about 15 years for multiple different organizations before I joined Trimark about two and a half years ago. I was a senior security consultant for them and just got promoted to the service lead role for our Microsoft Cloud assessment. So I'm kind of joking and saying that this might be my last on-prem Active Directory presentation. So maybe next year you'll come to see, like, Winning the Game of Entra ID or something like that. Recently founded my own company and got a logo created, so I threw it up there. So B&R Consulting is a company that I just started. I'm a father. Here's one of my kids with me at a Chiefs game. I saw a Chiefs hat. Go Chiefs! And my wife Bridget came with me today, so I am a very loving husband, as I hope she'd also agree. First time at DEF CON as well, so... And so before we really start digging in, I want, I mean, the title of the game is How to Win the Game of Active Directory. So let's talk about what I'm talking about when I talk about the Game of Active Directory. So GoAD, as I like to call it, or somebody said GoAD. So Prebuilt Active Directory Lab is a multi-domain environment. They have multiple different builds that you can create and touts over 30 different vulnerable configurations just out of the box. It's created and maintained by Mayfly of Orange Cyber Defense. And Mayfly gave me permission to go ahead and use this in the presentation. He just wanted to know when it gets posted online, and he wants my slides. So it was originally created for penetration testers to practice attacking Active Directory. So real quick, where are my penetration testers in the audience, or any red team side people? How about anybody on the blue side? Okay, so we're heavily blue. Awesome. And then everyone else is just unaffiliated, I'm assuming. You don't get a vote. So when you start playing a game, first thing you have to do is character selection screen, right? So we can choose to be a penetration tester, which your job is to exploit vulnerabilities, misconfigurations. Moving to a little bit of a red teamer, you're going to start looking a little bit more at testing detections and doing a little bit more stealthy activities when performing Active Directory tests. And then our defenders, like most of you, are looking forward to learning how to harden your environments, performing consistent monitoring of those environments, and just consistently improving the overall security posture of your Active Directory. The other character you could choose is to be an adversary, so I'm going to assume that the rest of you who didn't raise your hands are my adversaries, right? But they don't play by the rules anyway. So the most important rule when you play a game is how do you win, right? And that's what I'm here to talk about, is how do you win the game of Active Directory. And a lot of people think that you can win the game of Active Directory by gaining domain admins, right? That's the keys to the kingdom. Once you get domain admin, it's game over. It may be a spill of data. Maybe you want some of that juicy information that's in Active Directory. Or maybe you just want to create persistence and you want to be slow and methodic about your efforts. However, I'm here to kind of challenge that a little bit and say that the way that you truly win the game of Active Directory, regardless of which character you choose, is to maintain a secure environment, continuously improve that environment, and implement the safeguards that are needed to keep your Active Directory safe. And also continuous progress. So what I'm here to do today is kind of show you both sides of that. I'm going to take a little bit of an attack methodology and also defense methodology. So we have a... Ted Mosby likes to say, we have a tightly scheduled evening of awesomeness ahead of us, so let's go. And I guess technically now it is evening. Or afternoon, anyway. So our agenda, we're going to stick with the gameplay idea. We've got three different levels. So level one, we're going to call Reconnaissance, Enumeration, PrivEsc. And then level four is when we pwn Active Directory, and that's really our end boss. So starting off with Reconnaissance, our first question when we are either protecting or attacking Active Directory is kind of what's visible with simply network access. No usernames, no passwords, we just are on the network, and maybe in this case we just know the IP address of a domain controller. So here's an example of using CrackMap Exec, and this is our first misconfiguration, which is called anonymous access. If this is configured in your domain, anybody with network access, direct line of sight to your domain controller, can query for a list of users, as well as some of the public information, such as description. And so here if we drill in, we identify that we've already got our first credential in Samuel, who must have had an administrator put his password in the description field for some odd reason. So how do we mitigate this, other than just don't put passwords in description fields, right? That's kind of the obvious one here, is removing these groups from your domain. Domain root, sorry. The pre-Windows 2000 group, I'm not saying to delete this from the domain root, but if the members of this include the everyone group, or the authenticated, I'm sorry, not authenticated, the anonymous logons group, then this is possible. In the Go lab, the screenshot on the right is actually how it was configured, is you're just giving root access to anonymous logon, and that's what enables the ability to see everything without having any sort of initial user. So once we've removed that, we rerun the attack, we get nothing. So we get an error message, nothing comes back, anonymous access no longer relevant, so now we have to dig in a separate way. So if we can't do it anonymously, we're going to have to build a user list. And so the game of Active Directory, if you've used it before, you may know it's based on the game of Thrones, which is kind of where the game of thing comes from, right? So this is a good place for us to start scraping credentials. I'm sorry, not credentials, usernames. So we're going to pull out the first names, last names, combine those, and form a user list. So the screenshot on the left is the user list that I'm using, which is a first name dot last name. That's the methodology that's used in the lab. But in your environments, it might be first initial dot last name, you might not have a dot, it might be your last name and then your first name, something like that. So we can go ahead and we can throw all of those into a user list. And then we can attack Active Directory, still anonymously, using a script like this. So this is just an in-map script that all you need to have is your user list in a text file. And again, the domain IP, and what it's going to do is it's going to attempt to authenticate to Kerberos, or it's going to query Kerberos. Kerberos is going to come back and tell you one of two things. It's either going to say, yeah, that's valid or no, that's invalid. So now we've got a list of nine valid accounts that were in that file. And so now we know who we can attack. And you guys might say, hey, it's not fair. You knew it was the Game of Thrones. So you knew who you were attacking. Well, there are plenty of lists out there on GitHub that you can just do a very top 100 common names, and you can do the same style of attack. And once you get one or two hits, then you kind of know the naming convention. And then you just go out to LinkedIn and you search up Microsoft or whoever you're attacking, and you scrape from there. So this is real-world stuff that you can obviously do. And so the reason that this works is it's ingrained in the Kerberos protocol. So if an account doesn't exist, then you're going to get this first error message, which is that the principle is unknown. If the user does exist, you're going to get one of those other two responses. And that's basically what happens under the covers of this nmap script. Sorry, I'm going to drink, and this is weird. Okay, so the fix for this is not easy and sometimes not even possible. And this is a no-fix bug, I guess you can say. Microsoft doesn't consider user enumeration to be a bug. So the best thing that we can really offer is just, if you're looking at being able to change things, is don't use the same email address that you use for your same account name or vice versa. Instead, maybe create some sort of non-standard naming convention by throwing something about the department or the type of person. Like I used to work at a university, so maybe like a F for faculty, S for staff, A for administration. Maybe you do F for finance, I for IT, something like that. Or probably the best thing to do is use multiple trailing digits. And this is going to exponentially create a whole lot more trouble where you're going to have to have a much larger user list and a whole lot more time to be able to really enumerate a full contents of Active Directory. And I understand that this is hard. Mitigations are more around password policies, which we're going to attack here in a little while. But because I talked about the Kerberos protocol, I want to go back through another anonymous thing that you can do, is attack Kerberos pre-authentication. And so this is known as an AS rep-roast. And so this is what it looks like when you perform an AS rep-roast attack using the ImpactKit toolkit. And accounts that do not require pre-authentication are going to come back and give us a password hash. So in this case, Brandon Stark, no relation by the way, gives us password hash for free. And with that, we can use Hashcat or John the Ripper or some other offline attack tool where we can throw this through, and I just threw it through a ROKU, which is just a typical user list, password list, sorry. And we get the cleartext credentials in just a matter of a few minutes. So fixing this is pretty easy. It's just a checkbox. So there is a Kerberos pre-authentication checkbox on user accounts. It says do not require Kerberos pre-authentication. This is a super, super legacy thing, pretty free of a win in an environment. So if you've got any of this in your environment, removing that checkbox is going to mitigate it, which means after we remove that checkbox, Brandon no longer gives out his password freely. So we're going to have to attack the passwords using some of the more well-known styles of password attacks. Okay, so password attacks kind of fall into a few different categories. And so we're going to attack password reuse by doing a password spray. And so password spray is trying a small handful of passwords against all usernames in an environment. So in this case, I used some of the passwords that I already found in the environment. And I'm just seeing if there's possible password reuse across user accounts. In this one, it didn't hit anything. But some common uses for this is things like using Summer 2024 or Defcon 32 or whatever, right? And just seeing kind of what hits. A similar attack is a credential stuff attack. And this is more commonly used with breach credentials. So this is also a password reuse attack, but it's more specific to the user account themselves or the user themselves. So if they use the same password, say, for LinkedIn, and we're able to identify that the email address that they signed in with LinkedIn was the same as the Active Directory that we're attacking, it's possible that we may be able to hit something using a credential stuffing attack. In this specific screenshot, I kind of lazily just used the same user list as the password list, which simulates the situation where a user has the same password as their username, which is not terribly common anymore, but used to be common around, like, service accounts and things like that. So if you've got passwords that haven't changed in your environment for a very long time, this may be possible. And so we did get a hit on that one. We got the account Hodor, which we'll use later in another authenticated attack. But so some of the things that we can do is, and I showcase here just checking out the password policy, to prove that you can view it as any user in the domain. So once you have that initial user, you can query the password policy and maybe tailor your password attacks a little bit more specific. And so if you're wondering why on earth someone could have the same username and password, it's due to the complexity requirement that's disabled in this lab. Also, the character limit is only five, which I have seen worse than that. So five, not the worst. Some other things that you want to do with your password policy, other than kind of the obvious two there, is looking at some of the account lockout threshold, and also some of the other password requirements in there. I do have a link to an article I wrote called Password Policy a la carte. That's going to be in my resources. So check that out after the talk. I do want to talk a little bit about account lockout, because it is an effective strategy to blocking some password style attacks. I'm not going to talk about monitoring, because that's another thing. But you can query things using password crack map exec. And so here I've just simulated something. This is an oopsie. So for the red teamers, you're probably somewhat familiar, hopefully not, with seeing something like this, where you see log on failure, log on failure, log on failure, and then you see account locked out. And hopefully this is just the one account and not like all the accounts, right? Mistakes happen. But log on failures are going to kind of reset that account lockout counter. So to help combat that, whether you're looking... I am showing the attack tools, but defense tools is kind of another way that you can look at stuff like this. When we rerun the crack map exec script using the user's flag authenticated, we can get the bad password count. So here we identify the very bottom account was the one that we accidentally locked out. The other ones are sitting at four, and so we can wait for those password resets to retime before you attempt to attack them again. So that concludes level one. Yes, so we gained three account credentials, but that's not necessarily the goal that we talked about. So the goal, rather than getting those credentials, is more so the vulnerabilities that we've identified as being able to patch. And so in level one, we talked about anonymous access, removing that from an environment, using a little bit more robust usernames, and how attacks like that might occur, Kerberos pre-authentication and how that's a pretty quick, easy win, and then improvements to password hygiene and account lockout. All right, so on to level two. I like that cute little bunny over there. So I called this one enumeration, and then I told myself, nah, I should change it, because this is a little bit more like privilege escalation and lateral movement stuff, and I realized that whatever, it's just hard, so we're just going to call it more hacks. So the main difference between this level and the first level is that we're doing a little bit more while authenticated. So what type of Active Directory presentation would be complete without talking about Kerberosting? So Kerberosting is an attack on accounts that have service principal names or SPNs. So here's what that looks like. It's an authenticated attack. You're able to identify both John Snow and the SQL service account are vulnerable to a Kerberosting attack. So we're going to take those hashes. We're going to throw those through Hashcat again. And here we cracked the John Snow account because it was a weak password. So you can run something like this. So this is a quick PowerShell search that you can run. Get AD user where you just are looking for accounts that have service principles. And these usually are not cleaned up because service accounts are scary. So if you're an administrator, you don't want to touch a service account because you don't know if it's being used or where it's used, and you dare not change the password because you have no idea where to change it, what's going to break, and change it back. Like what's going to happen, right? I've been there. I did that for 15 years. And no, I didn't do this. And no, I didn't change those passwords. But what I'm telling you we can do is we can look at things like LastLogon, which may not be 100% accurate, but it may be helpful. Is the account privileged? If it's privileged and it's Kerberostable, then that's pretty much a free win for an adversary. So specifically look at those first. For the remaining ones, go ahead and look at what the service principle says. So in our case, the John Snow account, and I realize that's a little bit small, but there's a HTTP setting in there. So there's a website that it's attempting to coordinate with called the wall.north, seven kingdoms, etc. If I check DNS for that, it doesn't even exist. So if I can't access that web server at all, then this service account's not doing anything. So we're going to go ahead and remove that. The one that's going to remain is the SQL service account because it actually is running SQL. It's required to do that. That one didn't crack because it's using a long, strong, complicated, random password. And so that's how you protect other accounts that are Kerberostable is with that. And so this is what the attack looks like now that we removed the service principle. John Snow no longer shows up as even being attackable. On path attacks. So this I like to claim to be God's gift to AD pentesters. Is that right, you pentesters? Right. This responder, you set this up and it'll just listen and respond to clients on the network. Client's going to come out and say, hey, I'm looking for so-and-so. And it's like, yeah, that's me. Yeah, that's me, too. That's me, too. And if we have it set up in this way, you can poison those requests and we can actually get NTLM hashes. In this case, it's NTLM v1 hashes for these accounts. And so we can do what we've done twice already is we can crack them hashes again with Hashcat. And so here we've got our third account that we've been able to crack. And this one was just from listening to the network. And while that's scary, the scarier thing that you can do is you can configure Responder to run in a similar way. But instead of giving you the hashed credentials, you can tell it to go ahead and pass those or relay those using NTLM RelayX. And you can relay that authentication attempt to a target or targets. So in this case, I'm targeting a web server, the one that ends in 22 there. And I'm just going to wait for Responder to get some authentication to happen. It's going to send that here. And then I told it to set up a Socks proxy. So I've got an active connection using Eddard Stark, which just happens to be an administrator on that web server. So now we've got a shell on our target. So we can do things like this, where we can interact with that session. And we can run Secret Stump on it. Pardon me. So you can see I specified no password. I don't need a password. I've already authenticated to it. I have an active session. And I can run Secret Stump against it. And I can dump the local SAM hashes. So this includes the local administrator account, any other local accounts that exist. Like a help desk account or something like that, that you've placed on systems. This will dump all local credentials on that server or workstation. Also more fun, it's going to extract saved credentials. So here we're attacking service account. So if you may recognize the SQL service account that was not Kerberoastable. You will not be Kerberoasting me. Was in plain text because it's configured as a service. It's running a service which is required for SQL Express. So that account was free on that machine. And so what can we do for on path attacks? So the quickest and probably the easiest of all of these is preventing the LLMNR, which is link local multicast name resolution. Yes, I had to write that down. And no, I'll not memorize that. I do have a great article linked for that one as well. Actually, I have articles for all these. You may have remembered or noticed that those hashes were NTLMV1 hashes, which are infinitely easier to attack than NTLMV2. So enforcing this on your domain controller and setting it to the highest security level of enforcing NTLMV2 to exist on your network. Ideally, not allowing NTLM at all and allowing Kerberos to do what it's supposed to do for the last 20 years. This is hard. And I don't know that I've ever fully seen this. I've seen people auditing it and really starting to get ready for it. Another thing that we've seen, I think twice at Trimark, is LDAP signing and channel binding. This is another thing that's incredibly difficult. It can break a lot of those non-Windows devices. I've also got a couple links to some articles that have been written about this as well. A thing that I don't think is all that hard, some administrators do think that this is hard, this is protecting the accounts themselves. So this might be a little bit easier to get through some of that change management for you, is using the protected users group. Because you're only impacting whatever users you put in it and not the enterprise when you're making domain controller changes. A coworker of mine, Jake Hildreth, which owns our Active Directory Security Assessments, he has a blog and a presentation. He's writing a tool to help assist with end users adding accounts to the protected users group. So again, I've got that in the resources. Alright, so level two is down. We Kerberos to John Snow. We crack the hash from Responder for Rob Stark. And we found the SQL service account running. So now we've got six accounts. And we've got five more vulnerabilities that we have patched. So we cleaned up SPNs. We disabled LLMNR and NTLM v1 by enforcing v2. We talked a little bit about at least thinking about LDAP signing and channel binding. And then also the protected users group, protecting those highly privileged users in your domain. So level three, I called Privesk. Again, this is maybe a little bit more lateral movement-y. Also some pretty domain crushing attacks in this one too. And I'm going to kind of start by going backwards just a smidge because I wanted to show Bloodhound just a little bit. Bloodhound is an amazing tool that you can use to scan your Active Directory environment. And here I'm just showcasing what paths are available to domain admin. And here I'm going to zoom in on the one that we just owned. So we just got that Rob Stark account. And Rob Stark is a member of the administrators group, which is just this very simple step away from domain admins. And so that one's just a little bit too boring because you can just add yourself to that group, right? So we're going to do something cool. And we're going to identify what ACL modification may look like. So here you might remember our old friend Samwell, who was our first attack with that description field misconfiguration. Well, Samwell, for whatever reason, has the ability, has a write DAQL on a GPO that's linked to the domain root. So what does that look like? So here's what it looks like when we look at the policy itself. We see that the delegation tab shows us that we have some privileges with Samwell. If we dig into him a little bit, we identify he doesn't look too terribly dangerous because he doesn't have write permission. He has read and he has delete. But we have to actually look at advanced to identify what the real threat to this is, which is that write DAQL permission, which translates to modify permissions and modify ownership. So Sam can give himself or anyone else access to modify this GPO. And there's a number of different things you can do once you can modify a GPO specifically at the domain root. One such example is just creating a file that's going to run at login for all users on all computers in your environment. So we can do some pretty messy stuff with that. So mitigating this is fairly simple. You just have to check out the GPOs. I don't have a script for this. I should probably write one. So I may write one and put it up on GitHub where you can actually scan some of the ACLs that might be dangerous. But specifically start with your domain root and then move on to domain controllers, move to other protected OUs to identify group policies that maybe have delegation. Also ownership. So identify who has owner on your GPOs. And so if we clean that up, then we're in a lot better shape for any of that ACL modification. So I'm going to take us a little bit back. So you remember when we attacked the web server that we were targeting with stuff? I don't really remember either. But basically what we did was we were able to gain the local credentials for that web server. And what we can do with local credentials is we can do a pass the hash attack. So in this example, we're using the administrator. This could be, like I said, a help desk account or any other local account. And we can target all other known IPs in that domain. And this could be servers, this could be workstations. And in this case, we identify that very first one, the Castle Black. That's the one that we attacked. We expected that one to show up as pwned. But that bottom one, Winterfell, is actually a domain controller. I mean, this is a lab, so this is fairly unrealistic. But the reason this works is because when you promote your first domain controller, it's going to use that credential as the domain administrator credential. So just a little bit of digression on that. But with that, we don't even need to know what the password is for that administrative account. We can just pass that hash and authenticate. And here I'm using EvilWinRM, and you can see at the bottom that I've got a shell on our domain controller. And solution for this is to use something like LAPS. So old admins like myself maybe remember the days before LAPS was a thing where you would use a GPO, and you'd set the local administrator account on all machines. And thanks to the cpassword, where everybody could read that, we've now got cleartext credentials. So other than even just reuse and passing the hash, cpassword has cleartext creds. That's not even an attack that I showcased in this. It's fairly old. We do still see it on old GPOs. Even if they're unlinked, they still have some cpasswords in them. So you may check that. But this is what LAPS looks like. I've got articles on that as well, because I'm not going to go super into LAP. I am going to go a little bit into Kerberos delegation, though. So Kerberos delegation is a required feature of Windows. An example would be when a user authenticates to a web server, and then that web server needs to authenticate on behalf of that user to a database server, for example, to be able to provide the correct results for the user that's asking. So it's kind of a security thing. It's pretty much built in. But in this case, when we talk about delegation, we're talking about impersonation, which means that web server has the ability to impersonate any user in the domain. And so what that looks like, specifically when we're attacking unconstrained delegation, is we have a shell on that web server that we had shown that we attacked earlier. And since it's set up for unconstrained delegation, we either wait, or we can coerce an administrator to log into that system that we're in control of. And so here, using Mimikatz, I was able to export the tickets for Brandon. Brandon was very impressionable admin at the time. So Brandon logged into our server that we had control of. Using Mimikatz, we were able to set up what's called a pass-the-ticket attack. And then we load that ticket into our session. And we can view that using that klist tickets to identify that we have that cached ticket for Brandon. And then that last command in the bottom is just opening a PowerShell session to a domain controller. So we're authenticating as a domain admin to a domain controller. And now we've got a shell on the domain. We run whoami. We just look at sysvol. And so now we've basically owned that domain controller. I've got a lot more attacks to go, so I'm not going to stop there though. So how do we stop this specifically? So moving unconstrained delegation to constrained delegation is a good way to mitigate this. You can specify the specific service or server that's required instead of just allowing delegation to occur wherever it needs. That, again, can be somewhat difficult to identify. So what I like to do, even in the... I'm not saying don't do that, but what I am saying do is mark accounts as sensitive and cannot be delegated. So all of your administrators, this is kind of a baby step to the protected users group, set them up like this because, like I said, Brandon was very impressionable and he could be tricked to logging into wherever because he's an admin. You know, somebody in user calls, he logs in wherever they tell him to log in as his domain admin credentials, right? What could go wrong? So now that I've set Brandon as sensitive, he can't be delegated, on the right here is what we just did, so that's what the attack looked like in Mimikatz. If that attack were to attempt... be attempted when the account was set up, he was still... he still logged in and we can still look at some stuff in Mimikatz, but we don't have that ticket granting ticket, which means we can't load it into the session and we can't attack that account anymore. All right, so level three is over. We don't have any new accounts, but we're kind of beyond that now. You know, we've kind of gotten to the point where we're already on the precipice of domain admin. We've already kind of gained that full domain compromise. So what we've learned in level three is how to fix ACL and ownership issues, specifically on GPOs, but other objects are also important. Configuring LAPS to prevent things like local administrative credentials being on multiple machines, being able to perform lateral movement, implementing constrained delegation instead of unconstrained, and then protecting your admin accounts using the account is sensitive and cannot be delegated flag. All right, now the fun one. Okay, we're going to Pwn AD. So the print nightmare. I don't know if you all remember this. It was three years ago, I think now, and this I like to call the attack that got me into InfoSec. So I told you I worked for TriMark for two and a half years now. Print nightmare came out when I was still a sysadmin. It let me poke at it and prove to my administrators that it was exploitable, so we had something to do. So this is what that looks like. So running a CrackMap exec tool as well as the impact tool, we identified that the spooler is running on our target system, and the protocols necessary to perform the attack are also available. So what this attack looks like is we can just host a malicious DLL on a Samba share from this Kali box. This is where the screenshots are coming from. Using the cube 0x0 exploit, we can target the domain controller, and we're using just a regular user account, so that Hodor account that we grabbed, no administrative credentials in the domain whatsoever, can authenticate to that domain controller, and because the print spooler is available on that server, we can throw this nightmare DLL at it, and it says exploit completed. And what that exploit does is it's created a new account for us in the domain. It's called PrintNightmare2, and it is in the administrators group. And this is my favorite mitigation, because it's the easiest mitigation. So we just disable the print spooler. And yes, I know PrintNightmare has been patched. Thank goodness. So not this specific attack is available everywhere anymore, but the print spooler is used in so many coercion attacks that can occur now that I like to say, if you're not printing or performing printing as a print server, then you have no need to run the print spooler whatsoever. So disable it either manually here or use a GPO to disable it, and here you see on the right-hand side that that server is no longer vulnerable to attack. So our last attack is going to be one of the Active Directory certificate services, so ADCS, vulnerable configuration that we're going to attack using the Certify tool. So this has been very popular over the last couple years. About two years ago or so, we saw this as a critical vulnerability on almost every single assessment that we did. Thankfully, things have gotten a little bit better in the industry now, but this is what that looks like. So we're going to run our Certify tool with a find command. This is just using a regular user account to a domain controller. So our output is going to include all the vulnerabilities that exist in that domain if it's running certificate services. And I'm going to drill into that because it's hard to see. So the specific one that we're going to pick out is called ESC1 or Escalation 1. This is from the Certify pre-owned stuff that Spectrops put out. It's also in the resources. So what makes this vulnerable is that enrollee supply subject, which equals the subject alternative name, can be applied when you enroll a certificate. The second half of that puzzle is who can enroll dangerous certificates. So in this case, we have domain users, have enrollment rights, and that means that anybody can enroll a certificate and they can specify that they are whoever they want to be. And so we can go take the next step and we can run Certify and request our certificate. So here we can see we're targeting that ESC1 template. We're telling it that we want to be administrator. We can tell it whatever we want, but of course we want to be the administrator account. So we've saved that private key locally, and now we're going to authenticate with it. So now we run the Certify Auth command. We specify the PFX, the domain controller, and we've now got the credential cache, so the Kerberos credential, as well as the hash for the administrator account, which means we can do bad things. So we can run secrets dump using that hash. We could also authenticate with that C cache file doing that, and we can dump the entirety of the domain controller. So here we've got the SAM, but that's not even really what we want. We want the NTDS.DIT file, so this contains the entire contents of Active Directory and all the NT hashes for every single user. And we did this with very little privilege whatsoever. So in that context, that attack was game over, right? But we're not quite done. We still have some work to do because we're learning that domain admin doesn't mean that we're finished as administrators. So we need to investigate why the vulnerable template existed in the first place. So this is what I said earlier. It's that two-piece, the domain users. It doesn't have to be domain users. It could just be a subset of regular user accounts that could enroll certificates. So the bigger issue is that supply and the request. So a little bit better of a mitigation is to require manager approval for specific certificates. There's a number of different things that you can do. And this is what the certificate that was issued looks like. So here you'll see the subject was Brandon because he was the one that requested the certificate, but he requested it using the subject alternative name as administrator. So that's what it looks like when a certificate's enrolled. And so we already talked about how you can detect it, but how can you do it automatically? So this is another tool that a friend of mine, Jake, has put out called Locksmith. You can run this whether you're on the blue side or the red side. This is a fantastic tool that discovers several different misconfigurations in environments. So this is what it looks like when it detects ESC1. I think the coolest thing that it does is it provides fixes for you. So it can output some PowerShell that will actually mitigate this, and it looks at not only ESC1 but all the way through 8 with the exception of 7 and also looks at some auditing being enabled, which does not happen by default in ADCS. So it provides fixes for every single one of these as well. And so technically we created the Brandon Rocks account, but I wanted to put it up here because I hope you agree. So... We got our last two vulnerabilities patched. So two more mitigations is to disable that print spooler and run Locksmith in your environment. Our game is still not over, though. So even though we've reached the end boss and we've fought it, there's always that next level. Our princess is always in another castle. There's always something else you can do. There's always that next step. Active Directory is not done with new vulnerabilities that come out on a regular basis. It's old, but there's new research that occurs every day. So I urge you all to get an assessment done, get a pen test done, try out some of these tools. So this is a list of all of the resources that I used. So use if you have permission to run these tools, everybody, please. I'm not telling you to go hack yourself without permission. I'll hold that up there just for a second. I will share these on my GitHub. Because here's a list of all of those resources I talked about. As well as the character selection screen. So I put this back up because I love AI art and how bad it is at spelling things, specifically. I also told it to give me a character selection screen for the game of Active Directory. And it came back with this, and everybody is sad. Every single person has a frown on their face. Like this guy bottom, like three from the right, he's got circles under his eyes. I don't know, he's beat up. And then there's the names of them. There's dad and oh lordy and doy. It's fantastic. So with that, thank you all for coming. Packed house, fantastic, guys. So you can follow me or find me on pretty much everything. Tech Brandon, GitHub's Tech Brandon. Twitter, LinkedIn. Thank you, Packet Hacking Village, thank you, DEF CON. I do think I've got a decent amount of time for questions. So if anyone wants to stick around and has any questions, I will do my best. Cool. Or you can go early and you can go get a snack, because it's lunchtime.