start	end	text
0	320	All right.
320	2900	Good evening, DEF CON Track 4.
2900	3520	Welcome.
3520	4660	Welcome back.
4660	6920	We have one more speaker for you guys.
6920	10960	It is my absolute pleasure to introduce Antoine.
10960	16740	The title of his talk is Overlaps, Overriding Lapsed Logic.
16740	18660	Let's give it up for Antoine.
24320	25340	Okay.
25340	26460	So, hello.
26500	28120	Thank you very much.
28120	32360	So this is my second DEF CON but first time as a speaker.
32360	39520	And I will present some subject about lapsed and in particular its internal logic.
39580	41000	So, quick introduction.
41000	43520	I am Antoine, working at Pederasi Luxembourg.
43520	49000	I spent the last 10 years breaking things to help our clients improving their security.
49000	52820	And yes, I am from Dijon, the capital of the mustard.
53460	56660	A quick agenda.
56660	59480	So we will start with a quick refresher about lapsed.
59480	62960	We will cover the background and scope of this talk.
62960	67380	And the core of the talk will be how lapsed works and how we can mess with it.
67380	69580	And we will finish with a conclusion.
70640	73000	So let's start with some definitions.
73100	76260	So lapsed stands for Local Administrator Password Solution.
76300	84580	It's a Microsoft product to manage local admin password by setting unique random password that will change regularly.
84580	86640	There is two versions of lapsed.
86640	92540	First one, Microsoft Lapse, that we will call V1 in this talk, that was released 10 years ago.
92540	97840	It's Active Directory only and passwords are stored in clear text, in AD.
98320	104600	And we have Windows Lapse, that we will call V2, or the current version, that was released 2 years ago.
104600	110380	It's built-in into Windows and supports both Active Directory and Enter ID setup.
110380	113920	And passwords are encrypted and it supports extra features.
115060	119080	Now, let's have a quick overview about lapsed.
119080	126320	So both versions, V1 and V2, follow the same high-level process during each password rotation cycle.
126320	132400	So if the password needs to be changed, first we will generate a new password on the local system.
132400	139060	Then we will send the password to the directory, so either Enter ID or Active Directory, depending on the config.
139060	142160	After that, we set the password locally on the system.
142160	148080	And there is also an additional step for device match via Entra.
148600	152800	There is an update in the registry on the local system that we will cover later.
153260	164740	And basically, on Active Directory, resetting the lapsed password equals to setting the expiration time to now and wait for a new cycle.
165460	169180	So just a quick word on Lapse V1 for completeness.
169180	172960	So it runs as a group policy extension on domain-joined machines.
172960	180120	On the device, there is one DLL called admpwd.dll in charge of the core logic of Lapse.
180420	187280	Password and expiration time are stored in Active Directory on the computer object and in clear text.
187280	196640	The password is only protected by ACLs, meaning that only authorized users can access the password, but the expiration time is visible to anyone.
197460	199480	And we have now Lapse V2.
199480	206840	So first difference, managed device can be either domain-joined or Entra-joined.
206840	211440	It's not a GPO extension anymore, but it still reacts to policy changes.
211440	217840	You can also manually use PowerShell complex with admin privileges to force a refresh cycle.
217840	221340	The polling cycle is hard-coded to once per hour.
221520	225480	On the managed devices, we have three main DLLs.
225480	231880	And the passwords are now stored both with encryption and ACL on Active Directory.
232020	238920	And for Entra-ID, it's in the cloud, but it's written in the documentation that passwords are further encrypted at rest.
238920	243460	And there is also protection against password tampering on the local system.
244520	250400	So moving on, we'll start about the motivation and goals behind this research.
250600	253520	So Lapse V1 and V2 have been widely analyzed.
253520	256640	There is a lot of tools, a lot of paper on this subject.
256740	266940	But most of the attacks focus on the server side of Lapse, so meaning abusing authorized accounts to read the password.
267380	274720	On the other hand, client-side remains not so explored in public tooling and research, but it's not a new observation.
274940	283690	Actually, we studied the client-side of Lapse V1 eight years ago with my colleague Max Clements, who is in this room with me.
284180	293220	And just to summarize our previous talk, Lapse V1 is based on an open source project called ADMPWD, and it's backward compatible.
293220	301670	So basically, you recompile ADMPWD with your extra features, and you put it on the device, and you will override Lapse.
303400	307060	Eight years later, a lot of things changed.
307060	313270	There is a new feature, and it's not based on an open source component anymore.
313880	320500	So we have the support of EnterID with Active Directory, so making things a bit more complex.
320540	326000	Passwords are stored with encryption, and there is this password tampering protection mechanism.
326780	331400	In this context, we would like to explore three different questions.
331400	333540	Can we capture the password?
333540	340140	Can we desynchronize the password from the local system to the directory?
340640	343560	And can we trigger a password change on demand?
344700	352560	So for this research, we have defined a scope, so we will focus exclusively on Lapse V2.
352840	360200	We will enable encryption, but I will not take into the details of cryptographic internals.
360200	364880	For that, you can check XPN blog that is really great on this subject.
365620	376560	And our testing lab will include two small infrastructures, one with Active Directory, with one client, and the other with a client that is domain joined.
377040	385900	In both cases, we will use Windows 11, and Lapse will be used to manage the built-in local admin account.
385900	394900	And an important note, so now Lapse runs inside LSAS process, so we will disable run as PPL just to ease our research.
394940	403520	Bypassing run as PPL is a different topic, and we assume local, temporary administrator access on the client device.
404360	408200	So, time to dig into the guts of Windows Lapse.
408500	417800	So, as I mentioned earlier, the client side relies on three main DLLs, but we will focus only on Lapse.dll, which contains the core logic of Lapse.
417960	427980	And luckily for us, Microsoft provides with the PDB files, which makes the understanding of the logic easier, and gives us as well internal function names.
430240	440220	Here we have a simplified code tree of some of the Lapse functions inside Lapse.dll, and we can see three main zones in this diagram.
440220	445860	So first, on the left, we have functions that are for active directory setup only.
446160	452040	On the other side, we have functions only for intra-join setup.
452040	457740	And on the middle, we have shared functions that are used for password generation, and password changes.
459040	467240	We will use Frida just to ease our research, and to hook some functions that we will see in a minute.
467840	469180	Actually, in a second.
469180	476040	To start with our objective, we will try to capture the password every time it changes.
476040	487080	So we can have a look at this function, that is an undocumented function exposed by some server DLL, and is used by Lapse to change the manager account password.
487620	497420	And by doing some instrumentation, we can find that two parameters are quite interesting, and are pointers to Unicode string structure.
497420	506260	And just by applying an offset, we can have the actual string that is stored in these pointers.
506260	510820	And you can see on the slide, for instance, a password.
510820	514520	But we will have a demo to ease the understanding.
515140	522380	So before we start, on the left, we have a domain controller.
522400	524600	On the right, our client.
525460	528800	On the machine, you will see two command prompts.
528800	536160	The one on the top will run with admin privileges, and we will use it to attach to Lsas and to hook our function.
536500	547100	And below, we will use it just to run a GP update, just to have a refresh of the GPO easier.
547640	550340	So let's start the video.
550340	554320	So first, we check the password is not expired.
556620	559220	We launch our hook.
561420	565040	Now we expire the password, and we launch a GP update.
565040	571940	It's just to force, to ease the setup, and to avoid waiting for a real expiration.
571940	575080	And you can see that we have already captured the password.
575520	584300	And I will just test the password on the local system, just to prove that the password that I captured is really the LAPS password.
587160	588060	And here we are.
588060	589520	We are administrator.
590300	593200	Now, same on the EnterID setup.
593200	594900	So exact same code.
595100	604440	And again, we will force an expiration just to ease, but the process is the same when the password expires for real.
605060	611980	We just wait a couple of seconds that the password will be changed.
611980	613040	Yes, it is.
613520	618540	And same, we can see that the password on Entra is the same that the one that we have captured.
622480	625420	Here, another example to achieve the same result.
625420	627800	We can hook internal function with Frida.
627800	639760	So for instance, if we look at reset local admin account password, we just need to find the offset of this function, and then to find interesting parameters.
640000	649240	And again, by doing some instrumentation, we can find that there is a parameter that contains the password.
649240	653780	So again, we just hook this function and we can capture the password in cleartext.
654360	658160	And it works exactly the same on EntraID setup.
660280	666540	So basically, we have achieved our first objective, and we will move to our second objective.
666540	670240	So can we try to desynchronize the LAPS password?
671040	673120	So for this, we have two options.
673120	685280	So either we modify the password on the local system, so we have a control on the local password, but the password on the directory remains random.
685720	687400	Or we do the opposite.
687400	693260	We don't modify the local password, but we modify the one on the directory.
693260	699940	But the impact is quite limited used alone, because the actual password will be random and you don't have it.
700440	714040	Both options can be useful for a kind of denial of service, because LAPS will not be usable by administrator, because the password they will see on the directory is not the one that is actually set.
714740	722300	I didn't record a video for this one, but just a screenshot to demonstrate this.
722300	728780	So on top, you have the Active Directory setup.
728780	737100	So the actual password is a random password, while the one that admin will see on the domain controller is really random.
737100	739440	And on the bottom, it's the opposite.
739440	747240	So we have changed the password that is sent to the directory without changing the real one.
748840	750740	So second objective achieved.
750740	754100	So we will move on to the third one.
754100	756800	So can we trigger a password change on demand?
758020	767060	So our goal now is to hook the password expiration check and force it to return that the password is expired, even when it's not.
768300	770920	And to do this, it's quite easy.
770920	773380	So we can use these two functions.
773380	777600	So one for Active Directory setup and the other for Enter ID setup.
777620	784120	And we will just basically modify one parameter before the function returns.
785000	796980	So you can see on the screenshot, we just modify the args5 in parameter and we change the value to 1 to force the reset.
797400	800740	So we'll have a quick video on this.
800740	802760	Again, same setup.
804800	807120	We attach our hook.
809080	816500	And now, each and every time a GP update or a GPO refresh will happen, the password will be changed.
817360	819520	So here, we just check.
819520	824700	So the password that we have captured is the same as the one on the directory.
825180	836440	And now, I will do it a couple of times, but each and every time there will be a GPO update, the password will be changed.
837300	840480	And in this case, synchronized with the Active Directory.
843200	845900	And it works the same on Enter ID setup.
845900	853760	It's just less convenient to force a refresh cycle, except using the PowerShell samelet.
854880	857860	But for Enter ID, we have another approach.
857860	866140	In this introduction, I briefly mentioned that for Enter ID setups, there is the expiration time that is stored locally on the register.
866300	871220	And I didn't really explain how the password expire block works in that case.
871900	879940	If you look at Microsoft documentation, you will see basically the same diagram as mine, but they are separated in two parts.
880180	884340	One for Active Directory and one for Enter ID.
884520	887480	But functions are basically the same.
887480	891760	And if we zoom a bit on the top of the diagram, there is this block.
891760	895580	Query local registry password for current password expiration time.
895700	898320	So maybe you have the same idea as mine.
898320	900140	What if we change it?
900200	906440	So on the registry, there is two values that are interesting.
906440	911340	One called Azure Password Expiry Time and the other Last Password Update Time.
911340	914100	The purpose is pretty self-explanatory.
914100	919080	Azure Password Expiry Time will be used to have the expiration of the password.
919080	923160	Both values are stored as Windows file time.
923160	929060	And here you can see readable functions for humans.
930420	935440	So question now, what if we change the Azure Password Expiry Time key?
936600	938620	Let's have a quick video.
940420	948940	So I will just run the simulate function and check the logs to see if the password is expired.
949000	950160	The answer is not.
950160	952980	The password is not expired at this time.
954260	960060	Now we'll go on the registry and edit the key just for convenience.
960060	968880	And because the format is quite complex, I will just copy the value from the other key in this one.
970000	974080	And now I will force a cycle with the PowerShell commandlet.
975600	983790	And now if we check the logs, the local admin account was updated with a new password.
983790	987470	And the reason, the current password was considered expired.
988470	993250	So basically we managed to force a reset of the password.
993990	1010730	If you are wondering what if we put a password in the future, basically it will break LAPS because on the directory it's written that the password is expired, but on the local system it says that it's not expired.
1010830	1013810	So LAPS is in a weird state.
1013810	1017890	So basically we have achieved our three objectives.
1018310	1025450	But with Frida, maybe Frida is not installed on the victims.
1025450	1030630	So we can use, for instance, Microsoft Detour library.
1030630	1034040	So it's an open source looking library from Microsoft.
1034330	1035830	And the diagram shows the principle.
1035830	1040550	We place our own function between the original call and destination call.
1040550	1042130	And we will do something in between.
1042130	1045390	So for instance, capturing the LAPS password.
1046850	1049330	So, quick video for this.
1049430	1058890	First we will hook some asset password for an user to, from some server DLL.
1059730	1063150	So again, I will force the expiration time, run gpupdate.
1063610	1067150	And here we have a txt file that has been created in the background.
1069070	1071850	And if we look, it contains the password.
1071850	1073510	So we managed to capture it.
1073530	1077710	And now I will do exactly the same but using an internal function.
1077710	1079830	So reset local admin account password.
1084890	1085970	Again.
1089090	1091510	And again, a new txt file is created.
1091510	1093970	And if we look, it contains the password.
1093970	1097710	So basically we can just do like this.
1099690	1103630	So now it will be time to conclude this talk.
1103630	1108710	So, if you are wondering, can we hook other functions for similar results?
1108750	1110710	The quick answer is yes.
1110950	1117920	Here on this screenshot, for instance, I captured the LAPS password on six different functions on active directory setup.
1118150	1122510	And there is probably other functions that can be hooked for similar results.
1123670	1128270	In the introduction, I mentioned the password tampering.
1128930	1135230	It's written in the documentation that LAPS protects accounts from accidental or careless tampering.
1135610	1139190	So, for instance, if you use a net user command, it won't work.
1139230	1141210	But with this approach, it will work.
1141210	1145830	So, in other words, intentional tampering is still possible if you know what you are doing.
1148090	1150610	So, did we accomplish our mission?
1150610	1153790	Yes, we managed to achieve our three objectives.
1153790	1160050	So, capturing the password, desynchronizing the password from the directory, and trigger a password change on demand.
1160530	1162250	But let's be clear.
1162270	1169630	For, let's say, a real scenario, you will need to bypass RANAS PPL, you will need to fight against ADR, and so on.
1169630	1173990	And we are touching ELSA, so it's always a tricky question.
1174350	1179990	But my objective was to, let's say, lay the foundation.
1179990	1189310	And I hope some of you will have some ideas and will build on this research to go further and to develop other scenarios.
1191510	1193630	Some key takeaways.
1193630	1197750	So , for our Red Team friends, in two words, be creative.
1197890	1199630	Think beyond the spoke.
1199630	1203830	You can retrieve the password via the network or other scenarios.
1203890	1208110	As I mentioned, other functions can be hooked or abused.
1209030	1222090	The logic of LAPS might change with updates, so we need to check basically each and every patch Tuesday if there is a new version of LAPS.
1222950	1228210	For Blue Teamers, watch for unexpected LAPS reset.
1228210	1239310	Because if you are not using LAPS evilly, the reset of the LAPS password should more or less match the rotation period that you have configured.
1239430	1246210	Of course, limit privilege escalation vector, because we assume that we have compromised already a system.
1246210	1251690	And ensure that your technical controls are working, such as RANAS PPL, ADR, and so on.
1253290	1256190	So, thank you all for your attention.
1256190	1263170	So, all the talks that I showed and additional words are available on this GitHub repository.
1263170	1271450	There is also some scripts to help finding the offset automatically once a new LAPS version is released.
1271850	1275550	So, feel free to check them out and reach out if you have any questions.
1275790	1276830	Thank you.
