start	end	text
0	10400	Okay. I am with the Packet Hacking Village, and this particular speaker is being sponsored by us.
10400	17760	And we are delighted to present Brandon Colley, who is going to obviously talk to you about Active Directory.
17760	22820	He has been... he'll tell a little bit about himself, but he works for Trimark Security,
22820	26660	and I'm also proud to call him friend. Take it away.
26660	36030	Thank you, Kathy. Friend Kathy. Investigator chick, everybody.
37630	42190	All right. Can you guys hear me okay in the back? Awesome. Let's do this.
42230	47230	So title, as you all know, is Winning the Game of Active Directory.
47470	54310	So a little bit about myself is I served in an operations role, managed Active Directory for about 15 years
54310	60270	for multiple different organizations before I joined Trimark about two and a half years ago.
60270	68750	I was a senior security consultant for them and just got promoted to the service lead role for our Microsoft Cloud assessment.
69050	74350	So I'm kind of joking and saying that this might be my last on-prem Active Directory presentation.
74650	79390	So maybe next year you'll come to see, like, Winning the Game of Entra ID or something like that.
80750	85990	Recently founded my own company and got a logo created, so I threw it up there.
85990	88810	So B&R Consulting is a company that I just started.
88810	95050	I'm a father. Here's one of my kids with me at a Chiefs game. I saw a Chiefs hat. Go Chiefs!
95710	102170	And my wife Bridget came with me today, so I am a very loving husband, as I hope she'd also agree.
102610	106010	First time at DEF CON as well, so...
111320	117260	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.
117420	121860	So let's talk about what I'm talking about when I talk about the Game of Active Directory.
121860	126640	So GoAD, as I like to call it, or somebody said GoAD.
126640	132320	So Prebuilt Active Directory Lab is a multi-domain environment.
132320	141140	They have multiple different builds that you can create and touts over 30 different vulnerable configurations just out of the box.
141160	145200	It's created and maintained by Mayfly of Orange Cyber Defense.
145200	150220	And Mayfly gave me permission to go ahead and use this in the presentation.
150220	154300	He just wanted to know when it gets posted online, and he wants my slides.
154300	160260	So it was originally created for penetration testers to practice attacking Active Directory.
160260	166520	So real quick, where are my penetration testers in the audience, or any red team side people?
166520	168520	How about anybody on the blue side?
168860	170760	Okay, so we're heavily blue. Awesome.
170760	173940	And then everyone else is just unaffiliated, I'm assuming.
174440	176000	You don't get a vote.
177060	181840	So when you start playing a game, first thing you have to do is character selection screen, right?
181840	188220	So we can choose to be a penetration tester, which your job is to exploit vulnerabilities, misconfigurations.
188720	193300	Moving to a little bit of a red teamer, you're going to start looking a little bit more at testing detections
193300	198660	and doing a little bit more stealthy activities when performing Active Directory tests.
198700	204700	And then our defenders, like most of you, are looking forward to learning how to harden your environments,
204700	207840	performing consistent monitoring of those environments,
207840	212040	and just consistently improving the overall security posture of your Active Directory.
212860	215160	The other character you could choose is to be an adversary,
215160	219720	so I'm going to assume that the rest of you who didn't raise your hands are my adversaries, right?
219740	221620	But they don't play by the rules anyway.
222740	225840	So the most important rule when you play a game is how do you win, right?
225840	228900	And that's what I'm here to talk about, is how do you win the game of Active Directory.
228960	234080	And a lot of people think that you can win the game of Active Directory by gaining domain admins, right?
234080	238240	That's the keys to the kingdom. Once you get domain admin, it's game over.
238380	244760	It may be a spill of data. Maybe you want some of that juicy information that's in Active Directory.
245220	251180	Or maybe you just want to create persistence and you want to be slow and methodic about your efforts.
251200	257360	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,
257360	262320	regardless of which character you choose, is to maintain a secure environment,
262320	268320	continuously improve that environment, and implement the safeguards that are needed to keep your Active Directory safe.
268320	273320	And also continuous progress. So what I'm here to do today is kind of show you both sides of that.
273320	277760	I'm going to take a little bit of an attack methodology and also defense methodology.
277760	283780	So we have a... Ted Mosby likes to say, we have a tightly scheduled evening of awesomeness ahead of us, so let's go.
283780	287840	And I guess technically now it is evening. Or afternoon, anyway.
287840	291640	So our agenda, we're going to stick with the gameplay idea.
292160	298200	We've got three different levels. So level one, we're going to call Reconnaissance, Enumeration, PrivEsc.
298200	303180	And then level four is when we pwn Active Directory, and that's really our end boss.
307780	319540	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.
319540	327420	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.
327420	333680	So here's an example of using CrackMap Exec, and this is our first misconfiguration, which is called anonymous access.
333680	340080	If this is configured in your domain, anybody with network access, direct line of sight to your domain controller,
340080	346780	can query for a list of users, as well as some of the public information, such as description.
346780	353040	And so here if we drill in, we identify that we've already got our first credential in Samuel,
353040	359040	who must have had an administrator put his password in the description field for some odd reason.
360440	365100	So how do we mitigate this, other than just don't put passwords in description fields, right?
365100	372580	That's kind of the obvious one here, is removing these groups from your domain.
372580	380440	Domain root, sorry. The pre-Windows 2000 group, I'm not saying to delete this from the domain root,
380440	386680	but if the members of this include the everyone group, or the authenticated, I'm sorry, not authenticated,
386680	391780	the anonymous logons group, then this is possible.
392000	396180	In the Go lab, the screenshot on the right is actually how it was configured,
396180	400100	is you're just giving root access to anonymous logon,
400100	405800	and that's what enables the ability to see everything without having any sort of initial user.
406560	410280	So once we've removed that, we rerun the attack, we get nothing.
410440	416500	So we get an error message, nothing comes back, anonymous access no longer relevant,
416500	418280	so now we have to dig in a separate way.
418980	422880	So if we can't do it anonymously, we're going to have to build a user list.
422880	430380	And so the game of Active Directory, if you've used it before, you may know it's based on the game of Thrones,
430380	432700	which is kind of where the game of thing comes from, right?
432700	436000	So this is a good place for us to start scraping credentials.
436480	439300	I'm sorry, not credentials, usernames.
439300	445340	So we're going to pull out the first names, last names, combine those, and form a user list.
445520	451780	So the screenshot on the left is the user list that I'm using, which is a first name dot last name.
451780	455660	That's the methodology that's used in the lab.
456160	461360	But in your environments, it might be first initial dot last name, you might not have a dot,
461360	464940	it might be your last name and then your first name, something like that.
464940	468200	So we can go ahead and we can throw all of those into a user list.
469060	474220	And then we can attack Active Directory, still anonymously, using a script like this.
474220	480640	So this is just an in-map script that all you need to have is your user list in a text file.
480640	485900	And again, the domain IP, and what it's going to do is it's going to attempt to authenticate to Kerberos,
485900	487440	or it's going to query Kerberos.
488660	491080	Kerberos is going to come back and tell you one of two things.
491080	494560	It's either going to say, yeah, that's valid or no, that's invalid.
494560	499640	So now we've got a list of nine valid accounts that were in that file.
499640	502340	And so now we know who we can attack.
502340	505780	And you guys might say, hey, it's not fair. You knew it was the Game of Thrones.
505780	506940	So you knew who you were attacking.
506940	514760	Well, there are plenty of lists out there on GitHub that you can just do a very top 100 common names,
514760	516740	and you can do the same style of attack.
516740	520380	And once you get one or two hits, then you kind of know the naming convention.
520660	526560	And then you just go out to LinkedIn and you search up Microsoft or whoever you're attacking,
526560	528120	and you scrape from there.
528120	532080	So this is real-world stuff that you can obviously do.
533860	539160	And so the reason that this works is it's ingrained in the Kerberos protocol.
539160	545120	So if an account doesn't exist, then you're going to get this first error message, which is that the principle is unknown.
545160	549900	If the user does exist, you're going to get one of those other two responses.
549900	553400	And that's basically what happens under the covers of this nmap script.
553400	555220	Sorry, I'm going to drink, and this is weird.
566770	575690	Okay, so the fix for this is not easy and sometimes not even possible.
575950	580910	And this is a no-fix bug, I guess you can say.
580910	584770	Microsoft doesn't consider user enumeration to be a bug.
584770	591010	So the best thing that we can really offer is just, if you're looking at being able to change things,
591010	596030	is don't use the same email address that you use for your same account name or vice versa.
596550	603590	Instead, maybe create some sort of non-standard naming convention by throwing something about the department or the type of person.
604010	609930	Like I used to work at a university, so maybe like a F for faculty, S for staff, A for administration.
610150	614110	Maybe you do F for finance, I for IT, something like that.
614110	617730	Or probably the best thing to do is use multiple trailing digits.
618470	624310	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
624310	629030	and a whole lot more time to be able to really enumerate a full contents of Active Directory.
629130	631010	And I understand that this is hard.
631990	637310	Mitigations are more around password policies, which we're going to attack here in a little while.
637890	645270	But because I talked about the Kerberos protocol, I want to go back through another anonymous thing that you can do,
645270	648750	is attack Kerberos pre-authentication.
648750	650710	And so this is known as an AS rep-roast.
650710	656590	And so this is what it looks like when you perform an AS rep-roast attack using the ImpactKit toolkit.
657250	663510	And accounts that do not require pre-authentication are going to come back and give us a password hash.
663510	669370	So in this case, Brandon Stark, no relation by the way, gives us password hash for free.
671390	678030	And with that, we can use Hashcat or John the Ripper or some other offline attack tool where we can throw this through,
678030	684470	and I just threw it through a ROKU, which is just a typical user list, password list, sorry.
684790	690070	And we get the cleartext credentials in just a matter of a few minutes.
694670	699550	So fixing this is pretty easy. It's just a checkbox.
699550	704150	So there is a Kerberos pre-authentication checkbox on user accounts.
704150	706890	It says do not require Kerberos pre-authentication.
706890	712450	This is a super, super legacy thing, pretty free of a win in an environment.
712450	717750	So if you've got any of this in your environment, removing that checkbox is going to mitigate it,
717750	723510	which means after we remove that checkbox, Brandon no longer gives out his password freely.
723870	730230	So we're going to have to attack the passwords using some of the more well-known styles of password attacks.
738400	743460	Okay, so password attacks kind of fall into a few different categories.
743460	747660	And so we're going to attack password reuse by doing a password spray.
747660	758640	And so password spray is trying a small handful of passwords against all usernames in an environment.
758640	763580	So in this case, I used some of the passwords that I already found in the environment.
763580	768660	And I'm just seeing if there's possible password reuse across user accounts.
768660	770440	In this one, it didn't hit anything.
770440	778240	But some common uses for this is things like using Summer 2024 or Defcon 32 or whatever, right?
778260	780820	And just seeing kind of what hits.
783140	786180	A similar attack is a credential stuff attack.
786180	789960	And this is more commonly used with breach credentials.
789960	798360	So this is also a password reuse attack, but it's more specific to the user account themselves or the user themselves.
798360	801740	So if they use the same password, say, for LinkedIn,
801740	810920	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,
810920	816460	it's possible that we may be able to hit something using a credential stuffing attack.
816660	826260	In this specific screenshot, I kind of lazily just used the same user list as the password list,
826260	831920	which simulates the situation where a user has the same password as their username,
831920	838580	which is not terribly common anymore, but used to be common around, like, service accounts and things like that.
838580	844220	So if you've got passwords that haven't changed in your environment for a very long time, this may be possible.
844760	846940	And so we did get a hit on that one.
847160	853560	We got the account Hodor, which we'll use later in another authenticated attack.
853560	859360	But so some of the things that we can do is, and I showcase here just checking out the password policy,
859360	863240	to prove that you can view it as any user in the domain.
863240	870100	So once you have that initial user, you can query the password policy and maybe tailor your password attacks a little bit more specific.
870520	875180	And so if you're wondering why on earth someone could have the same username and password,
875180	879620	it's due to the complexity requirement that's disabled in this lab.
879620	884760	Also, the character limit is only five, which I have seen worse than that.
884760	887640	So five, not the worst.
888480	893060	Some other things that you want to do with your password policy, other than kind of the obvious two there,
893060	899600	is looking at some of the account lockout threshold, and also some of the other password requirements in there.
899600	903620	I do have a link to an article I wrote called Password Policy a la carte.
903620	908600	That's going to be in my resources. So check that out after the talk.
909900	917180	I do want to talk a little bit about account lockout, because it is an effective strategy to blocking some password style attacks.
917200	920820	I'm not going to talk about monitoring, because that's another thing.
921440	925180	But you can query things using password crack map exec.
925180	928380	And so here I've just simulated something.
928380	934860	This is an oopsie. So for the red teamers, you're probably somewhat familiar, hopefully not, with seeing something like this,
934860	939880	where you see log on failure, log on failure, log on failure, and then you see account locked out.
939880	944080	And hopefully this is just the one account and not like all the accounts, right?
944580	950540	Mistakes happen. But log on failures are going to kind of reset that account lockout counter.
951360	953880	So to help combat that, whether you're looking...
953880	959580	I am showing the attack tools, but defense tools is kind of another way that you can look at stuff like this.
960160	969280	When we rerun the crack map exec script using the user's flag authenticated, we can get the bad password count.
969380	973120	So here we identify the very bottom account was the one that we accidentally locked out.
973120	982620	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.
984660	993900	So that concludes level one. Yes, so we gained three account credentials, but that's not necessarily the goal that we talked about.
993940	1000960	So the goal, rather than getting those credentials, is more so the vulnerabilities that we've identified as being able to patch.
1000960	1008500	And so in level one, we talked about anonymous access, removing that from an environment, using a little bit more robust usernames,
1008500	1014940	and how attacks like that might occur, Kerberos pre-authentication and how that's a pretty quick, easy win,
1014940	1018400	and then improvements to password hygiene and account lockout.
1019740	1030760	All right, so on to level two. I like that cute little bunny over there.
1032400	1042060	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,
1042060	1046100	and I realized that whatever, it's just hard, so we're just going to call it more hacks.
1048300	1053880	So the main difference between this level and the first level is that we're doing a little bit more while authenticated.
1054000	1059340	So what type of Active Directory presentation would be complete without talking about Kerberosting?
1059340	1065320	So Kerberosting is an attack on accounts that have service principal names or SPNs.
1065320	1068520	So here's what that looks like. It's an authenticated attack.
1068520	1075640	You're able to identify both John Snow and the SQL service account are vulnerable to a Kerberosting attack.
1076100	1080660	So we're going to take those hashes. We're going to throw those through Hashcat again.
1082060	1087800	And here we cracked the John Snow account because it was a weak password.
1089240	1093980	So you can run something like this. So this is a quick PowerShell search that you can run.
1094180	1099780	Get AD user where you just are looking for accounts that have service principles.
1100100	1104760	And these usually are not cleaned up because service accounts are scary.
1104760	1110320	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,
1110320	1115180	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.
1115180	1118040	Like what's going to happen, right? I've been there. I did that for 15 years.
1118040	1120920	And no, I didn't do this. And no, I didn't change those passwords.
1121840	1128740	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.
1129760	1137040	Is the account privileged? If it's privileged and it's Kerberostable, then that's pretty much a free win for an adversary.
1137040	1141280	So specifically look at those first.
1141480	1146160	For the remaining ones, go ahead and look at what the service principle says.
1146160	1152360	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.
1152360	1157420	So there's a website that it's attempting to coordinate with called the wall.north, seven kingdoms, etc.
1157860	1160940	If I check DNS for that, it doesn't even exist.
1160940	1167220	So if I can't access that web server at all, then this service account's not doing anything.
1167260	1169280	So we're going to go ahead and remove that.
1169280	1174360	The one that's going to remain is the SQL service account because it actually is running SQL.
1174360	1176060	It's required to do that.
1176100	1181540	That one didn't crack because it's using a long, strong, complicated, random password.
1181820	1188840	And so that's how you protect other accounts that are Kerberostable is with that.
1188840	1192480	And so this is what the attack looks like now that we removed the service principle.
1192740	1196440	John Snow no longer shows up as even being attackable.
1202480	1204140	On path attacks.
1207460	1212260	So this I like to claim to be God's gift to AD pentesters.
1212260	1214360	Is that right, you pentesters? Right.
1214640	1220720	This responder, you set this up and it'll just listen and respond to clients on the network.
1223360	1225900	Client's going to come out and say, hey, I'm looking for so-and-so.
1225900	1228900	And it's like, yeah, that's me. Yeah, that's me, too. That's me, too.
1229120	1235600	And if we have it set up in this way, you can poison those requests and we can actually get NTLM hashes.
1235600	1239080	In this case, it's NTLM v1 hashes for these accounts.
1239300	1243880	And so we can do what we've done twice already is we can crack them hashes again with Hashcat.
1244400	1248060	And so here we've got our third account that we've been able to crack.
1248060	1250920	And this one was just from listening to the network.
1252940	1258920	And while that's scary, the scarier thing that you can do is you can configure Responder to run in a similar way.
1258920	1266540	But instead of giving you the hashed credentials, you can tell it to go ahead and pass those or relay those using NTLM RelayX.
1266540	1270220	And you can relay that authentication attempt to a target or targets.
1270220	1273880	So in this case, I'm targeting a web server, the one that ends in 22 there.
1274360	1278440	And I'm just going to wait for Responder to get some authentication to happen.
1278440	1280380	It's going to send that here.
1280380	1283160	And then I told it to set up a Socks proxy.
1283160	1289700	So I've got an active connection using Eddard Stark, which just happens to be an administrator on that web server.
1289920	1292680	So now we've got a shell on our target.
1292680	1298940	So we can do things like this, where we can interact with that session.
1299160	1301440	And we can run Secret Stump on it.
1303200	1304300	Pardon me.
1304660	1308120	So you can see I specified no password. I don't need a password.
1308120	1310540	I've already authenticated to it. I have an active session.
1310540	1312500	And I can run Secret Stump against it.
1312540	1315300	And I can dump the local SAM hashes.
1315300	1319760	So this includes the local administrator account, any other local accounts that exist.
1319760	1323720	Like a help desk account or something like that, that you've placed on systems.
1323720	1328180	This will dump all local credentials on that server or workstation.
1329540	1332760	Also more fun, it's going to extract saved credentials.
1332920	1335960	So here we're attacking service account.
1335960	1340220	So if you may recognize the SQL service account that was not Kerberoastable.
1340220	1342220	You will not be Kerberoasting me.
1343240	1346380	Was in plain text because it's configured as a service.
1346380	1350080	It's running a service which is required for SQL Express.
1350080	1353480	So that account was free on that machine.
1354220	1357660	And so what can we do for on path attacks?
1357780	1364220	So the quickest and probably the easiest of all of these is preventing the LLMNR,
1364220	1366880	which is link local multicast name resolution.
1366880	1369940	Yes, I had to write that down. And no, I'll not memorize that.
1369940	1374180	I do have a great article linked for that one as well.
1374180	1376140	Actually, I have articles for all these.
1378200	1382400	You may have remembered or noticed that those hashes were NTLMV1 hashes,
1382400	1386640	which are infinitely easier to attack than NTLMV2.
1386640	1391220	So enforcing this on your domain controller and setting it to the highest security level
1391220	1395860	of enforcing NTLMV2 to exist on your network.
1395860	1401760	Ideally, not allowing NTLM at all and allowing Kerberos to do what it's supposed to do
1401760	1403040	for the last 20 years.
1404140	1407940	This is hard. And I don't know that I've ever fully seen this.
1407940	1411380	I've seen people auditing it and really starting to get ready for it.
1411700	1415100	Another thing that we've seen, I think twice at Trimark,
1415100	1417220	is LDAP signing and channel binding.
1417640	1419660	This is another thing that's incredibly difficult.
1419660	1422560	It can break a lot of those non-Windows devices.
1422560	1427740	I've also got a couple links to some articles that have been written about this as well.
1429780	1432620	A thing that I don't think is all that hard,
1432620	1435440	some administrators do think that this is hard,
1435440	1437840	this is protecting the accounts themselves.
1437840	1441740	So this might be a little bit easier to get through some of that change management for you,
1442220	1444320	is using the protected users group.
1444320	1446620	Because you're only impacting whatever users you put in it
1446620	1450000	and not the enterprise when you're making domain controller changes.
1450000	1454940	A coworker of mine, Jake Hildreth, which owns our Active Directory Security Assessments,
1454940	1456580	he has a blog and a presentation.
1456580	1463300	He's writing a tool to help assist with end users adding accounts to the protected users group.
1463700	1465920	So again, I've got that in the resources.
1467500	1468960	Alright, so level two is down.
1468960	1470420	We Kerberos to John Snow.
1470420	1473640	We crack the hash from Responder for Rob Stark.
1473640	1477280	And we found the SQL service account running.
1477280	1478900	So now we've got six accounts.
1478900	1483520	And we've got five more vulnerabilities that we have patched.
1483520	1485380	So we cleaned up SPNs.
1485380	1491100	We disabled LLMNR and NTLM v1 by enforcing v2.
1491100	1494820	We talked a little bit about at least thinking about LDAP signing and channel binding.
1494820	1497260	And then also the protected users group,
1497260	1501160	protecting those highly privileged users in your domain.
1503960	1506440	So level three, I called Privesk.
1506440	1508920	Again, this is maybe a little bit more lateral movement-y.
1508920	1512940	Also some pretty domain crushing attacks in this one too.
1513820	1519500	And I'm going to kind of start by going backwards just a smidge because I wanted to show Bloodhound just a little bit.
1520320	1525080	Bloodhound is an amazing tool that you can use to scan your Active Directory environment.
1525080	1529600	And here I'm just showcasing what paths are available to domain admin.
1529600	1532660	And here I'm going to zoom in on the one that we just owned.
1532660	1534740	So we just got that Rob Stark account.
1535200	1537840	And Rob Stark is a member of the administrators group,
1537840	1541660	which is just this very simple step away from domain admins.
1541740	1545500	And so that one's just a little bit too boring because you can just add yourself to that group, right?
1545500	1547200	So we're going to do something cool.
1547700	1551340	And we're going to identify what ACL modification may look like.
1551420	1553780	So here you might remember our old friend Samwell,
1553780	1557740	who was our first attack with that description field misconfiguration.
1557740	1565000	Well, Samwell, for whatever reason, has the ability, has a write DAQL on a GPO that's linked to the domain root.
1565380	1567060	So what does that look like?
1568660	1571620	So here's what it looks like when we look at the policy itself.
1572040	1578040	We see that the delegation tab shows us that we have some privileges with Samwell.
1578040	1583640	If we dig into him a little bit, we identify he doesn't look too terribly dangerous because he doesn't have write permission.
1584140	1588260	He has read and he has delete.
1588380	1592420	But we have to actually look at advanced to identify what the real threat to this is,
1592420	1597580	which is that write DAQL permission, which translates to modify permissions and modify ownership.
1598140	1603300	So Sam can give himself or anyone else access to modify this GPO.
1603440	1608700	And there's a number of different things you can do once you can modify a GPO specifically at the domain root.
1608700	1615480	One such example is just creating a file that's going to run at login for all users on all computers in your environment.
1616180	1618440	So we can do some pretty messy stuff with that.
1619720	1622180	So mitigating this is fairly simple.
1622180	1625020	You just have to check out the GPOs.
1625120	1627320	I don't have a script for this.
1627320	1628360	I should probably write one.
1628360	1633300	So I may write one and put it up on GitHub where you can actually scan some of the ACLs that might be dangerous.
1633300	1637420	But specifically start with your domain root and then move on to domain controllers,
1637420	1643580	move to other protected OUs to identify group policies that maybe have delegation.
1643880	1645380	Also ownership.
1645380	1649540	So identify who has owner on your GPOs.
1650120	1655860	And so if we clean that up, then we're in a lot better shape for any of that ACL modification.
1657220	1659500	So I'm going to take us a little bit back.
1659500	1665560	So you remember when we attacked the web server that we were targeting with stuff?
1665560	1667220	I don't really remember either.
1667220	1675060	But basically what we did was we were able to gain the local credentials for that web server.
1675140	1679800	And what we can do with local credentials is we can do a pass the hash attack.
1680540	1683360	So in this example, we're using the administrator.
1683360	1686680	This could be, like I said, a help desk account or any other local account.
1686680	1690560	And we can target all other known IPs in that domain.
1690880	1694200	And this could be servers, this could be workstations.
1694580	1698980	And in this case, we identify that very first one, the Castle Black.
1698980	1702120	That's the one that we attacked. We expected that one to show up as pwned.
1702120	1706340	But that bottom one, Winterfell, is actually a domain controller.
1706920	1709900	I mean, this is a lab, so this is fairly unrealistic.
1709900	1713780	But the reason this works is because when you promote your first domain controller,
1713780	1718680	it's going to use that credential as the domain administrator credential.
1719700	1722620	So just a little bit of digression on that.
1722940	1726960	But with that, we don't even need to know what the password is for that administrative account.
1726960	1729580	We can just pass that hash and authenticate.
1729580	1735660	And here I'm using EvilWinRM, and you can see at the bottom that I've got a shell on our domain controller.
1736600	1740340	And solution for this is to use something like LAPS.
1740340	1748600	So old admins like myself maybe remember the days before LAPS was a thing where you would use a GPO,
1748600	1752160	and you'd set the local administrator account on all machines.
1752220	1759120	And thanks to the cpassword, where everybody could read that, we've now got cleartext credentials.
1759120	1764780	So other than even just reuse and passing the hash, cpassword has cleartext creds.
1764780	1768240	That's not even an attack that I showcased in this.
1768240	1771520	It's fairly old. We do still see it on old GPOs.
1771520	1774660	Even if they're unlinked, they still have some cpasswords in them.
1774660	1776620	So you may check that.
1776620	1778280	But this is what LAPS looks like.
1778400	1783060	I've got articles on that as well, because I'm not going to go super into LAP.
1783900	1787800	I am going to go a little bit into Kerberos delegation, though.
1793420	1797700	So Kerberos delegation is a required feature of Windows.
1799380	1802800	An example would be when a user authenticates to a web server,
1802800	1808720	and then that web server needs to authenticate on behalf of that user to a database server, for example,
1808720	1813920	to be able to provide the correct results for the user that's asking.
1814120	1816800	So it's kind of a security thing. It's pretty much built in.
1816940	1819980	But in this case, when we talk about delegation, we're talking about impersonation,
1819980	1824780	which means that web server has the ability to impersonate any user in the domain.
1826140	1831180	And so what that looks like, specifically when we're attacking unconstrained delegation,
1831180	1836540	is we have a shell on that web server that we had shown that we attacked earlier.
1837180	1841620	And since it's set up for unconstrained delegation, we either wait,
1841620	1847520	or we can coerce an administrator to log into that system that we're in control of.
1847760	1852660	And so here, using Mimikatz, I was able to export the tickets for Brandon.
1853480	1857940	Brandon was very impressionable admin at the time.
1861020	1866660	So Brandon logged into our server that we had control of.
1867300	1871880	Using Mimikatz, we were able to set up what's called a pass-the-ticket attack.
1871880	1874400	And then we load that ticket into our session.
1874400	1880620	And we can view that using that klist tickets to identify that we have that cached ticket for Brandon.
1880620	1884820	And then that last command in the bottom is just opening a PowerShell session
1884820	1890120	to a domain controller. So we're authenticating as a domain admin to a domain controller.
1891640	1897780	And now we've got a shell on the domain. We run whoami. We just look at sysvol.
1897780	1901020	And so now we've basically owned that domain controller.
1901320	1904960	I've got a lot more attacks to go, so I'm not going to stop there though.
1904960	1907420	So how do we stop this specifically?
1907740	1913600	So moving unconstrained delegation to constrained delegation is a good way to mitigate this.
1913600	1917460	You can specify the specific service or server that's required
1917460	1922780	instead of just allowing delegation to occur wherever it needs.
1924900	1928220	That, again, can be somewhat difficult to identify.
1928740	1932500	So what I like to do, even in the... I'm not saying don't do that,
1932500	1937160	but what I am saying do is mark accounts as sensitive and cannot be delegated.
1937160	1941660	So all of your administrators, this is kind of a baby step to the protected users group,
1941660	1945280	set them up like this because, like I said, Brandon was very impressionable
1945280	1949800	and he could be tricked to logging into wherever because he's an admin.
1949800	1953120	You know, somebody in user calls, he logs in wherever they tell him to log in
1953120	1955540	as his domain admin credentials, right? What could go wrong?
1956560	1960400	So now that I've set Brandon as sensitive, he can't be delegated,
1960400	1965260	on the right here is what we just did, so that's what the attack looked like in Mimikatz.
1965340	1971020	If that attack were to attempt... be attempted when the account was set up,
1971020	1975600	he was still... he still logged in and we can still look at some stuff in Mimikatz,
1975600	1979240	but we don't have that ticket granting ticket, which means we can't load it into the session
1979240	1980960	and we can't attack that account anymore.
1985910	1989210	All right, so level three is over. We don't have any new accounts,
1989210	1992030	but we're kind of beyond that now. You know, we've kind of gotten to the point
1992030	1996610	where we're already on the precipice of domain admin.
1996610	2000330	We've already kind of gained that full domain compromise.
2001090	2006370	So what we've learned in level three is how to fix ACL and ownership issues,
2006370	2009810	specifically on GPOs, but other objects are also important.
2010530	2013950	Configuring LAPS to prevent things like local administrative credentials
2013950	2017350	being on multiple machines, being able to perform lateral movement,
2017970	2020750	implementing constrained delegation instead of unconstrained,
2020750	2023350	and then protecting your admin accounts using the account is sensitive
2023350	2025150	and cannot be delegated flag.
2026530	2028270	All right, now the fun one.
2034880	2038500	Okay, we're going to Pwn AD. So the print nightmare.
2039020	2044420	I don't know if you all remember this. It was three years ago, I think now,
2044420	2047240	and this I like to call the attack that got me into InfoSec.
2047300	2050640	So I told you I worked for TriMark for two and a half years now.
2051160	2053740	Print nightmare came out when I was still a sysadmin.
2053920	2058540	It let me poke at it and prove to my administrators that it was exploitable,
2058540	2062140	so we had something to do. So this is what that looks like.
2062140	2066340	So running a CrackMap exec tool as well as the impact tool,
2066340	2070500	we identified that the spooler is running on our target system,
2070500	2074520	and the protocols necessary to perform the attack are also available.
2077900	2080880	So what this attack looks like is we can just host a malicious DLL
2081640	2085580	on a Samba share from this Kali box. This is where the screenshots are coming from.
2086160	2091640	Using the cube 0x0 exploit, we can target the domain controller,
2091640	2094380	and we're using just a regular user account, so that Hodor account
2094380	2099020	that we grabbed, no administrative credentials in the domain whatsoever,
2099020	2102500	can authenticate to that domain controller, and because the print spooler
2102500	2108520	is available on that server, we can throw this nightmare DLL at it,
2108520	2112480	and it says exploit completed. And what that exploit does
2113500	2116480	is it's created a new account for us in the domain.
2116480	2121500	It's called PrintNightmare2, and it is in the administrators group.
2124510	2128370	And this is my favorite mitigation, because it's the easiest mitigation.
2128370	2133630	So we just disable the print spooler. And yes, I know PrintNightmare has been patched.
2133630	2138030	Thank goodness. So not this specific attack is available everywhere anymore,
2138030	2141510	but the print spooler is used in so many coercion attacks that can occur now
2141510	2148330	that I like to say, if you're not printing or performing printing as a print server,
2148330	2152070	then you have no need to run the print spooler whatsoever.
2152150	2156930	So disable it either manually here or use a GPO to disable it,
2156930	2161330	and here you see on the right-hand side that that server is no longer vulnerable to attack.
2164750	2170150	So our last attack is going to be one of the Active Directory certificate services,
2170150	2176590	so ADCS, vulnerable configuration that we're going to attack using the Certify tool.
2176590	2179490	So this has been very popular over the last couple years.
2179490	2183870	About two years ago or so, we saw this as a critical vulnerability
2183870	2186530	on almost every single assessment that we did.
2186650	2190070	Thankfully, things have gotten a little bit better in the industry now,
2190070	2191590	but this is what that looks like.
2191590	2195190	So we're going to run our Certify tool with a find command.
2195190	2199610	This is just using a regular user account to a domain controller.
2202180	2206680	So our output is going to include all the vulnerabilities that exist in that domain
2206680	2209220	if it's running certificate services.
2209220	2211460	And I'm going to drill into that because it's hard to see.
2212340	2217940	So the specific one that we're going to pick out is called ESC1 or Escalation 1.
2217940	2221780	This is from the Certify pre-owned stuff that Spectrops put out.
2221780	2223440	It's also in the resources.
2224520	2229100	So what makes this vulnerable is that enrollee supply subject,
2229100	2233940	which equals the subject alternative name, can be applied when you enroll a certificate.
2235260	2240600	The second half of that puzzle is who can enroll dangerous certificates.
2240660	2244320	So in this case, we have domain users, have enrollment rights,
2244320	2247360	and that means that anybody can enroll a certificate
2247360	2250940	and they can specify that they are whoever they want to be.
2252640	2259300	And so we can go take the next step and we can run Certify and request our certificate.
2259300	2262520	So here we can see we're targeting that ESC1 template.
2262520	2265480	We're telling it that we want to be administrator.
2266040	2271080	We can tell it whatever we want, but of course we want to be the administrator account.
2271080	2279290	So we've saved that private key locally, and now we're going to authenticate with it.
2279290	2281630	So now we run the Certify Auth command.
2281630	2288390	We specify the PFX, the domain controller, and we've now got the credential cache,
2288390	2293330	so the Kerberos credential, as well as the hash for the administrator account,
2294170	2296470	which means we can do bad things.
2297930	2300630	So we can run secrets dump using that hash.
2300630	2304190	We could also authenticate with that C cache file doing that,
2304190	2307250	and we can dump the entirety of the domain controller.
2307250	2311290	So here we've got the SAM, but that's not even really what we want.
2311290	2316850	We want the NTDS.DIT file, so this contains the entire contents of Active Directory
2316850	2319590	and all the NT hashes for every single user.
2319590	2323590	And we did this with very little privilege whatsoever.
2323670	2328750	So in that context, that attack was game over, right?
2328750	2330110	But we're not quite done.
2330110	2332570	We still have some work to do because we're learning that domain admin
2332570	2335850	doesn't mean that we're finished as administrators.
2336530	2341270	So we need to investigate why the vulnerable template existed in the first place.
2341270	2342870	So this is what I said earlier.
2342870	2345250	It's that two-piece, the domain users.
2345250	2346650	It doesn't have to be domain users.
2346650	2351830	It could just be a subset of regular user accounts that could enroll certificates.
2351830	2355130	So the bigger issue is that supply and the request.
2355390	2360110	So a little bit better of a mitigation is to require manager approval for specific certificates.
2360110	2362370	There's a number of different things that you can do.
2364370	2367530	And this is what the certificate that was issued looks like.
2368010	2371950	So here you'll see the subject was Brandon because he was the one that requested the certificate,
2371950	2375890	but he requested it using the subject alternative name as administrator.
2375890	2378790	So that's what it looks like when a certificate's enrolled.
2381630	2385870	And so we already talked about how you can detect it, but how can you do it automatically?
2385910	2391870	So this is another tool that a friend of mine, Jake, has put out called Locksmith.
2391970	2395130	You can run this whether you're on the blue side or the red side.
2395130	2401930	This is a fantastic tool that discovers several different misconfigurations in environments.
2401930	2405070	So this is what it looks like when it detects ESC1.
2405070	2408990	I think the coolest thing that it does is it provides fixes for you.
2409230	2413590	So it can output some PowerShell that will actually mitigate this,
2413590	2418090	and it looks at not only ESC1 but all the way through 8 with the exception of 7
2418090	2423390	and also looks at some auditing being enabled, which does not happen by default in ADCS.
2423550	2426790	So it provides fixes for every single one of these as well.
2431680	2435220	And so technically we created the Brandon Rocks account,
2435220	2437500	but I wanted to put it up here because I hope you agree.
2438000	2438480	So...
2440800	2443620	We got our last two vulnerabilities patched.
2443620	2449500	So two more mitigations is to disable that print spooler and run Locksmith in your environment.
2449720	2451640	Our game is still not over, though.
2451640	2455920	So even though we've reached the end boss and we've fought it, there's always that next level.
2455920	2457860	Our princess is always in another castle.
2457860	2460980	There's always something else you can do. There's always that next step.
2461440	2467060	Active Directory is not done with new vulnerabilities that come out on a regular basis.
2467060	2471420	It's old, but there's new research that occurs every day.
2471420	2477420	So I urge you all to get an assessment done, get a pen test done, try out some of these tools.
2477420	2480400	So this is a list of all of the resources that I used.
2480600	2485060	So use if you have permission to run these tools, everybody, please.
2485220	2488740	I'm not telling you to go hack yourself without permission.
2489900	2492040	I'll hold that up there just for a second.
2492040	2495440	I will share these on my GitHub.
2497600	2500680	Because here's a list of all of those resources I talked about.
2500920	2503260	As well as the character selection screen.
2503260	2508920	So I put this back up because I love AI art and how bad it is at spelling things, specifically.
2509620	2515400	I also told it to give me a character selection screen for the game of Active Directory.
2515400	2518520	And it came back with this, and everybody is sad.
2521800	2524780	Every single person has a frown on their face.
2524780	2529700	Like this guy bottom, like three from the right, he's got circles under his eyes.
2529700	2530640	I don't know, he's beat up.
2530640	2535140	And then there's the names of them. There's dad and oh lordy and doy.
2535320	2536800	It's fantastic.
2537100	2540160	So with that, thank you all for coming.
2540160	2542040	Packed house, fantastic, guys.
2553790	2557450	So you can follow me or find me on pretty much everything.
2557450	2559710	Tech Brandon, GitHub's Tech Brandon.
2560250	2561670	Twitter, LinkedIn.
2562130	2564430	Thank you, Packet Hacking Village, thank you, DEF CON.
2564570	2568150	I do think I've got a decent amount of time for questions.
2568150	2572790	So if anyone wants to stick around and has any questions, I will do my best.
2577110	2577530	Cool.
2577530	2581730	Or you can go early and you can go get a snack, because it's lunchtime.
