nla

package
v0.0.0-...-b10d92e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package nla --- CredCSSP 协议 https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-cssp/85f57821-40bb-46aa-bfcb-ba9590b8fc30

Index

Constants

View Source
const (
	MsvAvEOL             = 0x0000
	MsvAvNbComputerName  = 0x0001
	MsvAvNbDomainName    = 0x0002
	MsvAvDnsComputerName = 0x0003
	MsvAvDnsDomainName   = 0x0004
	MsvAvDnsTreeName     = 0x0005
	MsvAvFlags           = 0x0006
	MsvAvTimestamp       = 0x0007
	MsvAvSingleHost      = 0x0008
	MsvAvTargetName      = 0x0009
	MsvChannelBindings   = 0x000A
)
View Source
const (
	WINDOWS_MINOR_VERSION_0 = 0x00
	WINDOWS_MINOR_VERSION_1 = 0x01
	WINDOWS_MINOR_VERSION_2 = 0x02
	WINDOWS_MINOR_VERSION_3 = 0x03

	WINDOWS_MAJOR_VERSION_5 = 0x05
	WINDOWS_MAJOR_VERSION_6 = 0x06
	NTLMSSP_REVISION_W2K3   = 0x0F
)
View Source
const (
	NTLMSSP_NEGOTIATE_56                       = 0x80000000
	NTLMSSP_NEGOTIATE_KEY_EXCH                 = 0x40000000
	NTLMSSP_NEGOTIATE_128                      = 0x20000000
	NTLMSSP_NEGOTIATE_VERSION                  = 0x02000000
	NTLMSSP_NEGOTIATE_TARGET_INFO              = 0x00800000
	NTLMSSP_REQUEST_NON_NT_SESSION_KEY         = 0x00400000
	NTLMSSP_NEGOTIATE_IDENTIFY                 = 0x00100000
	NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY = 0x00080000
	NTLMSSP_TARGET_TYPE_SERVER                 = 0x00020000
	NTLMSSP_TARGET_TYPE_DOMAIN                 = 0x00010000
	NTLMSSP_NEGOTIATE_ALWAYS_SIGN              = 0x00008000
	NTLMSSP_NEGOTIATE_OEM_WORKSTATION_SUPPLIED = 0x00002000
	NTLMSSP_NEGOTIATE_OEM_DOMAIN_SUPPLIED      = 0x00001000
	NTLMSSP_NEGOTIATE_NTLM                     = 0x00000200
	NTLMSSP_NEGOTIATE_LM_KEY                   = 0x00000080
	NTLMSSP_NEGOTIATE_DATAGRAM                 = 0x00000040
	NTLMSSP_NEGOTIATE_SEAL                     = 0x00000020
	NTLMSSP_NEGOTIATE_SIGN                     = 0x00000010
	NTLMSSP_REQUEST_TARGET                     = 0x00000004
	NTLM_NEGOTIATE_OEM                         = 0x00000002
	NTLMSSP_NEGOTIATE_UNICODE                  = 0x00000001
)

https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-nlmp/99d90ff4-957f-4c8a-80e4-5bfe5a9a9832

Variables

This section is empty.

Functions

func MIC

func MIC(exportedSessionKey []byte, negotiate *NegotiateMessage, challenge *ChallengeMessage, auth *AuthenticateMessage) []byte

Types

type AVPair

type AVPair struct {
	Must struct {
		Id  uint16
		Len uint16
	}

	Optional struct {
		Value []byte
	}
}

AVPair https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-nlmp/83f5e789-660d-4781-8491-5f8c6641f75e

func (*AVPair) Read

func (avPair *AVPair) Read(r io.Reader)

func (*AVPair) Write

func (avPair *AVPair) Write(w io.Writer)

type AVPairs

type AVPairs []AVPair

func ReadAvPairs

func ReadAvPairs(data []byte) AVPairs

func (AVPairs) GetTimeStamp

func (avPairs AVPairs) GetTimeStamp() []byte

func (AVPairs) Write

func (avPairs AVPairs) Write(w io.Writer)

type AuthenticateMessage

type AuthenticateMessage struct {
	Must struct {
		Signature   [8]byte // MUST contain the ASCII string ('N', 'T', 'L', 'M', 'S', 'S', 'P', '\0').
		MessageType uint32  //  This field MUST be set to 0x00000003.

		LmChallengeResponse    Field
		NtChallengeResponse    Field
		DomainName             Field
		UserName               Field
		Workstation            Field
		EncryptedRandomSession Field

		NegotiateFlags uint32
		Version        NVersion // 8bytes
		MIC            [16]byte
	}

	Optional struct {
		Payload []byte // variable

		NtlmSec *NTLMv2Security
		// contains filtered or unexported fields
	}
}

AuthenticateMessage 认证信息 https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-nlmp/033d32cc-88f9-4483-9bf2-b273055038ce?source=recommendations

func NewAuthenticateMessage

func NewAuthenticateMessage(user, pass string) *AuthenticateMessage

func (*AuthenticateMessage) BaseLen

func (m *AuthenticateMessage) BaseLen() uint32

func (*AuthenticateMessage) Serialize

func (m *AuthenticateMessage) Serialize() []byte

func (*AuthenticateMessage) SetDomainName

func (m *AuthenticateMessage) SetDomainName(length uint16) *AuthenticateMessage

func (*AuthenticateMessage) SetEncryptedRandomSession

func (m *AuthenticateMessage) SetEncryptedRandomSession(length uint16) *AuthenticateMessage

func (*AuthenticateMessage) SetLmChallengeResponse

func (m *AuthenticateMessage) SetLmChallengeResponse(length uint16) *AuthenticateMessage

func (*AuthenticateMessage) SetNegotiateFlags

func (m *AuthenticateMessage) SetNegotiateFlags(flags uint32) *AuthenticateMessage

func (*AuthenticateMessage) SetNtChallengeResponse

func (m *AuthenticateMessage) SetNtChallengeResponse(length uint16) *AuthenticateMessage

func (*AuthenticateMessage) SetUserName

func (m *AuthenticateMessage) SetUserName(length uint16) *AuthenticateMessage

func (*AuthenticateMessage) SetWorkstation

func (m *AuthenticateMessage) SetWorkstation(length uint16) *AuthenticateMessage

func (*AuthenticateMessage) Sign

func (m *AuthenticateMessage) Sign(pubKey []byte) *AuthenticateMessage

func (*AuthenticateMessage) Write

func (m *AuthenticateMessage) Write(w io.Writer)

type ChallengeMessage

type ChallengeMessage struct {
	Must struct {
		Signature       [8]byte // MUST contain the ASCII string ('N', 'T', 'L', 'M', 'S', 'S', 'P', '\0').
		MessageType     uint32  // This field MUST be set to 0x00000002.
		TargetName      Field   // NTLMSSP_REQUEST_TARGET
		NegotiateFlags  uint32
		ServerChallenge [8]byte //  A 64-bit value that contains the NTLM challenge. The challenge is a 64-bit nonce.
		Reserved        [8]byte
		TargetInfo      Field // NTLMSSP_NEGOTIATE_TARGET_INFO
	}
	Optional struct {
		Version NVersion // NTLMSSP_NEGOTIATE_VERSION
		Payload []byte
	}
	// contains filtered or unexported fields
}

func (*ChallengeMessage) BaseLen

func (m *ChallengeMessage) BaseLen() uint32

func (*ChallengeMessage) GetField

func (m *ChallengeMessage) GetField(data []byte, offset uint32, field *Field) []byte

func (*ChallengeMessage) Load

func (m *ChallengeMessage) Load(r *bytes.Reader)

func (*ChallengeMessage) Read

func (m *ChallengeMessage) Read(r io.Reader)

func (*ChallengeMessage) Serialize

func (m *ChallengeMessage) Serialize() []byte

type Field

type Field struct {
	Len    uint16
	MaxLen uint16
	Offset uint32
}

func (*Field) Set

func (field *Field) Set(length uint16, offset uint32)

type NTLMv2ClientChallenge

type NTLMv2ClientChallenge struct {
	Must struct {
		RespType            uint8
		HiRespType          uint8
		Reserved1           uint16
		Reserved2           uint32
		Timestamp           [8]byte
		ChallengeFromClient [8]byte
		Reserved3           uint32
	}
	Optional struct {
		AvPairs AVPairs
	}
}

NTLMv2ClientChallenge https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-nlmp/aee311d6-21a7-4470-92a5-c4ecb022a87b

func NewNTLMv2ClientChallenge

func NewNTLMv2ClientChallenge(serverInfo, timestamp []byte) *NTLMv2ClientChallenge

func (*NTLMv2ClientChallenge) Serialize

func (c *NTLMv2ClientChallenge) Serialize() []byte

type NTLMv2Response

type NTLMv2Response struct {
	Response              [16]byte
	NTLMv2ClientChallenge []byte
}

NTLMv2Response https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-nlmp/d43e2224-6fc3-449d-9f37-b90b55a29c80

type NTLMv2Security

type NTLMv2Security struct {
	EncryptRC4 *rc4.Cipher
	DecryptRC4 *rc4.Cipher
	SigningKey []byte
	VerifyKey  []byte
	SeqNum     uint32
}

func (*NTLMv2Security) Serialize

func (n *NTLMv2Security) Serialize(pubKey []byte) []byte

type NVersion

type NVersion struct {
	ProductMajorVersion uint8
	ProductMinorVersion uint8
	ProductBuild        uint16
	Reserved            [3]byte
	NTLMRevisionCurrent uint8
}

NVersion https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-nlmp/b1a6ceb2-f8ad-462b-b5af-f18527c48175

func NewNVersion

func NewNVersion() NVersion

type NegotiateMessage

type NegotiateMessage struct {
	Must struct {
		Signature      [8]byte // MUST contain the ASCII string ('N', 'T', 'L', 'M', 'S', 'S', 'P', '\0').
		MessageType    uint32  // This field MUST be set to 0x00000001.
		NegotiateFlags uint32

		DomainName  Field // NTLMSSP_NEGOTIATE_OEM_DOMAIN_SUPPLIED
		Workstation Field // NTLMSSP_NEGOTIATE_OEM_WORKSTATION_SUPPLIED

		Version NVersion // 8bytes
	}
	Optional struct {
		Payload [32]byte
	}
}

NegotiateMessage 协商Message https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-nlmp/b34032e5-3aae-4bc6-84c3-c6d80eadf7f2?source=recommendations

func NewNegotiateMessage

func NewNegotiateMessage() *NegotiateMessage

func (*NegotiateMessage) Serialize

func (m *NegotiateMessage) Serialize() []byte

func (*NegotiateMessage) Write

func (m *NegotiateMessage) Write(w io.Writer)

type TSCredentials

type TSCredentials struct {
	CredType    int    `asn1:"explicit,tag:0"`
	Credentials []byte `asn1:"explicit,tag:1"`
}

TSCredentials https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-cssp/94a1ab00-5500-42fd-8d3d-7a84e6c2cf03

func (TSCredentials) Serialize

func (c TSCredentials) Serialize() []byte

type TSCspDataDetail

type TSCspDataDetail struct {
	KeySpec       int    `asn1:"explicit,tag:0"`
	CardName      string `asn1:"explicit,tag:1"`
	ReaderName    string `asn1:"explicit,tag:2"`
	ContainerName string `asn1:"explicit,tag:3"`
	CspName       string `asn1:"explicit,tag:4"`
}

TSCspDataDetail https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-cssp/34ee27b3-5791-43bb-9201-076054b58123

type TSPasswordCreds

type TSPasswordCreds struct {
	DomainName []byte `asn1:"explicit,tag:0"`
	UserName   []byte `asn1:"explicit,tag:1"`
	Password   []byte `asn1:"explicit,tag:2"`
}

TSPasswordCreds https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-cssp/17773cc4-21e9-4a75-a0dd-72706b174fe5

func (TSPasswordCreds) Serialize

func (c TSPasswordCreds) Serialize() []byte

type TSRequest

type TSRequest struct {
	Version     int         `asn1:"explicit,tag:0"`
	NegoTokens  []NegoToken `asn1:"optional,explicit,tag:1"`
	AuthInfo    []byte      `asn1:"optional,explicit,tag:2"`
	PubKeyAuth  []byte      `asn1:"optional,explicit,tag:3"`
	ErrorCode   int         `asn1:"optional,explicit,tag:4"`
	ClientNonce int         `asn1:"optional,explicit,tag:5"`
}

TSRequest https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-cssp/6aac4dea-08ef-47a6-8747-22ea7f6d8685

func NewTsRequest

func NewTsRequest() *TSRequest

func (*TSRequest) Read

func (req *TSRequest) Read(r io.Reader)

func (*TSRequest) SetAuthInfo

func (req *TSRequest) SetAuthInfo(authInfo []byte) *TSRequest

func (*TSRequest) SetMessages

func (req *TSRequest) SetMessages(data []byte) *TSRequest

func (*TSRequest) SetPubKeyAuth

func (req *TSRequest) SetPubKeyAuth(pubKeyAuth []byte) *TSRequest

func (*TSRequest) Write

func (req *TSRequest) Write(w io.Writer)

type TSSmartCardCreds

type TSSmartCardCreds struct {
	Pin        string            `asn1:"explicit,tag:0"`
	CspData    []TSCspDataDetail `asn1:"explicit,tag:1"`
	UserHint   string            `asn1:"explicit,tag:2"`
	DomainHint string            `asn1:"explicit,tag:3"`
}

TSSmartCardCreds https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-cssp/4251d165-cf01-4513-a5d8-39ee4a98b7a4

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL