feat(ntlmv2+winrm): fix NTLMv2 crypto primitives, add targetinfo helpers, refactor WinRM auth#77
Open
0xbbuddha wants to merge 4 commits intoTheManticoreProject:mainfrom
Open
feat(ntlmv2+winrm): fix NTLMv2 crypto primitives, add targetinfo helpers, refactor WinRM auth#770xbbuddha wants to merge 4 commits intoTheManticoreProject:mainfrom
0xbbuddha wants to merge 4 commits intoTheManticoreProject:mainfrom
Conversation
Implements a WinRM client library (MS-WSMV over HTTP, port 5985/5986)
with full NTLMv2 message-level sealing (SIGN + SEAL + KEY_EXCH) as
required by the Windows WinRM service.
Public API:
c := client.NewClient(host, port)
c.Connect()
err := c.SessionSetup(creds)
Structure:
network/winrm/types/ — protocol constants
network/winrm/transport/ — raw TCP transport (NTLM connection-binding)
network/winrm/client/ — Client, SessionSetup, NTLM sealing pipeline
…pers
- Remove broken NTResponse/LMResponse (used NTHash instead of
ResponseKeyNT, no blob — incorrect per MS-NLMP 3.3.2)
- Add ComputeNTChallengeResponse: builds proper blob with timestamp,
client challenge and TargetInfo; returns (NTChallengeResponse, NTProofStr)
- Add ComputeLMChallengeResponse: returns Z(24) when MsvAvTimestamp
present, otherwise HMAC+ClientChallenge (24 bytes)
- Add ComputeSessionBaseKey: HMAC-MD5(ResponseKeyNT, NTProofStr)
- Fix ComputeResponse: timestamp was commented out, sig changed to []byte
- Add BuildBlobTargetInfo/HasTimestamp/GetTimestamp to targetinfo package
- Fix CreateAuthenticateMessage to use the above instead of broken methods
- Add tests for NTOWFv2, response structure and Z(24) rule
…ytes Replace ~80 lines of inline NTLMv2 crypto in session.go with calls to the cleaned-up crypto/ntlmv2 and targetinfo packages. Remove the three private helpers ntlmTargetInfoGetAvValue, ntlmBuildBlobTargetInfo, and ntlmTargetInfoHasAvId — their logic now lives in the shared packages.
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
Summary
crypto/ntlmv2: removal of brokenNTResponse/LMResponsemethods (they used theNTHashdirectly, without a blob); addition ofComputeNTChallengeResponse,ComputeLMChallengeResponse,ComputeSessionBaseKeyin accordance with the MS-NLMP 3.3.2 specification; fix toComputeResponse(the timestamp had been commented out); cleanup ofNTOWFv2; addition of a complete test suite (6 tests with RFC vectors).crypto/spnego/ntlm/targetinfo: addition of helpersHasTimestamp,GetTimestamp,BuildBlobTargetInfoto handleTargetInfo(MsvAvTimestamp,MsvAvFlags/ MIC bit).crypto/spnego/ntlm/message/authenticate: fix toCreateAuthenticateMessagein theEXTENDED_SESSIONSECURITYpath to use the correctedntlmv2primitives.network/winrm/client/session.go: refactoring ofbuildNTLMv2AuthBytesto usecrypto/ntlmv2andtargetinfo; removal of 3 inline private helpers:ntlmTargetInfoGetAvValue,ntlmBuildBlobTargetInfo,ntlmTargetInfoHasAvId.PS: Sorry,
winrmandntlmv2ended up in the same PR. I simply hadn’t paid attention to the roadmap, so I decided to adapt it to takentlmv2into account.