00:00:01.635-->00:00:05.038 [Music playing] >>Alright. We’re gonna start off with Sean. He’s got a little special message 00:00:05.038-->00:00:11.178 he’s gotta do so, here iss Sean. >>Morning Defcon how we doing? [Audience Cheers] [Applause] 00:00:11.178-->00:00:16.049 Love it. [Applause] So happy to be back back at Defcon. I got a friend here, this is Bunny. My 00:00:16.049-->00:00:21.622 daughter asked me to bring Bunny. So can everyone say, “hi Bunny”? [audience says hi Bunny] 00:00:21.622-->00:00:24.491 Awesome, thank you. [inaudible sound] [click] Alright so Bunny’s going to sit over here 00:00:24.491-->00:00:28.695 and get a front seat. So this is exploiting an active directory of administrator insecurities. 00:00:28.695-->00:00:33.233 I’m Sean Metcalf. I’m really excited about this slide deck because one of the things that 00:00:33.233-->00:00:37.237 I’ve talked about before. Problems with active directory, the way it’s configured, the way 00:00:37.237-->00:00:41.742 that people manage it, configurations within it but rarely have I gotten to talk 00:00:41.742-->00:00:46.146 about the problems with how it’s administered and the challenges with the systems that are often 00:00:46.146-->00:00:51.151 connected, that are secure. So I’m Sean Metcalf, the founder of TriMark. We help companies 00:00:53.287-->00:00:56.823 better secure their Microsoft platform which is part of the reason why I do all this fun 00:00:56.823-->00:01:00.627 active directory security stuff. I’m a Microsoft certified master in active directory. There’s 00:01:00.627-->00:01:05.832 about a hundred for the wo, in the world. Uh most of whom work at Microsoft, I don’t. Um, so I 00:01:05.832-->00:01:10.237 can talk about whatever I want. [Cheers] [Applause] Uh [speaker laughs] [applause] I’m very 00:01:10.237-->00:01:14.408 happy to be back on stage at Defcon. I’m a security consultant and researcher and I 00:01:14.408-->00:01:18.879 run AD Security dot org. Show of hands, have you used AD security dot org? Okay, everyone who’s 00:01:18.879-->00:01:22.115 not raising their hand, talk to one of the people that raised their hand and ask them what you 00:01:22.115-->00:01:27.587 they think about it so. >>Okay >>So we’re going to talk about the evolution of admin 00:01:27.587-->00:01:32.559 discovery. How do we find admins in the environment? Uh, the challenges with that, and some 00:01:32.559-->00:01:38.465 of the issues with correctly discovering admins around in active directory. How to exploit 00:01:38.465-->00:01:43.270 typical administration, at least how I often see [clapping] AD administered. Uh challenges and 00:01:43.270-->00:01:47.040 problems with multi factor [audience cough] Uh, password vaults seem to be more popular 00:01:47.040-->00:01:51.211 so we’re going to talk about bypassing and subverting password vaults and then the 00:01:51.211-->00:01:56.183 vaulted admin force, AKA The Red Force. And then I’m going to talk about how you can actually 00:01:56.183-->00:02:01.521 attack read only the main controllers to compromise AD, which should be fun. So the 00:02:01.521-->00:02:06.326 evolution of admin discovery, we look for domain admins. We love domain admins right? That’s 00:02:06.326-->00:02:11.698 great. So we run a command like this. Get net group member. Thank you uh Will HarmJoy for 00:02:11.698-->00:02:15.469 giving us Power View. [person whoops] [applause] So we can do this easily and and quickly and 00:02:15.469-->00:02:20.073 enumerate the members of domain admins. But a lot of times, pen testers and, red teamers and, 00:02:20.073-->00:02:24.745 security folks, forget about administrators. So if we’re just looking at domain admins, we’re 00:02:24.745-->00:02:30.217 going to miss a ton of active directory administrators. How does this look? Well in most of 00:02:30.217-->00:02:35.756 environments we end up with what, 6 domain admins? But once we enumerate the administrators 00:02:35.756-->00:02:41.028 group, we might have as many as 20 or more. And so if we don't pay attention to the 00:02:41.028-->00:02:46.967 administrators group, they have full AD admin rights, as well as full domain controller admins 00:02:46.967-->00:02:50.804 rights. So it’s very important to make sure we’re capturing both of those. And if we see 00:02:50.804-->00:02:56.209 something like this, what do you do? There are no domain admins. There doesn’t need to be any 00:02:56.209-->00:02:59.513 domain admins in order to correctly manage an administrator active directory. 00:02:59.513-->00:03:05.452 Domain admins really are not the AD admins, the administrators are. So, the other way that 00:03:05.452-->00:03:09.689 we’ve talked about, or I’ve talked about uh discovering admins is by using admin count 00:03:09.689-->00:03:14.261 equals 1. Right? Great. We look for any account in that domain that has admin count, the 00:03:14.261-->00:03:18.331 attribute set to 1. Uh active directory is the process that goes through and enumerates the 00:03:18.331-->00:03:23.303 most privileged accounts, groups in in the domain and then flags them, puts some security, 00:03:23.303-->00:03:27.474 additional security permissions on them and flags it with having a count that goes 1. The issue 00:03:27.474-->00:03:31.311 here is that if you’re just looking for this, that’s only in that own, that that single 00:03:31.311-->00:03:37.050 domain. So in a multi domain forest, you’re going to miss all of the others. In multi forest 00:03:37.050-->00:03:42.389 environments you’re going to miss the others as well. And if we have a tool that isn’t multi 00:03:42.389-->00:03:46.526 domain or multi forest capable, which by the way, this is Microsoft’s Powershell 00:03:46.526-->00:03:52.132 commandlet. It is not correctly multi forest capable because when I add a group from another 00:03:52.132-->00:03:57.904 forest into the administrator's group in this domain, it breaks. At Least in half the 00:03:57.904-->00:04:03.643 environments I've seen. And when I run it against the administrator's group recursive, 00:04:03.643-->00:04:09.649 it doesn't give me everything. So, definitely use the tool uh Will's Power View works really 00:04:09.649-->00:04:13.753 well for correctly enumerating the membership but test your tool in a lab test to make sure 00:04:13.753-->00:04:17.958 that you're getting what you're supposed to be seeing, otherwise you might miss something. So 00:04:17.958-->00:04:23.864 there's also what I call hidden admins. Many people forget about group policy. The default domain 00:04:23.864-->00:04:29.770 controllers group policy or policy, GPO, contains something called user rights assignments. 00:04:29.770-->00:04:34.074 These are the user rights assignments that you would find on a work stations, in servers, 00:04:34.074-->00:04:37.711 who can log on locally, who can do certain things on the system but, the ones who that are 00:04:37.711-->00:04:42.182 configured for domain controllers actually has domain rights also. Very privileged 00:04:42.182-->00:04:47.120 rights and this is often missed. This is what I call hidden gold. If your a pen tester or Red 00:04:47.120-->00:04:51.858 Teamer which is my target audience today, um and you're not looking at group policy 00:04:51.858-->00:04:55.962 settings that are applied to domain controllers, please start doing that. Because user rights 00:04:55.962-->00:05:01.501 assignments is going to help you find an easy an even easier way in and be able to get you to 00:05:01.501-->00:05:07.240 meet your object objective more quickly a lot of times. Why is this? Well it looks like this. I 00:05:07.240-->00:05:12.512 know you can't read that, it's okay. But this is the display, this is what you look at. So 00:05:12.512-->00:05:16.650 let's dig into a couple of these. Allow Log On locally. It is what you think it is. This 00:05:16.650-->00:05:21.121 gives you the ability to log on locally. But when you apply this setting to a domain controller, 00:05:21.121-->00:05:24.524 guess what? You can log on locally to that domain controller. So if you can walk 00:05:24.524-->00:05:29.596 up to that domain controller and physically get on that keyboard, you can log on to that domain 00:05:29.596-->00:05:33.800 controller like it was a workstation. And you might've noticed something weird on this 00:05:33.800-->00:05:40.240 slide. That is not a typo, I have actually found this in customer sites. So, anybody can 00:05:40.240-->00:05:44.644 log on to a domain controller. I don't know just incase the admin left early that Friday and they 00:05:44.644-->00:05:50.450 need to reboot it or something. Who knows. But, the thing about log on locally, it's not always 00:05:50.450-->00:05:56.223 local. There are remote ways to do local, right? When we have a VM, we can use the remote 00:05:56.223-->00:06:02.262 console to connect into that VM's console and logon locally over the network. There's also 00:06:02.262-->00:06:06.766 this little thing called I Low. Which is has bran, been around for many years. Uh, physical 00:06:06.766-->00:06:12.172 servers, physical domain controllers have I Low. It gives you the ability to out of band, 00:06:12.172-->00:06:17.210 off another network, connect into that server as if you could already P into or connect to it 00:06:17.210-->00:06:22.215 and get that console access and the recommendation is to often, have that I Low connection be on 00:06:25.318-->00:06:28.955 a separate network, and out of band network, a backup network. Not on the production network. 00:06:28.955-->00:06:34.361 But guess what everyone does? They put it on the production network. Guess what can happen? 00:06:34.361-->00:06:40.133 HP Allied vulnerability from last year, about year ago. Uh, some very clever researchers 00:06:40.133-->00:06:46.306 fuzzed reversed engineered uh the I Low configuration and what you can do with it and they 00:06:46.306-->00:06:51.311 discovered that. You want to see the POC? Uh? [audience agrees] Okay. Here it is. You run curl, 00:06:54.748-->00:06:59.753 you send 29 A's [audience laughter] and you completely bypass authentication. [audience 00:06:59.753-->00:07:06.293 says yeah] [applause] So this vulnerability is brought to you by the letter A. [audience 00:07:06.293-->00:07:11.364 cheers] [applause] So, this is not mine. They did a great job on it. I was chatting with one 00:07:11.364-->00:07:14.734 of the members of the team over at Mandalay the a couple days ago and he was talking about 00:07:14.734-->00:07:18.571 some really cool stuff that they figured off of this because I low is connected into the 00:07:18.571-->00:07:24.377 hardware. So not only can you bypass into the I low auth and just get local console access 00:07:24.377-->00:07:28.782 over I low, but there's some other interesting things they'll be talking about so, uh he he 00:07:28.782-->00:07:32.252 told me a little bit about it but I'll let him you know, talk about that later. [speaker 00:07:32.252-->00:07:35.221 giggles] Uh so that's one way that you can do it. So, you definitely want to check this 00:07:35.221-->00:07:39.125 out especially when you have physical DC's. By the way the physical TD DC's usually don't 00:07:39.125-->00:07:44.164 have VM in the name. Just a hint. [audience laughter] But, there is a way through the 00:07:44.164-->00:07:49.069 Microsoft settings in user rights assignments to have the ability to log on uh over RDP to 00:07:49.069-->00:07:54.174 a domain controller. If there's allowed log on locally, and the ability to log on to terminal 00:07:54.174-->00:07:59.379 services, well guess what? Server tier 3 can do this. Only domain admins and only 00:07:59.379-->00:08:04.117 administrators should ever be able to logon to the domain controllers via RDP but a lot of 00:08:04.117-->00:08:09.189 times we find this when we do assessments for customers. And who's a member of server tier 3? 00:08:09.189-->00:08:14.294 Well, it's Eddie and that's just a regular user account so whoever can control Eddie's 00:08:14.294-->00:08:19.299 account or manage Eddie's ac-account or compromise Eddie, I don't know. Uh, then they can 00:08:21.434-->00:08:25.038 get on to the domain controller. And if you can log on interactively on a domain 00:08:25.038-->00:08:29.676 controller, Uh eh you can do a lot of fun stuff from there. [inaudible sound] The other 00:08:29.676-->00:08:33.079 interesting thing is managed auditing and security logs. So when you're doing an assessment 00:08:33.079-->00:08:37.417 for a customer, you're on an engagement, definitely check this out. Uh you'll typically 00:08:37.417-->00:08:42.389 see exchange that's configured this way. But, this give you the rights to actually clear the 00:08:42.389-->00:08:46.760 event log now. Not advocating, depending on your scope to clear event logs on DC's, but 00:08:46.760-->00:08:50.463 certainly bring it up to your customer and say, "hey, by the way, this group lab admins, can 00:08:50.463-->00:08:54.934 clear your event logs on your DC's. You probably don't want that. And we compromised one of 00:08:54.934-->00:08:59.038 the members of this group and we could've cleared the event logs on all your domain controllers, 00:08:59.038-->00:09:04.344 as we were doing our our our engagement, so you want to take care of this." Trusted for 00:09:04.344-->00:09:08.581 delegation, this is a really interesting thing. um, Will HarmJoy did a great blog article 00:09:08.581-->00:09:12.752 about this. I've talked about the dangers of unconstrained Kerberos delegation. Kerberos 00:09:12.752-->00:09:16.890 delegation is impersonation. [coughing in background] So when you configure a computer or an 00:09:16.890-->00:09:22.162 account with the ability to de-deligate to impersonate a user, that means they can 00:09:22.162-->00:09:26.466 impersonate that user for Kerberos services on the network. This right that's 00:09:26.466-->00:09:30.503 configured in user rights assignments for domain controllers, enables these 00:09:30.503-->00:09:35.708 accounts actually set up and configure and can set the delegation, Kerberos 00:09:35.708-->00:09:40.046 delegation,on those accounts and those computer accounts. Now they do need one extra right for 00:09:40.046-->00:09:44.050 it to actually follow up and finish, but most of the time these groups will have those 00:09:44.050-->00:09:47.020 rights. They'll have full control over those those accounts because they have 00:09:47.020-->00:09:52.659 controls to, on those OU's. So it's dangerous and a lot of times if you if you enumerate 00:09:52.659-->00:09:56.963 the Kerberos delegation in the environment to see what accounts have Kerberos delegation 00:09:56.963-->00:10:02.101 configured, if there's more than like 30 or 40, you definitely want to check this out because 00:10:02.101-->00:10:05.405 there's probably a big group that has this ability that aren't make, that aren't the 00:10:05.405-->00:10:12.378 administrators. And then as we have environments that are getting better, uh some of you 00:10:12.378-->00:10:15.915 have probably seen some environments that have gotten stronger. They've set up better 00:10:15.915-->00:10:20.320 restrictions. They have more controls over their admin environment. Um, things that 00:10:20.320-->00:10:24.624 have been around forever that people have forgotten about are Log On Hours. So you can 00:10:24.624-->00:10:29.162 restrict when someone can log on to that directory and what they can do in that time frame. You 00:10:29.162-->00:10:32.799 can also configure what workstations or computers they're actually allowed to log 00:10:32.799-->00:10:38.438 on interactively to. So, most of the tools that I've looked at that are used in pentest and red 00:10:38.438-->00:10:42.442 teams don't look for this. So if you find an account and you're like, "I popped this account, 00:10:42.442-->00:10:47.847 but I can't do anything with it. Why?" Check this out. You want to check these 2 attributes. Log 00:10:47.847-->00:10:52.552 on hours and uh log on restrict, workstation. The other thing you want to check is a lot of times 00:10:52.552-->00:10:56.756 you'll have deceptive accounts or honey pot accounts in the environment that will look like 00:10:56.756-->00:10:59.292 they're great. They're honey tokens in the environment. They're a member of the right 00:10:59.292-->00:11:03.696 groups. You can't do anything with them. Check these attributes. It's probably why 00:11:03.696-->00:11:07.667 they're locked down. Why you can't do anything with them. So when we talk about 00:11:07.667-->00:11:13.406 administration, where it's been, where it's going, uh, who here remembers VNC? Just applause. 00:11:13.406-->00:11:19.212 [applause] Ya. Right? Um some environments still have VNC right? And VNC by default is not 00:11:19.212-->00:11:24.217 secure so that's probably a bad idea. Um, we've moved on to RDP. We had run as. People would use 00:11:26.286-->00:11:29.923 MMC on their on their computer in order to perform administrations. So we moved 00:11:29.923-->00:11:33.526 forward from that but in the beginning their were admins everywhere, user accounts for 00:11:33.526-->00:11:38.498 domain admins. Every local administrator account was the same. Probably, same now in some 00:11:38.498-->00:11:43.403 places. Please change that. Uh. [distant laugh] But some environments have as many domain 00:11:43.403-->00:11:48.041 admins as users which is bad so like, as many admins as ostriches in this picture. Cause 00:11:48.041-->00:11:52.545 I like ostriches. And so this was target rich, there was a lot of opportunities. Any account 00:11:52.545-->00:11:56.716 you found had some sort of admin rights. Which is probably not too much different then some of 00:11:56.716-->00:12:01.788 the environments you'd walk into. And the methods that were used then were bad. Log on to a 00:12:01.788-->00:12:07.060 workstation as an admin, credentials and L sass. Run as, credentials and L Sass. Even the 00:12:07.060-->00:12:10.296 RDP. So this is the thing that people forget. They stop doing the things on their local 00:12:10.296-->00:12:16.336 workstation, they then RDP into a server like an admin server and then don't track how that 00:12:16.336-->00:12:21.341 admin server's protected. How it's controlled. So me me cats, obviously. Newer admin security 00:12:23.409-->00:12:27.680 methods. So no more run as, no more MMC on the local system. Should be great, right? We're 00:12:27.680-->00:12:32.185 going to use RDP. We're going to connect to another system. I'm not going to log in with my 00:12:32.185-->00:12:35.121 admin credentials on this workstation because someone could use Blood Hound and know 00:12:35.121-->00:12:39.525 that I'm on this system and they could potentially get access to that and then compromise my 00:12:39.525-->00:12:45.431 account. So, I'm going to use RDP. And maybe I'll use MFA. Maybe I'll use something like 00:12:45.431-->00:12:50.536 Duo. I pick on Duo. They were in the news for something, I don't remember but, I pick on Duo. 00:12:50.536-->00:12:55.074 Duo's good. But, there's some interesting things that happen when you use a regular 00:12:55.074-->00:12:59.379 workstation to do administration and, as a pentester red teamer you want to be aware of some of 00:12:59.379-->00:13:03.349 those interesting things that happen. Some people are using password vaults. We're going to 00:13:03.349-->00:13:08.554 talk about those. So we have the typical administrator, logs on to their workstation as a 00:13:08.554-->00:13:13.326 regular user. Then they open up the RDP window and they connect to their server. Their domain 00:13:13.326-->00:13:18.197 controller. And they connect as a domain admin. But something interesting happens in the 00:13:18.197-->00:13:25.104 background when this occurs. There's a new file that shows up on the C Drive. Temp file. Well 00:13:25.104-->00:13:29.008 that's kind of weird. Okay but, Windows drops temp files everywhere because it's a crazy 00:13:29.008-->00:13:35.048 OS like that, so who cares. [laughter] Well we'll uh the problem is that in this 00:13:35.048-->00:13:39.852 situation, there's actually a WMI implant that's been dropped on this system. So there's a WMI 00:13:39.852-->00:13:45.458 implant that is looking for the process MSTSC dot EXC and when that executes, it's going to run 00:13:45.458-->00:13:50.596 the script that I'm very helpfully named SCCM health check. Which is probably benign. 00:13:50.596-->00:13:55.601 It's, it's for the good of the system. Let's make the Windows great again, yes. [background 00:13:58.337-->00:14:02.241 laughter] And so what actually happens is this is that SCCM health check powershell script 00:14:02.241-->00:14:07.547 and it actually had a function called get keystrokes. Well that's a little weird. What is 00:14:07.547-->00:14:12.552 that? So, let's look at that file. We open up that file to text file, and it's a keylogger. 00:14:15.321-->00:14:20.193 So as soon as someone opens up that RDP window, it's keylogging whatevers typed in on that 00:14:20.193-->00:14:25.998 keyboard ,and logging it to a file. And it keeps doing that for per a preset amount of time. 00:14:25.998-->00:14:30.403 20 minutes, 30 minutes whatever we set. And then we can use powershell to go through and 00:14:30.403-->00:14:35.708 parsh that and actually extract the information that would be useful for us. So, while the 00:14:35.708-->00:14:39.579 admin thinks their secure because they're not using their admin credentials on that 00:14:39.579-->00:14:45.651 workstation, they're typing them on their keyboard. So, we use MFA right? That'll solve the 00:14:45.651-->00:14:51.023 problem. We're going to MFA the RDP so we got our RDP [distant coughing] MFA'd. Problem solved, 00:14:51.023-->00:14:56.829 right? Okay, so let's look at that. We use RDP, we MFA it. We click on the button send me a 00:14:56.829-->00:15:03.436 push. I get the little pop up on my phone I go yeah that looks fine, approve. But, a second 00:15:03.436-->00:15:10.076 letter I get a second one. Um, I just approved the first one, I'll approve this one. It's 00:15:10.076-->00:15:16.149 probably a hiccup right? I'm sure it's okay. Do I tell anyone about it? Do I deny the first 00:15:16.149-->00:15:21.020 one? Do I approve? Like, what's the situation? How do I make that decision? Or with ADFS, 00:15:21.020-->00:15:26.826 same thing. I get 2 of these. Or maybe I'm the admin and I login in the morning, and I log into 3 00:15:26.826-->00:15:30.863 different systems and I get these prompts in a row. And I don't keep track, I'm like yeah, 00:15:30.863-->00:15:36.669 yeah, yeah, yeah. I gotta get my coffee, right? What happens when I get the pop up on my phone 00:15:36.669-->00:15:41.407 which says log on request and there's no, none of that additional detail? Like, the IP 00:15:41.407-->00:15:47.814 address, the location, the time, the date. Here I just, it just says log on request. Okay, yeah. 00:15:47.814-->00:15:52.819 Approve, oh wait. Approve, oh wait. Approve. Oh, I'm pretty sure I only logged in twice. I'm 00:15:55.021-->00:15:58.558 sure it was just like the phone. It's messed it's been acting up recently. It's it's probably 00:15:58.558-->00:16:02.929 okay. So if we can set up a situation where there's a race contition between the admin 00:16:02.929-->00:16:06.732 clicking the push, and the attacker clicking the push, we might be able to have a 00:16:06.732-->00:16:11.304 situation where the admin end the phase for us. And we, we've seen this before with other 00:16:11.304-->00:16:16.509 things like scams and and uh different situations where they get an email, they get a text 00:16:16.509-->00:16:19.512 message, they're like "Oh! By the way, if you see this just send that code to me. It's, it's 00:16:19.512-->00:16:24.917 okay. Please do that." But there's actually a way you can subvert MV, MFA in certain 00:16:24.917-->00:16:28.888 environments based on what I've seen. And so it has to do with this certain type of 00:16:28.888-->00:16:33.259 configuration which is fairly common. This is the self service portal. This is the 00:16:33.259-->00:16:37.063 configuration where users are able to update their own attributes. And there's very 00:16:37.063-->00:16:40.499 benign attributes like their work phone number, their mobile number, their work specific 00:16:40.499-->00:16:45.137 attributes. Uh, maybe sometimes title, department, whatever. It looks like this. So we have a 00:16:45.137-->00:16:49.642 user, has their mobile number set that way their boss can call them or they can be called when 00:16:49.642-->00:16:54.647 when they're on call. But, the problem is that if the attacker knows that they can change this, 00:16:57.550-->00:17:04.257 and then they do to their number: 8675309. That works well. Uh, so they change it to 00:17:04.257-->00:17:09.362 theirs, what they can actually do is instead of clicking the push button within Duo or the 00:17:09.362-->00:17:13.766 MFA product, they can force a text message to be sent to their phone. This number that they 00:17:13.766-->00:17:19.372 just updated. Because in some environments where they have this this attribute, The admin 00:17:19.372-->00:17:24.143 user has the attribute their mobile phone number associated with their account. And that's 00:17:24.143-->00:17:29.248 associated with their admin account for MFA. So if we can modify that phone number, we can 00:17:29.248-->00:17:35.354 say give me a text message and the admin gets nothing. No notification, at, nothing at 00:17:35.354-->00:17:40.726 all. And we c-can bypass an MFA configuration there's other MFA's that have this as a 00:17:40.726-->00:17:47.099 backup. Duo has it as a backup method that I've seen in a many environments. There's a quick 00:17:47.099-->00:17:52.338 summary for the people that're looking at slides later about how this actually works. There's 00:17:52.338-->00:17:57.343 another interesting thing about Duo is that Duo fails open. So for Duo to work it connects to 00:17:59.612-->00:18:05.718 an API A-record: Duo Security dot com. And that's configured with that company and that 00:18:05.718-->00:18:09.422 instance of Duo within that company. And what happens is when you connect to it and you 00:18:09.422-->00:18:14.527 have that prompt, it's got to check obviously to figure out how to push to you, how to know 00:18:14.527-->00:18:20.833 that you can access it, who you are, etc. What if we block that? If we block that communication, 00:18:20.833-->00:18:26.539 if we can interfere or influence that connection, [coughing] guess what happens. No MFA at 00:18:26.539-->00:18:30.943 all. So thanks to Newpi for this cause he did a blog post earlier this month and uh Jared Hayde 00:18:30.943-->00:18:37.283 pointed this out to me. There's another thing that's interesting here. If we change this default. 00:18:37.283-->00:18:42.188 So if we have access to the registry or something, we can actually turn off MFA for local 00:18:42.188-->00:18:46.625 accounts. So if we compromise the local account on this server, we can connect into that 00:18:46.625-->00:18:50.830 using user and password all day long without any MFA when we're going through the uh, RDP 00:18:50.830-->00:18:56.836 connection. The other interesting thing about MFA is there's an onboarding process. 00:18:56.836-->00:19:02.642 W-what is this o-onboarding process? Well a lot of times you go to a website, you click on 00:19:02.642-->00:19:07.580 something, you click your request and you get an email. Hmmm, that's interesting. The 00:19:07.580-->00:19:11.951 email comes in, they click on the link to approve it and the MFA gets set up for whatever 00:19:11.951-->00:19:16.055 they put in that form. [inaudible music] Alright, but we've if we've compromised that 00:19:16.055-->00:19:21.160 account, that admin account, we have influence over that email. So we can set up a rule to 00:19:21.160-->00:19:26.465 filter it out or we can just delete it so they never see it. So we could potentially add 00:19:26.465-->00:19:31.470 additional devices for MFA, or even switch it over entirely. Because, what happens when they 00:19:31.470-->00:19:34.573 lose their phone? They're at Defcon, they're hanging out at a party and they're like I don't 00:19:34.573-->00:19:41.047 know where my phone is. They've gotta get MFA set up again. A lot of times text, SMS is the 00:19:41.047-->00:19:45.184 back up to that. Okay I have a new phone. I gotta email this person say hey I got, I had to 00:19:45.184-->00:19:49.155 get a temporary phone cause I lost mine, here's the number. Can you just update the MFA? 00:19:49.155-->00:19:54.160 Because um, you know, the executive, Mr Kawasaki says I need this right now, so I've 00:19:54.160-->00:19:59.432 gotta do this. Okay, fine. So there's some recommendations around this. I put this slide 00:19:59.432-->00:20:04.203 up, you can look at em later. But yes, MFA is good. But there are situations and conditions 00:20:04.203-->00:20:08.908 where MFA can be subverted or bypassed depending on how it's configured. You wanna let your 00:20:08.908-->00:20:12.778 customers know about this. You wanna let them know oh you have M-MFA that great, that's going 00:20:12.778-->00:20:17.349 to make my life a little harder but let me take a look at what that actually is doing. And we 00:20:17.349-->00:20:21.187 want customers to better try to think through what are the potential bypass methods cause 00:20:21.187-->00:20:25.024 they know it better than we do. We talk to customers all the time. We're like, let's talk 00:20:25.024-->00:20:28.661 about your MFA and how that works and the setup and what if this happens and they're like, 00:20:28.661-->00:20:32.531 oh yeah we know that this can be an issue. Okay, well I'm gonna write that in my report thank 00:20:32.531-->00:20:39.071 you, here ya go. But what's interesting about this is attackers don't need to bother 00:20:39.071-->00:20:44.844 with MFA at all because nowadays MFA is typically something that's added to R-RDP. So if we 00:20:44.844-->00:20:49.849 can pull and extract that AD admin account name and password, we just can use that to DC sync. 00:20:52.751-->00:20:55.955 We don't have to [inaudible sound] bother RDP at all. [inaudible sound] And that way 00:20:55.955-->00:21:02.695 we can pull any credential we want from active directory. So, customers are gonna think well 00:21:02.695-->00:21:08.501 our admins have to use MFA to do things cause they RDP in. Make sure they understand that the 00:21:08.501-->00:21:14.773 attackers are not bound by the same rules. And there's something about password vaults. 00:21:14.773-->00:21:20.179 So I'm seeing password vaults more and more. I'm probably sure you are as well. It's typically 00:21:20.179-->00:21:24.416 Cyberark or Secret Server and often times there's a reconciliation account. Which is 00:21:24.416-->00:21:29.155 a domain admin account. Which is used to ensure that certain accounts th-that the password 00:21:29.155-->00:21:33.225 vault is managing, staying compliant, have the correct, current password. So if someone 00:21:33.225-->00:21:35.928 has changed the password for that count [inaudible sound] outside of that vault, 00:21:35.928-->00:21:39.398 [inaudible sound] then it goes through and sets it back to what it should be. But that means is 00:21:39.398-->00:21:44.904 that this password vault is running under the context of domain admins or AD 00:21:44.904-->00:21:49.441 administration. So if we can compromise or take over the password vault, we would have 00:21:49.441-->00:21:53.479 access to that account. And Password vaults, more and more are managing these AD admin 00:21:53.479-->00:21:59.051 accounts and have something called a session manager. Which uh is often used. Password 00:21:59.051-->00:22:04.323 vaults are being pushed more and more into being part of the administration workflow. So 00:22:04.323-->00:22:09.795 let's look at one these workflows. Scenario: the admin logs onto their work station as 00:22:09.795-->00:22:15.401 a user. They connect to the password vault via HTPS using their web browser, they then 00:22:15.401-->00:22:20.272 check out the password. They copy it out of their web browser i-into their clipboard. They 00:22:20.272-->00:22:24.710 paste it into RDP, their RDP window and then connect to their admin server, and they have a 00:22:24.710-->00:22:31.217 great day. [distant coughing] I'm sure you see a problem here. There's a password on that 00:22:31.217-->00:22:35.120 workstation and the clipboard. But we can use another power supply function called get 00:22:35.120-->00:22:39.692 clipboard contents. So we can do kind of the same thing as before. Malware has been doing 00:22:39.692-->00:22:43.896 this for years where they're monitoring the title windows in web browsers so if they see 00:22:43.896-->00:22:49.201 certain bank names, they see financial, they see password, they see logon, they screenshot. 00:22:49.201-->00:22:55.107 They key bo key log. You can also do keyboard clipboard straight scraping and then from 00:22:55.107-->00:22:59.478 that they have the information that's going into that web browser. So we can gather that, 00:22:59.478-->00:23:04.917 the same thing sort of happens. We have a second temp file here that has text file, that has 00:23:04.917-->00:23:08.754 passwords. I made up these passwords. These are not from a password vault. Hopefully a 00:23:08.754-->00:23:15.227 password vault would have a much better randomizer than my Star Wars knowledge. But the issue is 00:23:15.227-->00:23:20.032 that we can also on top of this to get timed screenshot. because if we just have the password and 00:23:20.032-->00:23:23.402 we're like I'm not really sure what that's for or what server they're connecting to, but we 00:23:23.402-->00:23:29.275 can combine these 2. We can say alright it was this account, at this time, on this server and 00:23:29.275-->00:23:34.747 here's the password and correlate that. So you want to make sure that organizations and 00:23:34.747-->00:23:38.417 companies know that just because they're using a password vault they are not secure just because 00:23:38.417-->00:23:43.422 they have dropped it into the environment. Second option, this hardens it up. So, we use the 00:23:45.524-->00:23:51.563 password vault as an RDP proxy. So the admin connects to the password vault via HTPS or or 00:23:51.563-->00:23:57.569 some sort of RDP pass pass through connection or RDP direct connection and they use the web 00:23:57.569-->00:24:02.374 browser just like before. And then the password vault then does the RDP connection to the 00:24:02.374-->00:24:07.379 server on the user's behalf. And the user never actually sees that account or credential. 00:24:09.548-->00:24:13.686 Which is interesting because everything's handled by the password vault. But there's a 00:24:13.686-->00:24:17.690 few issues with this approach. First of all, who's logging on to the work station? It's 00:24:17.690-->00:24:22.628 usually the admin user. It's so it's a user account. And then what account is used to connect 00:24:22.628-->00:24:27.833 to that password vault? Again, an admin user. Who has the ability to, or I'm sorry that 00:24:27.833-->00:24:34.340 that connectivity and connection and log on, is that using MFA? Sometimes it is, [distant cough] 00:24:34.340-->00:24:38.977 sometimes it's not. And then of course who has control over that password vault? Who's the who's 00:24:38.977-->00:24:43.315 the administrators of that password vault system? And then ultimately can just anybody on 00:24:43.315-->00:24:49.121 the network connect to that password vault over HTPS or any other connection? What else is 00:24:49.121-->00:24:54.727 running on that system? So I started thinking about this, I'm like there's a lot of 00:24:54.727-->00:24:59.531 dependencies on this web browser right? So what if we just compromise the web browser. We 00:24:59.531-->00:25:05.337 don't have to do anything else. What if we installed, I don't know, an extension and what if 00:25:05.337-->00:25:12.177 we didn't put it in the toolbar? And what if when all it did was it looked for the connection to 00:25:12.177-->00:25:17.483 the password vault system and when that happened, it just set up a secondary connection to 00:25:17.483-->00:25:21.787 another ser system that we own? And that way we could interact with the password vault in a 00:25:21.787-->00:25:26.792 separate hidden web web tab. So as the admin's doing what they're doing, we can go through 00:25:26.792-->00:25:32.965 and copy out credentials for admin accounts. But then the other problem is a lot of times 00:25:32.965-->00:25:38.570 the administrators of the password vault are regular users. I find this too often. 00:25:38.570-->00:25:43.108 It's very simple, you just look for secret server or cyberark and then you look for groups 00:25:43.108-->00:25:47.212 with those names. And you're probably going to find something like cyberark admins with a 00:25:47.212-->00:25:53.585 space or without, or some other things that are in there. These are user accounts. We just have 00:25:53.585-->00:25:59.024 to compromise this user and then I can potentially own the cyberark system. That sounds bad 00:25:59.024-->00:26:04.630 to me. And sometimes there's password vaults in the internet. I guess against the 00:26:04.630-->00:26:08.567 recommendations of the the vendors, people are putting their password vaults on the 00:26:08.567-->00:26:12.871 internet. So depending on your scoping you definitely wanna do some showden to see what other 00:26:12.871-->00:26:17.943 things pop up in their range. And sometimes they're using a really old version of that 00:26:17.943-->00:26:22.948 password vault and it's on the internet. I don't know what credentials they're storing, but 00:26:22.948-->00:26:28.887 they shouldn't be on the internet. So, here's a summary of what I've talked about. 00:26:28.887-->00:26:33.258 Again, making sure that what accounts are accessing the password vault. That they're 00:26:33.258-->00:26:36.962 admin accounts or they're protected with MFA. Making sure that the system is 00:26:36.962-->00:26:42.067 ad-administered correctly. Because as in a a pentester or red teamer, we want to make sure 00:26:42.067-->00:26:46.972 that we're testing out all of these defenses and password vaults are often times are not 00:26:46.972-->00:26:50.909 protected at the same level as say, a domain controller. I can tell you right now that they're 00:26:50.909-->00:26:55.514 not. Very rarely do I see an organization protecting their password vault and putting a lot 00:26:55.514-->00:26:59.451 of extra time and energy into it. A lot of times they just stand it up. And then the 00:26:59.451-->00:27:03.188 vulnerability or the the problem with that, could result in complete and total active 00:27:03.188-->00:27:06.892 directory compromise. [coughing] So, while I'm talking about vulnerabilities, there happened 00:27:06.892-->00:27:11.797 to be one a few months ago for cyberark. This is an RCE so that's what? About as bad as it 00:27:11.797-->00:27:17.970 can get, right? And this h-have to do with serialized dot net object to the authorization HTTP 00:27:17.970-->00:27:24.409 header. There were realized, th-this pentest team realized that they could modify the 00:27:24.409-->00:27:30.015 information that was sent to the this API that's built in part of the web server and connect into 00:27:30.015-->00:27:35.487 it. And what they could do is, they could use why so serial in order to modify it, and they 00:27:35.487-->00:27:40.259 could run ping on that system. They could something else on it, which is pretty interesting. So 00:27:40.259-->00:27:45.330 what about the admin force or the ad, red force? What do we do with that? This is meant to be 00:27:45.330-->00:27:51.737 the m- most secure method of of administering active directory in managing the system. Well, 00:27:51.737-->00:27:56.475 it's high security configuration, it's isolated from the production network with 00:27:56.475-->00:28:01.113 firewalls, encrypted communication. As a one way trust where the production 00:28:01.113-->00:28:07.986 forest trusts this admin forest and ideally, correctly, all of the admin groups in the 00:28:07.986-->00:28:14.526 production forest are emptied except for the one group that's in this admin forest. Well, as a 00:28:14.526-->00:28:19.631 tac emulators it's easy to discover this. We just needed enumerate the trust. Look for an 00:28:19.631-->00:28:25.671 outbound trust for something that looks kind of weird, like that priv. Or, alright, in 00:28:25.671-->00:28:30.943 addition to that we enumerate the administrators group and what we see in this group, is a 00:28:30.943-->00:28:35.647 group from this other domain. [coughing] And if we find that there's no other members of 00:28:35.647-->00:28:38.884 administrators this is very likely an admin forest. Which means that were probably not 00:28:38.884-->00:28:43.522 gonna find anyone that has really good privileges in this environment. In this active 00:28:43.522-->00:28:50.228 directory forest as far as accounts go. But, the other thing to look at is, for this 00:28:50.228-->00:28:54.232 account we noticed that it's in foreign security principals. That means that it's in a 00:28:54.232-->00:28:58.904 different forest. So that'll tell you right away that that account or that group or 00:28:58.904-->00:29:02.541 security principal is not something you can find in that forest. You'd have to try to 00:29:02.541-->00:29:05.644 connect to the other one and if you can't connect to the other one or do any kind of 00:29:05.644-->00:29:12.451 numeration, it's possible that it's an admin forest. So what do we go after? We look at agents, 00:29:12.451-->00:29:17.189 we look at service accounts. One of my favorites in this situation is backups. Everyone 00:29:17.189-->00:29:21.026 overlooks backups. It's a thing that we need so we're gonna make it work we're gonna make sure 00:29:21.026-->00:29:24.029 that it's configured, we're gonna make sure it has the rights it needs. Backup 00:29:24.029-->00:29:29.568 operators gives that backup surge count everything it needs. So here we have a backup 00:29:29.568-->00:29:33.672 computer account and backup operators which doesn't make sense to me but there's also a 00:29:33.672-->00:29:38.477 backup AD service account. Which is pretty interesting. And sometimes these backup accounts 00:29:38.477-->00:29:41.780 are members of the administrators group for the domain because they do a lot of 00:29:41.780-->00:29:48.186 interesting things like per attribute recovery. And so if we look at this backup server 00:29:48.186-->00:29:53.058 account at the top, this computer account. It's in the servers OU and a sub OU of that 00:29:53.058-->00:29:59.431 called backup. Very likely in this environment, first thing I think of is, who manages the 00:29:59.431-->00:30:05.037 server OU? And 9 times out of 10 it's a group called server a-admins or something along 00:30:05.037-->00:30:09.908 those lines. We can compromise one of those accounts. we can compromise this computer and 00:30:09.908-->00:30:14.846 this service account which will enable us to jump up and potentially compromise the 00:30:14.846-->00:30:20.318 domain without ever touching the admin forest. So if you run into an environment where you see 00:30:20.318-->00:30:24.589 it's locked down like this, don't worry about it. Just kind of ignore it for now. Focus on 00:30:24.589-->00:30:30.162 the production AD forest. Because 9 times out of 10 they have not fixed the issues that 00:30:30.162-->00:30:35.567 were inherent in that production AD forest. Someone sold the CIO a lot of the times, here's an 00:30:35.567-->00:30:38.970 admin forest we need this. Now there are some environments where and admin forest makes 00:30:38.970-->00:30:43.975 sense, but that's outside the s-scope of this talk. Did you know, this is interesting to me, 00:30:46.611-->00:30:50.849 the Splunk universal fortier is often installed on their main controller. It's effectively a 00:30:50.849-->00:30:55.654 mini version of Splunk and can run scripts. It's pretty fascinating. So I was trying to 00:30:55.654-->00:30:58.957 look up some more information about this and I found that there was this talk at S-Splunk 00:30:58.957-->00:31:02.627 conference a couple years ago where someone's talking about how you could leverage the 00:31:02.627-->00:31:07.833 deployment server, leverage splung to run scripts, run arbitrary commands. So that 00:31:07.833-->00:31:11.336 means if splunk is in the environment and it's installed on the main controllers 00:31:11.336-->00:31:15.640 depending on the configuration. If we can compromise the Splunk account or an admin account, we 00:31:15.640-->00:31:21.613 could potentially jump to our domain controllers. Pretty interesting. So again this is a 00:31:21.613-->00:31:25.417 summary of the things I just talked about but the key here is identifying those systems in 00:31:25.417-->00:31:30.322 agents that connect to the domain controllers. What agents, what services, what surge 00:31:30.322-->00:31:34.126 accounts have the ability to install and run code on domain controllers? And that answer 00:31:34.126-->00:31:41.032 isn't always obvious. But we can do a lot of that discovery from active directory cause most of 00:31:41.032-->00:31:46.738 this is in the directory. And the problem stems from cross forest administration. A lot of 00:31:46.738-->00:31:52.177 organizations have multiple forests. Well not, not a ton but a bunch of em do. And so they 00:31:52.177-->00:31:56.248 have their production forest, forest A and they have their production forest, forest B, 00:31:56.248-->00:32:01.186 cause I'm really creative in my naming. And there's a trust from forest B to forest A. This 00:32:01.186-->00:32:07.459 untrusted lower level of trust forest. Forest B, trusts all of the accounts in forest A to 00:32:07.459-->00:32:12.931 connect to it and connect to resources. So what is, how this is set up? So the users in 00:32:12.931-->00:32:17.903 forest A connect in. That means that we can have a domain admin in forest A actually administer 00:32:17.903-->00:32:23.942 and control and manage forest B. The problem here is that forest B is an untrusted environment. 00:32:23.942-->00:32:29.648 Often times it's in a DMZ it's a dev test environment. It's for some external configurations 00:32:29.648-->00:32:36.121 some external system. But since the domain admin account in forest A is connecting in via 00:32:36.121-->00:32:40.692 RDP to that forest B environment, the credentials are there. So if forest B gets 00:32:40.692-->00:32:45.430 compromised, or if your have that in scope and you can go after that forest to jump back 00:32:45.430-->00:32:50.702 to A, you can compromise forest B to compromise the domain admin account, to compromise the 00:32:50.702-->00:32:55.707 forest. The problem is that a lot of organizations are going by Microsoft guidance. Microsoft 00:32:57.943-->00:33:04.216 guidance from 10 years ago says this, this is okay. They don't realize and they haven't updated 00:33:04.216-->00:33:09.287 the documentation a lot of times to our new world of how me me cats works. How credentials are 00:33:09.287-->00:33:13.158 stored and managed in most organizations and that the compromise of this could lead to 00:33:13.158-->00:33:17.429 the other. So the recommendations you can give your customer is to please just 00:33:17.429-->00:33:23.702 use a, an external forest account to manager that forest or, use an unprivileged account 00:33:23.702-->00:33:28.707 in our production forest to then manage that other forest. This is not necessary. So let's talk 00:33:31.009-->00:33:33.578 about read only to main controllers. Um, read only to main controllers are very 00:33:33.578-->00:33:36.314 interesting. You probably won't see them on a lot of environments, some of the larger 00:33:36.314-->00:33:40.886 ones you will. Um, there's a very specific circumstance where read only will actually be 00:33:40.886-->00:33:46.591 deployed. Often times at a branch office where it can be trusted. Maybe it's just put 00:33:46.591-->00:33:51.396 next to the the the reception desk or in a closet. They can't trust that it's going to be well 00:33:51.396-->00:33:57.702 protected. Some environments put em in out uh DMZ's but the RDC's connect back in a production. 00:33:57.702-->00:34:01.606 That's not a good idea either. So discovering read only to main controllers, not that 00:34:01.606-->00:34:07.879 complicated. We look for is read only is true or uh or there's another option to do it. We this 00:34:07.879-->00:34:13.318 ones a little easier. We can just use look for the primary group ID 5 21. Or enumerate the 00:34:13.318-->00:34:17.255 membership of read only to main controllers and that'll give us a list of our domain control our 00:34:17.255-->00:34:21.626 read only to main controllers. So what's interesting about read only's is that often times I 00:34:21.626-->00:34:26.831 find these 3 things set up. They've been out all the time but I'd say half the time I find 00:34:26.831-->00:34:31.102 a configuration like this in an environment. They cache more passwords then are actually 00:34:31.102-->00:34:38.043 required, there typically administered by RODC admins which may include user accounts 00:34:38.043-->00:34:42.948 and the passwords for the DS rem account which is the built in administrator account for that 00:34:42.948-->00:34:47.319 single domain controller, is often the same across all the DC's and the read only to main 00:34:47.319-->00:34:52.324 controllers and that's text for later. So there's 4 key attributes on read only domain 00:34:54.326-->00:34:58.363 controllers that we want to enumerate. One is the reveal on demand group which tells it 00:34:58.363-->00:35:02.968 tells it the the RODC and the domain controllers what can actually be replicated. What 00:35:02.968-->00:35:08.039 accounts security principals can have their password data replicated to that RODC and then 00:35:08.039-->00:35:13.712 never reveal means that these can never be replicated. The revealed list is a list of the 00:35:13.712-->00:35:17.716 accounts that have ever had their passwords copied to that read only domain controller. The 00:35:17.716-->00:35:23.088 read only domain controller is a domain controller. It has NTDS just like the writeables and you 00:35:23.088-->00:35:27.492 can extract the information from it just like a writeables. The authenticated 2 is a little 00:35:27.492-->00:35:31.896 interesting because this tells you the accounts that have ever authenticated to the read only 00:35:31.896-->00:35:36.801 and if the read only um doesn't have the password data for that user, it's gonna chain up that 00:35:36.801-->00:35:41.172 authentication request to a nearby writeable. But you still know which which accounts are 00:35:41.172-->00:35:46.578 actually connecting to it. And then based on password replication policy, those are 00:35:46.578-->00:35:50.682 the ones that are allowed on there allowed to have their passwords there are not. So this 00:35:50.682-->00:35:55.587 allowed already received password policy defined at the domain level. A lot of times 00:35:55.587-->00:35:59.791 that's how it's configured. Domain level all of these groups for all alt read only domain 00:35:59.791-->00:36:04.729 controllers. Denied already seed passworded replication group is very often default. And then 00:36:06.831-->00:36:11.636 it's interesting because you can delegate rights to the read only regular server effectively. So 00:36:11.636-->00:36:15.907 Microsoft's recommendation and mine is not to use domain admins to manage replic uh manage read 00:36:15.907-->00:36:21.413 only's. But there full of administrators on the RODC. This is the easiest way they can do 00:36:21.413-->00:36:25.583 it during install. Or interestingly enough we can use the manage by attribute to 00:36:25.583-->00:36:30.588 update who has admin rights of this server. And so we can enumerate that manage by once we 00:36:33.024-->00:36:37.696 get that information about who the admins are, we can then enumerate the membership and we 00:36:37.696-->00:36:42.634 see there's Ray and Pogue here. It's interesting cause these have admin in the name but these 00:36:42.634-->00:36:48.139 are in the regular accounts OU, so we can compromise one of these accounts. Once we do, were 00:36:48.139-->00:36:52.410 an admin on the read only domain controller. So then we start poking around and figuring out 00:36:52.410-->00:36:56.381 what we can find in this environment and we can use the gooey to see what the password 00:36:56.381-->00:37:00.285 caching is but I mean we can get all this information from the attribute itself or the 00:37:00.285-->00:37:04.589 attributes on the read only. But there's an interesting part of the gooey here and this is 00:37:04.589-->00:37:09.694 something I haven't seen anyone wright about before. If you have admin rights in the active 00:37:09.694-->00:37:15.834 directory environment, you can interact with and control read only capability. And one of the 00:37:15.834-->00:37:19.971 things that read only's can do that most people aren't aware of is that can prepopulate 00:37:19.971-->00:37:24.642 passwords on a read only. So let's think of this from a persistence perspective. Let's 00:37:24.642-->00:37:29.481 say we have AD admin rights for like 5 minutes, what we can do is we can remove the curb che 00:37:29.481-->00:37:34.619 che account from the denied replicate, we can remove the administrators group from the 00:37:34.619-->00:37:41.559 denied replicate and then we can click prepopulate. And we can pre populate and say these 00:37:41.559-->00:37:47.398 accounts, I want your to put on the sar DC like now. Potentially, we can replicate 00:37:47.398-->00:37:52.103 the curb che che account password hash to our read only that we control. And if we can 00:37:52.103-->00:37:56.241 stay on the read only even if they can take away everything else we have, no one's going to 00:37:56.241-->00:38:02.981 notice this. So how do we figure out what password hashes are on a read only? Where there's an 00:38:02.981-->00:38:07.318 attribute called MSDS revealed users and its looks like this which looks very difficult to 00:38:07.318-->00:38:13.024 read so let's make it simpler. Basically here's Han Solo, he's logged in a bunch of times. 00:38:13.024-->00:38:17.162 Every time he logs in, the read only domain controller tried to authenticate him with a password 00:38:17.162-->00:38:22.500 that it has and if it can, then it's good. If it's not certain what going on, it'll track each 00:38:22.500-->00:38:27.338 instance of that authentication so we can see that there is a password has version and so the 00:38:27.338-->00:38:32.277 read only will update the password that it has everytime that user logs on if it needs to 00:38:32.277-->00:38:36.781 to make sure it has the current password for that user. So we can use powershell and break 00:38:36.781-->00:38:42.287 this down and identify all of the un-unique accounts on this read only domain controller. And 00:38:42.287-->00:38:45.657 one of them's pretty interesting because it's account provisioning. Well that sounds 00:38:45.657-->00:38:51.462 like an account that could have some rights so lets lets take a look at that. So we look at it a 00:38:51.462-->00:38:57.802 little bit close more closely and it has an S SRV er SVC name to it. So we're going to use a 00:38:57.802-->00:39:03.441 power of you function called invoke ACL scanner to look for anything in this domain that has 00:39:03.441-->00:39:10.315 permissions for this account. SVC account to see what it can do. And the first thing that we 00:39:10.315-->00:39:17.155 find is that it has generic all rights to this groups OU. Well generic all and active directory 00:39:17.155-->00:39:23.461 lingo just means full control. Kay so we have password has for the surge account that has full 00:39:23.461-->00:39:29.667 control of the groups OU. Okay well what's in that groups OU? It's the RODC admins which okay 00:39:29.667-->00:39:34.806 I don't really care about that but there a server admins group at the bottom here. Server 00:39:34.806-->00:39:40.278 admins probably has rights to a bunch of things like maybe the password vault. So we dig into 00:39:40.278-->00:39:45.650 server admins and we find that there's a group policy that's actually adding this server 00:39:45.650-->00:39:51.389 admins group to the local administrators group on all of the computers in this OU. So at 00:39:51.389-->00:39:57.195 this point, just because we compromised one user that had RODC admin rights we were able 00:39:57.195-->00:40:02.200 to compromise all of the servers that are in this server OU. But what else can we get? What else 00:40:04.936-->00:40:09.540 can we find off in RODC depending on the configuration? And if you're thinking well 00:40:09.540-->00:40:14.913 RODC's they don't c-cache passwords by default. You're right they don't. But, pretty 00:40:14.913-->00:40:20.418 much 99 percent of the time in order to effectively use RODC's you have to turn on password 00:40:20.418-->00:40:24.789 cache. Because it cannot authenticate users without their password data and computer 00:40:24.789-->00:40:30.395 accounts as well. So in order for an RODC to authenticate a user they need that user's 00:40:30.395-->00:40:36.167 password hash and the computer p-password hash that the user is as authenticated from. So RODC's 00:40:36.167-->00:40:41.472 can be a gold mine because organizations ignore them a lot of the time. So let's look again 00:40:41.472-->00:40:45.476 at the at this again. W-What else can we find in here? That's really interesting. There's a 00:40:45.476-->00:40:49.380 computer account that says admin in the name. Let's look that let's look at that, what is 00:40:49.380-->00:40:55.286 that? Well we do some discovery do some more digging in and we discover that this admin server, 00:40:55.286-->00:41:01.025 or admin in the name is the admin server. All of the admins use this server. Somehow this 00:41:01.025-->00:41:07.098 computer account password for this admin server ended up on this read only. And so we just 00:41:07.098-->00:41:13.237 go ahead and dump the password hash for this account this computer account and then we can 00:41:13.237-->00:41:19.010 create a silver ticket. Create a couple of silver tickets and then we can do powershell 00:41:19.010-->00:41:24.349 remoting once we have those Kerberos tickets on that on on our system. Just because we were 00:41:24.349-->00:41:30.154 able to compromise that RODC and get that password hash. So once we get on to that we can implant 00:41:30.154-->00:41:34.425 whatever we want. We can start dumping credentials from Lsass because all of our admins are 00:41:34.425-->00:41:39.430 going to be logged in on that admin server. [inaudible sounds] And then there's one other thing 00:41:42.500-->00:41:47.205 that's pretty interesting. Is I mentioned the DS rem account and I've talked about this before. 00:41:47.205-->00:41:52.777 The DS rem account is that built in default admin account on domain controllers. Uh, when in 00:41:52.777-->00:41:57.582 a domain admin is setting up a new domain controller they type in the credential or a password 00:41:57.582-->00:42:01.552 for this DS rem account and it's a it's account is a break glass account incase you need to get 00:42:01.552-->00:42:05.556 on the domain controller. Typically you need to restart the domain controller in to DSRM 00:42:05.556-->00:42:10.395 mode. Directory services restore mode in order to use this account and do anything with it. 00:42:10.395-->00:42:16.067 But there's a registry key as of 2008 where you can log in with this uh, [inaudible word] not on 00:42:16.067-->00:42:20.204 by default but you can configure this registry key as of 2008 where you can log on to the 00:42:20.204-->00:42:24.175 domain controller without restarting it in to this special mode. You can log on from the 00:42:24.175-->00:42:29.914 console. Depending on the registry key, if it's set to 1 you can logon when the active 00:42:29.914-->00:42:36.487 directory services are stopped. If it's set to 2, you can log on anytime you want. If it's set to 00:42:36.487-->00:42:42.026 2 you can actually pass the hash using this password hash on the network and there are 00:42:42.026-->00:42:47.098 environments that have that configured. So, it is entirely possible that you could 00:42:47.098-->00:42:52.103 compromise the environment from just taking over a dingle RODC. So some key recommendations here 00:42:55.006-->00:42:59.510 for you to give to your customers and and for uh redteamers and pentesters make 00:42:59.510-->00:43:03.114 sure that you're actively looking for all the AD admins you can find. See what you can 00:43:03.114-->00:43:07.318 discover. Correlate these user to admin accounts because if you're using a net session, 00:43:07.318-->00:43:12.590 enumeration or group membership uh to see where users are or to see what computer they're logged 00:43:12.590-->00:43:16.227 on to, you might not be seeing the full picture and there's a lot more that could be there. 00:43:16.227-->00:43:21.032 Look at MFA, look at password vaults see what how they're configured. Poke the edges 00:43:21.032-->00:43:25.403 around them and then look at the RODC's if there's any in the environment because they're 00:43:25.403-->00:43:29.974 rarely configured in a very secure manner. That's been my time. Thank you so much for 00:43:29.974-->00:43:34.979 yours. I think I have some time for questions. [applause]