默认分类

smb协议初探

我想通过golang实现SMB服务

协议步骤介绍走起:

数据包 1: SMB_COM_NEGOTIATE
Direction: 客户端至服务端
Description: 客户端发送请求链接服务端,磋商协议版本

数据包 2: SMB_COM_NEGOTIATE
Direction: 服务端至客户端
Description:服务端返回磋商的协议版本给客户端,返回数据还包含8字节所及字符串用于下一步登录验证

数据包 3: SMB_COM_SESSION_SETUP_ANDX
Direction: 客户端至服务端
Description: 发送的数据包包含客户端的功能信息,就算服务端只有共享级安全,该包页会被发送

数据包 3: SMB_COM_SESSION_SETUP_ANDX
Direction: 服务端至客户端
Description: 如果询问/应答被服务端接受,一个有效的UID会被包含于数据包中,返回给客户端。如果不接受,服务端则会返回一个错误代码,并拒绝客户端访问.

数据包 4: SMB_COM_TREE_CONNECT_ANDX
Direction: 客户端至服务端
Description: 客户端发送共享访问请求.数据包会包含一个UNC格式的完整路径.

数据包 5: SMB_COM_TREE_CONNECT_ANDX
Direction: 服务端至客户端
Description: If access to the share is granted, then the server returns the 16-bit tree ID (TID) that corresponds to the share in this packet. If the share does not exist or the user has insufficient credentials to access the share, the server will return an error code in this packet and deny access to the share.

数据包 6: SMB_COM_OPEN_ANDX
Direction: 客户端至服务端
Description: The client requests the server to open a file on the accessed share on behalf of the client. This packet contains the name of the file to be opened.

数据包 7: SMB_COM_OPEN_ANDX
Direction: 服务端至客户端
Description: If access to the file is granted, then the server returns the file ID of the requested file. If the file does not exist or the user has insufficient credentials to access the file, the server will return an error code in this packet and deny access to the file.

数据包 8: SMB_COM_READ_ANDX
Direction: 客户端至服务端
Description: The client requests the server to read data from the opened file on behalf of the client and return this data to the client. The file ID that is obtained by the client when the file was opened is included in this packet in order to identify which opened file the server should read data from.

数据包 9: SMB_COM_READ_ANDX
Direction: 服务端至客户端
Description: The server returns the requested file data in this packet. An error here is unlikely given that access to the server, share, and file has been granted. It can happen in some situations, however: for example, if access to a share is changed between the time the file is opened and the time it is read from.

// todo...

This is just a placeholder img.