Refactor SMB client to Manticore network/smb/client v1.1.5#1
Open
p0dalirius wants to merge 3 commits into
Open
Refactor SMB client to Manticore network/smb/client v1.1.5#1p0dalirius wants to merge 3 commits into
p0dalirius wants to merge 3 commits into
Conversation
Replace the jfjallid/go-smb SMB stack with the generic Manticore SMB client (github.com/TheManticoreProject/Manticore v1.1.5). The recursive SYSVOL walk and the GPP XML file retrieval now go through the Manticore client's Dial/Login/TreeConnect/ListDirectory/OpenFile/ReadFile surface, which negotiates the highest dialect the server supports.
The -H/--hashes flag was parsed but never propagated to the SMB connection. Carry it through config.Credentials into FindCPasswords so credentials.NewCredentials receives the NT/LM hashes; the Manticore SMB client then authenticates with the NT hash (pass-the-hash) instead of the password.
The LDAP bind only supported simple bind with a password. Carry the NT/LM hashes into the LDAP session and bind over NTLMSSP with the NT hash (NTLMBindWithHash) when they are supplied, so the DC enumeration step honors -H/--hashes like the SMB connection now does. The bind logic is factored into a shared authenticate helper used by both Connect and CanLogin.
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.
Summary
Replaces the
jfjallid/go-smbSMB stack with the generic Manticore SMB client fromgithub.com/TheManticoreProject/Manticorev1.1.5. SMB usage in this project was confined to two files (the SYSVOL recursive walk and GPP XML retrieval); both now go through the Manticore client.Motivation
Standardize on the in-house Manticore SMB client, consistent with other tools in TheManticoreProject (e.g.
smbclient-ng). The Manticore generic client negotiates the highest dialect the server supports (SMB1/SMB2/SMB3) transparently, where the previous stack was a separate third-party dependency.Changes
core/workers.goFindCPasswordsnow buildscredentials.Credentialsand connects withsmbclient.Dial, thenLogin/TreeConnect("SYSVOL"), withDisconnect/Logoff/TreeDisconnectdeferred for clean teardown.SMBListFilesRecursivelyAndCallbacktakes a*smbclient.Clientinstead of an*smb.Connection. The tree connect now happens once inFindCPasswordsrather than per recursion level, and the walk usesclient.ListDirectory(dir, "*"). Full paths are built by joining the parent dir with each entry'sName(backslash separated), and the./..pseudo-entries returned by the server are skipped.core/crypto/grouppolicypreferencepasswords.goCallbackFunctionCPasswordtakes a*smbclient.Client; the UNC path now usesclient.ServerIdentity().DNSComputerName.session.RetrieveFile) is replaced by areadRemoteFilehelper usingOpenFile/ReadFile/CloseFilewith the appropriatefileflags, streaming the file into the buffer.go.mod/go.sum: dropgithub.com/jfjallid/go-smb(and its transitivegofork/gokrb5/golog); addgithub.com/TheManticoreProject/Manticore v1.1.5.go mod tidybrought the toolchain to go 1.24.0 and upgraded a few transitive dependencies pulled in by Manticore.Verification
go build ./...— succeeds.go vet ./...— clean.go test ./...— no test files in the repo; nothing to run.grep -rn "jfjallid\|go-smb\|spnego"over*.go— no remaining references.Scope of change
core/workers.go,core/crypto/grouppolicypreferencepasswords.go,go.mod,go.sum.The Manticore v1.1.5 SMB stack supports pass-the-hash (the SMB1/SMB2 session setup authenticates from
creds.GetNTHash()when set). The-H/--hashesflag, however, was parsed but never propagated to the connection (this predated the refactor). A second commit wires it through:core/config/config.go: addHashestoconfig.Credentials.main.go: storeauthHashesintoconfig.Credentials.Hashes.core/workers.go: passconfig.Credentials.Hashestocredentials.NewCredentialsinstead of"".Verified against a live host (SMB 2.0.2): authenticating as
Administratorwith only the NT hash and an empty password succeeds —Login,TreeConnect("SYSVOL"), andListDirectoryall work, andCanPassTheHash()returns true for the parsed hash.Note: the LDAP DC-enumeration step uses
go-ldap/ldap/v3(not the Manticore LDAP client), so-Hstill does not apply to that initial LDAP bind — that would be a separate change.## Follow-up: LDAP pass-the-hash wiringPass-the-hash is now also honored by the initial LDAP DC-enumeration bind (previously password-only simple bind).
go-ldap/ldap/v3providesNTLMBindWithHash, so no LDAP-client swap is needed:network/ldap/ldap.go: add ahashesfield +InitSessionparameter; factor binding into a sharedauthenticate(conn)helper (used by bothConnectandCanLogin) that binds over NTLMSSP with the NT hash when-His supplied, falling back to simple/unauthenticated bind otherwise. The NT hash is parsed withcredentials.ParseLMNTHashes.main.go: passconfig.Credentials.Hashesto the primaryInitSession, and""for the credential-testing session (which tests recovered cleartext passwords).Verified end-to-end against a live DC with only the NT hash and an empty password:
The LDAP bind, DC enumeration, and the SMB SYSVOL connection all authenticated via pass-the-hash.