Skip to content

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

Open
aimogging wants to merge 2 commits intomandiant:mainfrom
aimogging:fix/wmi-dcom-proxy-support
Open

wmi/dcom: respect proxy in dcerpc.Dial sites#21
aimogging wants to merge 2 commits intomandiant: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
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.

1 participant