Skip to content

Commit 8840482

Browse files
authored
Merge pull request #1133 from HackTricks-wiki/update_Automating_MS-RPC_vulnerability_research_20250715_183154
Automating MS-RPC vulnerability research
2 parents b228d7c + fc4a526 commit 8840482

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

src/network-services-pentesting/135-pentesting-msrpc.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,89 @@ It is possible to execute remote code on a machine, if the credentials of a vali
8989

9090
The **rpcdump.exe** from [rpctools](https://resources.oreilly.com/examples/9780596510305/tree/master/tools/rpctools) can interact with this port.
9191

92+
### Automated Interface Enumeration & Dynamic Client Generation (NtObjectManager)
93+
94+
PowerShell guru **James Forshaw** exposed most of the Windows RPC internals inside the open–source *NtObjectManager* module. Using it you can turn any RPC server DLL / EXE into a **fully-featured client stub** in seconds – no IDL, MIDL or manual unmarshalling required.
95+
96+
```powershell
97+
# Install the module once
98+
Install-Module NtObjectManager -Force
99+
100+
# Parse every RPC interface exported by the target binary
101+
$rpcinterfaces = Get-RpcServer "C:\Windows\System32\efssvc.dll"
102+
$rpcinterfaces | Format-Table Name,Uuid,Version,Procedures
103+
104+
# Inspect a single procedure (opnum 0)
105+
$rpcinterfaces[0].Procedures[0] | Format-List *
106+
```
107+
108+
Typical output exposes parameter types exactly as they appear in **MIDL** (e.g. `FC_C_WSTRING`, `FC_LONG`, `FC_BIND_CONTEXT`).
109+
110+
Once you know the interface you can **generate a ready-to-compile C# client**:
111+
112+
```powershell
113+
# Reverse the MS-EFSR (EfsRpc*) interface into C#
114+
Format-RpcClient $rpcinterfaces[0] -Namespace MS_EFSR -OutputPath .\MS_EFSR.cs
115+
```
116+
117+
Inside the produced stub you will find methods such as:
118+
119+
```csharp
120+
public int EfsRpcOpenFileRaw(out Marshal.NdrContextHandle ctx, string FileName, int Flags) {
121+
// marshals parameters & calls opnum 0
122+
}
123+
```
124+
125+
The PowerShell helper `Get-RpcClient` can create an **interactive client object** so you can call the procedure immediately:
126+
127+
```powershell
128+
$client = Get-RpcClient $rpcinterfaces[0]
129+
Connect-RpcClient $client -stringbinding 'ncacn_np:127.0.0.1[\\pipe\\efsrpc]' `
130+
-AuthenticationLevel PacketPrivacy `
131+
-AuthenticationType WinNT # NTLM auth
132+
133+
# Invoke the procedure → returns an authenticated context handle
134+
$ctx = New-Object Marshal.NdrContextHandle
135+
$client.EfsRpcOpenFileRaw([ref]$ctx, "\\\127.0.0.1\test", 0)
136+
```
137+
138+
Authentication (Kerberos / NTLM) and encryption levels (`PacketIntegrity`, `PacketPrivacy`, …) can be supplied directly via the `Connect-RpcClient` cmdlet – ideal for **bypassing Security Descriptors** that protect high-privilege named pipes.
139+
140+
---
141+
142+
### Context-Aware RPC Fuzzing (MS-RPC-Fuzzer)
143+
144+
Static interface knowledge is great, but what you really want is **coverage-guided fuzzing** that understands *context handles* and complex parameter chains. The open-source **MS-RPC-Fuzzer** project automates exactly that workflow:
145+
146+
1. Enumerate every interface/procedure exported by the target binary (`Get-RpcServer`).
147+
2. Generate dynamic clients for each interface (`Format-RpcClient`).
148+
3. Randomise input parameters (wide strings length, integer ranges, enums) while respecting the original **NDR type**.
149+
4. Track *context handles* returned by one call to feed follow-up procedures automatically.
150+
5. Fire high-volume calls against the chosen transport (ALPC, TCP, HTTP or named pipe).
151+
6. Log exit statuses / faults / timeouts and export a **Neo4j** import file to visualise *interface → procedure → parameter* relationships and crash clusters.
152+
153+
Example run (named–pipe target):
154+
155+
```powershell
156+
Invoke-MSRPCFuzzer -Pipe "\\.\pipe\efsrpc" -Auth NTLM `
157+
-MinLen 1 -MaxLen 0x400 `
158+
-Iterations 100000 `
159+
-OutDir .\results
160+
```
161+
162+
A single out-of-bounds write or unexpected exception will be surfaced immediately with the exact opnum + fuzzed payload that triggered it – perfect starting point for a stable proof-of-concept exploit.
163+
164+
> ⚠️ Many RPC services execute in processes running as **NT AUTHORITY\SYSTEM**. Any memory-safety issue here usually translates to local privilege escalation or (when exposed over SMB/135) *remote code execution*.
165+
166+
---
167+
92168
## References
93169

170+
- [Automating MS-RPC vulnerability research (2025, Incendium.rocks)](https://www.incendium.rocks/posts/Automating-MS-RPC-Vulnerability-Research/)
171+
- [MS-RPC-Fuzzer – context-aware RPC fuzzer](https://github.com/warpnet/MS-RPC-Fuzzer)
172+
- [NtObjectManager PowerShell module](https://github.com/googleprojectzero/sandbox-attacksurface-analysis-tools/tree/master/NtObjectManager)
173+
174+
94175
- [https://www.cyber.airbus.com/the-oxid-resolver-part-1-remote-enumeration-of-network-interfaces-without-any-authentication/](https://www.cyber.airbus.com/the-oxid-resolver-part-1-remote-enumeration-of-network-interfaces-without-any-authentication/)
95176
- [https://www.cyber.airbus.com/the-oxid-resolver-part-2-accessing-a-remote-object-inside-dcom/](https://www.cyber.airbus.com/the-oxid-resolver-part-2-accessing-a-remote-object-inside-dcom/)
96177
- [https://0xffsec.com/handbook/services/msrpc/](https://0xffsec.com/handbook/services/msrpc/)

0 commit comments

Comments
 (0)