ntlm

package
v0.0.0-...-d5d6b14 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NtLmNegotiate    = 0x00000001
	NtLmChallenge    = 0x00000002
	NtLmAuthenticate = 0x00000003
)
View Source
const (
	NTLMSSP_NEGOTIATE_UNICODE = 1 << iota
	NTLM_NEGOTIATE_OEM
	NTLMSSP_REQUEST_TARGET

	NTLMSSP_NEGOTIATE_SIGN
	NTLMSSP_NEGOTIATE_SEAL
	NTLMSSP_NEGOTIATE_DATAGRAM
	NTLMSSP_NEGOTIATE_LM_KEY

	NTLMSSP_NEGOTIATE_NTLM

	NTLMSSP_ANONYMOUS
	NTLMSSP_NEGOTIATE_OEM_DOMAIN_SUPPLIED
	NTLMSSP_NEGOTIATE_OEM_WORKSTATION_SUPPLIED

	NTLMSSP_NEGOTIATE_ALWAYS_SIGN
	NTLMSSP_TARGET_TYPE_DOMAIN
	NTLMSSP_TARGET_TYPE_SERVER

	NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY
	NTLMSSP_NEGOTIATE_IDENTIFY

	NTLMSSP_REQUEST_NON_NT_SESSION_KEY
	NTLMSSP_NEGOTIATE_TARGET_INFO

	NTLMSSP_NEGOTIATE_VERSION

	NTLMSSP_NEGOTIATE_128
	NTLMSSP_NEGOTIATE_KEY_EXCH
	NTLMSSP_NEGOTIATE_56
)
View Source
const (
	WINDOWS_MAJOR_VERSION_5  = 0x05
	WINDOWS_MAJOR_VERSION_6  = 0x06
	WINDOWS_MAJOR_VERSION_10 = 0x0a
)
View Source
const (
	WINDOWS_MINOR_VERSION_0 = 0x00
	WINDOWS_MINOR_VERSION_1 = 0x01
	WINDOWS_MINOR_VERSION_2 = 0x02
	WINDOWS_MINOR_VERSION_3 = 0x03
)
View Source
const (
	NTLMSSP_REVISION_W2K3 = 0x0f
)

Variables

View Source
var DefaultSignature = [8]byte{'N', 'T', 'L', 'M', 'S', 'S', 'P', 0}

Functions

This section is empty.

Types

type Addr

type Addr struct {
	Typ uint32
	Val []byte
}

type AuthenicateMessage

type AuthenicateMessage struct {
	MessageHeader
	LmChallengeResponseFields      utils.VarField
	NtChallengeResponseFields      utils.VarField
	DomainNameFields               utils.VarField
	UsernameFields                 utils.VarField
	WorkstationFields              utils.VarField
	EncryptedRandomSessionKeyField utils.VarField
	NegotiateFlags                 uint32
	MIC                            [16]byte
	Payload                        []byte
}

type AvID

type AvID uint16
const (
	AvIDMsvAvEOL AvID = iota
	AvIDMsvAvNbComputerName
	AvIDMsvAvNbDomainName
	AvIDMsvAvDNSComputerName
	AvIDMsvAvDNSDomainName
	AvIDMsvAvDNSTreeName
	AvIDMsvAvFlags
	AvIDMsvAvTimestamp
	AvIDMsvAvSingleHost
	AvIDMsvAvTargetName
	AvIDMsvChannelBindings
)

type AvPairs

type AvPairs map[AvID][]byte

func NewAvPairs

func NewAvPairs(b []byte) (AvPairs, error)

func (AvPairs) Bytes

func (p AvPairs) Bytes(spn []byte) []byte

func (AvPairs) Get

func (p AvPairs) Get(id AvID) interface{}

type ChallengeMessage

type ChallengeMessage struct {
	MessageHeader
	TargetName      utils.VarField
	NegotiateFlags  uint32
	ServerChallenge [8]byte

	TargetInformation utils.VarField
	Version           [8]byte
	Payload           []byte
	// contains filtered or unexported fields
}

func ParseChallengeMessage

func ParseChallengeMessage(cmsg []byte) (ChallengeMessage, error)

type ChannelBindings

type ChannelBindings struct {
	InitiatorAddress Addr
	AcceptorAddress  Addr
	AppData          []byte
}

channelBindings represents gss_channel_bindings_struct

type Client

type Client struct {
	User        string
	Password    string
	Hash        []byte
	Domain      string
	Workstation string
	TargetSPN   string

	ChannelBinding *ChannelBindings // reserved for future implementation

	// Session Tracking
	NegotiateFlags     uint32
	ExportedSessionKey []byte
	ClientSigningKey   []byte
	ServerSigningKey   []byte
	ClientHandle       *rc4.Cipher
	ServerHandle       *rc4.Cipher

	// Don't use unless you know what you're doing
	NegMsg                NegotiateMessage
	TargetInfo            TargetInformation
	NegotiateMessageBytes []byte
}

func (*Client) Authenticate

func (c *Client) Authenticate(cmsg []byte) (amsg []byte, err error)

func (*Client) GetNTLMHashFunc

func (c *Client) GetNTLMHashFunc(targetName []byte) hash.Hash

func (*Client) Negotiate

func (c *Client) Negotiate() ([]byte, error)

type MessageHeader

type MessageHeader struct {
	Signature   [8]byte
	MessageType uint32
}

type NTLMServer

type NTLMServer struct {
	TargetName string
	Accounts   map[string]string //map["username"]"password"

	// Session Tracking
	SeqNum             uint32
	NegotiateFlags     uint32
	ExportedSessionKey []byte
	SigningKey         []byte
	Handle             *rc4.Cipher
}

type NTLMv2ClientChallenge

type NTLMv2ClientChallenge struct {
	RespType   byte
	HiRespType byte

	Timestamp           uint64
	ChallengeFromClient [8]byte

	AvPairs []byte
	// contains filtered or unexported fields
}
      NTLMv2ClientChallenge
 0-1: RespType
 1-2: HiRespType
 2-4: _
 4-8: _
8-16: TimeStamp

16-24: ChallengeFromClient 24-28: _

28-: AvPairs

type NTLMv2Response

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

0-16: Response

16-: NTLMv2ClientChallenge

type NegotiateMessage

type NegotiateMessage struct {
	MessageHeader
	NegotiateFlags    uint32
	DomainNameFields  utils.VarField
	WorkstationFields utils.VarField
	Version           [8]byte
	Payload           []byte
}

type SingleHostData

type SingleHostData struct {
	Size       uint32
	Z4         uint32
	CustomData uint8
	MachineID  [32]byte
}

type TargetInformation

type TargetInformation struct {
	NbComputerName  string
	NbDomainName    string
	DNSComputerName string
	DNSDomainName   string
	DNSTreeName     string
	Flags           uint32
	Timestamp       uint64
	SingleHost      SingleHostData
	TargetName      string
	ChBindings      ChannelBindings
	// contains filtered or unexported fields
}

func ParseAvPairs

func ParseAvPairs(b []byte) (*TargetInformation, error)

func (TargetInformation) Raw

func (t TargetInformation) Raw(spn []byte) []byte

func (TargetInformation) Set

func (t TargetInformation) Set(k AvID, v []byte) error

func (TargetInformation) Size

func (t TargetInformation) Size() int

Jump to

Keyboard shortcuts

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