Skip to content

wmi/dcom: respect proxy in dcerpc.Dial sites#21

Closed
aimogging wants to merge 2 commits into
mandiant:mainfrom
aimogging:fix/wmi-dcom-proxy-support
Closed

wmi/dcom: respect proxy in dcerpc.Dial sites#21
aimogging wants to merge 2 commits into
mandiant:mainfrom
aimogging:fix/wmi-dcom-proxy-support

Conversation

@aimogging
Copy link
Copy Markdown

Thanks for maintaining gopacket. Ran into a small bug while driving it through a SOCKS5 proxy and (claude) put together a fix.

Running gopacket-wmiexec through SOCKS5, all three proxy mechanisms (-proxy, proxychains, ALL_PROXY) silently bypassed. tcpdump showed SYNs heading straight to the target on 135. wmiquery, wmipersist, and dcomexec exhibit the same behavior. All four call upstream dcerpc.Dial without a WithDialer option, so it falls back to net.Dialer and skips both proxy paths. Looks like these four were missed when SOCKS5 support landed.

The fix adds a DialContext method to pkg/transport.Dialer (additive; the existing Dial is untouched) and passes dcerpc.WithDialer(&transport.Dialer{}) into every dcerpc.Dial site in the four tools. Hanging it off the existing Dialer rather than per-tool adapters means any future go-msrpc-based tool picks up proxy support automatically. Verified end-to-end: wmiexec succeeds through all three proxy mechanisms, wmiquery returns query rows, dcomexec reaches the target (its DCOM-layer errors are pre-existing and unrelated). Regression-checked rpcdump and smbclient direct and proxied. tcpdump on the egress interface captured zero packets to the target across every proxied run.

Open to a different shape if you'd prefer (per-tool adapters, a separate ContextDialer type, etc.).

@google-cla
Copy link
Copy Markdown

google-cla Bot commented Apr 26, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@aimogging aimogging changed the title wmi/dcom: fix -proxy/proxychains being silently bypassed wmi/dcom: respect proxy in dcerpc.Dial sites Apr 26, 2026
wmiexec, wmiquery, wmipersist, and dcomexec called upstream
go-msrpc/dcerpc.Dial directly with no WithDialer option, so connections
fell back to net.Dialer. That bypassed both the SOCKS5 dialer that -proxy
and ALL_PROXY configure, and the libc connect() hook that proxychains
relies on. Tools that go through pkg/dcerpc.DialTCP (secretsdump et al.)
were unaffected.

Add a DialContext method to transport.Dialer so it satisfies the upstream
dcerpc.Dialer interface, then pass dcerpc.WithDialer(&transport.Dialer{})
into every dcerpc.Dial call in the four affected tools (the EPM connect
on 135 and the OXID-resolved high-port connect).

Verified end-to-end against a live target: -proxy, ALL_PROXY, and
proxychains all succeed and tcpdump on the egress interface shows zero
packets to the target on port 135.
@aimogging aimogging force-pushed the fix/wmi-dcom-proxy-support branch from 5d4ae9c to 0406637 Compare April 26, 2026 05:10
@Jah-yee
Copy link
Copy Markdown
Contributor

Jah-yee commented May 8, 2026

Hi @Not exactly! Checking in on this PR - it's been open for 12 days without any reviews. Just wanted to bump it for visibility. Happy to make any changes if you have feedback!

@Jah-yee
Copy link
Copy Markdown
Contributor

Jah-yee commented May 9, 2026

👋 Hi @mandiant/gopacket - this PR has been open for 14 days with no review feedback. Just checking in — is there anything I can help with to move this forward?

@Jah-yee
Copy link
Copy Markdown
Contributor

Jah-yee commented May 9, 2026

Hi! Just checking in — this PR has been open for 13+ days without any reviews. Happy to make changes or clarify anything. Thanks for considering it!

@psycep
Copy link
Copy Markdown
Collaborator

psycep commented May 12, 2026

Thanks for catching this and writing it up so clearly. PR #26 just merged and ended up covering this. Lab testing surfaced two additional leak layers: gokrb5.fork/v9 KDCDialer for the Kerberos handshake inside the proxied dcerpc connection, and go-msrpc's pre-dial net.LookupIP that leaks target FQDNs to the operator's resolver. The proxy fix you proposed for the dcerpc dials is included in #26, with a slightly different shape (a separate ContextDialer type rather than extending Dialer, and the "ncacn_ip_tcp:" StringBinding prefix to bypass the upstream LookupIP). Closing this as already fixed.

Separately, the wmiexec sharing-violation refactor in your second commit is interesting but out of scope here. Would you mind opening it as its own PR with a brief note on which error string the SMB layer actually produces in each path? Happy to review.

Appreciate the careful writeup and the offer to take feedback on shape. Hope to see more contributions.

@psycep psycep closed this May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants