1 00:00:00,000 --> 00:00:05,360 All right, welcome to the last track of track four of DEF CON 33. 2 00:00:06,440 --> 00:00:11,380 And he's going to be talking to us a little bit of his research into SCCM security. 3 00:00:12,940 --> 00:00:14,300 Hi, everyone. 4 00:00:14,460 --> 00:00:16,240 I'm super glad to be here. 5 00:00:16,240 --> 00:00:18,140 And thank you for staying till the end. 6 00:00:18,220 --> 00:00:23,780 So today in this last session, I will walk you through my research on SCCM. 7 00:00:24,320 --> 00:00:27,160 So let me first introduce myself. 8 00:00:27,160 --> 00: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. 9 00:00:36,780 --> 00:00:42,100 So I've been working in IT security for eight years now, and I started as a pen tester. 10 00:00:42,320 --> 00:00:46,200 And now I do red teaming full-time. 11 00:00:46,360 --> 00:00:52,960 And I mainly focus on breaking web applications and also on Active Directory stuff. 12 00:00:54,260 --> 00:00:56,760 So this talk will cover the following topics. 13 00:00:56,760 --> 00: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. 14 00:01:05,060 --> 00:01:08,790 Then I will cover the CVs I've discovered in SCCM. 15 00:01:09,180 --> 00: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. 16 00:01:20,900 --> 00: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. 17 00:01:30,660 --> 00:01:33,680 So let's start with the SCCM internals. 18 00:01:33,680 --> 00:01:41,040 For those who don't know what SCCM actually is, it was renamed recently to Microsoft Configuration Manager. 19 00:01:41,200 --> 00:01:45,780 So it's an IT asset management solution edited by Microsoft. 20 00:01:45,780 --> 00:01:52,900 It has been around for a long time now, and it is still widely used and deployed within organizations. 21 00:01:52,900 --> 00:02:01,600 And so to manage devices, SCCM installs an agent on the clients, and it provides code execution capabilities. 22 00:02:01,780 --> 00: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. 23 00:02:11,600 --> 00: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. 24 00:02:22,900 --> 00:02:29,020 But they were widely documented until now, so I won't cover them in this talk. 25 00:02:29,360 --> 00:02:35,900 So let's start with the first internal, and the first concept to introduce this part is the client communication modes. 26 00:02:35,900 --> 00:02:37,220 So you have two of them. 27 00:02:37,220 --> 00:02:43,320 So SCCM client mainly talks over HTTP with the management point. 28 00:02:44,120 --> 00:02:50,700 So you have on the management point, you can configure it either with enhanced HTTP mode. 29 00:02:50,700 --> 00:02:54,880 So this is mainly using plain HTTP transport mode. 30 00:02:54,880 --> 00:03:05,320 Or you have HTTPS mode, which is advised by Microsoft, which requires an internal PKI to issue certificates such as ADCS. 31 00:03:06,300 --> 00:03:13,660 And this is done to make the clients do mutual TLS with the management point services. 32 00:03:13,660 --> 00:03:18,660 So this is what makes the clients present 33 00:03:23,520 --> 00:03:26,220 a certificate to talk with the management point. 34 00:03:26,220 --> 00:03:36,280 So sometimes in an engagement, you need that certificate, and it can be a bit painful to exploit SCCM. 35 00:03:37,480 --> 00:03:41,230 Now let's take a look at how SCCM works under the hood. 36 00:03:41,230 --> 00:03:45,010 Most services are web applications hosted on IIS. 37 00:03:45,890 --> 00:03:52,410 From what I've seen, it's a mix of old and new technologies that are glued together sometimes. 38 00:03:52,410 --> 00:03:57,010 You have mainly ASAPI modules alongside .NET applications. 39 00:03:57,590 --> 00:04:04,770 And you also have COM that is heavily used between components, often with deep chains of COM codes. 40 00:04:04,770 --> 00:04:10,350 So when you do reverse engineering, it can be hard to follow the code flow. 41 00:04:11,490 --> 00:04:17,250 And as I have limited time, I will focus only on the services that I tied to the management point. 42 00:04:17,990 --> 00:04:21,110 And let's start with the SMS management point service. 43 00:04:21,110 --> 00:04:27,510 So on the right side, this is a snippet of a dump I did on the IIS web configuration. 44 00:04:27,510 --> 00:04:34,410 So this is only for the SMS management point service, but we'll get other snippets for other services. 45 00:04:34,590 --> 00:04:39,210 And you can observe here that there are three ASAPI modules in use. 46 00:04:39,210 --> 00: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. 47 00:04:48,010 --> 00:04:51,450 So this service has four different entry points. 48 00:04:51,450 --> 00: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. 49 00:05:03,670 --> 00: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. 50 00:05:16,370 --> 00:05:17,410 So that's weird. 51 00:05:17,970 --> 00: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. 52 00:05:27,330 --> 00:05:31,130 This is the theory, but in practice, you can bypass this. 53 00:05:31,150 --> 00:05:36,970 To do so, you have to use the SMS MP, Token-Auth, or Alt-Auth entry points. 54 00:05:37,390 --> 00:05:40,530 And here, there is no need for a client certificate. 55 00:05:40,770 --> 00: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. 56 00:05:49,850 --> 00:05:55,190 But if you hit it with the other entry points, you get 200, and you can reach the services. 57 00:05:57,130 --> 00:05:58,830 What can you do with this? 58 00:05:58,830 --> 00: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. 59 00:06:09,130 --> 00:06:11,330 There are two interesting fields. 60 00:06:11,330 --> 00: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. 61 00:06:20,370 --> 00:06:23,430 You also have another method, which is MP list one. 62 00:06:23,830 --> 00: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. 63 00:06:34,910 --> 00: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. 64 00:06:48,090 --> 00:06:52,110 Let me now cover another key service, which is CCM messaging. 65 00:06:52,530 --> 00: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. 66 00:07:02,370 --> 00:07:06,690 And here, too, anonymous authentication is enabled on three entry points. 67 00:07:08,810 --> 00:07:17,950 So in practice, CCM messaging is an HTTP-based communication protocol that uses a custom method, CCM underscore post. 68 00:07:18,210 --> 00: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. 69 00:07:30,910 --> 00:07:34,810 In this snippet below, you have the structure of a message. 70 00:07:34,810 --> 00:07:41,590 There is two main parts in a multi-part body, the XML header and the request, which is an XML document. 71 00:07:41,670 --> 00:07:49,830 So in the header, sometimes you get a message signature that is included and it proves the device identity. 72 00:07:49,830 --> 00:07:53,610 So this is how authentication is done here in this protocol. 73 00:07:55,370 --> 00: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. 74 00:08:06,030 --> 00: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. 75 00:08:13,550 --> 00:08:18,510 And once again, everything is done through COM as the service handler are COM classes. 76 00:08:18,530 --> 00: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. 77 00:08:32,690 --> 00:08:38,090 So the first one is where the configuration is persisted between reboots. 78 00:08:39,150 --> 00: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. 79 00:08:55,790 --> 00:08:58,870 So this is where the authorization level is defined. 80 00:08:59,570 --> 00:09:07,770 And as you can see in the dump below, the MP services are configured with either all or client signed visibility. 81 00:09:08,170 --> 00:09:13,090 And I will circle back to this knowledge at the end of this talk for the persistence part. 82 00:09:14,570 --> 00:09:22,450 And once again, when HTTPS mode is enabled, there is also a trick to bypass mutual TLS for CCM messaging. 83 00:09:22,810 --> 00:09:27,710 So you need to use CCM system alt-auth entry point to do so. 84 00:09:27,790 --> 00:09:33,030 Unfortunately, the other entry point with the token auth doesn't work at this time. 85 00:09:33,030 --> 00: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. 86 00:09:45,230 --> 00:09:50,890 So how can you leverage this bypass to do some nasty thing on ECCM? 87 00:09:50,950 --> 00:09:56,790 In fact, you can loot NIA credentials without having Windows credentials on the network. 88 00:09:57,410 --> 00: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. 89 00:10:09,470 --> 00:10:10,470 That's needed. 90 00:10:10,470 --> 00:10:15,650 So when you do that registration, the SSM client is approved. 91 00:10:15,650 --> 00:10:18,430 And this is mandatory to pull policies. 92 00:10:18,430 --> 00:10:26,370 However, with this mutual TLS bypass, if you register a client with a domain credentials, it is automatically marked as approved. 93 00:10:26,670 --> 00:10:31,030 Thus, this gives you the ability to loot NIA credentials unauthenticated. 94 00:10:31,410 --> 00:10:37,710 So I plan on updating the tool SSCM secrets, which is available on GitHub already. 95 00:10:37,850 --> 00:10:42,850 So I will do a pull request in the next day, right after the DevCon. 96 00:10:42,850 --> 00:10:46,230 So I've discovered this while preparing this talk. 97 00:10:47,970 --> 00:10:48,510 All right. 98 00:10:48,510 --> 00:10:54,310 Another service that is interesting is the one that is named SMS Provider. 99 00:10:54,310 --> 00:10:59,130 It acts as an abstraction layer for read and write operation on the database. 100 00:10:59,190 --> 00:11:01,950 So this is a completely different role. 101 00:11:01,950 --> 00:11:08,390 It creates a specific WMI namespace named SMS underscore this three-letter site code. 102 00:11:08,970 --> 00:11:14,550 And access control is managed through airbag, withdrawals that are defined in the database. 103 00:11:14,910 --> 00: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. 104 00:11:24,230 --> 00: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. 105 00:11:33,730 --> 00:11:36,810 So this gives you the ability to do some relaying. 106 00:11:38,710 --> 00:11:44,730 And on top of that, the SMS Provider exposes the Admin Service REST API. 107 00:11:45,790 --> 00: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. 108 00:11:57,810 --> 00:12:05,210 And this API is a .NET application built with Owen, and there is no way to configure or enable EPA. 109 00:12:05,210 --> 00:12:11,170 So this makes it vulnerable by default, by design, to relay attacks. 110 00:12:11,910 --> 00:12:13,430 So you can't fix that. 111 00:12:14,350 --> 00:12:18,190 And let me finish with the Tenant Attach concept. 112 00:12:18,190 --> 00:12:24,530 So for a hybrid management approach, an SCCM site can be configured with Tenant Attach. 113 00:12:24,710 --> 00:12:30,490 Basically, the feature allows the on-premise SCCM instance to connect to Intune. 114 00:12:30,730 --> 00:12:35,610 And when enabled, the SCCM instance uploads service device information to Intune. 115 00:12:35,610 --> 00: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. 116 00:12:47,350 --> 00: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. 117 00:12:56,810 --> 00:13:02,990 So it's an intra-ID application, granted the following permission on the tenant. 118 00:13:02,990 --> 00:13:11,850 So we have read and write collection data on the configuration manager microservice API, which is an undocumented API. 119 00:13:12,110 --> 00:13:16,650 But also we have directory read-all granted on the graph API. 120 00:13:16,970 --> 00:13:23,010 So this is an account that you can extract from the on-premise to perform reconnaissance on the tenant. 121 00:13:23,710 --> 00:13:29,590 And I'll get back later to this account and show you how you can recover its credentials from the database. 122 00:13:31,110 --> 00:13:34,390 All right, let's talk a bit about zero days. 123 00:13:34,390 --> 00:13:40,570 So now I'm gonna walk you through how I identified vulnerabilities in SCCM. 124 00:13:40,610 --> 00:13:49,890 I will mostly detail the methodology I applied so you can see exactly how the issues were discovered. 125 00:13:49,890 --> 00:13:51,890 So I got two of them today. 126 00:13:52,470 --> 00:13:54,990 So the first one, it's CVE-2024. 127 00:13:54,990 --> 00:14:00,430 It's an unauthenticated SQL injection that I discussed earlier this year. 128 00:14:00,470 --> 00:14:08,370 So it affects SCCM messaging, the MP location manager handler. 129 00:14:08,890 --> 00: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. 130 00:14:19,150 --> 00:14:24,910 And usually the management point and site server roles are installed on the same server. 131 00:14:24,910 --> 00: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. 132 00:14:34,450 --> 00:14:40,170 And to mitigate the impact, Microsoft advises to install the roles on distinct servers. 133 00:14:40,170 --> 00:14:43,530 So the code is already available on our GitHub. 134 00:14:45,230 --> 00: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. 135 00:14:54,330 --> 00:14:58,730 And some SQL format string patterns stand out right away. 136 00:14:58,730 --> 00: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. 137 00:15:08,470 --> 00: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. 138 00:15:23,730 --> 00: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. 139 00:15:35,210 --> 00:15:39,070 So here comes the question, how to reach this flawed method? 140 00:15:40,950 --> 00: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. 141 00:15:52,570 --> 00:15:56,250 It stands out as the simplest route to reach the code. 142 00:15:56,910 --> 00:15:59,610 So this is the one I took for the exploit. 143 00:15:59,710 --> 00:16:03,130 There is less hassle and less condition to reach the code. 144 00:16:04,330 --> 00:16:09,490 And following that shortest path from the CTO, I landed in the code location shown in this screenshot. 145 00:16:09,790 --> 00: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. 146 00:16:19,650 --> 00:16:24,910 So this is helpful next to choose which requests to pick up. 147 00:16:24,910 --> 00: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. 148 00:16:37,290 --> 00: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. 149 00:16:49,830 --> 00:16:53,050 And here is the final CCM message to exploit the injection. 150 00:16:53,050 --> 00:17:00,310 So on the left side, you have the header part where the injection point is located in the source ID field. 151 00:17:00,310 --> 00:17:08,110 So this is the injection point is in the header, which isn't even signed by the client. 152 00:17:08,150 --> 00: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. 153 00:17:15,610 --> 00:17:17,090 So that's the exploitation. 154 00:17:17,910 --> 00:17:24,670 All right, so when the patch was released, I confirmed the issue was fixed because they now use prepared statements. 155 00:17:25,470 --> 00: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. 156 00:17:39,470 --> 00:17:45,730 And digging a bit further, I concluded that the if condition checks if a registry value is set on the system. 157 00:17:45,730 --> 00:17:48,430 So it's named disable additional validations. 158 00:17:48,730 --> 00:17:52,770 So this is clearly a fail-safe to bypass that patch. 159 00:17:53,110 --> 00:17:59,390 So when you exploit the system and you put that value, you will get the vulnerability again. 160 00:17:59,830 --> 00: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. 161 00:18:09,810 --> 00:18:16,750 So they left that if condition as a rollback for customers that are complaining about the patch. 162 00:18:18,430 --> 00:18:22,670 All right, let's talk now about the other CVE 2025. 163 00:18:22,690 --> 00:18:27,910 It's a not authenticated SQL injection in the SMS provider component. 164 00:18:27,910 --> 00:18:29,450 It's the admin service. 165 00:18:29,990 --> 00:18:35,630 Microsoft released a patch in July 2025 to address this flow. 166 00:18:36,250 --> 00:18:42,050 So this vulnerability can be exploited using any SCCM airbag role, even the read-only one. 167 00:18:42,050 --> 00:18:43,710 We'll see later why. 168 00:18:44,370 --> 00:18:49,550 And I am releasing the proof of concept for this issue right after this talk. 169 00:18:52,090 --> 00:18:57,530 So to discover this bug, I reviewed the MOV file for the SMS provider namespace. 170 00:18:57,530 --> 00:19:07,030 I looked mostly for patterns where methods had parameters that appear numeric but are defined as strings in the WMI side. 171 00:19:07,070 --> 00:19:16,370 So this mismatch between the expected type and the one defined into WMI enables potential injection. 172 00:19:16,370 --> 00: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. 173 00:19:28,810 --> 00:19:31,690 So you have its definition here in the snippet. 174 00:19:34,170 --> 00: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. 175 00:19:44,970 --> 00:19:50,890 So that's why a user with any RBAC role, even the read-only one, can exploit this injection. 176 00:19:53,050 --> 00:19:57,070 And from my point of view, there are two ways to exploit this issue. 177 00:19:57,090 --> 00:20:03,950 First is obtaining credentials for a user having any SSCM administrative role. 178 00:20:04,090 --> 00:20:08,130 But this is not that easy on an engagement. 179 00:20:08,790 --> 00:20:19,710 Otherwise, you can perform authentication relay against the admin service API on which EPA protection can't be required. 180 00:20:19,930 --> 00:20:25,650 So depending on the topology of the deployment you got, you have multiple scenarios. 181 00:20:25,650 --> 00: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. 182 00:20:37,170 --> 00: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. 183 00:20:47,230 --> 00: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. 184 00:20:59,010 --> 00:21:04,710 So remember, there is a CVE for NLM reflection that was disclosed in June. 185 00:21:04,710 --> 00:21:06,590 So you can use that to exploit. 186 00:21:08,730 --> 00:21:14,010 All right, so I have other unresolved issues with Microsoft, but I cannot cover them in this session. 187 00:21:14,010 --> 00:21:21,210 But stay tuned, I will share the details at the appropriate time when I got the disclosure is okay. 188 00:21:22,370 --> 00:21:28,670 Let me cover now the post-exploitation phase, when you got yourself an admin access. 189 00:21:29,190 --> 00:21:32,070 Let's see what you can do from the database, for example. 190 00:21:32,750 --> 00:21:36,910 So in SCCM, there is the create and run script feature. 191 00:21:36,910 --> 00:21:41,690 It's super interesting as it allows you to run PowerShell on a single device. 192 00:21:41,930 --> 00:21:49,130 The execution is done as system, and the process is spawned by the CCM exec process, which is highly trusted binary. 193 00:21:49,470 --> 00:21:55,810 And to exploit this feature, actual public tools leverage the admin service API of the SMS provider to do so. 194 00:21:55,910 --> 00:22:01,010 So there are some downsides to doing that, especially during a red team. 195 00:22:01,010 --> 00:22:03,450 First, all actions are logged. 196 00:22:03,890 --> 00:22:07,690 Then there is also a double approval mechanism by default. 197 00:22:07,690 --> 00:22:10,770 So you need two accounts to exploit this. 198 00:22:10,770 --> 00:22:14,230 One to create the script and another one to approve it. 199 00:22:14,310 --> 00:22:19,190 And finally, you can't properly clean exploitation artifacts behind yourself. 200 00:22:20,970 --> 00:22:29,410 So I asked myself if it was possible to trigger the script execution feature directly from the database access. 201 00:22:29,570 --> 00:22:31,010 And the answer is yes. 202 00:22:31,010 --> 00:22:37,070 Doing so bypasses the double approval process, and it leaves minimal logging press behind you. 203 00:22:37,330 --> 00:22:38,550 And here is how to do so. 204 00:22:38,550 --> 00:22:40,430 We have some steps to do so. 205 00:22:40,670 --> 00:22:44,410 First, you'll have to create an entry in the scripts table. 206 00:22:45,490 --> 00:22:47,630 There are some columns that are interesting. 207 00:22:47,950 --> 00:22:52,030 For example, the script type set to zero is for PowerShell. 208 00:22:52,070 --> 00:22:53,110 You have the approver set. 209 00:22:53,110 --> 00:22:57,010 You directly set it to three, so to mark the script as already approved. 210 00:22:57,230 --> 00:22:58,450 You have a feature. 211 00:22:58,450 --> 00:23:01,950 If you set it to one, the script won't show up in the admin console. 212 00:23:01,950 --> 00:23:07,530 Finally, the approver author are free text, so you can spoof whatever identity suits you. 213 00:23:09,290 --> 00:23:15,010 Then we add an entry in the BGP task table, which will reference the script that we've created. 214 00:23:15,010 --> 00:23:17,230 So we have one part is the template ID. 215 00:23:17,230 --> 00:23:22,290 We set it to 15 to say that it's a task to request script execution. 216 00:23:22,430 --> 00:23:28,090 Then you have the param column, which holds a task param XML document. 217 00:23:28,090 --> 00:23:32,670 So this document will include the ID of the script to execute. 218 00:23:32,670 --> 00: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. 219 00:23:43,170 --> 00:23:46,610 Then we add an entry in the BGP REST task table. 220 00:23:46,610 --> 00:23:49,650 So this is where you assign the task to a client. 221 00:23:49,650 --> 00: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. 222 00:23:57,610 --> 00:24:05,430 So this insertion triggers a push notification to the client, and it downloads the XML document and the script later. 223 00:24:06,950 --> 00: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. 224 00:24:17,550 --> 00:24:21,330 So you have the exit status code along the route output. 225 00:24:21,370 --> 00:24:25,550 So you have to, after a slight delay, you have to query that table. 226 00:24:28,130 --> 00: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. 227 00:24:40,350 --> 00:24:43,970 But the script content isn't logged, so that's OK. 228 00:24:44,090 --> 00:24:52,450 However, beware that the script, which is downloaded on the client side, is stored in a script store folder. 229 00:24:52,470 --> 00:24:58,750 But that file isn't removed after the execution, so you need to delete it manually. 230 00:25:00,930 --> 00:25:04,650 And now I'm glad to introduce you to sccm-sql-client.py. 231 00:25:04,650 --> 00:25:09,790 It's a tool that implements these techniques to automate as much as possible. 232 00:25:10,170 --> 00:25:16,570 So it started as a fork of Impact's MSSQL client with queries to explore an SCCM database. 233 00:25:16,990 --> 00: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. 234 00:25:29,310 --> 00:25:36,430 So regarding the feature, there are some queries to map the topology, but also to list clients or list store credentials. 235 00:25:36,510 --> 00:25:43,550 But also you have some features to run the PowerShell scripts on clients, but also to decrypt the credentials automatically. 236 00:25:44,310 --> 00: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. 237 00:25:53,410 --> 00:25:56,310 So you don't leave anything behind you. 238 00:25:56,310 --> 00:26:00,850 And it also includes some helpers to clean the artifacts easily from the database. 239 00:26:01,150 --> 00:26:04,770 And let me just describe you some of its key commands. 240 00:26:07,310 --> 00:26:10,630 First to map the topology, you can use SCCM servers. 241 00:26:10,630 --> 00:26:16,610 It will just list the servers within a hierarchy so you can check for server from other sites. 242 00:26:16,610 --> 00:26:18,330 Then you have SCCM devices. 243 00:26:18,330 --> 00:26:24,050 So you will get a full list of known devices, also devices from other sites. 244 00:26:24,350 --> 00:26:28,010 Then an important one is SCCM devices BGP status. 245 00:26:28,010 --> 00:26:34,550 So we get only the clients for your current sites with their BGP status. 246 00:26:34,550 --> 00:26:40,510 So the BGP status is the thing that will tell you if you can execute scripts on those clients. 247 00:26:42,230 --> 00: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. 248 00:26:53,130 --> 00:26:58,270 And then you'll have to run SCCM run script with the resource ID of your target device. 249 00:26:58,350 --> 00:27:02,790 And at this step, the tool prepends the commands to clean the script store folder, as I said. 250 00:27:03,490 --> 00:27:07,350 Then to get the output, you use last task output. 251 00:27:07,350 --> 00:27:09,910 It's a helper to check the execution output. 252 00:27:09,910 --> 00:27:13,990 It uses the generated GUIDs that are kept in memory. 253 00:27:14,630 --> 00:27:20,330 Finally, use the last task clean, which is a helper to clean the artifacts from the database. 254 00:27:20,330 --> 00:27:22,310 It will delete everything. 255 00:27:24,810 --> 00:27:32,110 Regarding secret extraction, so to look for secrets in the database, you can use SCCM user accounts. 256 00:27:32,110 --> 00:27:36,330 It will query the table that stores NAA accounts and push accounts. 257 00:27:36,610 --> 00:27:41,650 And here the password field is encrypted with crypto API on the site system server. 258 00:27:41,650 --> 00:27:45,970 And only that site system server that issued that blob can decrypt it. 259 00:27:48,450 --> 00:27:51,970 And you also have SCCM AAD apps. 260 00:27:52,090 --> 00: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. 261 00:28:01,370 --> 00: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. 262 00:28:13,610 --> 00:28:15,390 So this is mostly interesting. 263 00:28:15,390 --> 00:28:18,710 It makes it easier to decrypt. 264 00:28:19,770 --> 00:28:26,170 And to decrypt the secrets, we need to execute code on the site system servers that created the blobs. 265 00:28:26,550 --> 00:28:30,170 And by default, they are enrolled as clients too. 266 00:28:30,310 --> 00:28:33,950 So we can run a specific script to decrypt those blobs. 267 00:28:34,410 --> 00:28:39,290 So the tool has an SCCM decrypt blob command to automate that process. 268 00:28:39,910 --> 00:28:45,050 So you need to give it the resource ID of a site system server and the blob to decrypt. 269 00:28:45,050 --> 00:28:50,130 And depending on the blob format, it will use the right PowerShell command snippet to decrypt it. 270 00:28:50,130 --> 00:28:59,030 So these commands use C-sharp assemblies available on the SCCM servers and that expose methods to decrypt those secrets. 271 00:28:59,030 --> 00:29:03,310 So you have more details in the slides for later. 272 00:29:04,350 --> 00:29:06,410 So it's time for a demo. 273 00:29:06,410 --> 00: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. 274 00:29:15,330 --> 00: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. 275 00:29:27,770 --> 00:29:35,230 And finally, with the database level access, I will showcase you the SCCM SQL client tool for some commands. 276 00:29:38,980 --> 00:29:44,180 So I'm starting with some recon with the bypass for mutual TLS. 277 00:29:48,410 --> 00: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. 278 00:29:58,110 --> 00:30:03,970 And now I'm using a modified version of SCCM secrets to dump the policies. 279 00:30:03,970 --> 00:30:11,590 So I'm not giving it any Windows credentials and I will dump the policies like that over HTTPS too. 280 00:30:11,970 --> 00:30:15,990 So this is the name of the client, the fake client that will be created. 281 00:30:16,410 --> 00:30:17,470 And here we go. 282 00:30:19,150 --> 00:30:23,890 And we have three accounts that are dumped by the tool and the last one we'll use it later. 283 00:30:23,890 --> 00:30:30,010 So now I'm gonna show you that the fake clients that is created from in the SCCM console is approved. 284 00:30:30,010 --> 00:30:33,770 So this bypass makes you create an approved client. 285 00:30:35,530 --> 00: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. 286 00:30:54,010 --> 00:30:55,010 That's done. 287 00:30:55,010 --> 00:31:01,470 Now we can use SCCM SQL client to access the database and confirm that we are administrator. 288 00:31:02,630 --> 00:31:05,970 Now we can list the sites and it works. 289 00:31:05,970 --> 00:31:10,150 So now let me showcase the SCCM SQL client. 290 00:31:10,150 --> 00:31:13,530 First by executing commands on a domain controller. 291 00:31:13,530 --> 00:31:18,550 So now with the BGP status, I confirm that the DC has online status at one. 292 00:31:18,550 --> 00:31:20,810 So we can execute commands on it. 293 00:31:21,290 --> 00:31:26,430 And right here, I'm loading a command to execute on the controller. 294 00:31:26,950 --> 00:31:28,610 Then I will launch it. 295 00:31:28,610 --> 00:31:33,490 So you need to pass the resource ID to run the command. 296 00:31:37,670 --> 00:31:41,790 And now we wait a bit and we're gonna get the outputs. 297 00:31:41,790 --> 00:31:43,590 And that's all right. 298 00:31:50,630 --> 00:31:56,010 Okay, so with the last task clean, you can clean behind yourself the insertion that were done in the database. 299 00:31:56,310 --> 00:32:00,290 So now let me show you how we can extract the credential and decrypt them. 300 00:32:00,990 --> 00:32:02,970 So this is for the user accounts. 301 00:32:02,970 --> 00:32:05,770 We have the push account, the NA accounts here. 302 00:32:06,270 --> 00:32:14,210 So now I'm gonna look for the site system server, which is on this deployment is the management point. 303 00:32:14,210 --> 00:32:15,410 CMC. 304 00:32:15,690 --> 00:32:19,470 And I'm gonna get the resource ID of this server. 305 00:32:20,110 --> 00:32:26,890 Then use that resource ID with SCCM decrypt blog and pass the blog to. 306 00:32:28,090 --> 00:32:34,730 So right here, it's gonna run the scripts on the targets and wait a bit for the outputs. 307 00:32:34,730 --> 00:32:38,870 Then it will print out the passwords for that account. 308 00:32:40,150 --> 00:32:41,270 And that's it. 309 00:32:41,270 --> 00:32:43,270 We have the password right there. 310 00:32:44,210 --> 00:32:49,910 And now let me show you the same for those credentials for the application on Entry ID. 311 00:32:51,090 --> 00:32:52,950 So this is pretty much the same. 312 00:32:52,950 --> 00:32:58,570 We get our blog and we pass it in the comments for decryption. 313 00:33:10,350 --> 00:33:11,550 And that's our app. 314 00:33:12,990 --> 00:33:14,690 That's all for this demo. 315 00:33:20,970 --> 00:33:26,230 All right, so let me conclude this talk with two persistence methods. 316 00:33:26,950 --> 00:33:32,850 First, it consists in backdooring the CCM messaging protocol with a rogue service handler. 317 00:33:32,850 --> 00:33:41,590 So you only have to do is create a DLA that implements the ECCM endpoint interface and the method executes. 318 00:33:41,590 --> 00:33:42,990 It's a com method. 319 00:33:43,690 --> 00:33:50,730 So I will, in this example, the method will receive PowerShell commands and returns the commands in the outputs. 320 00:33:50,770 --> 00:33:55,430 Then you have to register the cellist ID on the management point. 321 00:33:55,430 --> 00:34:02,670 Then create a new CCM service endpoint configuration WMI object that use that rogue cellist ID. 322 00:34:02,930 --> 00:34:05,470 And the POC is available on our GitHub. 323 00:34:05,470 --> 00:34:08,310 So you can grab it if you want to test it. 324 00:34:11,970 --> 00: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. 325 00:34:19,210 --> 00:34:23,870 And to do so, the first agreement is the CCM messaging service. 326 00:34:24,330 --> 00:34:29,990 It has to be used to send the reply back with the send message method. 327 00:34:30,590 --> 00:34:37,290 And to process the incoming message, it's as the second argument of the execute method. 328 00:34:37,290 --> 00:34:46,090 So you use that argument and call the get body wide string method on it to get the input XML. 329 00:34:47,730 --> 00:34:51,070 Let me show you a demo of this backdoor in action quickly. 330 00:34:55,540 --> 00:34:58,480 So this is a session on a management point. 331 00:34:58,480 --> 00:35:03,920 I opened the WMI Explorer to explore the config related to SSM components. 332 00:35:03,960 --> 00:35:08,460 And mostly the one for the service handler that are registered on the management point. 333 00:35:09,540 --> 00:35:11,300 So I'm looking for it here. 334 00:35:14,050 --> 00: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. 335 00:35:21,990 --> 00:35:28,390 And this is the one that I'm going to copy and use as a template for the backdoor service handler. 336 00:35:29,170 --> 00:35:34,390 And now I'm going to compile the ROC service handler code which is written in C sharp here. 337 00:35:34,750 --> 00:35:39,130 Then I will use reg ASM to register the ROC class on the system. 338 00:35:44,590 --> 00: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. 339 00:35:54,790 --> 00:36:00,630 Here it is named MP backdoor and the visibility is set to all so we can exploit it unauthenticated. 340 00:36:02,190 --> 00: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. 341 00:36:11,090 --> 00:36:15,890 And now I'm going to use a Python client to interact with that service. 342 00:36:16,330 --> 00:36:20,730 So I'm going to talk with the management point over HTTPS. 343 00:36:22,430 --> 00:36:25,770 And now I'm giving it the name of the service backdoor. 344 00:36:25,770 --> 00:36:28,850 Then the command to execute WMI, for example. 345 00:36:33,470 --> 00:36:36,850 And we got the output here, the inter-authority system. 346 00:36:38,350 --> 00:36:42,470 And let's do some directory listing too. 347 00:36:42,730 --> 00:36:45,470 And we got the output too from the backdoor. 348 00:36:47,630 --> 00:36:52,190 So that's all for this demo. 349 00:36:55,510 --> 00:36:56,890 All right. 350 00:36:56,890 --> 00:37:01,410 Last persistent technique without a demo but it's an idea. 351 00:37:01,530 --> 00: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. 352 00:37:10,470 --> 00: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. 353 00:37:24,750 --> 00: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. 354 00:37:33,610 --> 00:37:43,510 And in such cases, the management point acts as a SQL client allowing execution of arbitrary commands through the backdoor procedure. 355 00:37:43,950 --> 00:37:53,190 And here below you have some example of unauthenticated endpoints exposed by the management point and the stored procedure they call. 356 00:37:53,570 --> 00: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. 357 00:38:06,950 --> 00: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. 358 00:38:18,210 --> 00: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. 359 00:38:26,530 --> 00: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. 360 00:38:33,950 --> 00:38:35,090 So thank you. 361 00:38:35,090 --> 00:38:37,030 Let me wrap this talk quickly. 362 00:38:37,030 --> 00:38:41,950 So all the code examples that I presented are accessible through the links provided here. 363 00:38:42,310 --> 00:38:48,350 And follow our blog for upcoming posts on this topic and also disclosure of pending issues. 364 00:38:48,350 --> 00:38:50,310 And thank you very much for your attention. 365 00:38:50,310 --> 00:38:51,770 I'm grabbing some questions from...