Add RPC helper class and migrate SMB/module callers#1191
Open
azoxlpf wants to merge 11 commits intoPennyw0rth:mainfrom
Open
Add RPC helper class and migrate SMB/module callers#1191azoxlpf wants to merge 11 commits intoPennyw0rth:mainfrom
azoxlpf wants to merge 11 commits intoPennyw0rth:mainfrom
Conversation
Contributor
|
Jezzz that PR 😭 |
Member
|
Thanks for the PR! Much needed! |
Member
|
Reminder to us: when #688 is merged we need to also replace RPC auth there with the class in here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Following the discussion on PR #1104 (
delegated Service Ticket reuse) and @NeffIsBack ’s feedback, this change introduces a small helper undernxc/helpers/instead of threading ad‑hocSMBTransport / DCERPCTransportFactorysetup through every caller.NXCRPCConnectiontakes the NetExec protocol connection as its first argument, applies the same credentials, hashes, AES key, and Kerberos options as the parent connection, and either reuses the existing SMB session whenconn.connis already established (so delegated tickets from S4U2Proxy apply to named-pipe RPC) or builds a new SMB transport from the stored auth. Aforce_tcp flagselects TCP (ncacn_ip_tcp) when needed. Callers can still passstring_binding,target_ip,anonymous_rpc, and optionalauth_levelwhere interfaces require privacy/signing.SMB core paths and the modules that were opening their own RPC transports have been migrated to use this helper. Special cases (e.g.
EPM hept_lookupon port 135) keep using the helper for transport/credentials but avoid an inappropriatedce.bind()where the protocol does not expect it.This addresses the original problem: operations after
--delegate / --use-kcacheno longer open “fresh” RPC transports that ignore the delegated ST and fall back to the machine (or other) password for Kerberos preauth.I migrated the call sites I found and do not believe anything obvious was missed, but the codebase uses RPC in many places, so full coverage is not guaranteed without a wider audit.
Testing: I exercised the flows touching the modified files (SMB features and modules on lab targets), behavior matched expectations versus the pre-refactor behavior, including scenarios that previously failed with delegated ST propagation.
I used Claude Opus 4.6 mainly to draft and iterate on the implementation plan (structure of the RPC helper, migration order, and edge cases).
Type of change
Insert an "x" inside the brackets for relevant items (do not delete options)
Setup guide for the review
Please provide guidance on what setup is needed to test the introduced changes, such as your locally running machine Python version & OS, as well as the target(s) you tested against, including software versions.
In particular:
Screenshots (if appropriate):
Example of delegated credentials being reused for subsequent RPC (atexec) after
--delegate:Checklist:
Insert an "x" inside the brackets for completed and relevant items (do not delete options)
poetry run ruff check ., use--fixto automatically fix what it can)tests/e2e_commands.txtfile if necessary (new modules or features are required to be added to the e2e tests)