Skip to main content

Overview

DCOM (Distributed Component Object Model) is Microsoft’s technology for component-based object-oriented programming over the network. Impacket provides support for DCOM and its most common use case: Windows Management Instrumentation (WMI).

DCOM Architecture

DCOM extends COM (Component Object Model) to support remote object creation and method invocation. Key concepts:
  • OBJREF: Object references that identify remote objects
  • IPID: Interface Pointer Identifier
  • OXID: Object Exporter Identifier
  • IRemUnknown: Base interface for remote objects

DCOM Modules

Location: impacket/dcerpc/v5/dcom/
  • dcomrt.py - DCOM runtime and core interfaces
  • wmi.py - WMI implementation
  • oaut.py - OLE Automation types
  • vds.py - Virtual Disk Service
  • comev.py - COM Event System
  • scmp.py - DCOM System Configuration

Windows Management Instrumentation (WMI)

Basic WMI Query

Common WMI Queries

Remote Command Execution via WMI

Semi-Interactive Shell via WMI

Event Subscriptions (Persistence)

DCOM Direct Interface Access

ShellWindows Interface

MMC20.Application

Authentication Options

Error Handling

DCOM Port Requirements

  • TCP 135: RPC Endpoint Mapper
  • TCP 49152-65535: Dynamic RPC ports (Windows 2008+)
  • TCP 1024-5000: Dynamic RPC ports (older Windows)
To restrict DCOM to specific ports, configure the server’s RPC settings.

Security Considerations

  1. Authentication: DCOM requires valid credentials
  2. Privileges: WMI access requires local admin rights
  3. Firewall: DCOM uses dynamic ports that may be blocked
  4. Logging: WMI activity is logged in Windows Event Logs
  5. Detection: WMI process creation is commonly monitored by EDR

Best Practices

  1. Always disconnect DCOM connections properly
  2. Handle exceptions for network and authentication errors
  3. Use specific WQL queries instead of SELECT * for performance
  4. Clean up WMI event subscriptions after use
  5. Consider using RemRelease() for interface cleanup

References

  • [MS-DCOM]: Distributed Component Object Model (DCOM) Remote Protocol
  • [MS-WMI]: Windows Management Instrumentation Remote Protocol
  • [MS-WMIO]: Windows Management Instrumentation Encoding
  • WQL (WMI Query Language) Documentation