package smb2
import (
"encoding/asn1"
"github.com/hirochachacha/go-smb2/internal/ntlm"
"github.com/hirochachacha/go-smb2/internal/spnego"
)
type Initiator interface {
oid() asn1 .ObjectIdentifier
initSecContext() ([]byte , error )
acceptSecContext(sc []byte ) ([]byte , error )
sum(bs []byte ) []byte
sessionKey() []byte
}
type NTLMInitiator struct {
User string
Password string
Hash []byte
Domain string
Workstation string
TargetSPN string
ntlm *ntlm .Client
seqNum uint32
}
func (i *NTLMInitiator ) oid () asn1 .ObjectIdentifier {
return spnego .NlmpOid
}
func (i *NTLMInitiator ) initSecContext () ([]byte , error ) {
i .ntlm = &ntlm .Client {
User : i .User ,
Password : i .Password ,
Hash : i .Hash ,
Domain : i .Domain ,
Workstation : i .Workstation ,
TargetSPN : i .TargetSPN ,
}
nmsg , err := i .ntlm .Negotiate ()
if err != nil {
return nil , err
}
return nmsg , nil
}
func (i *NTLMInitiator ) acceptSecContext (sc []byte ) ([]byte , error ) {
amsg , err := i .ntlm .Authenticate (sc )
if err != nil {
return nil , err
}
return amsg , nil
}
func (i *NTLMInitiator ) sum (bs []byte ) []byte {
mic , _ := i .ntlm .Session ().Sum (bs , i .seqNum )
return mic
}
func (i *NTLMInitiator ) sessionKey () []byte {
return i .ntlm .Session ().SessionKey ()
}
func (i *NTLMInitiator ) infoMap () *ntlm .InfoMap {
return i .ntlm .Session ().InfoMap ()
}
The pages are generated with Golds v0.6.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds .