Use golang's log, so we don't need log4go.
This commit is contained in:
parent
52b7efa603
commit
b00ec39bbd
@ -8,8 +8,9 @@ import (
|
|||||||
md5P "crypto/md5"
|
md5P "crypto/md5"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
rc4P "crypto/rc4"
|
rc4P "crypto/rc4"
|
||||||
md4P "github.com/ThomsonReutersEikon/go-ntlm/ntlm/md4"
|
|
||||||
crc32P "hash/crc32"
|
crc32P "hash/crc32"
|
||||||
|
|
||||||
|
md4P "github.com/ThomsonReutersEikon/go-ntlm/ntlm/md4"
|
||||||
)
|
)
|
||||||
|
|
||||||
func md4(data []byte) []byte {
|
func md4(data []byte) []byte {
|
||||||
|
@ -5,8 +5,8 @@ package ntlm
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"unicode/utf16"
|
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"unicode/utf16"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Concatenate two byte slices into a new slice
|
// Concatenate two byte slices into a new slice
|
||||||
@ -67,23 +67,22 @@ func utf16FromString(s string) []byte {
|
|||||||
|
|
||||||
// Convert a UTF16 string to UTF8 string for Go usage
|
// Convert a UTF16 string to UTF8 string for Go usage
|
||||||
func utf16ToString(bytes []byte) string {
|
func utf16ToString(bytes []byte) string {
|
||||||
var data []uint16
|
var data []uint16
|
||||||
|
|
||||||
// NOTE: This is definitely not the best way to do this, but when I tried using a buffer.Read I could not get it to work
|
// NOTE: This is definitely not the best way to do this, but when I tried using a buffer.Read I could not get it to work
|
||||||
for offset := 0; offset < len(bytes); offset = offset + 2 {
|
for offset := 0; offset < len(bytes); offset = offset + 2 {
|
||||||
i := binary.LittleEndian.Uint16(bytes[offset : offset+2])
|
i := binary.LittleEndian.Uint16(bytes[offset : offset+2])
|
||||||
data = append(data, i)
|
data = append(data, i)
|
||||||
}
|
}
|
||||||
|
|
||||||
return string(utf16.Decode(data))
|
return string(utf16.Decode(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
func uint32ToBytes(v uint32) []byte {
|
func uint32ToBytes(v uint32) []byte {
|
||||||
bytes := make([]byte, 4)
|
bytes := make([]byte, 4)
|
||||||
bytes[0] = byte(v & 0xff)
|
bytes[0] = byte(v & 0xff)
|
||||||
bytes[1] = byte((v >> 8) & 0xff)
|
bytes[1] = byte((v >> 8) & 0xff)
|
||||||
bytes[2] = byte((v >> 16) & 0xff)
|
bytes[2] = byte((v >> 16) & 0xff)
|
||||||
bytes[3] = byte((v >> 24) & 0xff)
|
bytes[3] = byte((v >> 24) & 0xff)
|
||||||
return bytes
|
return bytes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ type AuthenticateMessage struct {
|
|||||||
/// MS-NLMP 2.2.1.3 - In connectionless mode, a NEGOTIATE structure that contains a set of bit flags (section 2.2.2.5) and represents the
|
/// MS-NLMP 2.2.1.3 - In connectionless mode, a NEGOTIATE structure that contains a set of bit flags (section 2.2.2.5) and represents the
|
||||||
// conclusion of negotiation—the choices the client has made from the options the server offered in the CHALLENGE_MESSAGE.
|
// conclusion of negotiation—the choices the client has made from the options the server offered in the CHALLENGE_MESSAGE.
|
||||||
// In connection-oriented mode, a NEGOTIATE structure that contains the set of bit flags (section 2.2.2.5) negotiated in
|
// In connection-oriented mode, a NEGOTIATE structure that contains the set of bit flags (section 2.2.2.5) negotiated in
|
||||||
// the previous
|
// the previous
|
||||||
NegotiateFlags uint32 // 4 bytes
|
NegotiateFlags uint32 // 4 bytes
|
||||||
|
|
||||||
// Version (8 bytes): A VERSION structure (section 2.2.2.10) that is present only when the NTLMSSP_NEGOTIATE_VERSION
|
// Version (8 bytes): A VERSION structure (section 2.2.2.10) that is present only when the NTLMSSP_NEGOTIATE_VERSION
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
rc4P "crypto/rc4"
|
rc4P "crypto/rc4"
|
||||||
"errors"
|
"errors"
|
||||||
l4g "github.com/ThomsonReutersEikon/log4go"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ func (n *V1ServerSession) ProcessAuthenticateMessage(am *AuthenticateMessage) (e
|
|||||||
// They should always be correct (I hope)
|
// They should always be correct (I hope)
|
||||||
n.user = am.UserName.String()
|
n.user = am.UserName.String()
|
||||||
n.userDomain = am.DomainName.String()
|
n.userDomain = am.DomainName.String()
|
||||||
l4g.Info("(ProcessAuthenticateMessage)NTLM v1 User %s Domain %s", n.user, n.userDomain)
|
log.Printf("(ProcessAuthenticateMessage)NTLM v1 User %s Domain %s", n.user, n.userDomain)
|
||||||
|
|
||||||
err = n.fetchResponseKeys()
|
err = n.fetchResponseKeys()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -225,7 +225,7 @@ func (n *V1ServerSession) ProcessAuthenticateMessage(am *AuthenticateMessage) (e
|
|||||||
//UGH not entirely sure how this could possibly happen, going to put this in for now
|
//UGH not entirely sure how this could possibly happen, going to put this in for now
|
||||||
//TODO investigate if this ever is really happening
|
//TODO investigate if this ever is really happening
|
||||||
am.Version = &VersionStruct{ProductMajorVersion: uint8(5), ProductMinorVersion: uint8(1), ProductBuild: uint16(2600), NTLMRevisionCurrent: uint8(15)}
|
am.Version = &VersionStruct{ProductMajorVersion: uint8(5), ProductMinorVersion: uint8(1), ProductBuild: uint16(2600), NTLMRevisionCurrent: uint8(15)}
|
||||||
l4g.Error("Nil version in ntlmv1")
|
log.Printf("Nil version in ntlmv1")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = n.calculateKeys(am.Version.NTLMRevisionCurrent)
|
err = n.calculateKeys(am.Version.NTLMRevisionCurrent)
|
||||||
|
@ -42,14 +42,14 @@ func checkV1Value(t *testing.T, name string, value []byte, expected string, err
|
|||||||
// would authenticate. This was due to a bug in the MS-NLMP docs. This tests for that issue
|
// would authenticate. This was due to a bug in the MS-NLMP docs. This tests for that issue
|
||||||
func TestNtlmV1ExtendedSessionSecurity(t *testing.T) {
|
func TestNtlmV1ExtendedSessionSecurity(t *testing.T) {
|
||||||
// NTLMv1 with extended session security
|
// NTLMv1 with extended session security
|
||||||
challengeMessage := "TlRMTVNTUAACAAAAAAAAADgAAABVgphiRy3oSZvn1I4AAAAAAAAAAKIAogA4AAAABQEoCgAAAA8CAA4AUgBFAFUAVABFAFIAUwABABwAVQBLAEIAUAAtAEMAQgBUAFIATQBGAEUAMAA2AAQAFgBSAGUAdQB0AGUAcgBzAC4AbgBlAHQAAwA0AHUAawBiAHAALQBjAGIAdAByAG0AZgBlADAANgAuAFIAZQB1AHQAZQByAHMALgBuAGUAdAAFABYAUgBlAHUAdABlAHIAcwAuAG4AZQB0AAAAAAA="
|
challengeMessage := "TlRMTVNTUAACAAAAAAAAADgAAABVgphiRy3oSZvn1I4AAAAAAAAAAKIAogA4AAAABQEoCgAAAA8CAA4AUgBFAFUAVABFAFIAUwABABwAVQBLAEIAUAAtAEMAQgBUAFIATQBGAEUAMAA2AAQAFgBSAGUAdQB0AGUAcgBzAC4AbgBlAHQAAwA0AHUAawBiAHAALQBjAGIAdAByAG0AZgBlADAANgAuAFIAZQB1AHQAZQByAHMALgBuAGUAdAAFABYAUgBlAHUAdABlAHIAcwAuAG4AZQB0AAAAAAA="
|
||||||
authenticateMessage := "TlRMTVNTUAADAAAAGAAYAJgAAAAYABgAsAAAAAAAAABIAAAAOgA6AEgAAAAWABYAggAAABAAEADIAAAAVYKYYgUCzg4AAAAPMQAwADAAMAAwADEALgB3AGMAcABAAHQAaABvAG0AcwBvAG4AcgBlAHUAdABlAHIAcwAuAGMAbwBtAE4AWQBDAFMATQBTAEcAOQA5ADAAOQBRWAK3h/TIywAAAAAAAAAAAAAAAAAAAAA3tp89kZU1hs1XZp7KTyGm3XsFAT9stEDW9YXDaeYVBmBcBb//2FOu"
|
authenticateMessage := "TlRMTVNTUAADAAAAGAAYAJgAAAAYABgAsAAAAAAAAABIAAAAOgA6AEgAAAAWABYAggAAABAAEADIAAAAVYKYYgUCzg4AAAAPMQAwADAAMAAwADEALgB3AGMAcABAAHQAaABvAG0AcwBvAG4AcgBlAHUAdABlAHIAcwAuAGMAbwBtAE4AWQBDAFMATQBTAEcAOQA5ADAAOQBRWAK3h/TIywAAAAAAAAAAAAAAAAAAAAA3tp89kZU1hs1XZp7KTyGm3XsFAT9stEDW9YXDaeYVBmBcBb//2FOu"
|
||||||
|
|
||||||
challengeData, _ := base64.StdEncoding.DecodeString(challengeMessage)
|
challengeData, _ := base64.StdEncoding.DecodeString(challengeMessage)
|
||||||
c, _ := ParseChallengeMessage(challengeData)
|
c, _ := ParseChallengeMessage(challengeData)
|
||||||
|
|
||||||
authenticateData, _ := base64.StdEncoding.DecodeString(authenticateMessage)
|
authenticateData, _ := base64.StdEncoding.DecodeString(authenticateMessage)
|
||||||
msg, err := ParseAuthenticateMessage(authenticateData, 1)
|
msg, err := ParseAuthenticateMessage(authenticateData, 1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Could not process authenticate message: %s", err)
|
t.Errorf("Could not process authenticate message: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
rc4P "crypto/rc4"
|
rc4P "crypto/rc4"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
l4g "github.com/ThomsonReutersEikon/log4go"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@ -204,7 +204,7 @@ func (n *V2ServerSession) ProcessAuthenticateMessage(am *AuthenticateMessage) (e
|
|||||||
// They should always be correct (I hope)
|
// They should always be correct (I hope)
|
||||||
n.user = am.UserName.String()
|
n.user = am.UserName.String()
|
||||||
n.userDomain = am.DomainName.String()
|
n.userDomain = am.DomainName.String()
|
||||||
l4g.Info("(ProcessAuthenticateMessage)NTLM v2 User %s Domain %s", n.user, n.userDomain)
|
log.Printf("(ProcessAuthenticateMessage)NTLM v2 User %s Domain %s", n.user, n.userDomain)
|
||||||
|
|
||||||
err = n.fetchResponseKeys()
|
err = n.fetchResponseKeys()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -238,14 +238,13 @@ func (n *V2ServerSession) ProcessAuthenticateMessage(am *AuthenticateMessage) (e
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if am.Version == nil {
|
if am.Version == nil {
|
||||||
//UGH not entirely sure how this could possibly happen, going to put this in for now
|
//UGH not entirely sure how this could possibly happen, going to put this in for now
|
||||||
//TODO investigate if this ever is really happening
|
//TODO investigate if this ever is really happening
|
||||||
am.Version = &VersionStruct{ProductMajorVersion: uint8(5), ProductMinorVersion: uint8(1), ProductBuild: uint16(2600), NTLMRevisionCurrent: uint8(15)}
|
am.Version = &VersionStruct{ProductMajorVersion: uint8(5), ProductMinorVersion: uint8(1), ProductBuild: uint16(2600), NTLMRevisionCurrent: uint8(15)}
|
||||||
|
|
||||||
l4g.Error("Nil version in ntlmv2")
|
log.Printf("Nil version in ntlmv2")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = n.calculateKeys(am.Version.NTLMRevisionCurrent)
|
err = n.calculateKeys(am.Version.NTLMRevisionCurrent)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -4,6 +4,8 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/ThomsonReutersEikon/go-ntlm/ntlm"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/ThomsonReutersEikon/go-ntlm/ntlm"
|
"github.com/ThomsonReutersEikon/go-ntlm/ntlm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user