hirochachacha / go-smb2

SMB2/3 client library written in Go.
BSD 2-Clause "Simplified" License
350 stars 94 forks source link

Login issue with empty domain name #71

Open witjon opened 1 year ago

witjon commented 1 year ago

I need to login to a SMB server that requires a empty domain. By default, go-smb2 fetches a default domain name from the network. So I tried:

Initiator: &smb2.NTLMInitiator{
    User: "user",
    Domain: "",
    Password: "secret",
    Workstation: "",
},

However, this still uses a default domain name. I tried various values, like nil, \ etc. but none of them work. go-smb2 always prefixes the \ string with an additional \ so setting Domain to "\\" (remember to escape the \) results in a \\ in the login string. Samba's smbclient works for me.

I can verify this behaviour in Wireshark. Here are the relevant parts of the NTLMSSP_AUTH frames:

Samba:

 Session Id: 0x000 Acct:user Domain: Host:
    [Account: user]
    [Domain: ]
    [Host: ]
    [Authenticated in Frame: 000]

\user is used as full authentication string, access granted.

go-smb2 (with Domain: "\\"):

Session Id: 0x000 Acct:user Domain:\ Host:
    [Account: user]
    [Domain: \]
    [Host: ]
    [Authenticated in Frame: 000]

\\user is used as full authentication string, access denied.

It seems that there is no way to set an empty Domain in go-smb2.

ozanh commented 1 year ago

Is there any update about this issue @witjon ? I solved an issue that may be related to this issue by setting SAMBA to the domain field.