Documentation
¶
Index ¶
- Constants
- func ClearNTOWFCache()
- func EncodeDERTCredentials(domain, username, password []byte) []byte
- func EncodeDERTRequest(version int, msgs []Message, authInfo, pubKeyAuth, clientNonce []byte) []byte
- func HMAC_MD5(key, data []byte) []byte
- func LMOWFv2(password, user, domain string) []byte
- func MD4(data []byte) []byte
- func MD5(data []byte) []byte
- func MIC(exportedSessionKey []byte, ...) []byte
- func NTOWFv2(password, user, domain string) []byte
- func RC4K(key, src []byte) []byte
- func SetNTOWFCacheSize(size int)
- type AVPair
- type AuthenticateMessage
- type ChallengeMessage
- type Message
- type NTLMv2
- type NTLMv2Security
- type NVersion
- type NegoToken
- type NegotiateMessage
- type TSCredentials
- type TSCspDataDetail
- type TSPasswordCreds
- type TSRequest
- type TSSmartCardCreds
Constants ¶
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 )
const ( MsvAvEOL = 0x0000 MsvAvNbComputerName = 0x0001 MsvAvNbDomainName = 0x0002 MsvAvDnsComputerName = 0x0003 MsvAvDnsDomainName = 0x0004 MsvAvDnsTreeName = 0x0005 MsvAvFlags = 0x0006 MsvAvTimestamp = 0x0007 MsvAvSingleHost = 0x0008 MsvAvTargetName = 0x0009 MsvChannelBindings = 0x000A )
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 )
const DefaultNTOWFCacheSize = 4096
DefaultNTOWFCacheSize is the maximum number of entries the NTOWFv2 cache will hold before evicting the least-recently-used entry. Each entry is approximately 64 bytes (16-byte hash + ~40-byte key + overhead), so the default of 4096 entries uses roughly 256 KB — negligible for most applications, but enough to cover a typical brute-force password list.
Callers that need a different bound can call SetNTOWFCacheSize before the first NTOWFv2 call.
Variables ¶
This section is empty.
Functions ¶
func ClearNTOWFCache ¶
func ClearNTOWFCache()
ClearNTOWFCache empties both the NTOWFv2 cache and the MD4(password) cache. Call this if you want to release the memory used by cached hashes (e.g. after a large brute-force run completes).
func EncodeDERTCredentials ¶
func EncodeDERTRequest ¶
func NTOWFv2 ¶
Version 2 of NTLM hash function.
Results are cached in a two-level bounded LRU:
- Level 1 (md4PasswordCache): MD4(UTF16(password)) — depends only on password
- Level 2 (ntowfCache): full HMAC-MD5 result — depends on (password, user, domain)
On a level-2 cache hit, no crypto is done at all (~50 ns). On a level-2 miss but level-1 hit, only the cheap HMAC-MD5 is done. On a level-1 miss, both MD4 and HMAC-MD5 are done.
Use SetNTOWFCacheSize to adjust the cache size, or ClearNTOWFCache to empty both caches.
func SetNTOWFCacheSize ¶
func SetNTOWFCacheSize(size int)
SetNTOWFCacheSize changes the maximum number of entries in both the NTOWFv2 cache and the MD4(password) cache. If the new size is smaller than the current number of entries, the least-recently-used entries are evicted. This function is safe to call at any time, but should ideally be called once at startup before any NTOWFv2 calls.
Set size to 0 to effectively disable caching (every call recomputes).
Types ¶
type AuthenticateMessage ¶
type AuthenticateMessage struct {
Signature [8]byte
MessageType uint32 `struc:"little"`
LmChallengeResponseLen uint16 `struc:"little"`
LmChallengeResponseMaxLen uint16 `struc:"little"`
LmChallengeResponseBufferOffset uint32 `struc:"little"`
NtChallengeResponseLen uint16 `struc:"little"`
NtChallengeResponseMaxLen uint16 `struc:"little"`
NtChallengeResponseBufferOffset uint32 `struc:"little"`
DomainNameLen uint16 `struc:"little"`
DomainNameMaxLen uint16 `struc:"little"`
DomainNameBufferOffset uint32 `struc:"little"`
UserNameLen uint16 `struc:"little"`
UserNameMaxLen uint16 `struc:"little"`
UserNameBufferOffset uint32 `struc:"little"`
WorkstationLen uint16 `struc:"little"`
WorkstationMaxLen uint16 `struc:"little"`
WorkstationBufferOffset uint32 `struc:"little"`
EncryptedRandomSessionLen uint16 `struc:"little"`
EncryptedRandomSessionMaxLen uint16 `struc:"little"`
EncryptedRandomSessionBufferOffset uint32 `struc:"little"`
NegotiateFlags uint32 `struc:"little"`
Version NVersion `struc:"little"`
MIC [16]byte `struc:"little"`
Payload []byte `struc:"skip"`
}
func NewAuthenticateMessage ¶
func NewAuthenticateMessage(negFlag uint32, domain, user, workstation []byte, lmchallResp, ntchallResp, enRandomSessKey []byte) *AuthenticateMessage
func (*AuthenticateMessage) BaseLen ¶
func (m *AuthenticateMessage) BaseLen() uint32
func (*AuthenticateMessage) Serialize ¶
func (m *AuthenticateMessage) Serialize() []byte
type ChallengeMessage ¶
type ChallengeMessage struct {
Signature []byte `struc:"[8]byte"`
MessageType uint32 `struc:"little"`
TargetNameLen uint16 `struc:"little"`
TargetNameMaxLen uint16 `struc:"little"`
TargetNameBufferOffset uint32 `struc:"little"`
NegotiateFlags uint32 `struc:"little"`
ServerChallenge [8]byte `struc:"little"`
Reserved [8]byte `struc:"little"`
TargetInfoLen uint16 `struc:"little"`
TargetInfoMaxLen uint16 `struc:"little"`
TargetInfoBufferOffset uint32 `struc:"little"`
Version NVersion `struc:"skip"`
Payload []byte `struc:"skip"`
}
func NewChallengeMessage ¶
func NewChallengeMessage() *ChallengeMessage
func (*ChallengeMessage) BaseLen ¶
func (m *ChallengeMessage) BaseLen() uint32
total len - payload len
func (*ChallengeMessage) Serialize ¶
func (m *ChallengeMessage) Serialize() []byte
type NTLMv2 ¶
type NTLMv2 struct {
// contains filtered or unexported fields
}
func (*NTLMv2) ComputeResponseV2 ¶
func (n *NTLMv2) ComputeResponseV2(respKeyNT, respKeyLM, serverChallenge, clientChallenge, timestamp, serverInfo []byte) (ntChallResp, lmChallResp, SessBaseKey []byte)
process NTLMv2 Authenticate hash
func (*NTLMv2) GetAuthenticateMessage ¶
func (n *NTLMv2) GetAuthenticateMessage(s []byte) (*AuthenticateMessage, *NTLMv2Security)
func (*NTLMv2) GetEncodedCredentials ¶
func (*NTLMv2) GetNegotiateMessage ¶
func (n *NTLMv2) GetNegotiateMessage() *NegotiateMessage
generate first handshake messgae
type NTLMv2Security ¶
type NTLMv2Security struct {
EncryptRC4 *rc4.Cipher
DecryptRC4 *rc4.Cipher
SigningKey []byte
VerifyKey []byte
SeqNum uint32
}
func (*NTLMv2Security) GssDecrypt ¶
func (n *NTLMv2Security) GssDecrypt(s []byte) []byte
func (*NTLMv2Security) GssEncrypt ¶
func (n *NTLMv2Security) GssEncrypt(s []byte) []byte
type NVersion ¶
type NVersion struct {
ProductMajorVersion uint8 `struc:"little"`
ProductMinorVersion uint8 `struc:"little"`
ProductBuild uint16 `struc:"little"`
Reserved [3]byte `struc:"little"`
NTLMRevisionCurrent uint8 `struc:"little"`
}
func NewNVersion ¶
func NewNVersion() NVersion
type NegotiateMessage ¶
type NegotiateMessage struct {
Signature [8]byte `struc:"little"`
MessageType uint32 `struc:"little"`
NegotiateFlags uint32 `struc:"little"`
DomainNameLen uint16 `struc:"little"`
DomainNameMaxLen uint16 `struc:"little"`
DomainNameBufferOffset uint32 `struc:"little"`
WorkstationLen uint16 `struc:"little"`
WorkstationMaxLen uint16 `struc:"little"`
WorkstationBufferOffset uint32 `struc:"little"`
Version NVersion `struc:"little"`
Payload [32]byte `struc:"skip"`
}
func NewNegotiateMessage ¶
func NewNegotiateMessage() *NegotiateMessage
func (*NegotiateMessage) Serialize ¶
func (m *NegotiateMessage) Serialize() []byte
type TSCredentials ¶
type TSCredentials struct {
CredType int `asn1:"explicit,tag:0"`
Credentials []byte `asn1:"explicit,tag:1"`
}
func DecodeDERTCredentials ¶
func DecodeDERTCredentials(s []byte) (*TSCredentials, error)
type TSCspDataDetail ¶
type TSPasswordCreds ¶
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 []byte `asn1:"optional,explicit,tag:5"`
}
func DecodeDERTRequest ¶
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"`
}