Fix S4U2Proxy altservice sname substitution duplicating hostname part when providing full SPN in altservice - #223
Open
jimmexploit wants to merge 1 commit into
Conversation
…onent if altservice provided full SPN
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.
Bug
S4U2Proxy()inRubeus/lib/S4U.csonly overwrites index[0]ofsname.name_stringwhen applying/altservice:If the original
targetSPNhad two components (e.g.dhcp/GHOSTDB), index[1](GHOSTDB) is never cleared. When/altserviceitself contains a host (e.g./altservice:cifs/host.domain.com), the result is a malformed 3-part sname:instead of the intended:
This breaks the single-command usage (
s4u ... /altservice:service/host /ptt) for any case where the original SPN differs from the target host which is exactly the scenario/altservicewith a host is meant to support (e.g. abusing a constrained-delegation entry pointed at a stale/deleted SPN and redirecting to a live host AKA Ghost SPN-Jacking). The only workaround is runnings4uandtgssubas two separate steps, sincetgssubalready does a full Clear()+Split('/') replace this PR bringsS4U2Proxy's handling in line with that existing, correct logic.Fix
Branch on whether
altService(oraltSname, in the comma-separatedmulti-service loop) contains
/:/: preserve current behavior exactly service-class-only swap, original host untouched. (/altservice:cifsonldap/PRIMARY.test.local→cifs/PRIMARY.test.local, same as today.)/: full replace ofname_stringviaClear()+AddRange(Split('/')), matchingtgssub's existing approach.Applied to both the single-
/altservicebranch and the comma-separated multi-service loop inS4U2Proxy().Testing
Lab: single-forest AD domain, JACKATK$ trusted for constrained delegation w/ protocol transition to
dhcp/GHOSTDB(SPN with no backing computer object). Target: DESKTOP-01, SPN-jacked to holddhcp/GHOSTDB.Before Fix
the workaround
After Fix
one shot
keeping the current functionality as it is when user provides only service name