debugging
This commit is contained in:
@@ -3,6 +3,7 @@ package ntlmssp
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
|
"encoding/base64"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
"time"
|
"time"
|
||||||
@@ -86,6 +87,10 @@ func ProcessChallenge(challengeMessageData []byte, user, password string) ([]byt
|
|||||||
return nil, errors.New("Anonymous authentication not supported")
|
return nil, errors.New("Anonymous authentication not supported")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// debugging
|
||||||
|
PrintDebug("Received NTLM Type 2 Challenge: %s", base64.StdEncoding.EncodeToString(challengeMessageData))
|
||||||
|
DecodeNTLMMessage(challengeMessageData)
|
||||||
|
|
||||||
var cm challengeMessage
|
var cm challengeMessage
|
||||||
if err := cm.UnmarshalBinary(challengeMessageData); err != nil {
|
if err := cm.UnmarshalBinary(challengeMessageData); err != nil {
|
||||||
PrintDebug("Failed to unmarshal challenge data")
|
PrintDebug("Failed to unmarshal challenge data")
|
||||||
@@ -119,7 +124,7 @@ func ProcessChallenge(challengeMessageData []byte, user, password string) ([]byt
|
|||||||
rand.Reader.Read(clientChallenge)
|
rand.Reader.Read(clientChallenge)
|
||||||
|
|
||||||
ntlmV2Hash := getNtlmV2Hash(password, user, cm.TargetName)
|
ntlmV2Hash := getNtlmV2Hash(password, user, cm.TargetName)
|
||||||
PrintDebug("NTLM V2 hash '%s'", ntlmV2Hash)
|
PrintDebug("NTLM V2 hash '%s'", base64.StdEncoding.EncodeToString(ntlmV2Hash))
|
||||||
|
|
||||||
am.NtChallengeResponse = computeNtlmV2Response(ntlmV2Hash,
|
am.NtChallengeResponse = computeNtlmV2Response(ntlmV2Hash,
|
||||||
cm.ServerChallenge[:], clientChallenge, timestamp, cm.TargetInfoRaw)
|
cm.ServerChallenge[:], clientChallenge, timestamp, cm.TargetInfoRaw)
|
||||||
|
@@ -123,8 +123,8 @@ func (l Negotiator) RoundTrip(req *http.Request) (res *http.Response, err error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// debugging
|
// debugging
|
||||||
PrintDebug("Received NTLM Type 2 Challenge: %s", base64.StdEncoding.EncodeToString(challengeMessage))
|
//PrintDebug("Received NTLM Type 2 Challenge: %s", base64.StdEncoding.EncodeToString(challengeMessage))
|
||||||
DecodeNTLMMessage(challengeMessage)
|
//DecodeNTLMMessage(challengeMessage)
|
||||||
|
|
||||||
if !(resauth.IsNegotiate() || resauth.IsNTLM()) || len(challengeMessage) == 0 {
|
if !(resauth.IsNegotiate() || resauth.IsNTLM()) || len(challengeMessage) == 0 {
|
||||||
// Negotiation failed, let client deal with response
|
// Negotiation failed, let client deal with response
|
||||||
|
10
nlmp.go
10
nlmp.go
@@ -10,8 +10,9 @@ package ntlmssp
|
|||||||
import (
|
import (
|
||||||
"crypto/hmac"
|
"crypto/hmac"
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"golang.org/x/crypto/md4"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"golang.org/x/crypto/md4"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getNtlmV2Hash(password, username, target string) []byte {
|
func getNtlmV2Hash(password, username, target string) []byte {
|
||||||
@@ -28,13 +29,20 @@ func computeNtlmV2Response(ntlmV2Hash, serverChallenge, clientChallenge,
|
|||||||
timestamp, targetInfo []byte) []byte {
|
timestamp, targetInfo []byte) []byte {
|
||||||
|
|
||||||
temp := []byte{1, 1, 0, 0, 0, 0, 0, 0}
|
temp := []byte{1, 1, 0, 0, 0, 0, 0, 0}
|
||||||
|
PrintDebug("NTLMv2 response", temp)
|
||||||
temp = append(temp, timestamp...)
|
temp = append(temp, timestamp...)
|
||||||
|
PrintDebug("NTLMv2 response", temp)
|
||||||
temp = append(temp, clientChallenge...)
|
temp = append(temp, clientChallenge...)
|
||||||
|
PrintDebug("NTLMv2 response", temp)
|
||||||
temp = append(temp, 0, 0, 0, 0)
|
temp = append(temp, 0, 0, 0, 0)
|
||||||
|
PrintDebug("NTLMv2 response", temp)
|
||||||
temp = append(temp, targetInfo...)
|
temp = append(temp, targetInfo...)
|
||||||
|
PrintDebug("NTLMv2 response", temp)
|
||||||
temp = append(temp, 0, 0, 0, 0)
|
temp = append(temp, 0, 0, 0, 0)
|
||||||
|
PrintDebug("NTLMv2 response", temp)
|
||||||
|
|
||||||
NTProofStr := hmacMd5(ntlmV2Hash, serverChallenge, temp)
|
NTProofStr := hmacMd5(ntlmV2Hash, serverChallenge, temp)
|
||||||
|
PrintDebug("Proof string", NTProofStr)
|
||||||
return append(NTProofStr, temp...)
|
return append(NTProofStr, temp...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user