feat: add SMB share name anonymization to variant generator - #35
Merged
Conversation
…iant generator **Added:** - Share name mapping via new `mapShares` in the variant generator, renaming SMB shares declared under a host's `vulns_vars.shares` while skipping names shorter than `minShareNameLength` (5 chars) that are too generic to replace safely - `GenerateShareName` and `GenerateServiceAccountName` generators with dedicated `shareWords` and `serviceWords` word lists (all >= 5 chars to avoid corrupting unrelated text) - `namegen.go` - Password-equals-username collision handling in `mapPasswords` so credentials like GOAD's hodor reuse the username mapping deterministically, preserving the pairing and the intended weak-credential vulnerability - Free-text description rewriting for single-name accounts, rebuilt from the generated name since text replacement never touches unmapped lore - `Shares` field to the `Mappings` struct and its wiring into `buildOrderedReplacements` with word-boundary matching so both the JSON key and filesystem path (e.g. `C:\thewall`) are covered - Tests covering service account renaming, lore/share string rewriting, and password-equals-username pairing across 20 runs - `generator_test.go` **Changed:** - Service account handling: renamed the `preservedUsers` concept to `serviceAccounts`/`serviceAcctNew`, so accounts like `sql_svc` are now renamed to `svc_*` form (not preserved) while their generic firstname/surname/description fields are left intact - Share ACL probe now discovers share roots dynamically via `Get-SmbShare` (skipping administrative `$` shares) instead of a hardcoded path list, since variant labs randomize share names; `C:\inetpub\wwwroot\upload` is appended explicitly as an unpublished ACL target - `share_permissive_acls.ps1` - Expanded `originalNames` validation list with additional domains, hosts, houses, given names, groups, shares, and lore strings that must not survive into a variant
**Changed:**
- Replaced the service-account renaming mechanism with a preservation model in `generator.go`, keeping `sql_svc`'s original sAMAccountName intact because the name is hardcoded across the ares attack tooling and renaming it silently breaks ares against every variant lab
- Consolidated the `serviceAccounts`/`serviceAcctNew` tracking into a single `preservedUsers` map backed by the new package-level `preservedUsernames` variable
- Updated `mapUsers` and `fixUserFirstnameSurname` to skip preserved accounts, ensuring generic fields ("sql"/"service") are never registered as global replacements that would rewrite unrelated SQL references
- Removed `sql_svc` from the `originalNames` validator blocklist so preserved variants no longer fail validation every run
- Reworked tests to pin `sql_svc` as preserved (`TestServiceAccountPreserved`) and added `TestPreservedUserNotInOriginalNames` to guard against a name being both preserved and blocklisted
**Removed:**
- Removed the `GenerateServiceAccountName` method and its backing `serviceWords` list from `namegen.go`, now unused since service accounts are no longer renamed
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.
Key Changes:
Added:
mapSharesand aSharesfield onMappingsto rename SMB shares declared under a host'svulns_vars.shares, using word-boundary matching so both the JSON key and its path (C:\thewall) are rewritten together (generator.go)GenerateShareNameand ashareWordslist (all >= 5 characters to avoid corrupting generic words) to theNameGenerator(namegen.go)mapPasswords(generator.go)TestServiceAccountPreserved,TestPreservedUserNotInOriginalNames,TestLoreStringsRewritten, andTestPasswordEqualToUsernamePreservesPairing(with a 20-iteration determinism loop), plus agenerateAndReadhelper and expanded test fixtures for shares, lore descriptions, and the hodor account (generator_test.go)preservedUsernamesandminShareNameLengthwith rationale explaining the ares contract tradeoff and why short share names are skipped (generator.go)Changed:
share_permissive_acls.ps1to enumerate share roots viaGet-SmbShare(skipping administrative$shares) and appendC:\inetpub\wwwroot\uploadexplicitly, since variant labs randomize share names and a fixed path list would report a false clean resultfixUserFirstnameSurnameto rebuild descriptions for dotless accounts (e.g. hodor) from the generated name, since their free-text lore descriptions contain no mapped entity and were never touched by text replacement (generator.go)originalNameswith additional domains, hosts, houses, given names, groups, shares, and lore strings, while documenting thatsql_svcis deliberately absent to avoid failing validation every run (generator.go)SharesintobuildOrderedReplacementswith explicit word-boundary tagging (generator.go)Removed:
map[string]bool{"sql_svc": true}inNewGeneratorwith the sharedpreservedUsernamesvariable (generator.go)sql_svcpreservation check fromTestGeneratorEndToEnd, now covered by the dedicatedTestServiceAccountPreserved(generator_test.go)