ntlm

package
v0.0.0-...-43cd48d Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2017 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClientToServerSigning = "session key to client-to-server signing key magic constant\000"
	ServerToClientSigning = "session key to server-to-client signing key magic constant\000"
	ClientToServerSealing = "session key to client-to-server sealing key magic constant\000"
	ServerToClientSealing = "session key to server-to-client sealing key magic constant\000"
)
View Source
const NTLMSig = "NTLMSSP\000"
View Source
const TimeOffset = Uint64LE(116444736000000000)

Variables

View Source
var ErrHeadersNotFound = fmt.Errorf("NTLM Headers not found")
View Source
var ErrMalformedHeader = fmt.Errorf("Malformed NTLM Headers")
View Source
var MalformedBytesError = fmt.Errorf("Malformed bytes")

Functions

func HMACMD5

func HMACMD5(key, data []byte) []byte

func NTLMHash

func NTLMHash(password string, flag NegotiateFlag) []byte

func NTLMV2Hash

func NTLMV2Hash(username, password, domain string, flag NegotiateFlag) []byte

func NTProof

func NTProof(ntlmV2Hash []byte, serverChallenge []byte, blob []byte) []byte

func NtlmV2Response

func NtlmV2Response(ntProofStr []byte, blob []byte) []byte

func Serialize

func Serialize(sz Serializable) []byte

func SerializeBytesToBase64

func SerializeBytesToBase64(b []byte) string

Types

type AuthenticateMessage

type AuthenticateMessage struct {
	Signature    string
	Type         Uint32LE
	LMResponse   SecurityBuffer
	NTLMResponse SecurityBuffer
	Domain       SecurityBuffer
	User         SecurityBuffer
	WorkStation  SecurityBuffer
	SessionKey   SecurityBuffer
	Flag         NegotiateFlag
}

func NewAuthenticateMessage

func NewAuthenticateMessage() AuthenticateMessage

func (AuthenticateMessage) WriteBytesToBuffer

func (am AuthenticateMessage) WriteBytesToBuffer(buf *bytes.Buffer)

type Authenticator

type Authenticator interface {
	Authenticate(string) (string, error)
}

type AvPair

type AvPair struct {
	AvID  Uint16LE
	AvLen Uint16LE
	AvVal []byte
}

func ParseAvp

func ParseAvp(p []byte) (AvPair, error)

func (AvPair) WriteBytesToBuffer

func (avp AvPair) WriteBytesToBuffer(buf *bytes.Buffer)

type AvPairs

type AvPairs []AvPair

func ParseAvps

func ParseAvps(p []byte) (AvPairs, error)

func (AvPairs) WriteBytesToBuffer

func (avps AvPairs) WriteBytesToBuffer(buf *bytes.Buffer)

type Blob

type Blob struct {
	Signature  Uint32LE
	Reserved   Uint32LE
	Timestamp  Uint64LE
	Challenge  []byte
	Unknown    Uint32LE
	TargetInfo []byte
	Unknown2   Uint32LE
}

func NewBlob

func NewBlob() Blob

func NewBlobWithChallenge

func NewBlobWithChallenge(clientChallenge []byte, targetInfo []byte) Blob

func ParseBlob

func ParseBlob(p []byte, si int) (Blob, error)

func (Blob) WriteBytesToBuffer

func (b Blob) WriteBytesToBuffer(buf *bytes.Buffer)

type ChallengeMessage

type ChallengeMessage struct {
	Signature       string
	Type            Uint32LE
	TargetName      SecurityBuffer
	Flag            NegotiateFlag
	ServerChallenge []byte
	Reserved        Uint64LE
	TargetInfo      SecurityBuffer
	// contains filtered or unexported fields
}

func ParseChallengeMessage

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

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(username, domain, password, target string, port uint16) *Client

func (*Client) Authenticate

func (c *Client) Authenticate() error

func (*Client) SendMessage

func (c *Client) SendMessage(bs []byte) error

type NegotiateFlag

type NegotiateFlag Uint32LE
const (
	NegotiateUnicode             NegotiateFlag = 0x00000001
	NegotiateOEM                 NegotiateFlag = 0x00000002
	NegotiateRequestTarget       NegotiateFlag = 0x00000004
	NegotiateMBZ9                NegotiateFlag = 0x00000008
	NegotiateSign                NegotiateFlag = 0x00000010
	NegotiateSeal                NegotiateFlag = 0x00000020
	NegotiateDatagram            NegotiateFlag = 0x00000040
	NegotiateNetware             NegotiateFlag = 0x00000100
	NegotiateNTLM                NegotiateFlag = 0x00000200
	NegotiateNTOnly              NegotiateFlag = 0x00000400
	NegotiateMBZ7                NegotiateFlag = 0x00000800
	NegotiateDomainSupplied      NegotiateFlag = 0x00001000
	NegotiateWorkstationSupplied NegotiateFlag = 0x00002000
	NegotiateLocalCall           NegotiateFlag = 0x00004000
	NegotiateAlwaysSign          NegotiateFlag = 0x00008000
	NegotiateTargetTypeDomain    NegotiateFlag = 0x00010000
	NegotiateNTLMV2Key           NegotiateFlag = 0x00080000
	NegotiateTargetInfo          NegotiateFlag = 0x00800000
	NegotiateKey128              NegotiateFlag = 0x20000000
	NegotiateKeyExchange         NegotiateFlag = 0x40000000
	NegotiateKey56               NegotiateFlag = 0x80000000
)

func ParseNegotiateFlag

func ParseNegotiateFlag(p []byte) (NegotiateFlag, error)

func (NegotiateFlag) String

func (n NegotiateFlag) String() string

func (NegotiateFlag) WriteBytesToBuffer

func (n NegotiateFlag) WriteBytesToBuffer(buf *bytes.Buffer)

type NegotiateMessage

type NegotiateMessage struct {
	Signature   string
	Type        Uint32LE
	Flag        NegotiateFlag
	Domain      SecurityBuffer
	WorkStation SecurityBuffer
	OSVersion   Uint32LE
	// contains filtered or unexported fields
}

func NewNegotiateMessage

func NewNegotiateMessage(domain string, workstation string) NegotiateMessage

func ParseNegotiateMessage

func ParseNegotiateMessage(p []byte) (NegotiateMessage, error)

func (NegotiateMessage) WriteBytesToBuffer

func (nm NegotiateMessage) WriteBytesToBuffer(buf *bytes.Buffer)

type Negotiator

type Negotiator interface {
	Negotiate() (string, error)
}

type Sealer

type Sealer interface {
	Seal([]byte) ([]byte, error)
}

type SecurityBuffer

type SecurityBuffer struct {
	Len    Uint16LE
	MaxLen Uint16LE
	OffSet Uint32LE
	Value  []byte
}

func ParseSecurityBuffer

func ParseSecurityBuffer(p []byte) (SecurityBuffer, error)

func (SecurityBuffer) WriteBytesToBuffer

func (sb SecurityBuffer) WriteBytesToBuffer(buf *bytes.Buffer, payload *bytes.Buffer)

type Serializable

type Serializable interface {
	WriteBytesToBuffer(*bytes.Buffer)
}

type Session

type Session struct {
	State State
	// contains filtered or unexported fields
}

func NewSession

func NewSession(username, domain, password, target string) *Session

func (*Session) Authenticate

func (s *Session) Authenticate(cm string) (string, error)

func (*Session) GetState

func (s *Session) GetState() State

func (*Session) GetTargetInfo

func (s *Session) GetTargetInfo(cm ChallengeMessage) []byte

func (*Session) GetWorkStationName

func (s *Session) GetWorkStationName() string

func (*Session) Negotiate

func (s *Session) Negotiate() (string, error)

func (*Session) ProcessChallengeMessage

func (s *Session) ProcessChallengeMessage(ps []byte) (AuthenticateMessage, error)

func (*Session) Seal

func (s *Session) Seal([]byte) ([]byte, error)

func (*Session) Sign

func (s *Session) Sign([]byte) ([]byte, error)

type SignedSealedNegotiatingAuthenticator

type SignedSealedNegotiatingAuthenticator interface {
	GetState() State
	Negotiator
	Authenticator
	Signer
	Sealer
}

type Signer

type Signer interface {
	Sign([]byte) ([]byte, error)
}

type State

type State uint16
const (
	Initial     State = 0
	Negotiating State = 1 << iota
	Negotiated
	ChallengeReceived
	Authenticated
)

type Uint16LE

type Uint16LE uint16
const (
	MsvAvEol             Uint16LE = 0x00
	MsvAvNbComputerName  Uint16LE = 0x01
	MsvAvNbDomainName    Uint16LE = 0x02
	MsvAvDNSComputerName Uint16LE = 0x03
	MsvAvDNSDomainName   Uint16LE = 0x04
	MsvAvDNSTreeName     Uint16LE = 0x05
	MsvAvFlags           Uint16LE = 0x06
	MsvAvTimestamp       Uint16LE = 0x07
	MsvAvSingleHost      Uint16LE = 0x08
	MsvAvTargetName      Uint16LE = 0x09
	MsvAvChannelBindings Uint16LE = 0x0A
)

func ParseUint16LE

func ParseUint16LE(p []byte) (Uint16LE, error)

func (Uint16LE) WriteBytesToBuffer

func (u Uint16LE) WriteBytesToBuffer(buf *bytes.Buffer)

type Uint32LE

type Uint32LE uint32

func ParseUint32LE

func ParseUint32LE(p []byte) (Uint32LE, error)

func (Uint32LE) WriteBytesToBuffer

func (u Uint32LE) WriteBytesToBuffer(buf *bytes.Buffer)

type Uint64LE

type Uint64LE uint64

func ParseUint64LE

func ParseUint64LE(p []byte) (Uint64LE, error)

func TimeStamp

func TimeStamp() Uint64LE

func (Uint64LE) WriteBytesToBuffer

func (u Uint64LE) WriteBytesToBuffer(buf *bytes.Buffer)

Jump to

Keyboard shortcuts

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