[00:00.000 --> 00:05.360] All right, welcome to the last track of track four of DEF CON 33. [00:06.440 --> 00:11.380] And he's going to be talking to us a little bit of his research into SCCM security. [00:12.940 --> 00:14.300] Hi, everyone. [00:14.460 --> 00:16.240] I'm super glad to be here. [00:16.240 --> 00:18.140] And thank you for staying till the end. [00:18.220 --> 00:23.780] So today in this last session, I will walk you through my research on SCCM. [00:24.320 --> 00:27.160] So let me first introduce myself. [00:27.160 --> 00:36.760] My name is Mehdi Eliassar, and I work as a red teamer at Synactive, which is an offensive security company based in Paris, in France. [00:36.780 --> 00:42.100] So I've been working in IT security for eight years now, and I started as a pen tester. [00:42.320 --> 00:46.200] And now I do red teaming full-time. [00:46.360 --> 00:52.960] And I mainly focus on breaking web applications and also on Active Directory stuff. [00:54.260 --> 00:56.760] So this talk will cover the following topics. [00:56.760 --> 01:04.550] First, I will present and describe some key internals of SCCM, mainly to give you a grasp on how it works under the hood. [01:05.060 --> 01:08.790] Then I will cover the CVs I've discovered in SCCM. [01:09.180 --> 01:20.170] Then I will introduce some post-exploitation techniques that I've been using throughout my engagements, but also these techniques that led to the creation of a tool that I will present here. [01:20.900 --> 01:29.040] And finally, based on the knowledge that we've got about the internals of SCCM, I will share with you some techniques to backdoor an instance. [01:30.660 --> 01:33.680] So let's start with the SCCM internals. [01:33.680 --> 01:41.040] For those who don't know what SCCM actually is, it was renamed recently to Microsoft Configuration Manager. [01:41.200 --> 01:45.780] So it's an IT asset management solution edited by Microsoft. [01:45.780 --> 01:52.900] It has been around for a long time now, and it is still widely used and deployed within organizations. [01:52.900 --> 02:01.600] And so to manage devices, SCCM installs an agent on the clients, and it provides code execution capabilities. [02:01.780 --> 02:10.900] And for us, on the offensive side, this makes it Microsoft's native C2, and it's a prime target during our engagements. [02:11.600 --> 02:22.180] And today, there are many attack techniques to take over an SCCM instance, and they primarily arise from misconfiguration or a lack of hardening. [02:22.900 --> 02:29.020] But they were widely documented until now, so I won't cover them in this talk. [02:29.360 --> 02:35.900] So let's start with the first internal, and the first concept to introduce this part is the client communication modes. [02:35.900 --> 02:37.220] So you have two of them. [02:37.220 --> 02:43.320] So SCCM client mainly talks over HTTP with the management point. [02:44.120 --> 02:50.700] So you have on the management point, you can configure it either with enhanced HTTP mode. [02:50.700 --> 02:54.880] So this is mainly using plain HTTP transport mode. [02:54.880 --> 03:05.320] Or you have HTTPS mode, which is advised by Microsoft, which requires an internal PKI to issue certificates such as ADCS. [03:06.300 --> 03:13.660] And this is done to make the clients do mutual TLS with the management point services. [03:13.660 --> 03:18.660] So this is what makes the clients present [03:23.520 --> 03:26.220] a certificate to talk with the management point. [03:26.220 --> 03:36.280] So sometimes in an engagement, you need that certificate, and it can be a bit painful to exploit SCCM. [03:37.480 --> 03:41.230] Now let's take a look at how SCCM works under the hood. [03:41.230 --> 03:45.010] Most services are web applications hosted on IIS. [03:45.890 --> 03:52.410] From what I've seen, it's a mix of old and new technologies that are glued together sometimes. [03:52.410 --> 03:57.010] You have mainly ASAPI modules alongside .NET applications. [03:57.590 --> 04:04.770] And you also have COM that is heavily used between components, often with deep chains of COM codes. [04:04.770 --> 04:10.350] So when you do reverse engineering, it can be hard to follow the code flow. [04:11.490 --> 04:17.250] And as I have limited time, I will focus only on the services that I tied to the management point. [04:17.990 --> 04:21.110] And let's start with the SMS management point service. [04:21.110 --> 04:27.510] So on the right side, this is a snippet of a dump I did on the IIS web configuration. [04:27.510 --> 04:34.410] So this is only for the SMS management point service, but we'll get other snippets for other services. [04:34.590 --> 04:39.210] And you can observe here that there are three ASAPI modules in use. [04:39.210 --> 04:47.470] One to serve policies to clients, another to serve scripts to clients, and the last one to serve location services information to clients. [04:48.010 --> 04:51.450] So this service has four different entry points. [04:51.450 --> 05:03.230] You have the standard one that is named SMS underscore MP, and other ones with the same modules, but different authentication methods, such as Windows Auth, Alt-Auth, and Token-Auth. [05:03.670 --> 05:15.910] But also you can observe on the right side in the configuration on IIS that anonymous authentication is enabled on three entry points out of four. [05:16.370 --> 05:17.410] So that's weird. [05:17.970 --> 05:27.150] And as I said previously, when the management point is configured in HTTPS mode, a mutual TLS is required from the client to access the services. [05:27.330 --> 05:31.130] This is the theory, but in practice, you can bypass this. [05:31.150 --> 05:36.970] To do so, you have to use the SMS MP, Token-Auth, or Alt-Auth entry points. [05:37.390 --> 05:40.530] And here, there is no need for a client certificate. [05:40.770 --> 05:49.830] As you can see in the snippet below, the first query, we get a 403 error from the server asking for a client certificate. [05:49.850 --> 05:55.190] But if you hit it with the other entry points, you get 200, and you can reach the services. [05:57.130 --> 05:58.830] What can you do with this? [05:58.830 --> 06:09.010] For example, on the service, you can hit the method MP list on the get-auth module to get a full list of management points within a site. [06:09.130 --> 06:11.330] There are two interesting fields. [06:11.330 --> 06:20.250] You have the version with the build number of SCCM and also the SSL state, which indicates if HTTPS mode is enabled on the management point or not. [06:20.370 --> 06:23.430] You also have another method, which is MP list one. [06:23.830 --> 06:34.090] You give it a parameter of the site code so you can enumerate management points from other sites within the same hierarchy. [06:34.910 --> 06:45.970] So you can do with this unauthenticated reconnaissance on HTTP, but also on HTTPS if you use those TLS bypass, mutual TLS bypass that I showed you earlier. [06:48.090 --> 06:52.110] Let me now cover another key service, which is CCM messaging. [06:52.530 --> 07:01.710] This web app has a single ASAPI module with entry point named in a similar way than the ones we've seen before. [07:02.370 --> 07:06.690] And here, too, anonymous authentication is enabled on three entry points. [07:08.810 --> 07:17.950] So in practice, CCM messaging is an HTTP-based communication protocol that uses a custom method, CCM underscore post. [07:18.210 --> 07:29.750] And this protocol is mainly used by the clients to discuss with the management points, but also it's used by other site servers, such as management points or between internal services. [07:30.910 --> 07:34.810] In this snippet below, you have the structure of a message. [07:34.810 --> 07:41.590] There is two main parts in a multi-part body, the XML header and the request, which is an XML document. [07:41.670 --> 07:49.830] So in the header, sometimes you get a message signature that is included and it proves the device identity. [07:49.830 --> 07:53.610] So this is how authentication is done here in this protocol. [07:55.370 --> 08:05.990] And under the hood again, the ISAPI module serves as a single entry point that dispatches the messages to the right service handler. [08:06.030 --> 08:13.510] So it does so by checking the value of the target and point field in the header part in the system message. [08:13.550 --> 08:18.510] And once again, everything is done through COM as the service handler are COM classes. [08:18.530 --> 08:31.770] They are configured within the WMI database as instances of the CCM service and point configuration class, and these objects can be found in two distinct namespaces. [08:32.690 --> 08:38.090] So the first one is where the configuration is persisted between reboots. [08:39.150 --> 08:55.790] And on this class, you have two interesting fields, the CO class one, which is the cellist ID of the COM service handler to call, and also the visibility field, which is super important as it indicates if a device identity is needed to interact with this service. [08:55.790 --> 08:58.870] So this is where the authorization level is defined. [08:59.570 --> 09:07.770] And as you can see in the dump below, the MP services are configured with either all or client signed visibility. [09:08.170 --> 09:13.090] And I will circle back to this knowledge at the end of this talk for the persistence part. [09:14.570 --> 09:22.450] And once again, when HTTPS mode is enabled, there is also a trick to bypass mutual TLS for CCM messaging. [09:22.810 --> 09:27.710] So you need to use CCM system alt-auth entry point to do so. [09:27.790 --> 09:33.030] Unfortunately, the other entry point with the token auth doesn't work at this time. [09:33.030 --> 09:43.990] And as the alt-auth was introduced in recent version of ECCM 2403, this bypass won't work in older version of ECCM. [09:45.230 --> 09:50.890] So how can you leverage this bypass to do some nasty thing on ECCM? [09:50.950 --> 09:56.790] In fact, you can loot NIA credentials without having Windows credentials on the network. [09:57.410 --> 10:09.310] So there is a well-known technique to harvest NIA credential is to register fake clients when you got yourself a Windows credential for a machine account. [10:09.470 --> 10:10.470] That's needed. [10:10.470 --> 10:15.650] So when you do that registration, the SSM client is approved. [10:15.650 --> 10:18.430] And this is mandatory to pull policies. [10:18.430 --> 10:26.370] However, with this mutual TLS bypass, if you register a client with a domain credentials, it is automatically marked as approved. [10:26.670 --> 10:31.030] Thus, this gives you the ability to loot NIA credentials unauthenticated. [10:31.410 --> 10:37.710] So I plan on updating the tool SSCM secrets, which is available on GitHub already. [10:37.850 --> 10:42.850] So I will do a pull request in the next day, right after the DevCon. [10:42.850 --> 10:46.230] So I've discovered this while preparing this talk. [10:47.970 --> 10:48.510] All right. [10:48.510 --> 10:54.310] Another service that is interesting is the one that is named SMS Provider. [10:54.310 --> 10:59.130] It acts as an abstraction layer for read and write operation on the database. [10:59.190 --> 11:01.950] So this is a completely different role. [11:01.950 --> 11:08.390] It creates a specific WMI namespace named SMS underscore this three-letter site code. [11:08.970 --> 11:14.550] And access control is managed through airbag, withdrawals that are defined in the database. [11:14.910 --> 11:24.150] And there is also a local Windows group, SMS admin that is created, and it is granted access permission to the WMI namespace. [11:24.230 --> 11:33.730] So this group automatically includes any user or group assigned an airbag role, as well as machine accounts of management points servers. [11:33.730 --> 11:36.810] So this gives you the ability to do some relaying. [11:38.710 --> 11:44.730] And on top of that, the SMS Provider exposes the Admin Service REST API. [11:45.790 --> 11:57.810] So this API offers two routes, one for the OData protocol, and another one for WMI, supporting GET and POST operation on over 700 classes. [11:57.810 --> 12:05.210] And this API is a .NET application built with Owen, and there is no way to configure or enable EPA. [12:05.210 --> 12:11.170] So this makes it vulnerable by default, by design, to relay attacks. [12:11.910 --> 12:13.430] So you can't fix that. [12:14.350 --> 12:18.190] And let me finish with the Tenant Attach concept. [12:18.190 --> 12:24.530] So for a hybrid management approach, an SCCM site can be configured with Tenant Attach. [12:24.710 --> 12:30.490] Basically, the feature allows the on-premise SCCM instance to connect to Intune. [12:30.730 --> 12:35.610] And when enabled, the SCCM instance uploads service device information to Intune. [12:35.610 --> 12:46.890] But also from the Intune web console, you can run some actions on those on-premise device, such as asking for a device restart, but also installing application or running scripts. [12:47.350 --> 12:56.730] And when this feature is enabled, there is a principle named config-manager-svc-underscore-guid that is created on your tenant. [12:56.810 --> 13:02.990] So it's an intra-ID application, granted the following permission on the tenant. [13:02.990 --> 13:11.850] So we have read and write collection data on the configuration manager microservice API, which is an undocumented API. [13:12.110 --> 13:16.650] But also we have directory read-all granted on the graph API. [13:16.970 --> 13:23.010] So this is an account that you can extract from the on-premise to perform reconnaissance on the tenant. [13:23.710 --> 13:29.590] And I'll get back later to this account and show you how you can recover its credentials from the database. [13:31.110 --> 13:34.390] All right, let's talk a bit about zero days. [13:34.390 --> 13:40.570] So now I'm gonna walk you through how I identified vulnerabilities in SCCM. [13:40.610 --> 13:49.890] I will mostly detail the methodology I applied so you can see exactly how the issues were discovered. [13:49.890 --> 13:51.890] So I got two of them today. [13:52.470 --> 13:54.990] So the first one, it's CVE-2024. [13:54.990 --> 14:00.430] It's an unauthenticated SQL injection that I discussed earlier this year. [14:00.470 --> 14:08.370] So it affects SCCM messaging, the MP location manager handler. [14:08.890 --> 14:17.990] And as this handler is configured with visibility at all, so there is no need to prove the device identity which makes the exploitation unauthenticated. [14:19.150 --> 14:24.910] And usually the management point and site server roles are installed on the same server. [14:24.910 --> 14:34.370] So as the site server has the sysadmin role on the database, this issue allows you to instantly take over the database and all the sites. [14:34.450 --> 14:40.170] And to mitigate the impact, Microsoft advises to install the roles on distinct servers. [14:40.170 --> 14:43.530] So the code is already available on our GitHub. [14:45.230 --> 14:53.650] All right, so to discover this issue, I kick-started my research by extracting strings from all the libraries used by SCCM. [14:54.330 --> 14:58.730] And some SQL format string patterns stand out right away. [14:58.730 --> 15:07.430] Also, there were method signatures that show up in the debugging messages that are left in the code of SCCM, which reveal the internal code structure. [15:08.470 --> 15:22.830] Among those SQL patterns in the location manager library, precisely, there are some format strings used by the service to execute stored procedures, like the one calling MP get machine ID, which is highlighted here in the snippet. [15:23.730 --> 15:34.810] So looking at the code next with the compiler like IDA, we can confirm that the input is formatted into the SQL string without escaping. [15:35.210 --> 15:39.070] So here comes the question, how to reach this flawed method? [15:40.950 --> 15:52.190] And thanks to the call tree overview plugin in IDA, you can observe that there are multiple paths to the flawed method, but one clearly stands out, the one highlighted here. [15:52.570 --> 15:56.250] It stands out as the simplest route to reach the code. [15:56.910 --> 15:59.610] So this is the one I took for the exploit. [15:59.710 --> 16:03.130] There is less hassle and less condition to reach the code. [16:04.330 --> 16:09.490] And following that shortest path from the CTO, I landed in the code location shown in this screenshot. [16:09.790 --> 16:19.250] And once again, the debugging strings are helpful, as they indicate that the get machine ID is called right before an update SF method. [16:19.650 --> 16:24.910] So this is helpful next to choose which requests to pick up. [16:24.910 --> 16:37.250] So this is an extract of the partial request body, in which there are at least 20 names of XML document that are processed by this service that you can reach. [16:37.290 --> 16:47.690] And with the information that you, the hint that I got from the debug string, I could quickly choose the update SF request as the one to use to reach the flawed code. [16:49.830 --> 16:53.050] And here is the final CCM message to exploit the injection. [16:53.050 --> 17:00.310] So on the left side, you have the header part where the injection point is located in the source ID field. [17:00.310 --> 17:08.110] So this is the injection point is in the header, which isn't even signed by the client. [17:08.150 --> 17:15.610] And on the right side, you have a minimal update SF request filled with the placeholder values just so the exploit can work. [17:15.610 --> 17:17.090] So that's the exploitation. [17:17.910 --> 17:24.670] All right, so when the patch was released, I confirmed the issue was fixed because they now use prepared statements. [17:25.470 --> 17:37.830] However, I've also noticed that the flawed code is still there and it's now gated by an if condition, which was raising questions about the purpose of that. [17:39.470 --> 17:45.730] And digging a bit further, I concluded that the if condition checks if a registry value is set on the system. [17:45.730 --> 17:48.430] So it's named disable additional validations. [17:48.730 --> 17:52.770] So this is clearly a fail-safe to bypass that patch. [17:53.110 --> 17:59.390] So when you exploit the system and you put that value, you will get the vulnerability again. [17:59.830 --> 18:09.430] And I think the main reason is that the first version of the patch that was released by Microsoft was causing serious trouble to the customers. [18:09.810 --> 18:16.750] So they left that if condition as a rollback for customers that are complaining about the patch. [18:18.430 --> 18:22.670] All right, let's talk now about the other CVE 2025. [18:22.690 --> 18:27.910] It's a not authenticated SQL injection in the SMS provider component. [18:27.910 --> 18:29.450] It's the admin service. [18:29.990 --> 18:35.630] Microsoft released a patch in July 2025 to address this flow. [18:36.250 --> 18:42.050] So this vulnerability can be exploited using any SCCM airbag role, even the read-only one. [18:42.050 --> 18:43.710] We'll see later why. [18:44.370 --> 18:49.550] And I am releasing the proof of concept for this issue right after this talk. [18:52.090 --> 18:57.530] So to discover this bug, I reviewed the MOV file for the SMS provider namespace. [18:57.530 --> 19:07.030] I looked mostly for patterns where methods had parameters that appear numeric but are defined as strings in the WMI side. [19:07.070 --> 19:16.370] So this mismatch between the expected type and the one defined into WMI enables potential injection. [19:16.370 --> 19:28.810] So this, I identified the method update classic deployment as a good candidate, as its offer ID parameter seems numeric, but it's defined as a string in the WMI MOV. [19:28.810 --> 19:31.690] So you have its definition here in the snippet. [19:34.170 --> 19:44.630] All right, so looking into the code behind of update classic deployment, I noticed that the SQL injection occurs in the permission check step. [19:44.970 --> 19:50.890] So that's why a user with any RBAC role, even the read-only one, can exploit this injection. [19:53.050 --> 19:57.070] And from my point of view, there are two ways to exploit this issue. [19:57.090 --> 20:03.950] First is obtaining credentials for a user having any SSCM administrative role. [20:04.090 --> 20:08.130] But this is not that easy on an engagement. [20:08.790 --> 20:19.710] Otherwise, you can perform authentication relay against the admin service API on which EPA protection can't be required. [20:19.930 --> 20:25.650] So depending on the topology of the deployment you got, you have multiple scenarios. [20:25.650 --> 20:37.170] First, if the SMS provider role is installed on a dedicated server or not on the management points, you can relay the management point to the admin service and exploit the injection. [20:37.170 --> 20:47.110] If there are multiple management points deployed on a site, you can relay one management point to another management point hosting the SMS provider role. [20:47.230 --> 20:58.910] And if there is a single management point in a standalone mode with also the SMS provider role on the same server, you can try some self-relay attacks if it isn't patched against it. [20:59.010 --> 21:04.710] So remember, there is a CVE for NLM reflection that was disclosed in June. [21:04.710 --> 21:06.590] So you can use that to exploit. [21:08.730 --> 21:14.010] All right, so I have other unresolved issues with Microsoft, but I cannot cover them in this session. [21:14.010 --> 21:21.210] But stay tuned, I will share the details at the appropriate time when I got the disclosure is okay. [21:22.370 --> 21:28.670] Let me cover now the post-exploitation phase, when you got yourself an admin access. [21:29.190 --> 21:32.070] Let's see what you can do from the database, for example. [21:32.750 --> 21:36.910] So in SCCM, there is the create and run script feature. [21:36.910 --> 21:41.690] It's super interesting as it allows you to run PowerShell on a single device. [21:41.930 --> 21:49.130] The execution is done as system, and the process is spawned by the CCM exec process, which is highly trusted binary. [21:49.470 --> 21:55.810] And to exploit this feature, actual public tools leverage the admin service API of the SMS provider to do so. [21:55.910 --> 22:01.010] So there are some downsides to doing that, especially during a red team. [22:01.010 --> 22:03.450] First, all actions are logged. [22:03.890 --> 22:07.690] Then there is also a double approval mechanism by default. [22:07.690 --> 22:10.770] So you need two accounts to exploit this. [22:10.770 --> 22:14.230] One to create the script and another one to approve it. [22:14.310 --> 22:19.190] And finally, you can't properly clean exploitation artifacts behind yourself. [22:20.970 --> 22:29.410] So I asked myself if it was possible to trigger the script execution feature directly from the database access. [22:29.570 --> 22:31.010] And the answer is yes. [22:31.010 --> 22:37.070] Doing so bypasses the double approval process, and it leaves minimal logging press behind you. [22:37.330 --> 22:38.550] And here is how to do so. [22:38.550 --> 22:40.430] We have some steps to do so. [22:40.670 --> 22:44.410] First, you'll have to create an entry in the scripts table. [22:45.490 --> 22:47.630] There are some columns that are interesting. [22:47.950 --> 22:52.030] For example, the script type set to zero is for PowerShell. [22:52.070 --> 22:53.110] You have the approver set. [22:53.110 --> 22:57.010] You directly set it to three, so to mark the script as already approved. [22:57.230 --> 22:58.450] You have a feature. [22:58.450 --> 23:01.950] If you set it to one, the script won't show up in the admin console. [23:01.950 --> 23:07.530] Finally, the approver author are free text, so you can spoof whatever identity suits you. [23:09.290 --> 23:15.010] Then we add an entry in the BGP task table, which will reference the script that we've created. [23:15.010 --> 23:17.230] So we have one part is the template ID. [23:17.230 --> 23:22.290] We set it to 15 to say that it's a task to request script execution. [23:22.430 --> 23:28.090] Then you have the param column, which holds a task param XML document. [23:28.090 --> 23:32.670] So this document will include the ID of the script to execute. [23:32.670 --> 23:41.070] So this is the document that will be sent to the clients, and the clients will use that information to fetch the script and execute it. [23:43.170 --> 23:46.610] Then we add an entry in the BGP REST task table. [23:46.610 --> 23:49.650] So this is where you assign the task to a client. [23:49.650 --> 23:57.610] You can see there is a field for the resource ID for the device, managed device, that you want the task to be executed on. [23:57.610 --> 24:05.430] So this insertion triggers a push notification to the client, and it downloads the XML document and the script later. [24:06.950 --> 24:17.110] To check the script output, in fact, the task's output is sent back by the client to the management point, which stores it in the script execution status table. [24:17.550 --> 24:21.330] So you have the exit status code along the route output. [24:21.370 --> 24:25.550] So you have to, after a slight delay, you have to query that table. [24:28.130 --> 24:40.170] Regarding the login, the only thing on the client side that is logged is the task param XML document that is left in the CCM notification agent log file. [24:40.350 --> 24:43.970] But the script content isn't logged, so that's OK. [24:44.090 --> 24:52.450] However, beware that the script, which is downloaded on the client side, is stored in a script store folder. [24:52.470 --> 24:58.750] But that file isn't removed after the execution, so you need to delete it manually. [25:00.930 --> 25:04.650] And now I'm glad to introduce you to sccm-sql-client.py. [25:04.650 --> 25:09.790] It's a tool that implements these techniques to automate as much as possible. [25:10.170 --> 25:16.570] So it started as a fork of Impact's MSSQL client with queries to explore an SCCM database. [25:16.990 --> 25:29.230] This is a tool that I've created for a red team a year ago and that I've kept improving with new ideas from the on-the-field experience, but also the knowledge I've gained from my research throughout the time. [25:29.310 --> 25:36.430] So regarding the feature, there are some queries to map the topology, but also to list clients or list store credentials. [25:36.510 --> 25:43.550] But also you have some features to run the PowerShell scripts on clients, but also to decrypt the credentials automatically. [25:44.310 --> 25:53.410] And this tool also includes some anti-forensic measures as it automatically prepends a small command to your scripts to clean the script store folder. [25:53.410 --> 25:56.310] So you don't leave anything behind you. [25:56.310 --> 26:00.850] And it also includes some helpers to clean the artifacts easily from the database. [26:01.150 --> 26:04.770] And let me just describe you some of its key commands. [26:07.310 --> 26:10.630] First to map the topology, you can use SCCM servers. [26:10.630 --> 26:16.610] It will just list the servers within a hierarchy so you can check for server from other sites. [26:16.610 --> 26:18.330] Then you have SCCM devices. [26:18.330 --> 26:24.050] So you will get a full list of known devices, also devices from other sites. [26:24.350 --> 26:28.010] Then an important one is SCCM devices BGP status. [26:28.010 --> 26:34.550] So we get only the clients for your current sites with their BGP status. [26:34.550 --> 26:40.510] So the BGP status is the thing that will tell you if you can execute scripts on those clients. [26:42.230 --> 26:52.830] And to run scripts on a device with the tool, you will have to load its content first, either in line with a set PS1 script or from a local file with load PS1 script. [26:53.130 --> 26:58.270] And then you'll have to run SCCM run script with the resource ID of your target device. [26:58.350 --> 27:02.790] And at this step, the tool prepends the commands to clean the script store folder, as I said. [27:03.490 --> 27:07.350] Then to get the output, you use last task output. [27:07.350 --> 27:09.910] It's a helper to check the execution output. [27:09.910 --> 27:13.990] It uses the generated GUIDs that are kept in memory. [27:14.630 --> 27:20.330] Finally, use the last task clean, which is a helper to clean the artifacts from the database. [27:20.330 --> 27:22.310] It will delete everything. [27:24.810 --> 27:32.110] Regarding secret extraction, so to look for secrets in the database, you can use SCCM user accounts. [27:32.110 --> 27:36.330] It will query the table that stores NAA accounts and push accounts. [27:36.610 --> 27:41.650] And here the password field is encrypted with crypto API on the site system server. [27:41.650 --> 27:45.970] And only that site system server that issued that blob can decrypt it. [27:48.450 --> 27:51.970] And you also have SCCM AAD apps. [27:52.090 --> 28:01.010] So this is the command to list the intra-ID credentials that are stored when you have configured to not attach feature. [28:01.370 --> 28:13.610] So here we have two columns, secret key, which is a blob that can be decrypted by a single site system, but also secret key for SCP, which uses a key shared between all systems. [28:13.610 --> 28:15.390] So this is mostly interesting. [28:15.390 --> 28:18.710] It makes it easier to decrypt. [28:19.770 --> 28:26.170] And to decrypt the secrets, we need to execute code on the site system servers that created the blobs. [28:26.550 --> 28:30.170] And by default, they are enrolled as clients too. [28:30.310 --> 28:33.950] So we can run a specific script to decrypt those blobs. [28:34.410 --> 28:39.290] So the tool has an SCCM decrypt blob command to automate that process. [28:39.910 --> 28:45.050] So you need to give it the resource ID of a site system server and the blob to decrypt. [28:45.050 --> 28:50.130] And depending on the blob format, it will use the right PowerShell command snippet to decrypt it. [28:50.130 --> 28:59.030] So these commands use C-sharp assemblies available on the SCCM servers and that expose methods to decrypt those secrets. [28:59.030 --> 29:03.310] So you have more details in the slides for later. [29:04.350 --> 29:06.410] So it's time for a demo. [29:06.410 --> 29:15.210] So I will start as an authenticated attacker and I will exploit the mutual TLS bypass to register clients, then dump the NAA credentials. [29:15.330 --> 29:27.770] Within those NAA credentials, I will use one of those accounts to access the admin service API, exploit the SQL injection to create myself and admin access to the database. [29:27.770 --> 29:35.230] And finally, with the database level access, I will showcase you the SCCM SQL client tool for some commands. [29:38.980 --> 29:44.180] So I'm starting with some recon with the bypass for mutual TLS. [29:48.410 --> 29:57.550] So here with the token auth, and with the auth auth, I'll show you that I can get the list of management points over HTTPS. [29:58.110 --> 30:03.970] And now I'm using a modified version of SCCM secrets to dump the policies. [30:03.970 --> 30:11.590] So I'm not giving it any Windows credentials and I will dump the policies like that over HTTPS too. [30:11.970 --> 30:15.990] So this is the name of the client, the fake client that will be created. [30:16.410 --> 30:17.470] And here we go. [30:19.150 --> 30:23.890] And we have three accounts that are dumped by the tool and the last one we'll use it later. [30:23.890 --> 30:30.010] So now I'm gonna show you that the fake clients that is created from in the SCCM console is approved. [30:30.010 --> 30:33.770] So this bypass makes you create an approved client. [30:35.530 --> 30:49.770] So now let's use the SCCM user, user SCCM read only to access the admin service API and exploit the CV 2025 and create our self an admin account on the database. [30:54.010 --> 30:55.010] That's done. [30:55.010 --> 31:01.470] Now we can use SCCM SQL client to access the database and confirm that we are administrator. [31:02.630 --> 31:05.970] Now we can list the sites and it works. [31:05.970 --> 31:10.150] So now let me showcase the SCCM SQL client. [31:10.150 --> 31:13.530] First by executing commands on a domain controller. [31:13.530 --> 31:18.550] So now with the BGP status, I confirm that the DC has online status at one. [31:18.550 --> 31:20.810] So we can execute commands on it. [31:21.290 --> 31:26.430] And right here, I'm loading a command to execute on the controller. [31:26.950 --> 31:28.610] Then I will launch it. [31:28.610 --> 31:33.490] So you need to pass the resource ID to run the command. [31:37.670 --> 31:41.790] And now we wait a bit and we're gonna get the outputs. [31:41.790 --> 31:43.590] And that's all right. [31:50.630 --> 31:56.010] Okay, so with the last task clean, you can clean behind yourself the insertion that were done in the database. [31:56.310 --> 32:00.290] So now let me show you how we can extract the credential and decrypt them. [32:00.990 --> 32:02.970] So this is for the user accounts. [32:02.970 --> 32:05.770] We have the push account, the NA accounts here. [32:06.270 --> 32:14.210] So now I'm gonna look for the site system server, which is on this deployment is the management point. [32:14.210 --> 32:15.410] CMC. [32:15.690 --> 32:19.470] And I'm gonna get the resource ID of this server. [32:20.110 --> 32:26.890] Then use that resource ID with SCCM decrypt blog and pass the blog to. [32:28.090 --> 32:34.730] So right here, it's gonna run the scripts on the targets and wait a bit for the outputs. [32:34.730 --> 32:38.870] Then it will print out the passwords for that account. [32:40.150 --> 32:41.270] And that's it. [32:41.270 --> 32:43.270] We have the password right there. [32:44.210 --> 32:49.910] And now let me show you the same for those credentials for the application on Entry ID. [32:51.090 --> 32:52.950] So this is pretty much the same. [32:52.950 --> 32:58.570] We get our blog and we pass it in the comments for decryption. [33:10.350 --> 33:11.550] And that's our app. [33:12.990 --> 33:14.690] That's all for this demo. [33:20.970 --> 33:26.230] All right, so let me conclude this talk with two persistence methods. [33:26.950 --> 33:32.850] First, it consists in backdooring the CCM messaging protocol with a rogue service handler. [33:32.850 --> 33:41.590] So you only have to do is create a DLA that implements the ECCM endpoint interface and the method executes. [33:41.590 --> 33:42.990] It's a com method. [33:43.690 --> 33:50.730] So I will, in this example, the method will receive PowerShell commands and returns the commands in the outputs. [33:50.770 --> 33:55.430] Then you have to register the cellist ID on the management point. [33:55.430 --> 34:02.670] Then create a new CCM service endpoint configuration WMI object that use that rogue cellist ID. [34:02.930 --> 34:05.470] And the POC is available on our GitHub. [34:05.470 --> 34:08.310] So you can grab it if you want to test it. [34:11.970 --> 34:19.210] And right here, this is the signature of the execute method that you need to implement for this backdoor to process incoming messages. [34:19.210 --> 34:23.870] And to do so, the first agreement is the CCM messaging service. [34:24.330 --> 34:29.990] It has to be used to send the reply back with the send message method. [34:30.590 --> 34:37.290] And to process the incoming message, it's as the second argument of the execute method. [34:37.290 --> 34:46.090] So you use that argument and call the get body wide string method on it to get the input XML. [34:47.730 --> 34:51.070] Let me show you a demo of this backdoor in action quickly. [34:55.540 --> 34:58.480] So this is a session on a management point. [34:58.480 --> 35:03.920] I opened the WMI Explorer to explore the config related to SSM components. [35:03.960 --> 35:08.460] And mostly the one for the service handler that are registered on the management point. [35:09.540 --> 35:11.300] So I'm looking for it here. [35:14.050 --> 35:21.830] So I'm going to look for the one that starts with MP and the one with the visibility set to all. [35:21.990 --> 35:28.390] And this is the one that I'm going to copy and use as a template for the backdoor service handler. [35:29.170 --> 35:34.390] And now I'm going to compile the ROC service handler code which is written in C sharp here. [35:34.750 --> 35:39.130] Then I will use reg ASM to register the ROC class on the system. [35:44.590 --> 35:54.790] And finally, I'm going to use a partial script to register the ROC service handler in the WMI database of the CCM as a CCM service endpoint configuration instance. [35:54.790 --> 36:00.630] Here it is named MP backdoor and the visibility is set to all so we can exploit it unauthenticated. [36:02.190 --> 36:09.850] And we can see in the WMI explorer that we have our ROC service installed and it will persist between reboots too. [36:11.090 --> 36:15.890] And now I'm going to use a Python client to interact with that service. [36:16.330 --> 36:20.730] So I'm going to talk with the management point over HTTPS. [36:22.430 --> 36:25.770] And now I'm giving it the name of the service backdoor. [36:25.770 --> 36:28.850] Then the command to execute WMI, for example. [36:33.470 --> 36:36.850] And we got the output here, the inter-authority system. [36:38.350 --> 36:42.470] And let's do some directory listing too. [36:42.730 --> 36:45.470] And we got the output too from the backdoor. [36:47.630 --> 36:52.190] So that's all for this demo. [36:55.510 --> 36:56.890] All right. [36:56.890 --> 37:01.410] Last persistent technique without a demo but it's an idea. [37:01.530 --> 37:10.330] And the idea here is to backdoor the stored procedure that are used by endpoints accessible without authentication on the management point. [37:10.470 --> 37:24.630] So there are some legitimate procedures that are altered so that when a specific pattern is detected in the input, the procedure executes our supplied SQL statement. [37:24.750 --> 37:33.610] And beyond functioning as a backdoor, this technique can be leveraged when a SQL injection exists but direct access to the database isn't possible, for example. [37:33.610 --> 37:43.510] And in such cases, the management point acts as a SQL client allowing execution of arbitrary commands through the backdoor procedure. [37:43.950 --> 37:53.190] And here below you have some example of unauthenticated endpoints exposed by the management point and the stored procedure they call. [37:53.570 --> 38:06.590] So you have the first two ones for downloading policies and script documents that call MP get policy body or MP get SDM document. [38:06.950 --> 38:18.210] But also the last one is more interesting because it is through the CCM messaging and through post requests so you can send bigger payloads. [38:18.210 --> 38:25.870] So you use the site information request, for example, on the MP location service handler which calls the MP get sit info. [38:26.530 --> 38:32.950] So this is a technique that I'm going to blog about a bit later with more details, so stay tuned about it. [38:33.950 --> 38:35.090] So thank you. [38:35.090 --> 38:37.030] Let me wrap this talk quickly. [38:37.030 --> 38:41.950] So all the code examples that I presented are accessible through the links provided here. [38:42.310 --> 38:48.350] And follow our blog for upcoming posts on this topic and also disclosure of pending issues. [38:48.350 --> 38:50.310] And thank you very much for your attention. [38:50.310 --> 38:51.770] I'm grabbing some questions from...