go-smb2 icon indicating copy to clipboard operation
go-smb2 copied to clipboard

Invalid response error: invalid negotiate flags

Open Yihao-G opened this issue 4 years ago • 2 comments
trafficstars

I'm having problems with connecting to the smb server when I run smbDialer.Dial(conn). It reports invalid response error: invalid negotiate flags.

	conn, err := net.Dial("tcp", "123.123.123.123:445")
	if err != nil {
		fmt.Println(err)
		return
	}
	defer conn.Close()

	smbDialer := &smb2.Dialer{
		Initiator: &smb2.NTLMInitiator{
			User:     "myusername",
			Password: "mypassword",
			Domain:   "NTADMIN",
		},
	}
	smbSession, err := smbDialer.Dial(conn)
	if err != nil {
		fmt.Println(err) // error reported here
		return
	}
	defer smbSession.Logoff()

After digging into the source code, I found the error is from this if statement: https://github.com/hirochachacha/go-smb2/blob/6569ee9e2547186eadde5cc7686551107183ec9e/internal/ntlm/client.go#L83-L85

After commenting out this if statement, I can connect to the smb server and read files no problem.

Looks like this is the part of the NegotiateFlags field. Will it have any security concerns if I comment out this if statement as a quick fix on my side?

Can you please let me know how I can debug this better for you to diagnose the problem? I'm happy to provide more information if needed.

Yihao-G avatar Sep 13 '21 02:09 Yihao-G

Facing the same issue, any update or comments on this?

cocmorph avatar Dec 23 '22 06:12 cocmorph

Users have seen this problem in the SMB backend in rclone.

https://github.com/rclone/rclone/issues/6659

It seems to be maybe problems interacting with embedded SMB agents?

ncw avatar Dec 29 '22 18:12 ncw