00:00:00.200,00:00:06.640 >>Well we have a great opportunity to see the best looking speaker. Oh, here he is, 00:00:06.640,00:00:10.510 sorry. At least that’s what he tells me. So uh- anyway. We’re going to be learning a little 00:00:10.510,00:00:15.515 bit about some uh- active directory attacks uh- this afternoon. >>Thanks. [Applause] 00:00:21.622,00:00:26.627 >>Hi DefCon. [laugh] So well- I’m Nikhil Mittal and I’m going to talk about uh- minimal rights 00:00:34.801,00:00:40.274 and ACE for active directory dominance. Uh- so let’s get started. A couple of things 00:00:40.274,00:00:46.747 about me. I’m a hacker. I- I like to research stuff when it comes to windows security, 00:00:46.747,00:00:51.752 mostly on the userline part. Uh- thereto on powershell on active directory et cetera. Um- I’m a 00:00:55.122,00:01:00.060 speak, I train at conferences, um- I’m with Pen Tester Academy dot com. Um- you can find me on 00:01:02.796,00:01:07.801 Twitter as nikhil underscore m i double t. So please take a pic and tag me there. Uh- I blog 00:01:10.604,00:01:16.710 regularly on Lab of a Penetration Tester dot com and I made a few open source toolkits 00:01:16.710,00:01:23.216 for uh- for offensive security research like Nishang. Uh- there was one- uh- there is one on- 00:01:23.216,00:01:28.755 for the defensive part as well called deploy deception which I released last year. Uh- I 00:01:28.755,00:01:35.195 generally like to- to learn and research about methodologies to break into- into environments, 00:01:35.195,00:01:39.766 of course where I have the permissions to do so. I’ve previously spoken at DefCon of 00:01:39.766,00:01:44.771 course at uh- BlackHat and a few more conferences. So what we are going to discuss today is, uh- 00:01:47.541,00:01:52.879 this is the agenda right? That is, we will begin with a very quick introduction to what ACE 00:01:52.879,00:01:59.453 is, or ACLs are, when it comes to the access control model in active directory. Uh- then the 00:01:59.453,00:02:04.658 philosophy of uh- minimal rights; what- what- what do I mean by minimal rights? Why are 00:02:04.658,00:02:09.663 they required? Uh- then we uh- have a quick look at uh- a toolkit called RACE, which I’m 00:02:12.032,00:02:18.438 going to uh- release with today’s talk. Then persistence, how we can use uh- different 00:02:18.438,00:02:25.012 methodologies uh- commands from RACE for persistence and on demand privilege- on demand 00:02:25.012,00:02:31.151 privilege escalation. Uh- these would be covered both for non-domain controller machines 00:02:31.151,00:02:37.024 and member uh- both for domain controller and member machines in active directory. Then we 00:02:37.024,00:02:42.863 look for some stacks- uh attacks just specific to the domain controller. And then a quick 00:02:42.863,00:02:47.868 look at defenses, past work, future, et cetera. So uh- those of you who are not really 00:02:51.371,00:02:56.376 familiar with how access control model works in active directory, uh- this is how it works. When 00:02:58.478,00:03:03.417 you want, or a process wants to access a resource, which in the uh- SID lingo is called 00:03:05.419,00:03:10.424 securable, whenever you want to access that, uh- your thread or process token has the following 00:03:12.793,00:03:18.432 uh- information. It contains your user SIDs, that’s physical, right? Your user SIDs, your 00:03:18.432,00:03:24.438 group SIDs, uh- privileged information and other access information like CDs, et cetera. 00:03:24.438,00:03:29.443 When you- the process token presents uh- itself to the target object or the securable, 00:03:32.212,00:03:34.815 the system does the following checks. Um- it compares with- now the system has an ACL, an 00:03:34.815,00:03:36.817 access control list. The one in which we are interested in right now is called DACL, which is- 00:03:36.817,00:03:39.486 it’s a list, it is made up of entries. Now the system checks each and every ACE for any 00:03:39.486,00:03:42.222 particular specific allow or deny entry for your access token. It keeps checking for 00:03:42.222,00:03:44.891 each entry as long as it finds either an allow or a deny. That’s- that’s how basically 00:03:44.891,00:03:46.893 access control model works. Now when we talk about uh- let’s say, uh- there’s an access 00:03:46.893,00:03:51.898 control entry let’s say for each and every trustee, right? The list contains entries for 00:04:00.640,00:04:05.645 different trustees. Now when we talk about let’s say domain admins, we say domain admins 00:04:15.322,00:04:20.327 have, and we have seen that, we know that, domain admins have privileges or permissions over 00:04:30.704,00:04:35.709 all of the objects or most of the objects in a domain. So why is that? It is because domain 00:04:38.044,00:04:43.049 admins have entries or ACEs on multiple objects, on all of the objects in- in- in the entire 00:04:45.452,00:04:50.457 domain. Right? That is what allows domain admins to be domain admins, right? To control 00:04:53.059,00:04:58.064 different objects. Now that was- I’m now going to uh- dive deeper into how DACL or how ACLs look 00:05:01.968,00:05:06.973 like, et cetera. Uh- that I save for a longer discussion. Now, once we understand that, once we 00:05:09.109,00:05:14.114 know that, how access control model works in active directory, how important ACEs or ACLs are, 00:05:17.284,00:05:24.157 then we can begin a discussion on minimum permissions. So, domain admins or other high 00:05:24.157,00:05:30.096 privileged groups or users usually have full control permissions over different 00:05:30.096,00:05:36.536 objects on machines or in domain. Now that’s good right? Full control is awesome but that 00:05:36.536,00:05:42.809 is something which we do not desire all the time. Why don’t we stick to only those 00:05:42.809,00:05:49.549 permissions which are required for a specific attack? Right? Uh- for example if you want to 00:05:49.549,00:05:55.488 reset password for a domain user, do you really need full permissions, or full control of 00:05:55.488,00:06:01.628 generic all, over that particular user object? No we don’t. And that is something 00:06:01.628,00:06:06.733 what the philosophy, or methodology of minimal permissions is. We stick to 00:06:06.733,00:06:13.440 whatever we require, for a particular task, so that we are a lot more stealthy, a lot more 00:06:13.440,00:06:19.479 silent, and we can still get the objectives or the goals of an assessment, or an attack, or 00:06:19.479,00:06:24.484 whatsoever. So, for example, let’s- let’s take this as an example. You want to connect to 00:06:28.622,00:06:33.593 a domain controller or any machine using powershell remoting. Now by default, you 00:06:33.593,00:06:40.367 must be a part, a member of the local administrator’s group. Right? Now, why is it possible? 00:06:40.367,00:06:46.239 Uh- this is because administrators, or the local group administrators, it has 00:06:46.239,00:06:52.879 full access on the ACL of the powershell endpoint. We’re taking it just as an example. It 00:06:52.879,00:06:58.084 has full control over the- the ACL of the powershell endpoint to which you connect, which 00:06:58.084,00:07:03.023 allows them to access it. Now, what if we add permissions for a user which we control which is a 00:07:05.592,00:07:12.132 proxy user or- or- or a uh- virtual user. We add the permissions for that particular 00:07:12.132,00:07:17.137 user to the ACL of the powershell remoting endpoint, but in place of having full 00:07:17.137,00:07:22.108 control, which is not required here, we go ahead and selectively choose the 00:07:22.108,00:07:27.113 permissions required. That is what the minimum permissions part is. Right? And throughout 00:07:29.182,00:07:33.753 the talk, that is something in which we are going to use. We sought out what minimal 00:07:33.753,00:07:40.026 permissions or rights are required to access a particular resource or a securable object, 00:07:40.026,00:07:45.465 and then we uh- modify the permissions, get those privileges and execute the task. 00:07:45.465,00:07:50.103 We are going to avoid full control or gen control, as long as possible. Now, we are going 00:07:50.103,00:07:52.105 to use the RACE toolkit, which would be available on my github repository. It is a powershell 00:07:52.105,00:07:57.110 module which you can use to- uh which has uh- a lot of functions and code which you can use to 00:08:07.987,00:08:12.992 execute attacks which we are going to discuss. Uh- RACE makes use of Microsoft sign active 00:08:14.994,00:08:18.732 directory module, the one in which you will find on any machine where the AD RSAT set is 00:08:18.732,00:08:20.734 installed. So I maintain a meter of that, or you can copy it from any domain controller or any 00:08:20.734,00:08:25.739 machine where the- the AD RSAT is installed. Right? So let’s get started. Uh- we are going to 00:08:39.152,00:08:45.392 discuss both persistence and privilege escalation. Uh- please note that we are not going to 00:08:45.392,00:08:50.397 use any patchable exploit. There is no exploit discussion in the talk. In cases we talk 00:08:52.899,00:08:58.838 specifically about modifying ACLs, we have to assume that on member machines we have the 00:08:58.838,00:09:03.243 local admin privileges and on the domain controllers we have the domain admin privileges, 00:09:03.243,00:09:08.248 right? So by the- when we do the modification of ACLs and when we abuse that, in- in a real world 00:09:11.084,00:09:16.489 assessment on a- during a real world attack, there is a time gap, right? You once the local 00:09:16.489,00:09:20.360 admin privileges, now you need to hold onto that. That is something which we are going to 00:09:20.360,00:09:24.964 discuss so please don’t be disappointed that we have those privileges, right? This is a 00:09:24.964,00:09:30.703 persistence or a backdoor scenario which we will be discussing in- in most of the 00:09:30.703,00:09:37.444 cases. Uh- so we’ll begin with very simple, well known techniques, not well known ones, 00:09:37.444,00:09:43.883 probably. Simple ones, then we’ll move onto a bit more complex ones as we move ahead. 00:09:43.883,00:09:49.055 So let’s pickup powershell remoting the- the thing which we started the discussion. Now, to 00:09:49.055,00:09:55.395 allow code execution, without administrator rights, we need to modify the permissions of the 00:09:55.395,00:10:01.100 ACL of the powershell endpoint, right? If you run, for example, get PSSession configuration on 00:10:01.100,00:10:07.106 any windows machine, you will get a list of the remoting endpoints enabled on that 00:10:07.106,00:10:13.079 particular box. So we are going to modify the ACLs of the default one- the default 00:10:13.079,00:10:19.319 endpoint, and provide one of all- or one of the users Vcontroller privileges to 00:10:19.319,00:10:24.324 connect to that machine. So, from that RACE toolkit, if you use the following command, uh- 00:10:26.426,00:10:32.332 we are trying to add or modify the privileges, uh- so to modify the ACL of the powershell 00:10:32.332,00:10:38.238 remoting on the machine specified in the computer name parameter, for the user labuser. 00:10:38.238,00:10:43.243 Right? So uh- let’s have a look at it’s demonstration. So what we are going to do, we’re going 00:10:55.455,00:11:00.393 to modify the ACL of the default uh- powershell remoting endpoint on a domain controller with the 00:11:03.296,00:11:07.800 domain admin privileges, right, that’s what we’re looking at. So we use overpass the hash to 00:11:07.800,00:11:12.805 start the session as domain admin. Uh once we- uh once we have those privileges, uh we can 00:11:23.983,00:11:28.988 go ahead and modify the ACL on the domain controller, using this command. Right? You may uh- 00:11:41.834,00:11:48.041 get this error when you run this particular command because we modify the ACL of the powershell 00:11:48.041,00:11:52.845 remoting endpoint for this current session, so you may get an i o operation error which we 00:11:52.845,00:11:57.850 can safely ignore. Now what we did was to modify the ACL for the labuser, now as labuser, 00:12:01.654,00:12:08.094 that is the current user for this particular uh- machine. We can access the domain 00:12:08.094,00:12:13.099 controller. Right? You would like to keep in mind that the privileges will still be of that 00:12:16.336,00:12:22.475 non-special user. Right? So could you please give me a ‘so what’ really loud? >>[inaudible] 00:12:22.475,00:12:27.480 >>Thank you. So we’ll see uh- what is the benefit of having privileges- whoops, privileges 00:12:32.719,00:12:37.724 on a domain controller, even as a normal user. Right? So similarly, we can go for WMI. 00:12:49.035,00:12:55.108 WMI if you uh- know that- WMI is a two part authentication process. You must have 00:12:55.108,00:13:00.346 privileges one, to connect to the DCOM endpoint, second, you must have the privileges or 00:13:00.346,00:13:06.386 permissions to connect to a particular namespace. So when we do this similar stuff for WMI we 00:13:06.386,00:13:13.092 need to modify multiple ACLs. For the DCOM remote- DCOM endpoint, as well as the WMI 00:13:13.092,00:13:18.097 namespaces. So, WMI is another method of replicating this similar attack. Now one failure 00:13:22.869,00:13:29.208 which I would like to uh share with you is for the WMI permanent event consumers. So 00:13:29.208,00:13:35.381 WMI supports permanent event consumers which are fantastic for persistence. They persist 00:13:35.381,00:13:41.254 across reboots, execute your commands with system privileges, which uh- is desirable when you 00:13:41.254,00:13:46.259 want to backdoor a target machine. Now when I tried the same stuff with modifying the 00:13:48.695,00:13:54.701 ACL of the root subscription namespace, which is used by the permanent event consumers, it 00:13:54.701,00:13:59.706 was possible to create permanent events but it was not possible to get a command execution out 00:14:02.375,00:14:08.047 of it. Right? So if- if- uh- this interests you, you may like to explore this further, but if 00:14:08.047,00:14:13.052 you really have used WMI, you really know it well, you may like to correct me later on. 00:14:16.122,00:14:21.861 Now, what if you would like to have on demand privileges escalation. That is, we have 00:14:21.861,00:14:26.866 persistence, with privileges, for example, the two scenarios we saw, powershell remoting and 00:14:29.302,00:14:35.007 WMI, in that case we did not have local admin privileges or administrator privileges, with 00:14:35.007,00:14:40.012 persistence. What if you would like to have the persistence along with high privileges? In 00:14:42.115,00:14:47.086 that case one really useful option is using, or abusing, Windows services ACLs. Now ACLs 00:14:47.086,00:14:53.259 have their own- uh sorry. Services have their own ACLs. Right? Or security descriptors, 00:14:53.259,00:14:58.264 we can modify that as well, to get backdoor support systems with administrative privileges. 00:15:01.701,00:15:06.639 Now, unlike the WMI and powershell remoting part, which no one really cares about, there 00:15:06.639,00:15:13.346 is minimal logging, other than the access logs, there is absolutely no logging by default 00:15:13.346,00:15:18.217 when you modify ACL of a powershell uh- remoting endpoint. But of course in case 00:15:18.217,00:15:23.923 of services, this is not going to be the same, this is a bit- not a bit, this is noisy in the 00:15:23.923,00:15:28.928 logs. As simple as that. Now there could be uh- a plethora of services which are entrusting 00:15:31.264,00:15:36.969 service control manager or SCM is the one which is of interests, which is of the 00:15:36.969,00:15:42.575 interests, right? SCM provides, this is the service manager right? It provides the ability 00:15:42.575,00:15:49.382 to create, configure, start, stop services. So if we have Generic All, in this case we 00:15:49.382,00:15:55.755 need generic all, if we have generic all permissions on the SC manager’s service, we can 00:15:55.755,00:16:00.693 create, config, start, stop services, uh- which means that, for example, we can create a new 00:16:03.529,00:16:10.503 service, which runs a system, and a user in which we control, has the permissions to start and 00:16:10.503,00:16:17.343 stop the service. Right? Or we can simply go ahead, create a service, and provide a user 00:16:17.343,00:16:22.582 Vcontrol, generic all permissions on that particular service. What would that mean? 00:16:22.582,00:16:28.588 That means the user we control can modify the configuration of the service, make it run as 00:16:28.588,00:16:33.593 system, and change the executable part of the service to run the payload we desire, 00:16:35.795,00:16:39.065 right? That is something in which we are doing here. Uh- we provide a user, once again we 00:16:39.065,00:16:41.534 are going to use labuser as a proxy user all the time. We provide labuser rights which are 00:16:41.534,00:16:46.539 equal to what the built in administrators have on SC manager on the target machine. 00:16:49.108,00:16:54.113 That’s one. Then, we create a new service, evil svc for example, which runs as local 00:17:02.455,00:17:07.460 system, and labuser has permissions to start it or configure it. Right? Once the 00:17:10.162,00:17:15.434 service is started, there is another user, you can use the same user or another proxy user 00:17:15.434,00:17:21.073 to the local administrator’s group. So, really not silent, but that is the easiest way you 00:17:21.073,00:17:26.078 can abuse uh- the- the services. Right? Now if uh- I mean if you use SC manager, creating a 00:17:30.883,00:17:37.456 service is still a lot more noisy than simply deconfiguring a service. So in place of that, 00:17:37.456,00:17:42.628 what we can do, because we are assuming the local administrator privileges on the target 00:17:42.628,00:17:47.633 machine, we reconfigure an existing service, and provide our proxy user local- uh sorry- 00:17:50.503,00:17:57.310 all permissions on that particular service, so that, our proxy user can reconfigure the 00:17:57.310,00:18:02.248 service, run it as system, and point it to the payload we want. Right? So that is the- uh- the 00:18:04.483,00:18:09.488 service permissions issue. Now let’s have a look at this one. So. So we start uh- a partial 00:18:26.906,00:18:31.911 session with the privileges of a user who is a local admin on the target machine. Uh we load up 00:18:43.856,00:18:48.861 the- the risk toolkit and modify the ALG service on target machine so that the user- 00:18:56.002,00:19:00.940 labuser which we control has the permissions to change whatever we want on the target service. 00:19:03.342,00:19:08.347 So here you can see that uh- the- the SDDL of the ALG service has these entries for the built 00:19:11.417,00:19:16.689 in administrator’s group right? This B A stands for the built in administrator here. So what we 00:19:16.689,00:19:21.694 simply did was to copy that entry and provide it to one of the users which we control, 00:19:25.264,00:19:30.269 right? Once that is done, then we- as labuser we go ahead and uh- run the plain command. So, 00:19:37.810,00:19:42.815 as uh the user, for which we modified it. [inaudible] So we run it. And we changed the 00:20:04.970,00:20:09.475 configuration of the ALG. How could we do that? Because we modified the SDDL or ACL of the 00:20:09.475,00:20:14.480 target service. So all of the ser- service start fail. Let’s try to access the target machine 00:20:17.083,00:20:22.221 now using powershell remoting because by default we need administrator privileges for 00:20:22.221,00:20:27.226 that. So we done this. We can successfully connect to the target machine. Just to be sure, 00:20:30.463,00:20:34.900 let’s have a look at the uh- membership of the local administrator’s group there. You 00:20:34.900,00:20:39.905 can see that our current user, or proxy user has access to uh. It’s a member of the local 00:20:44.710,00:20:49.715 administrator’s group, right? Now, we have seen two interesting methods, three 00:20:55.221,00:20:59.959 interesting methods. So powershell remoting and WMI provides two of the ways to 00:20:59.959,00:21:05.865 access a machine. Third one is remote registry. Now remote registry in not enabled by 00:21:05.865,00:21:10.870 default on the desktop was like Windows 10, but it is enabled on the server versions of Windows. 00:21:15.007,00:21:20.713 Now we can use uh- registry stores a lot of interesting information. It provides you uh 00:21:20.713,00:21:23.315 command execution privileges, for example we can use the permissions on uh- uh- well 00:21:23.315,00:21:25.317 known autoruns keys to get command execution. Now you will likel to notice that not only 00:21:25.317,00:21:27.319 the domain objects, but services and registry keys have permissions as well. So as a 00:21:27.319,00:21:29.321 very simple example, uh- we can modify ACLs of the popular, or the infamous, uh- remote 00:21:29.321,00:21:31.323 registry key, which allows us to connect to remote registry even without having local admin 00:21:31.323,00:21:34.493 privileges. And then, we modify the permissions of the image file execution key. What does 00:21:34.493,00:21:38.197 this mean? What uh- with this command executed on any target machine, this- this is the 00:21:38.197,00:21:42.134 famous sticky keys option, right? I chose this as a very simple example. You modify these 00:21:42.134,00:21:44.436 keys on a machine. The command also disables NLA. If you use MSTSC or RDP to connect to this 00:21:44.436,00:21:46.605 machine you will get the login prompt and then you press shift keys five times, then you will 00:21:46.605,00:21:48.607 have your payloads executed as system. That’s what- what it does. Very famous, probably 00:21:48.607,00:21:50.609 maybe detected by some antivirus. Even that is possible but I chose this one because 00:21:50.609,00:21:52.611 this is an example which is the most easiest one to understand. Now when we discussed WMI I say 00:21:52.611,00:21:54.613 that WMI is a two part authentication. We need to be able to authenticate DCOM 00:21:54.613,00:21:56.615 endpoint as well as to the namespace. Now, if we are already modifying the ACLs of 00:21:56.615,00:21:58.617 the DCOM endpoint, why don’t we use that to execute commands on the target machine. That is 00:21:58.617,00:22:01.687 exactly what this particular command does. You modify the privileges or ACL- uh- ACL of 00:22:01.687,00:22:04.657 the DCOM endpoint, and then you can run command on that particular machine using DCOM. 00:22:04.657,00:22:07.026 There is no need to modify ACLs of any namespace whatsoever. Right? Now another interesting 00:22:07.026,00:22:09.195 option when- when it comes to powershell remoting, Microsoft introduced JEA, which is also 00:22:09.195,00:22:11.964 pronounced or called as jaw. Just enough administration a few years back. Now jaw which is a 00:22:11.964,00:22:15.668 DSA technology, what it does is, it is useful for allowing non admins to do admin tasks. And 00:22:15.668,00:22:18.771 how- how does it happen, how it works? By default, anyone connecting to the jaw endpoint 00:22:18.771,00:22:21.340 using powershell remoting will have admin privileges, regardless of what privileges 00:22:21.340,00:22:26.345 they have in the domain. On the domain machines, they will have whom’s server is connecting to 00:22:54.273,00:22:59.311 the jaw endpoint, will have local admin privileges and on the domain control- controller, 00:22:59.311,00:23:05.184 they will have the domain admin privileges. Right? Which does- doesn’t sound right. But the 00:23:05.184,00:23:11.490 access is controlled by the number of commands or command lets uh- they can run. Right? 00:23:11.490,00:23:17.429 Whenever you configure a jaw endpoint, you- you need to define a rule capability. That 00:23:17.429,00:23:22.434 rule capability seemingly limits what commands you can run on a target machine, even with admin 00:24:22.761,00:24:27.766 privileges. For example, you can- let’s say you just want to restart permissions to a group 00:24:48.287,00:24:53.292 or a user, you can simply expose just simple command let restart dash computer with a single 00:24:55.327,00:25:00.265 parameter call that’s a dash force. That is the uh- type of control which jaw provides you. 00:25:03.369,00:25:08.374 Right? Uh- so as I said, it is a four four domain controllers, the domain admin privileges you 00:25:10.542,00:25:16.582 get are limited to the domain controller. You cannot access any network resource with those 00:25:16.582,00:25:21.587 privileges. Now how do- uh- how are the privileges provided to anyone connecting to the- to the 00:25:25.023,00:25:31.697 jaw endpoint? There is a virtual user created for uh- every connection. Now the problem of 00:25:31.697,00:25:36.702 course, is if you specify asterisk, while defining the rule capability file, it is 00:25:39.438,00:25:45.411 possible to expose all the commands, not only the powershell commands or command 00:25:45.411,00:25:51.550 lets, but also the built in commands. The ex- executables, that is also poss- that can also 00:25:51.550,00:25:58.223 be exposed on a jaw endpoint. Because we are discussing a persistence mechanism, or on 00:25:58.223,00:26:03.095 demand privilege escalation with persistence, what we are going to do, we are going to, we are 00:26:03.095,00:26:08.100 going to create or register a new jaw endpoint which allows everything- every command, every 00:26:10.702,00:26:15.607 command let to anyone who connects to that particular endpoint. And the results are 00:26:15.607,00:26:20.612 terrific, or uh- terrifying, depending on what side you belong. Once again, if you have 00:26:23.215,00:26:29.221 administrative privileges on a machine, on a member machine, or on a domain controller, we can 00:26:29.221,00:26:34.226 create a new remoting endpoint, or a JEA endpoint and then we can simply go ahead and connect 00:26:36.495,00:26:42.234 to this. Here you can see that, in place of normal Enter PS session, and the computer named 00:26:42.234,00:26:48.006 parameter, we are also adding a configuration name. This is the name of configuration which gets 00:26:48.006,00:26:53.011 added onto the target machine. Are there any logs? Uh- not at all. This is as silent as it can 00:26:55.948,00:27:01.353 be. Of course there will be access logs on all the time. A four six two four, and a four 00:27:01.353,00:27:06.358 six three four, and, that would be for this virtual user right? So it would still be possible to 00:27:09.328,00:27:13.565 track you if someone is looking at the access logs. Other than that, there are- I mean access 00:27:13.565,00:27:20.172 logs are there even if you run nat user slash dom. So that is something which uh- is not very- 00:27:20.172,00:27:25.177 not really standout. Now let’s have a look at its demo. So what we are going to do here, is we 00:27:33.051,00:27:39.791 are going to create a JEA endpoint onto the domain controller, so that when we 00:27:39.791,00:27:44.796 connect to it, we get local admin privileges on the DC, right? So we done this on the 00:27:47.933,00:27:52.938 DC. Here you can see that we create Microsoft dot powershell 64 uh- config. [inaudible] When 00:28:00.479,00:28:05.484 we run this particular command, as the user which we control, you can see that we can access 00:28:11.557,00:28:17.896 the DC. Let’s have a look at our privileges. So we are running as this particular virtual user, 00:28:17.896,00:28:22.901 and if you have a look at our privileges, those are useful for local administration on the DC, 00:28:28.173,00:28:34.980 but not useful for accessing any network resource. Right, so this is uh- this is very useful and 00:28:34.980,00:28:39.985 very silent. So, now we can go ahead, we can uh- the registry stores a lot of uh- interesting 00:28:51.797,00:28:57.336 credentials as well, so what we can do by modifying permissions for multiple registry keys, we 00:28:57.336,00:29:01.573 can go ahead and extract credentials from them. What are the credentials stored in 00:29:01.573,00:29:07.980 registry? Machine account hash, local users hash, uh- domain cached credentials. So right now 00:29:07.980,00:29:13.852 we are going to make user uh- code from DAMP toolkit, that’s what included in the RACE 00:29:13.852,00:29:20.158 toolkit as well. So by using following commands, we can access- or we can extract 00:29:20.158,00:29:26.498 information from the registry. Now to an- answer the ‘so what’ which I asked you guys to shout, 00:29:26.498,00:29:32.037 if- even if remote registry is not running on the target machine, or it is filtered out 00:29:32.037,00:29:38.343 by the firewall, we can simply go ahead, modify the- the powershell remoting ACL, then we 00:29:38.343,00:29:43.348 can run the commands to extract credentials from the registry without having domain admin 00:29:45.617,00:29:50.188 privileges. And what is the least which we can do with the machine account hash of the DC? 00:29:50.188,00:29:55.193 At least the DC sync attack. Right? So I- I think I’m running out of time so let’s skip out 00:29:59.531,00:30:04.536 uh- passed the demo. Another interesting group is DNS admins. DNS admins is basically uh- the 00:30:06.872,00:30:08.874 domain admin if you are running DNS service on your domain controller. It is also not a 00:30:08.874,00:30:10.876 part of the protected users group. So we can either modify the ACL of the domain uh- the 00:30:10.876,00:30:12.878 DNS object, or the domain uh- DNS admins group is not a group. And we can have our privileges 00:30:12.878,00:30:16.982 back. This is very specific to the DC. Right? Same goes for the DSR admin which is the built in 00:30:16.982,00:30:20.452 administrator on the DC. The local administrator on the DC. Its logon behavior is controlled 00:30:20.452,00:30:24.289 with a particular registry key, which we can modify the permissions to, so once we have 00:30:24.289,00:30:27.659 the machine uh- the local account hash, modifying the permissions, then we can modify 00:30:27.659,00:30:31.730 the permissions of the registry key, the logon be- and we can access the domain controller as 00:30:31.730,00:30:36.334 a local admin. Same goes for the resource based constrained delegation part, the RBCD, 00:30:36.334,00:30:38.336 right? Oh, Exchange groups are also very uh- interesting. Exchange groups are not part of 00:30:38.336,00:30:40.338 the protected groups, their ACLs are not- not protected by admin SD holder, so uh- we can modify 00:30:40.338,00:30:46.144 the ACL of the exchange windows permissions group, which itself has rights to modify the ACL of 00:30:46.144,00:30:52.317 the domain object. So by using this cascading effect, we can actually run attacks like, at 00:30:52.317,00:30:57.322 least DC sync, o the domain object. Right? I need to skip passed- through this one 00:31:00.092,00:31:05.097 actually. Then there are some well known ones, like user object ACL, we can modify the 00:31:55.614,00:32:00.552 ACL of a user object to reset its password, or to force set an SPN of the user, and then CAD 00:32:03.121,00:32:08.126 roast it. Or we can modify the permissions of the SD holder. This is very well known right? 00:32:10.529,00:32:16.301 Or we can run the DC sync attack by modifying the ACL of the domain object itself. This is 00:32:16.301,00:32:21.306 also very well known. Uh- finally we can run the DC shadow attack if you have not used it 00:32:30.215,00:32:35.187 [inaudible] By default you need domain admin privileges to run the DC shadow attack. But it is 00:32:35.187,00:32:40.192 possible to use minimal permissions we can [inaudible] run DC shadow without having to 00:32:42.627,00:32:47.632 have privileges. So this is a summary of whatever we have discussed. So this is more of a 00:32:50.068,00:32:55.440 reference slide for those who are not uh- did not attend the talk so that they can come back 00:32:55.440,00:33:01.947 and have a look at that later on. Now this was not something which was discovered uh- just 00:33:01.947,00:33:06.952 months back. Minimal permissions have been in use for so long that when I was a researcher, I 00:33:09.788,00:33:14.793 found articles at least which date back to 2001, where uh- the ACLs of the DCOM endpoint. So 00:33:17.996,00:33:24.669 in- in slide notes you will find that there is one for DCOM in 2001, another one for WMI from 00:33:24.669,00:33:31.376 2002. And there was some fundamental work uh- which was in French, I think this was in- 00:33:31.376,00:33:36.381 this was in 2014, a couple of years back at DefCon, there was a very excellent presentation 00:33:38.783,00:33:43.788 about DACL backdoors. In fact DC sync and admin SD holder are one of- some of the attacks which 00:33:46.758,00:33:51.763 these guys discussed in much detail. Now of course event logs are our best bet when it comes 00:33:55.433,00:34:00.272 to uh- detecting these attacks. Other than of course protecting your domain administrators or 00:34:00.272,00:34:05.043 local administrators. Right, if someone would not have that access in the first place, these 00:34:05.043,00:34:10.048 attacks would not be possible. Uh- by default ACL modification has no detection at all. Uh- 00:34:13.218,00:34:19.524 even though- even if you enable it, it is easier [inaudible] the domain objects for services 00:34:19.524,00:34:24.529 [inaudible] it is still hard to detect. [inaudible] Other than that as we uh- as we discussed 00:34:32.737,00:34:38.476 earlier, access logs are the best things you have, four six two four and a four six three 00:34:38.476,00:34:44.516 four, in case of a non admin access, four six seven two in case of an admin access. Right? 00:34:44.516,00:34:50.622 You can refer to this uh- document, this article from Microsoft to uh- to have a look 00:34:50.622,00:34:55.627 at why, or how to detect ACL changes. The tools which we can use for uh- ACL auditing other 00:34:57.896,00:35:02.834 than logging: Bloodhound of course, ADACL scanner, and uh- Ping Castle. You can use all of 00:35:04.936,00:35:09.941 these three, any one which you want to detect or to audit ACLs. And also uh- a shameless self 00:35:12.043,00:35:18.583 plug, you can use Deploy Deception, the tool I wrote to create decoy users and objects 00:35:18.583,00:35:23.588 which have interesting ACLs to- to uh- trap or deceive an attacker using that. Right? So 00:35:28.593,00:35:33.098 uh- for future work, what we have uh- what I have not explored is when you change 00:35:33.098,00:35:39.270 service permissions, those are stored in the Windows registry. So that would be a very 00:35:39.270,00:35:45.677 interesting part to discover or to- to have a look at. As we says- uh discussed earlier, WMI 00:35:45.677,00:35:52.083 permanent event consumers, not really uh- successful uh- I was not really successful with that 00:35:52.083,00:35:57.088 but that may be an interesting point. For the RACE toolkit, uh- specifically, I have worked on 00:36:00.125,00:36:06.364 hiding the ACEs once we have modified the ACL. That would be an interesting part. More 00:36:06.364,00:36:11.369 registry autoruns would also be really interesting. So uh- that would be all. Please fire your 00:36:13.471,00:36:18.476 questions right now or you can contact me on Twitter or on my email. That would be all. Thank 00:36:22.313,00:36:27.318 you. [Applause]