start	end	text
0	1520	Anyway, are you all ready?
1900	5420	Without further ado, Quentin and Will are going to wow you for the next 45 minutes.
5420	6600	So let's give it up for them.
10940	12260	Thank you.
13420	14480	Hi, everyone.
14480	18460	Welcome to our talk, turning your Active Directory into the attacker C2.
19800	25720	Today we'll talk about group policy, object enumeration and exploitation.
27000	28740	Let's first introduce ourselves.
28920	33140	My name is Wilfred with my colleague Quentin, or Quentin in French.
33600	39800	We do pen tests and red team at SYNACTIVE and this is the first time for us at DEF CON.
41220	43780	So, let's start by a quick introduction.
45820	57120	During an assessment, one of our colleagues said, well, yeah, we have an account that can modify a GPO that applies to domain controllers, but let us check for the ADCS first.
57720	63320	So they enumerate ADCS, they find out they can exploit ESC4 which is a previous escalation.
63480	66980	They exploited it successfully, but at the end, they got detected.
67540	74520	So now we always mess up with them, like next time, maybe don't go straight for ADCS and look at GPO.
75040	77580	So this is why we are talking about GPO today.
78300	83020	Group policy object attack vectors may just be the ugly ducklings of ID exploitation.
83780	84280	Why?
84280	90120	Maybe it's not well known, maybe it's too risky to exploit because you can mess up active directory.
90340	92040	Maybe there's not enough tooling.
92420	96480	So we think it's a shame because attackers don't have such concern.
96700	103340	And also GPO exploitation can be quite powerful because you can manage a lot of things into the active directory.
104740	111300	So today we are going to brief, uh, give you a brief recap on how GPO works, how they are implemented.
111380	118240	And we release four tools that will show that we can enumerate them and also exploit them with different kind of parts.
119100	122400	Okay, so let's start by explaining group policy objects.
123360	127960	A GPO is a collection of misconfiguration that applies to, uh, AD objects.
128160	131220	It's a core feature of active directory.
131360	134180	It deals with device and identity management.
134580	138020	And a GPO can define user settings and computer settings.
138300	141440	I will get into the details of that later.
142900	147760	When you want to configure GPOs, you can open the group policy management console.
148240	155920	And GPO has not directly, uh, not applied directly to user and computers, but most of the time to organizational units.
156700	161840	They can be also applied to different objects such as sites or domains, but is less common.
163080	170860	Something to, important to mention is like when you define settings for GPOs, by default GPO will inherit from the parent container.
170960	177060	For instance here, the default domain policy will apply to all child containers, all child organizational units.
177060	181260	For instance here, workstation, uh, servers and so on.
183700	187660	The implementation of GPO in active directory is bit specific.
188180	190820	They are basically made of two components.
190980	195000	The first one will be the group policy container, which is a LDAP object.
195080	200380	You will find out, you will find, uh, GPO metadata, name, description, version and so on.
200380	202960	I will get some specific details after.
203680	212900	You will also find the group policy template, which is the SMB share, that will contain the GPO files that describe the configuration that will be applied by the clients.
214400	224380	So what you have to remember is basically you have two components, the LDAP parts and the SMB parts, as are tied together by a specific unique identifier, the GUID.
225060	233300	And basically the LDAP part say what the, where the GPO applies and the SMB part said, okay, the GPO does this specific settings.
234900	238280	Okay, so let's try to go into the details of the first part.
238280	240420	The, everything regarding the LDAP.
241080	254200	There are some noteworthy LDAP attributes, such as on GPC objects, the GPC file sys path, it will indicate where the, the UNC path of the GPT, so the SMB parts, where the GPO file located.
254620	260340	You also have more attributes such as flags that will say the status of the user or computer configuration.
260420	262020	It might be enabled or disabled.
262460	264140	I will move on on that later.
264900	268240	You also have specific LDAP attributes on organizational units.
268620	274260	For instance, the GP link, it will say if the GPO is linked to this organizational unit, it can also be enforced.
274420	277040	And you also have options such as inheritance.
279360	291080	And the other part, the SMB part was the GPO templates, so in the SMB share you have multiple uh, configuration file, such as group.xml, received.xml and so on.
291100	294320	When you can specify those, those settings.
294980	302980	If I take a quick example on the bottom, you say group.xml, which is where you can assign uh, group assignments.
303300	308020	Here we can see that the user Jack is added to the remote desktop user group.
309140	310140	Okay.
310360	314380	So, this is the basics, so now let's go into the details of the attributes.
315080	318920	First, we will talk about inheritance on organizational units.
319540	324600	I mentioned previously that by default, GPO will be inherited on the child containers.
324900	339580	What you can do is like, you can avoid this by blocking inheritance, and when you go on the management console, right click on the workstation, and on the organizational unit, you can block inheritance, and what does, what's the change?
339580	345440	On the LDAP you have the GPO option that will switch from 0 to 1, and it will be 1 if inheritance is blocked.
345620	352420	And when you do that, any uh, parent uh, GPO will not apply to the specific organizational units.
354120	363060	We also have the link attributes, so GPO are linked to organizational unit, like I mentioned earlier, and this is done by the GP link attributes.
363500	371120	You will find in this specific attribute the common name of the GPO, and at the end you will find an integer that will describe the link status.
371860	378380	This integer may vary from 0 to 3, and it will say if the GPO is linked, unforced, and so on.
379620	384480	And if the GPO for instance is unforced, it will ignore the inheritance status.
385640	397260	Here we have the, the table that said the configuration, most of the time you will find out that the integer value will be 0, but we also, we can also see unforced GPO, so we will find the integer value of 2.
399120	403300	Move on to other attributes, now it's related to GPOs.
403600	412100	So I mentioned earlier that GPO can apply to a user or computer configuration, and you can change it with the specific flags.
412260	416520	So you can enable everything, which is the default.
416700	421980	You can also choose to apply only computer or user settings, and you can also choose to disable everything.
422960	434300	And what's going on behind the scene is like, we have a specific attribute again on the GPO object, which is called the flags, and we have an integer that will describe which component is enabled.
435440	447960	So the integer, by default the integer value will be 0, so basically computer and user configuration are both applied, but we can see sometimes it's, for instance, if the integer value is 1, only computer settings are applied.
450940	463700	Last part regarding GPO implementation is like, we have by default, the computers that updates their GPO, they are doing a background update every 90 minutes, with a random offset from 0 to 30 minutes.
464340	474280	The setting can be changed, on the eGPO you can change the settings and put the value of 0, and the documentation, if the value is 0, it will try to update the GPO every 7 seconds.
474520	479020	I will not recommend to update your GPO every 7 seconds, but it's technically possible.
480760	485140	And so another thing to mention is like, not all policy are proceed.
485220	495040	For instance, uh, software installation will be only applied when the computer starts, or there are also specific GPO that are triggered when the user logs on on the computer.
497180	500280	So now, how do computers update these GPOs?
500420	510420	So first, it interact with the domain controller, querying for the LDAP, for specific attributes, to know what are the GPO tied to the spe- to the specific computers.
511080	515840	It queries the attributes such as GP link, or GP option, that I mentioned earlier.
516420	519820	And is it now, the computer have a list of which GPO applies.
520880	530860	Then it query the LDAP again for more information, such as GP file sys path, so now the computers know where the, uh, files are located, where the SMB share.
531120	534920	By default it will be on the domain controllers in the CISVOL share.
536200	544200	We also retrieve all the information such as flag, is computer or, uh, user or computer configuration are, are enabled or not.
544940	553720	And now because it have all information regarding the LDAP, it initiate the SMB connection, and it retrieves all the file and applies the GPO.
555380	559200	Okay, so this was, uh, how GPO works.
559500	566160	There's also few, uh, other attributes that we don't have time to talk about, but it's not the main, main important one.
566740	574440	So now, we want to present you a tool that we developed when we want to enumerate GPOs, and also doing like a stealthy way.
575780	578940	We find out that during assessment, GPO enumeration is quite useful.
578940	583500	It reveals valuable insights into the security posture of the system.
583960	592120	And most of the time we will see, uh, interesting stuff like group membership or addition, previous assignment, risk modification and so on.
592960	597680	So it's quite interesting from an offensive perspective and we go into the detail of each one.
598420	601980	The first one will be, the most common one will be group memberships.
602660	605260	Group memberships are frequently defined through GPO.
606000	609720	Information that can prove crucial for lateral movements.
609840	619400	For instance, I want to perform lateral movements, but I don't want to, I have a specific account, I don't want to try this specific account on every computer, it's quite noisy.
619560	625200	And I don't want to perform, uh, wide range scans such as using net exec on large ranges.
625800	635620	So by enumerating this through GPO, I know exactly where this specific user has admi- administrative privilege rights, or where it can do on specific computers.
635860	638420	So I have a better understanding of group assignments.
638880	640940	So, let's do an example.
641800	648820	Here, I'm calling the LDAP, for uh, with a tool that is called LDAP, and I try to enumerate all the GPO.
648960	658960	The first one is called LORGP, which is quite interesting for us because I want to perform lateral movements, uh, and this is also something that we already seen during our assessments.
659640	662760	So, I'm interested in this specific one.
663480	676900	I'm looking at this specific unique ID identifier, which starts with 008, and then I go to the domain controller on the SysVol share, and I try to retrieve all the file dedicated to this specific GPO.
677300	686780	And within those files, I find out there's a group.xml file that say basically, the group domain user is added to the remote desktop user group.
687200	690780	So I know this GPO is adding domain user to remote desktop.
691040	693780	Now I need to find out where, on which computer.
694800	701520	So, like I mentioned earlier, by default GPO, I mean, most of the time GPO are linked to organizational units.
701660	710400	So again, I try to animate all the organizational units, and I can see here that my GPO LORGP is tied to workstation organizational units.
711260	719180	Next step is to find out which computers within this organizational units, and here we have the works, WKS01corp.com.
719640	729800	So, now if I, uh, type everything together, I can, I can know that the domain user group can LGP on the workstation01corp.com.
730440	734520	So now I can move laterally easily without doing any noise.
734520	736320	I don't want, I want to be stealthy.
736320	738300	So it's better to animate GPOs.
739260	741900	What you can do also is privilege assignments.
742460	746080	You can assign, uh, interesting privilege for GPO.
746320	755160	For instance, you can assign the SU debug privilege, which allows to debug any processes that you do not own, and it can be a free privilege escalation.
755980	759580	We found out this is really uncommon, but still possible.
759980	762560	But, in reality, it happens.
762860	775360	Here we have an, uh, a practical example that's, we, the SETCB privilege has been assigned to any user on the, on the machine, and basically it's a free privilege escalation.
775360	783060	With this specific privilege, you can add, uh, arbitrary groups to your token, such as administrator, and compromise the, the computer.
785940	790520	What we see most of the time will be, uh, connection restriction.
791400	806020	When you don't want your domain admin to connect anywhere to, in order to reduce the risk of credential exposure, you can perform connection restriction through, through GPOs, and basically they will deny, uh, access to specific computers.
806160	811400	So it mitigates privilege escalation, and try to preserve the, the tiering model.
812440	823220	So when you do it, when you're performing this kind of enumeration, you know, for instance, that domain admin will never connect to specific workstation, or specific machine to, uh, tie to organizational units.
823340	827100	So, there's no point to go there and waiting for domain admin.
829300	833020	You can also perform registry, registry modification through GPOs.
834200	843280	Legacy name resolution protocols such as LMNA, MD, MDNS, and BNS are, are relative good, uh, exploitation vectors.
843440	848300	It have, it have, it has been exploited since long time with such, with tools such as Responder.
848760	852800	And administrator disable, disable those protocols through GPOs.
853440	858100	Here, we can see that the, uh, MDNS protocol has been disabled through GPOs.
858100	864700	So, by doing this kind of reconnaissance, I know that this, there's no point to exploit it on those specific machines.
866500	871320	So, it helps, it, it helps me to, to choose, uh, re-revalent attack.
873060	875860	Through GPO, you can also gather more information.
875860	878560	For instance, you can go through hardening process.
879120	884380	You can see that, for instance, LDAP or SMB signature has been enforced on which computer.
884840	890900	You can also, so it's, it, it helps you to choose if relay attacks will be revalent or not.
891520	896060	You can also, uh, we often see, uh, credential, um, credential hardening.
896060	901340	For instance, the restrictions such as run SPPL and credential guard has been enabled.
902560	908580	You can get more information regarding, uh, additional software installation such as EDR, so you know what you're dealing with.
911260	916680	At the end, GPO animation can be time consuming and quite complex because there's a lot of things to take into consideration.
916680	920220	You have to check for inheritance, you have to check for enforce link or not.
920400	923880	You have to check if computer or user computer is enabled or disabled.
924020	928560	There's also more specific filters, so we have to automate this.
930180	938720	There's a lot of tools that try to enumerate, uh, GPO, uh, GPO, I mean, group PC objects, such as a well known blow down.
938840	943440	But we, we noticed that it doesn't take every parameter into account.
943440	956380	Here, I, I have an example where, um, within my workstation organizational unit, I have a child container, admin, and admin on the admin container, the original unit, the inheritance is blocked.
957000	964200	I'm using the same GPO, L-O-L-G-P, that I mentioned previously , which allow any domain user to connect on those machines.
964980	971100	So, I have a workstation one, which is within the admin container, and the inheritance is blocked.
971100	975120	And the GPO, L-O-L-G-P, is on the workstation organizational unit.
975260	979780	So basically, it prevents any user to connect to my workstation admin.
980840	989120	On the right, on this, we have a partial command, when I try to, I mean, I update my GPOs, and I enumerate the members of the remote desktop user group.
989340	995560	And the GPO, when the GPO are successfully updated, I can see there's no members, which is quite normal, because inheritance has been disabled.
996460	1013200	And when I collect the data with blood on, and I ingest it, blood on doesn't forget to take into consideration that the inheritance has been blocked on the admin container, and it show a path from domain user to workstation one, with the L-O-L-G-P edge,
1013200	1014540	which is false.
1016840	1028100	So, we notice there's other tools, but they also don't take every parameter into consideration , so we develop a tool, which is called GPO parser, that could parse all GPO configuration parameter that's presented earlier.
1028500	1033040	It tries to, it tries to reveal misconfiguration and privileged relationships.
1033760	1040820	It supports both online and offline analysis, and we, also we try to enrich blood on with useful hedger.
1040820	1049940	This way we can create admin, the new hedges that we have lost from our GPO collection, such as admin tool, can L-G-P, can PS remote.
1050880	1054620	You will find the tool on the, on the Synaptic GitHub right after the talk.
1055040	1058240	So, I will give you a quick demo of this one.
1059700	1073020	First we'll try to, um, collect it, I will, we'll collect it, uh, sorry, demo, I will, I will first show the, the demo that goes online.
1076810	1081390	Okay, so basically you have to, here I'm doing the collection on remotely.
1081570	1092710	You can collect GPO with, uh, a low privilege, uh, user, so I'm specifying the credential, I'm specifying the, the, um, the LDAP, and also the domain controller.
1092950	1097030	It tries to connect, which is all the, all the file, and it parse.
1097030	1105270	And here we can see for instance, this specific GPO, which is called Unforced SMB Signing, has been applied, you can see there's, there's some specific connection restriction tied to domain admin.
1105610	1110530	You can also assign privilege, for instance, SA debug privilege to the developer groups, and so on.
1110530	1116730	You can, for instance, you can see that the group, all, uh, admin, all over station are workstation admins.
1117990	1120510	You can also perform this reconnaissance offline.
1121910	1130350	So what you have to do is you have to collect all the LDAP data, I will do this LDAP, collect few information getting the LDAP.
1130370	1135010	I will also need to connect the, retrieve the policy, which are by default on the SysVault share.
1135230	1137110	I'm retrieving everything here.
1137270	1142330	It can be, we can retrieve all the needed files, but here for the presentation, I just retrieve everything.
1143130	1144590	And I will pass it locally.
1144630	1148470	So I have to specify where I find the SysVault share and the LDAP folder.
1149310	1156430	And what I also want to mention here, like, we can also filter, for instance, we want to know the GPO that's only applied to a specific target.
1156550	1159530	For instance, the specific computer workstation one.
1159810	1170110	And here, locally, I can see that all the GPO that's applied to this specific workstation, and now I can see the same information, but tied to this specific workstation.
1172030	1178850	So basically it's the same, you can see that domain user can, uh, can, can connect through a remote desktop user group.
1179750	1184050	Now I would like to let my colleague contact, speak about abusing ACLs.
1185130	1186870	Alright, thank you Wilfred.
1186870	1194110	So Wilfred explained to you how GPOs are implemented, and how you can abuse them to enumerate some security relevant, uh, configurations.
1194430	1202710	For my part, I will actually explain to you how we can abuse GPO objects in order to compromise active directory objects, so users and computers.
1203090	1209890	And the first way I'm going to do that is with the most standard way you would exploit a GPO in an active directory engagement.
1209890	1218970	So let's say you have, uh, write access to a GPO with a user, um, and this is not an uncommon situation, we encounter it pretty often in engagements.
1218970	1224050	This can be T1 accounts, this can result from administration, uh, mistakes, et cetera.
1224130	1238050	And this is actually a very powerful primitive, attack primitive, because when you control a GPO, you can compromise all the objects that are linked, um, that are included in all linked organizational units, including sub-OS.
1238450	1251130	Um, when you exploit a GPO, what you basically want to do is just leverage some built-in GPO features in order to deploy malicious configurations to the users and computers to which the GPO applies.
1251130	1254930	And you can really, um, deploy a lot of malicious configurations.
1254930	1267810	You can deploy some scheduled tasks, you can deploy some immediate tasks, or you can do something like add a user to a local group, you can, uh, transfer files, execute files, setting registry keys, you can define some logon or logoff scripts.
1267990	1276550	Uh, what I want to, to, to point out is that imagination is really your only limit when you want to exploit a GPO to, in order to compromise the objects to which it applies.
1277530	1282310	And, uh, we have some, some offensive tooling to exploit GPOs, not so many.
1282650	1288970	Um, we can have some things like charge GPU abuse, by GPU abuse, GPONs, or the DRST tool suites.
1289070	1296290	But, uh, during engagements, we found out that these tools have some limitations that made them pretty difficult to exploit.
1296310	1300370	Uh, the main one is, uh, the stability and exploit safety consideration.
1300710	1303190	So, GPOs are very critical in active directory.
1303190	1308570	They are sensitive, uh, architecture components, so you really don't want to screw them up.
1308570	1310910	So, exploit safety is really important.
1311310	1315590	Um, there was also some, some lack, some lacking in clean up and revert capabilities.
1315590	1320370	After we exploited, we want to clean up for stealth or just, just to clean up after yourself.
1320530	1335830	Um, very often, there was no possibility to create GPOs, to manage links, to target specific objects with your malicious configurations, and more generally, there was a lack of available actions and options that you could configure, uh, to exploit your GPO.
1335910	1339810	So, we created the group policy backdoor.py, uh, tool.
1339990	1346750	This is a Python implementation using only LF3 and SMB protocol, so no impact for stealth considerations .
1347010	1350350	Um, you can do quite a bunch of things with group policy backdoor.
1350350	1353130	You can create your GPOs, delete them, back up them.
1353130	1354330	You can manage your links.
1354330	1357230	You can inject some customizable configurations.
1357510	1366550	Um, importantly, you can also leverage the item level targeting feature of GPOs in order to only inject your configuration to specific objects.
1366590	1370550	So, if you want to target a specific computer, you can, with group policy, uh, backdoor.
1370570	1374550	You can also clean up after yourself and revert the actions you perform on clients.
1374550	1377390	So, it will be available on GitHub, uh, after DEF CON.
1378470	1384270	For it to be a little bit more concrete, let's take a real world example that we encountered, like, a few months ago.
1384490	1387530	So, and let's try to exploit it with group policy backdoor.
1387670	1400830	So, we compromised an account a few months back, uh, that has, that has, uh, right privileges of a pretty interesting GPO because the GPO was applying to a gem server that was used by domain administrators in order to perform some administrative actions.
1400950	1404830	We didn't have any kind of privilege other than the rights on the GPO.
1404850	1408090	We did not even have network access to this gem server.
1408150	1414310	But what we did was that we exploited the GPO in order to add a scheduled task on this gem server.
1414310	1420890	We configured this scheduled task to run in a privileged context in the, using the identity of a domain admin.
1420950	1426650	And the scheduled task only added, uh, an account under our control to the domain admin's group.
1426650	1439910	And you can see here a pretty interesting thing, is that we are exploiting a GPO that applies to a gem server in order to, let's, so to say, trap the gem server so that the scheduled task will trigger when the domain admin connects to it.
1440210	1442770	All right, let's see a demonst- a quick demo.
1444490	1452960	All right, uh, it's, this one, I think it's coming.
1453040	1454420	All right, all right.
1454440	1458160	So, let's say that we compromise the user that is called Aloy.
1458160	1461140	You can see here, I'm authenticated with Kairos, with Aloy.
1461560	1464780	Um, Aloy has some standard groups.
1464780	1466300	You can see here I named the groups.
1466300	1469200	It is part of the IT support group, quite standard.
1469440	1475180	Uh, let's use group policy backdoor first to enumerate the GPOs of the domain with the enum list GPOs commands.
1475300	1477300	You can see there is a bunch of GPOs.
1477320	1480060	The one that interests us is called gem servers handling.
1480860	1486640	Let's use group policy backdoor to get some more details on this GPO with the, uh, GPO details commands.
1487160	1488160	All right .
1488360	1494600	Um, the most important, uh, thing that we notice is that our current user, Aloy, has right permission of the GPO.
1494600	1495440	This is pretty good.
1495440	1498080	This means that we will be able to exploit it.
1498360	1503200	And this GPO is, is tied to an organization unit that is called gem servers.
1503340	1508420	In this gem servers organization unit, we have the gem server that we are trying to compromise.
1508420	1513680	As you can see here, the AD01 bastion, which is the gem server that we are trying to exploit.
1513720	1514120	All right.
1514120	1517700	So, let's inject our malicious schedule task into the gem server.
1517800	1533860	In order to do that, with group policy backdoor, you define a configuration through a .ini file that, uh, specifies what configuration you want to inject into the GPO and what option you want to, uh, configure your, uh, your malicious configuration with.
1533860	1538000	So you can see here, quite standard, we want to inject a schedule task.
1538020	1541140	Uh, we want it to run the cmd.exe program.
1541140	1544320	We want it to add our user, Aloy, to the domain admins group.
1544580	1549780	Uh, we want to impersonate ADM, which is a domain admin that connects to the gem server.
1549860	1554180	And we want to repeat this, uh, schedule task every minute because we don't want to wait.
1554660	1556720	Additionally, you can provide some filters.
1556720	1563140	Here I say, I only want this schedule task to be defined on the AD01 bastion.com.com computer and not on anything else.
1563140	1564300	For stealth, for instance.
1564300	1570580	And you just, uh, provide a filter with a computer, computer name, um, uh, title.
1570980	1577180	So let's run group policy backdoor with this configuration file, and this will inject our malicious schedule task into the GPO.
1577180	1585700	You can see here, we provide the modify commands, and we provide the .ini file that I just, uh, showed, uh, to the gem server's hardening GPO on which we have write access.
1585840	1587780	So we execute group policy backdoor.
1587860	1589120	It does a bunch of stuff.
1589120	1592800	I won't go into details, but it, uh, modifies the group policy container.
1592800	1596080	It modifies the group policy templates in order to inject your configuration.
1596160	1601120	In bub, it also bumps the GPO version so that clients will actually update the GPO.
1601120	1612520	And now, all we have to do is, you, we can see on the domain controller here that, uh, the gem server's hardening GPO defines the schedule task with the group policy management console, just for illustration.
1612820	1615120	So you can see here, our schedule task is there.
1615260	1623400	It is configured to run with a trigger , with an action that adds our user to domain admin, some item level targeting in order to only be defined on the bastion.
1623760	1624460	All right.
1624820	1632240	So at this point, we would just wait for the bastion to refresh, uh, its GPOs, define the schedule task, and then add our user to the domain admins group.
1632280	1633780	So that's what we're going to do.
1633940	1640100	We will force the GPO refresh with GPO updates, because we don't have time to, to wait for 90 minutes.
1640480	1643160	Um, so yeah, the GPO update command is executed.
1643160	1653620	And you can see right after, that, uh, our schedule task will be defined on the gem server, and then the domain admin at the MQL will execute it, and add our user to the domain admins group.
1653620	1659160	You can see here, we have the schedule task defined, running as MQL, and then it's all set.
1659160	1664560	We just have to wait one minute, and our user will be actually added to the domain admins group.
1664600	1671980	So I just cut the minute out, but, uh, you can see here with an LDIP command, that alloy is now part of the domain admins group.
1672340	1673160	All right.
1673160	1676560	So, you, you did your exploitation, that's great.
1676680	1679360	What you want to do then, is clean up after yourself.
1679360	1684500	You want, uh, to, to, to remove this configuration you injected into the GPO.
1684600	1699640	And group policy backdoor makes it pretty easy, because each time it runs, it creates a state folder, that has many information about what it did, and you just have to provide the state folder to the clean commands, in order to, um, to clean up after yourself,
1699640	1703400	and to, to remove the configuration that you injected from the GPO.
1703400	1714420	So you can see here, I provide the state folder into the clean commands, I execute the commands, and it just, again, does a bunch of stuff, I won't go into details, but just removes the configuration from the GPO.
1715320	1716080	All right.
1718560	1725720	So that was, uh, I mean, we have a lot more examples of how we exploit the GPO during engagements.
1725780	1731060	We used it to reach some network isolated workstations that we could not, uh, even pivot to.
1731060	1734880	Uh, we used it to enable winarium, and add some firewall exceptions.
1734940	1739620	We also used it to persist in the active, uh, directory environments after detection.
1739620	1747500	So, the good news is that you can just extend group policy backdoor to your use cases, to, to add some more configurations that you want to inject into GPOs.
1747500	1750600	You can do this pretty easily, so, don't hesitate to do so .
1751440	1755760	All right, so this was kind of the standard GPO exploitation vector.
1755800	1764060	We are going to dig a little bit deeper, and we're going to see how we can exploit group policy objects via, uh, NTLM relaying.
1764320	1768080	A little, a little, um, context about this research.
1768080	1774260	We were doing an engagement, uh , we were able to perform some NTLM relaying to the LDAP service, which is often the case .
1774260	1779080	For instance, uh, you, you are able to relay HTTP to LDAP, right, in different configurations.
1779400	1787420	And we were able to, uh, relay an interesting user that had right privileges of very interesting GPO, and this GPO applied to domain controllers.
1787800	1797420	So, because we were relaying to the LDAP service, we had, we, we had the possibility to modify the group policy container, the LDAP, if you remember what Wilfred explains.
1797420	1804960	But we had absolutely no privileges over this, the SMB share, so the group policy templates, on which the GPO configuration files are located.
1805120	1808160	And we were wondering, is this even exploitable?
1808440	1811140	Um, and it turns out that yes, it is.
1811360	1821080	Because, uh, Wilfred mentioned it also a little bit earlier, but in the group policy, uh, container, you have an interesting attribute that is called the GPC file sys path.
1821080	1826080	And it specifies the location of the G, the group policy templates as a UNC path.
1826120	1829180	And by default, this will be simply the sys vault share , right.
1829820	1835200	But, uh, it is actually possible to specify an arbitrary SMB share location in this attribute.
1835200	1836380	Anything goes.
1836480	1843460	And for, for Microsoft, this is a legitimate feature, this is expected, but not so much because it crushes the group policy management console.
1843460	1845680	So, I guess this is kind of a gray area.
1846460	1853660	Um, so you can see here, I just modify, uh, in, uh, in Windows, the GPC file sys path to a random IP address, right.
1853660	1860300	And after 90 minutes, I start to see some objects that are trying to actually authenticate to me, in order to fetch the GPT files.
1860300	1863980	So you can just specify anything in the GPC file sys path attributes.
1864700	1874160	And so, if you pay attention, we now have, uh, an attack vector that is, uh, that you can implement through only NTM reading, by only modifying the group policy container.
1874260	1880960	The first two steps are pretty standard, so you relay your user, uh, to the LDAP service, you interact with the LDAP service as the user.
1881180	1886180	Um, this, the next step is to modify the GPC file sys path to point to your server.
1886180	1889340	You say basically, yeah, the group policy template is on my machine.
1889420	1898540	You implement an SMB server on your machine that serves malicious, uh, group policy template files, for instance, uh, defining a schedule task that you want to run on the victim.
1898540	1907800	And now you just wait for the objects to try to apply the GPO, realize that the, the configuration files are on your system, and fetch it, fetch the files on your system.
1907800	1909140	And it will work.
1909460	1914840	So we created a tool that is already available, that is called GPODT, and that does just that.
1915300	1933880	Um, I won't, I also won't go into details, but there was a main implementation challenge was to implement a working domain joined SMB server, because you can't just, uh, provide anonymous access to the object, so we refuse, modern, uh, Windows SMB clients will refuse to actually connect anonymously to,
1933880	1934660	to a server.
1934660	1939160	So, GPODT performs a net logon to overcome this, uh, this difficulty.
1939720	1941380	Alright, time for another demo.
1941800	1944060	Uh, with the GPODT tool.
1945320	1946260	Alright.
1946300	1960000	So, we have a domain , uh, we have the domain controllers, organizational units, with a GPO that applies to it , which is the DC corp hardening, uh, group policy objects, which is a standard group policy object, you have the GUID here.
1960000	1965360	But what is interesting is that the ADOV user has some rights over this GPO.
1965660	1974720	And, let's say that we relate the ADOV user to the LDAP service, we can see here, I've spinned off my NTM memory leaks, and I relate this user to the LDAP service.
1974720	1978220	And I am interacting with the LDAP service as an ADOV user.
1978300	1979340	Pretty standard.
1979840	1987220	Um, so, I spin off the impact, uh, LDAP shell in order to execute LDAP commands, uh, as an ADOV user.
1987480	2000140	Um, to be a little bit more comfortable, I will create a machine account, uh, with this LDAP shell that is called GPODT, and I will give all the rights over the group policy container for this machine account with the LDAP shell.
2000140	2009540	So now I miss situation that I described earlier, that is to say the GPODT account has privileges over the group policy container, but nothing over the group policy templates.
2009540	2011320	And we'll try to exploit this.
2011920	2022740	We'll try to exploit this to add a local admin to the domain controller, and most specifically we will add the GPODT machine account that we created to the local admin group of the domain controller.
2022880	2031160	We can see first that our GPODT account is not yet part of the domain, of the local admin group of the domain controller, within the same big client commands.
2031160	2034760	You can see here I tried to connect to the CDOR share with GPODT.
2034760	2036180	I got an access denied.
2036180	2037440	This is quite expected.
2037620	2041600	Now let's exploit, uh, let's exploit this situation with GPODT.
2041780	2044360	So the command will look something like this.
2044360	2047640	You specify the GUID of the GPO you want to exploit.
2047820	2052700	You specify the user name and password of the user that has rights over the group, the group policy container.
2052700	2056020	You specify the command that we want to execute.
2056020	2060660	Here I want to add my GPODT computer account to the local admin group of the domain controller.
2060740	2062860	And then you just press enter.
2063620	2075300	The policy, uh, GPODT will do some, a lot of things, but the most important thing is that it will modify the GPC5 attributes to, uh, my, uh, my attacker machine, as you can see here.
2075740	2083340	And now I just have to wait for the domain controller to update, update, uh, their GPOs and fetch the GPT files on my machine.
2083380	2092600	And you can see on the right, I just, uh, execute GP updates and as soon as I execute GP updates, I have the domain controller trying to authenticate to me to fetch the GPT files, right?
2092600	2105920	And I authenticate it with NetLogon and I provide, uh, the malicious, uh, GPT files to the domain controller and it will execute my immediate task that adds my GPODT machine accounts to the local admin group of the domain controller.
2106040	2112460	As you can see, uh, then now I can SMB clients, uh, into the C, C dollar share of the domain controller.
2112460	2116800	So yeah, I am local admin of the domain controller, which is, uh, good news.
2119200	2120120	Thanks.
2123680	2125160	Alright, last, last part.
2125160	2137380	We'll dig even deeper, uh, and it will be the last, uh, organizational units, uh, by poisoning the GPO link attributes.
2137380	2145160	A little bit, uh, a little bit of context, uh, we should explain to you that GPOs are linked right to organizational units through the GP link attributes.
2145160	2148280	That looks something like, uh, what I put on the slide.
2148560	2166400	Um, and when you have right access to an organizational unit, uh, Petros Petroupis showed a few years back that it is possible to add a GP link item in order to, um, simulate a many, a GPO that, uh, objects of the organizational units would try to apply.
2166420	2168480	And why is it interesting?
2168480	2174000	It is interesting in comparison with, uh, other organizational units at that vector that we previously have.
2174160	2181180	So previously we only had one attack vector that was targeting organizational units that relied on ACL inheritance.
2181740	2196040	And what you, what you did was basically to add a generic call, for instance, ACL to the organizational unit container, and it was by default inherited to, by all the objects of the OU, which was quite neat and simple and also reliable.
2196140	2200160	But, uh, this attack vector had some pretty heavy limitations.
2200160	2218020	It necessitated, uh, some high privileges, so write the ACL, and most importantly, it could not be used against what we call in active directory protected objects that has the admin counts equal to one and that attributes, because for these objects, ACL inheritance from the parent container is disabled.
2218420	2225960	So GP link poisoning is pretty interesting because it can be exploited with very limited privileges over the organizational units.
2225960	2233320	You only need to be able to write the GP link attributes, and it also works for privileged objects such as domain admins, right?
2234140	2235520	So how does it work?
2235520	2237840	What, what is, uh, precisely this attack?
2237840	2245460	So what you do is that you modify the GP link attributes in order, as I said, to inject an additional GPO link to the OU.
2245460	2253600	And as you can see here, uh, your injected item will not point to the domain, but to a domain name that resolves to your machine.
2253600	2259320	Here, I added a GP link item that points to attacker.cop.com instead of cop.com.
2259340	2276240	And when the objects are fetching the GPOs they should apply, because they are linked to their OUs, they will try to, to apply this GPO, and then the attacker should only simulate a group PC container, a simulator group PC template, and just execute malicious configurations through this,
2276240	2278280	uh, injected GPO.
2278340	2282720	So we created a tool that we called Unet, uh, to automate the attack.
2282720	2284260	It is available on GitHub.
2284260	2295240	We also added two edges to Bloodhound, so the right GP link, and then the right, uh, edges on organizational units, because they are exploitable through the, through the, um, attack vector I just described.
2295400	2299860	All right, if I, let's just, uh, uh, describe it more visually.
2299860	2304760	So first, you have a user that can modify, that can write the GP link of an OU, right, first step.
2304820	2308980	Then you poison the GP link, you add an, an item to the GP link.
2309040	2315000	Third, you, objects will try to fetch their group PC container on your machine, you simulate a group PC container.
2315020	2323700	And finally, fourth, uh, the, the objects will also try to fetch the group PC template on your machine, you simulate a group PC template, and they apply your malicious configurations.
2324160	2329200	All right, let's, uh, let's have the last demonstration of the session with the UNET tool.
2330480	2331320	All right.
2331740	2334860	So, we have a, we have a domain here.
2335200	2337060	All right, does it work?
2337180	2339820	Uh, I mean, it's weird.
2341180	2343400	All right, just a second.
2345640	2353160	Okay, so we have our domain, we have the PKI service, our UNET, that contains a, um, computer that is called 8001 PKI.
2354020	2359760	So we'll try to, so on this PKI service, our UNET, we have a user that we dubbed N.
2359760	2362920	Augustine, that will have some limited rights.
2362920	2371200	Uh, she will only have the rights that is called managed GP link, which, uh, allows her to, as you can see here, manage group policy links on this OU.
2371400	2375200	And so, we'll assume that we compromise the N.
2375200	2382940	Augustine user, and we'll try to abuse this privilege, uh, she have, she has, sorry, on the, on the OU of PKI service.
2383520	2384120	All right.
2384120	2386900	So, we'll try to exploit it, in order to add the N.
2386900	2393380	Augustine user to the local admin group of, um, of, uh, PKI, of the PKI server, 8001 PKI.
2393620	2402340	So you can see here first, uh, the, uh, the PKI service OU only have one, has one GP link, uh, legitimate GPO.
2402780	2403620	All right.
2403900	2404900	And the N.
2404900	2411140	Augustine user is not, uh, local admin of, uh, the 8001 PKI, uh, computer.
2411140	2412360	As you can see here, access denied.
2412360	2412860	All right.
2412860	2416420	So, let's exploit, uh, this privilege with UNET.
2416500	2421880	UNET takes, uh, config.ini file, that specifies some, some configurations.
2422060	2427900	Uh, there are a bunch of them, but, uh, most importantly, you specify the target Augustine units.
2428140	2436160	You specify the user that has the right to modify the GP link attributes, and you specify the command you want to run on child objects.
2436480	2438220	As you can see here, I'm adding the N.
2438220	2442940	Augustine user to the, um, to the local admin group of, uh, my targets.
2443040	2446300	There are a bunch of other configurations that doesn't matter.
2446380	2451720	Uh, we are spinning off a fake DC in order to simulate a good PC container, uh, but I won't go into details here.
2453320	2454300	All right.
2454900	2458720	So, let's execute, uh, UNET with this configuration.
2459000	2462520	And you can see that there are a bunch of things that UNET does.
2462700	2465860	Uh, it sets up fast forwarding to, to simulate a GPC.
2465860	2466780	It doesn't matter.
2466780	2471820	The most important thing is that it adds a GP link attributes into the Augustine units.
2471820	2480720	As you can see here, if I do some LDIP, I have another, um, GP link that was added here that points to UNET.com.com, right?
2480720	2483480	And UNET.com.com points to my machine.
2483480	2486740	And so, what happens is what I described earlier.
2486740	2494440	The objects will try to fetch, to apply the GPO by thinking that I am the LDAP server and I will simulate a good PC container.
2494780	2499660	So, on the right, on the ID01 PKI server, I will just execute the GP update commands.
2499660	2509600	And as soon as I do that, you can see on the left, on the UNET side, that I will have a communication from the ID01 PKI server that tries to authenticate to me.
2509600	2514540	First, to fetch the GPC, so the LDAP parts, and I will answer to, to the computer.
2514540	2522580	And then for the GPT, the good PC templates, and I will again authenticate it and respond with the, the appropriate files.
2522800	2531080	And finally, we can see that the attack works because the end-of-use end-user is now local admin of the ID01 PKI computer.
2531080	2535580	As you can see, I'm connecting to the C-dollar share and I am local admin of this computer.
2535580	2539240	So we have used this GP link write permission.
2540200	2541080	Thanks.
2544730	2548130	All right, just a few words to conclude.
2548130	2553730	So, we are, we believe that risk associated with GPUs are pretty much underestimated today.
2553970	2559610	GPUs are very powerful just for enumeration, as Wilfried showed you, but also for exploitation primitives.
2559610	2564230	There are a lot of exploitation primitives on GPUs, but also on the organizational units.
2564330	2578610	And of course, we aim to, to, to provide a better understanding of how GPUs work, how you can enumerate stuff from them, how you can exploit objects from them, and GPUs are just, just fun and don't, don't hesitate to, to research on it.
2578610	2579170	Thank you.
