コード例 #1
0
ファイル: ntlmv1.go プロジェクト: rbetts/go-ntlm
func (n *V1ClientSession) GenerateAuthenticateMessage() (am *messages.Authenticate, err error) {
	am = new(messages.Authenticate)
	am.Signature = []byte("NTLMSSP\x00")
	am.MessageType = uint32(3)
	am.LmChallengeResponse, _ = messages.CreateBytePayload(n.lmChallengeResponse)
	am.NtChallengeResponseFields, _ = messages.CreateBytePayload(n.ntChallengeResponse)
	am.DomainName, _ = messages.CreateStringPayload(n.userDomain)
	am.UserName, _ = messages.CreateStringPayload(n.user)
	am.Workstation, _ = messages.CreateStringPayload("SQUAREMILL")
	am.EncryptedRandomSessionKey, _ = messages.CreateBytePayload(n.encryptedRandomSessionKey)
	am.NegotiateFlags = n.NegotiateFlags
	am.Version = &messages.VersionStruct{ProductMajorVersion: uint8(5), ProductMinorVersion: uint8(1), ProductBuild: uint16(2600), NTLMRevisionCurrent: uint8(15)}
	return am, nil
}
コード例 #2
0
ファイル: ntlmv2.go プロジェクト: rbetts/go-ntlm
func (n *V2ServerSession) GenerateChallengeMessage() (cm *messages.Challenge, err error) {
	cm = new(messages.Challenge)
	cm.Signature = []byte("NTLMSSP\x00")
	cm.MessageType = uint32(2)
	cm.TargetName, _ = messages.CreateBytePayload(make([]byte, 0))

	flags := uint32(0)
	flags = messages.NTLMSSP_NEGOTIATE_KEY_EXCH.Set(flags)
	flags = messages.NTLMSSP_NEGOTIATE_VERSION.Set(flags)
	flags = messages.NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY.Set(flags)
	flags = messages.NTLMSSP_NEGOTIATE_TARGET_INFO.Set(flags)
	flags = messages.NTLMSSP_NEGOTIATE_IDENTIFY.Set(flags)
	flags = messages.NTLMSSP_NEGOTIATE_ALWAYS_SIGN.Set(flags)
	flags = messages.NTLMSSP_NEGOTIATE_NTLM.Set(flags)
	flags = messages.NTLMSSP_NEGOTIATE_DATAGRAM.Set(flags)
	flags = messages.NTLMSSP_NEGOTIATE_SIGN.Set(flags)
	flags = messages.NTLMSSP_REQUEST_TARGET.Set(flags)
	flags = messages.NTLMSSP_NEGOTIATE_UNICODE.Set(flags)
	flags = messages.NTLMSSP_NEGOTIATE_128.Set(flags)

	cm.NegotiateFlags = flags

	n.serverChallenge = randomBytes(8)
	cm.ServerChallenge = n.serverChallenge
	cm.Reserved = make([]byte, 8)

	// Create the AvPairs we need
	pairs := new(messages.AvPairs)
	pairs.AddAvPair(messages.MsvAvNbDomainName, messages.StringToUtf16("REUTERS"))
	pairs.AddAvPair(messages.MsvAvNbComputerName, messages.StringToUtf16("UKBP-CBTRMFE06"))
	pairs.AddAvPair(messages.MsvAvDnsDomainName, messages.StringToUtf16("Reuters.net"))
	pairs.AddAvPair(messages.MsvAvDnsComputerName, messages.StringToUtf16("ukbp-cbtrmfe06.Reuters.net"))
	pairs.AddAvPair(messages.MsvAvDnsTreeName, messages.StringToUtf16("Reuters.net"))
	pairs.AddAvPair(messages.MsvAvEOL, make([]byte, 0))
	cm.TargetInfo = pairs
	cm.TargetInfoPayloadStruct, _ = messages.CreateBytePayload(pairs.Bytes())

	cm.Version = &messages.VersionStruct{ProductMajorVersion: uint8(5), ProductMinorVersion: uint8(1), ProductBuild: uint16(2600), NTLMRevisionCurrent: uint8(15)}
	return cm, nil
}