"title"=>"SeeSeeYouExec: Windows Session Hijacking via CcmExec",
"summary"=>"
Written by: Andrew Oliveau
\n\n
Over the last several years, the security community has witnessed an uptick in System Center Configuration Manager (SCCM)-related attacks. From extracting network access account (NAA) credentials to deploying malicious applications to targeted devices, SCCM attacks have aided in accomplishing complex objectives and evading existing detections. Mandiant's Red Team has utilized SCCM technology to perform novel attacks against mature clients where conventional methodology was not possible. One such SCCM attack is introduced in this blog post.
\nThere was a time when red teamers with elevated privileges on a Windows system could effortlessly inject shellcode into an unsuspecting user's processes. This allowed red teamers to carry out post-exploitation activities within that new process, such as keylogging or accessing LDAP as the affected user. However, as endpoint detection and response (EDR) systems have improved, remote process injection has turned into a risky operation, pushing red teamers to seek alternative methods to hijack a user's session.
\nEnter CcmExec, a service native to SCCM Windows clients that has an interesting design that is useful for red teamers. In this blog post, we delve into how the CcmExec service can be utilized for session hijacking and introduce CcmPwn, a tool designed to facilitate this technique. Finally, we will discuss detection strategies for security teams.
\nAppDomainManager Injection
\nBefore diving into CcmExec, it is important to understand the intricacies of AppDomainManager injection, a loader hijacking technique used by attackers to execute arbitrary code within a .NET application. In essence, the .NET framework provides a way to manage application domains, which are isolated environments where .NET applications can run code. The AppDomainManager class is a key part of this infrastructure, responsible for creating and managing these application domains. However, if an attacker were to override the AppDomainManager class constructor, they could force the hosting application to run attacker-defined behavior when creating an application domain.
\nThe most common method to perform AppDomainManager injection is through a .config
file. This approach involves modifying the application's configuration file to specify a custom dynamic-link library file (DLL) and AppDomainManager to be executed by the .NET application. Here's how it's done:
- \n
- \n
Create a custom AppDomainManager: Develop a class that derives from AppDomainManager and includes malicious code. Compile this class into a DLL.
\n \n - \n
Create a configuration file: Modify or create the application's
\n.config
file (e.g., \"application.exe.config
\") and add the following XML elements to specify the custom DLL and AppDomainManager:
\n<configuration>\n <runtime>\n <appDomainManagerAssembly value=\"YourDLL, Version=1.0.0.0, \nCulture=neutral, PublicKeyToken=null\" />\n <appDomainManagerType value=\"YourAppDomainManager\" />\n </runtime>\n</configuration>\n
\n - Execute the application: When the .NET application is executed, the .NET runtime reads the
.config
file located in the same folder and loads the specified custom AppDomainManager. The code within the AppDomainManager is then executed within the context of the application. \n
Hijacking CcmExec
\nWhen analyzing the CcmExec service's process, CcmExec.exe
, with a process analyzing tool such as Process Explorer, a couple of things immediately stand out. The first thing that catches the eye is that the process spawns the C:\\Windows\\CCM\\SCNotification.exe
process for every interactive session on the Windows system, as shown in Figure 1. SCNotification.exe
is a component of the SCCM client responsible for displaying notifications to the user, such as software installation prompts or restart notifications.
Upon further inspection, it turns out that the SCNotification.exe
file is a .NET application, which comes with its application configuration file at C:\\Windows\\CCM\\SCNotification.exe.config
. Do you see where this is going?
By having administrator privileges on a Windows system configured as an SCCM client, we could modify the configuration file to instruct the .NET application to load a malicious DLL and obtain code execution on behalf of every logged-in user! The attack is simple:
\n- \n
- \n
Upload a malicious DLL to the target system: This DLL contains the AppDomainManager code to be executed in the user's session.
\n \n - \n
Modify the SCNotification.exe.config configuration file: Point to the malicious DLL within this file.
\n \n - \n
Restart the CcmExec service: This action causes the
\nCcmExec.exe
process to restart and runSCNotification.exe
for every logged-in user. \n
This technique provides a stealthy way to execute code across multiple user sessions without having to rely on remote shellcode injection.
\nWeaponizing Session Hijacking with CcmPwn
\nWeaponizing this technique is straightforward. Using the Impacket library, we developed CcmPwn to execute the aforementioned attack and hijack user sessions. CcmPwn is equipped with various modules. The exec
module uploads a custom configuration and DLL file to the target system, remotely restarts the CcmExec service, and then reuploads the original configuration file. An example is illustrated in Figure 2 and Figure 3, where using CcmPwn provided us with Cobalt Strike beacons for the hijacked sessions.
Additionally, CcmPwn features a coerce
module, which coerces an SMB or HTTP authentication request for every logged-in user. Red teamers can leverage these coerced authentications to attempt password cracking or conduct relay attacks. This module does not require a DLL, as it simply uploads a malicious configuration file to the target. This file instructs SCNotification.exe
to load a file from an attacker-controlled file share, as shown in Figure 4 and Figure 5.
Defensive Considerations
\nDepending on the security information and event management (SIEM) or EDR solution in use, this attack can be detected in a variety of ways. The following defensive measures are recommended:
\n- \n
- Monitor for 1026 Events for SCNotification.exe: Event ID 1026 is associated with .NET runtime errors. When using CcmPwn's
coerce
module,SCNotification.exe
attempts to load a non-existent DLL from an attacker-controlled file share. Since the DLL cannot be found, the application produces aSystem.IO.FileLoadException
error. An example of this behavior is shown in Figure 6. \n
- \n
- Monitor for 7036 Events and Remote Logon Type 3: The 7036 event corresponds to the starting and stopping of services. By monitoring this event, security teams can detect suspicious restarts of the CcmExec service, which may indicate an attempt to hijack user sessions. When using CcmPwn, a logon type 3 (network logon) event will occur at the same time as the service stop, followed by a 20-second delay before the service is started again. Monitoring for this pattern can help triage these service events and provide context around potentially malicious activity. \n
- Monitor File Modification and Configuration Strings: Since attackers need to modify the
SCNotification.exe.config
file to execute this attack, monitoring for changes to this file can provide an early warning. Additionally, the presence of the \"AppDomainManagerType
\" string in the configuration file should be scrutinized, as it is used in AppDomainManager injection attacks. Security teams should investigate any unexpected occurrences of this string inSCNotification.exe.config
. \n
By implementing these defensive measures and adapting them to the specific capabilities of their SIEM or EDR solutions, organizations can enhance their ability to detect and respond to session hijacking attacks via the CcmExec service.
"content"=>"",
"author"=>"Mandiant ",
"link"=>"https://cloud.google.com/blog/topics/threat-intelligence/windows-session-hijacking-via-ccmexec/",
"published_date"=>Thu, 28 Mar 2024 13:00:00.000000000 UTC +00:00,
"image_url"=>nil,
"feed_url"=>"https://cloud.google.com/blog/topics/threat-intelligence/windows-session-hijacking-via-ccmexec/",
"language"=>nil,
"active"=>true,
"ricc_source"=>"feedjira::v1",
"created_at"=>Sun, 31 Mar 2024 21:24:12.853342000 UTC +00:00,
"updated_at"=>Mon, 21 Oct 2024 16:59:06.112561000 UTC +00:00,
"newspaper"=>"Google Cloud Blog",
"macro_region"=>"Technology"}