Documentation ¶
Index ¶
- Constants
- func NewNegotiateResponse() smb.SMB2NegotiateResponseStruct
- func NewSMB2Packet() smb.SMB2PacketStruct
- func NewSessionSetupResponse() (smb.SMB2SessionSetupResponseStruct, error)
- type Client
- func (c *Client) Close()
- func (c *Client) ConnectAndBindNamedPipes(pipename string) (stdinpipe, stdoutpipe, stderrpipe []byte, err error)
- func (c *Client) ConnectAndWriteStdInPipes(pipename string) (treeid uint32, pipehandle []byte, err error)
- func (c *Client) CreatePipeRequest(treeId uint32, pipename string) (fileId []byte, err error)
- func (c *Client) CreateRequest(treeId uint32, filename string, r CreateRequestStruct) (fileId []byte, err error)
- func (c *Client) NegotiateProtocol() (err error)
- func (c *Client) NewCreateRequest(treeId uint32, filename string, r CreateRequestStruct) CreateRequestStruct
- func (c *Client) NewFSCTLPIPEWAITRequest(pipename string) FSCTLPIPEWAITRequestStruct
- func (c *Client) NewIOCTLRequest(treeId uint32) IOCTLRequestStruct
- func (c *Client) NewNegotiateRequest() smb.SMB2NegotiateRequestStruct
- func (c *Client) NewReadRequest(treeId uint32, fileId []byte) ReadRequestStruct
- func (c *Client) NewSessionSetup2Request() (smb.SMB2SessionSetup2RequestStruct, error)
- func (c *Client) NewSessionSetupRequest() (smb.SMB2SessionSetupRequestStruct, error)
- func (c *Client) NewTreeConnectRequest(name string) (TreeConnectRequestStruct, error)
- func (c *Client) NewTreeDisconnectRequest(treeId uint32) (TreeDisconnectRequestStruct, error)
- func (c *Client) NewWriteRequest(treeId uint32, fileId []byte, buf interface{}) WriteRequestStruct
- func (c *Client) ReadRequest(treeId uint32, fileId []byte) (info []byte, err error)
- func (c *Client) TreeConnect(name string) (treeId uint32, err error)
- func (c *Client) TreeDisconnect(name string) error
- func (c *Client) WritePipeRequest(treeId uint32, buffer, fileId []byte) error
- func (c *Client) WriteRequest(treeId uint32, filepath, filename string, fileId []byte) (err error)
- type CreateRequestStruct
- type CreateResponseStruct
- type FSCTLPIPEWAITRequestStruct
- type IOCTLRequestStruct
- type IOCTLResponseStruct
- type ReadRequestStruct
- type ReadResponseStruct
- type ReadResponseStruct2
- type TreeConnectRequestStruct
- type TreeConnectResponseStruct
- type TreeDisconnectRequestStruct
- type TreeDisconnectResponseStruct
- type WriteRequestStruct
- type WriteResponseStruct
Constants ¶
View Source
const ( FILE_ATTRIBUTE_READONLY = 0x00000001 FILE_ATTRIBUTE_HIDDEN = 0x00000002 FILE_ATTRIBUTE_SYSTEM = 0x00000004 FILE_ATTRIBUTE_DIRECTORY = 0x00000010 FILE_ATTRIBUTE_ARCHIVE = 0x00000020 FILE_ATTRIBUTE_NORMAL = 0x00000080 FILE_ATTRIBUTE_TEMPORARY = 0x00000100 FILE_ATTRIBUTE_SPARSE_FILE = 0x00000200 FILE_ATTRIBUTE_REPARSE_POINT = 0x00000400 FILE_ATTRIBUTE_COMPRESSED = 0x00000800 FILE_ATTRIBUTE_OFFLINE = 0x00001000 FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x00002000 FILE_ATTRIBUTE_ENCRYPTED = 0x00004000 FILE_ATTRIBUTE_INTEGRITY_STREAM = 0x00008000 FILE_ATTRIBUTE_NO_SCRUB_DATA = 0x00020000 FILE_ATTRIBUTE_RECALL_ON_OPEN = 0x00040000 FILE_ATTRIBUTE_PINNED = 0x00080000 FILE_ATTRIBUTE_UNPINNED = 0x00100000 FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS = 0x00400000 )
https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/ca28ec38-f155-4768-81d6-4bfeb8586fc9 FileAttributes属性
View Source
const ( SMB2_OPLOCK_LEVEL_NONE = 0x00 SMB2_OPLOCK_LEVEL_II = 0x01 SMB2_OPLOCK_LEVEL_EXCLUSIVE = 0x08 SMB2_OPLOCK_LEVEL_BATCH = 0x09 SMB2_OPLOCK_LEVEL_LEASE = 0xFF )
RequestedOplockLevel属性
View Source
const ( Anonymous = 0x00000000 Identification = 0x00000001 Impersonation = 0x00000002 Delegate = 0x00000003 )
ImpersonationLevel属性
View Source
const ( FILE_SUPERSEDE = 0x00000000 FILE_OPEN = 0x00000001 FILE_CREATE = 0x00000002 FILE_OPEN_IF = 0x00000003 FILE_OVERWRITE = 0x00000004 FILE_OVERWRITE_IF = 0x00000005 FILE_ACTION_ADDED_STREAM = 0x00000006 )
AccessMask、CreateDisposition属性
View Source
const ( FILE_SHARE_READ = 0x00000001 FILE_SHARE_WRITE = 0x00000002 FILE_SHARE_DELETE = 0x00000004 )
ShareAccess属性
View Source
const ( FILE_DIRECTORY_FILE = 0x00000001 FILE_WRITE_THROUGH = 0x00000002 FILE_SEQUENTIAL_ONLY = 0x00000004 FILE_NO_INTERMEDIATE_BUFFERING = 0x00000008 FILE_SYNCHRONOUS_IO_ALERT = 0x00000010 FILE_SYNCHRONOUS_IO_NONALERT = 0x00000020 FILE_NON_DIRECTORY_FILE = 0x00000040 FILE_COMPLETE_IF_OPLOCKED = 0x00000100 FILE_NO_EA_KNOWLEDGE = 0x00000200 FILE_RANDOM_ACCESS = 0x00000800 FILE_DELETE_ON_CLOSE = 0x00001000 FILE_OPEN_BY_FILE_ID = 0x00002000 FILE_OPEN_FOR_BACKUP_INTENT = 0x00004000 FILE_NO_COMPRESSION = 0x00008000 FILE_OPEN_REMOTE_INSTANCE = 0x00000400 FILE_OPEN_REQUIRING_OPLOCK = 0x00010000 FILE_DISALLOW_EXCLUSIVE = 0x00020000 FILE_RESERVE_OPFILTER = 0x00100000 FILE_OPEN_REPARSE_POINT = 0x00200000 FILE_OPEN_NO_RECALL = 0x00400000 FILE_OPEN_FOR_FREE_SPACE_QUERY = 0x00800000 )
CreateOptionss属性
View Source
const ( FILE_READ_DATA = 0x00000001 FILE_WRITE_DATA = 0x00000002 FILE_APPEND_DATA = 0x00000004 FILE_READ_EA = 0x00000008 FILE_WRITE_EA = 0x00000010 FILE_DELETE_CHILD = 0x00000040 FILE_EXECUTE = 0x00000020 FILE_READ_ATTRIBUTES = 0x00000080 FILE_WRITE_ATTRIBUTES = 0x00000100 DELETE = 0x00010000 READ_CONTROL = 0x00020000 WRITE_DAC = 0x00040000 WRITE_OWNER = 0x00080000 SYNCHRONIZE = 0x00100000 ACCESS_SYSTEM_SECURITY = 0x01000000 MAXIMUM_ALLOWED = 0x02000000 GENERIC_ALL = 0x10000000 GENERIC_EXECUTE = 0x20000000 GENERIC_WRITE = 0x40000000 GENERIC_READ = 0x80000000 )
https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/77b36d0f-6016-458a-a7a0-0f4a72ae1534 DesiredAccess属性
View Source
const ( FSCTL_DFS_GET_REFERRALS = 0x00060194 FSCTL_PIPE_PEEK = 0x0011400C FSCTL_PIPE_WAIT = 0x00110018 FSCTL_PIPE_TRANSCEIVE = 0x0011C017 FSCTL_SRV_COPYCHUNK = 0x001440F2 FSCTL_SRV_ENUMERATE_SNAPSHOTS = 0x00144064 FSCTL_SRV_REQUEST_RESUME_KEY = 0x00140078 FSCTL_SRV_READ_HASH = 0x001441bb FSCTL_SRV_COPYCHUNK_WRITE = 0x001480F2 FSCTL_LMR_REQUEST_RESILIENCY = 0x001401D4 FSCTL_QUERY_NETWORK_INTERFACE_INFO = 0x001401FC FSCTL_SET_REPARSE_POINT = 0x000900A4 FSCTL_DFS_GET_REFERRALS_EX = 0x000601B0 FSCTL_FILE_LEVEL_TRIM = 0x00098208 FSCTL_VALIDATE_NEGOTIATE_INFO = 0x00140204 )
Function属性
View Source
const ( SMB2_0_IOCTL_IS_IOCTL = 0x00000000 SMB2_0_IOCTL_IS_FSCTL = 0x00000001 )
Flags属性
View Source
const ( SMB2_CHANNEL_NONE = 0x00000000 SMB2_CHANNEL_RDMA_V1 = 0x00000001 SMB2_CHANNEL_RDMA_V1_INVALIDATE = 0x00000002 SMB2_CHANNEL_RDMA_TRANSFORM = 0x00000003 )
Channel属性
Variables ¶
This section is empty.
Functions ¶
func NewSMB2Packet ¶
func NewSMB2Packet() smb.SMB2PacketStruct
func NewSessionSetupResponse ¶
func NewSessionSetupResponse() (smb.SMB2SessionSetupResponseStruct, error)
质询响应初始化
Types ¶
type Client ¶
func NewSession ¶
func NewSession(opt common.ClientOptions, debug bool) (client *Client, err error)
SMB2连接封装
func (*Client) ConnectAndBindNamedPipes ¶
func (c *Client) ConnectAndBindNamedPipes(pipename string) (stdinpipe, stdoutpipe, stderrpipe []byte, err error)
拿到stdin、out、err句柄
func (*Client) ConnectAndWriteStdInPipes ¶
func (c *Client) ConnectAndWriteStdInPipes(pipename string) (treeid uint32, pipehandle []byte, err error)
连接并绑定命名管道,并拿到管道句柄
func (*Client) CreatePipeRequest ¶
打开管道
func (*Client) CreateRequest ¶
func (*Client) NegotiateProtocol ¶
func (*Client) NewCreateRequest ¶
func (c *Client) NewCreateRequest(treeId uint32, filename string, r CreateRequestStruct) CreateRequestStruct
创建文件请求
func (*Client) NewFSCTLPIPEWAITRequest ¶
func (c *Client) NewFSCTLPIPEWAITRequest(pipename string) FSCTLPIPEWAITRequestStruct
func (*Client) NewIOCTLRequest ¶
func (c *Client) NewIOCTLRequest(treeId uint32) IOCTLRequestStruct
func (*Client) NewNegotiateRequest ¶
func (c *Client) NewNegotiateRequest() smb.SMB2NegotiateRequestStruct
协商版本请求初始化
func (*Client) NewReadRequest ¶
func (c *Client) NewReadRequest(treeId uint32, fileId []byte) ReadRequestStruct
func (*Client) NewSessionSetup2Request ¶
func (c *Client) NewSessionSetup2Request() (smb.SMB2SessionSetup2RequestStruct, error)
认证请求初始化
func (*Client) NewSessionSetupRequest ¶
func (c *Client) NewSessionSetupRequest() (smb.SMB2SessionSetupRequestStruct, error)
质询请求初始化
func (*Client) NewTreeConnectRequest ¶
func (c *Client) NewTreeConnectRequest(name string) (TreeConnectRequestStruct, error)
func (*Client) NewTreeDisconnectRequest ¶
func (c *Client) NewTreeDisconnectRequest(treeId uint32) (TreeDisconnectRequestStruct, error)
func (*Client) NewWriteRequest ¶
func (c *Client) NewWriteRequest(treeId uint32, fileId []byte, buf interface{}) WriteRequestStruct
写入请求
func (*Client) ReadRequest ¶
func (*Client) TreeConnect ¶
树连接
func (*Client) WritePipeRequest ¶
写入管道数据
type CreateRequestStruct ¶
type CreateRequestStruct struct { smb.SMB2PacketStruct StructureSize uint16 SecurityFlags uint8 //1字节,保留字段,不得使用 OpLock uint8 //1字节,对应文档RequestedOplockLevel字段 ImpersonationLevel uint32 //4字节,模拟等级 CreateFlags []byte `smb:"fixed:8"` //8字节,保留字段,不得使用 Reserved []byte `smb:"fixed:8"` AccessMask uint32 //4字节,访问权限 FileAttributes uint32 //4字节,文件属性 CreateDisposition uint32 CreateOptions uint32 FilenameBufferOffset uint16 `smb:"offset:Filename"` FilenameBufferLength uint16 `smb:"len:Filename"` CreateContextsOffset uint32 CreateContextsLength uint32 Filename []byte `smb:"unicode"` }
type CreateResponseStruct ¶
type CreateResponseStruct struct { smb.SMB2PacketStruct StructureSize uint16 Oplock uint8 //1字节,对应文档RequestedOplockLevel字段 ResponseFlags uint8 CreateAction uint32 CreationTime []byte `smb:"fixed:8"` //8字节,创建时间 LastAccessTime []byte `smb:"fixed:8"` //8字节 LastWriteTime []byte `smb:"fixed:8"` //8字节 LastChangeTime []byte `smb:"fixed:8"` //8字节 AllocationSize []byte `smb:"fixed:8"` //8字节,文件大小 EndofFile []byte `smb:"fixed:8"` //8字节 FileAttributes uint32 Reserved2 uint32 `smb:"fixed:4"` FileId []byte `smb:"fixed:16"` //16字节,文件句柄 CreateContextsOffset uint32 CreateContextsLength uint32 }
type FSCTLPIPEWAITRequestStruct ¶
type IOCTLRequestStruct ¶
type IOCTLRequestStruct struct { smb.SMB2PacketStruct StructureSize uint16 Reserved uint16 Function uint32 GUIDHandle []byte `smb:"fixed:16"` InputOffset uint32 `smb:"offset:Buffer"` InputCount uint32 `smb:"len:Buffer"` MaxInputResponse uint32 OutputOffset uint32 OutputCount uint32 MaxOutputResponse uint32 Flags uint32 Reserved2 uint32 Buffer interface{} }
type IOCTLResponseStruct ¶
type IOCTLResponseStruct struct { smb.SMB2PacketStruct StructureSize uint16 Reserved uint16 Function uint32 GUIDHandle []byte `smb:"fixed:16"` BlobOffset uint32 BlobLength uint32 BlobOffset2 uint32 BlobLength2 uint32 Flags uint32 Reserved2 uint32 }
func NewIOCTLResponse ¶
func NewIOCTLResponse() IOCTLResponseStruct
type ReadRequestStruct ¶
type ReadRequestStruct struct { smb.SMB2PacketStruct StructureSize uint16 //2字节,必须设置49/0x0031 Padding uint8 Flags uint8 ReadLength uint32 FileOffset []byte `smb:"fixed:8"` //8字节 FileId []byte `smb:"fixed:16"` //8字节 MinCount uint32 Channel uint32 RemainingBytes uint32 BlobOffset uint16 BlobLength uint16 `smb:"len:Buffer"` Buffer []byte Reserved uint8 }
type ReadResponseStruct ¶
type ReadResponseStruct2 ¶
type ReadResponseStruct2 struct { smb.SMB2PacketStruct StructureSize uint16 BlobOffset uint8 Reserved uint8 BlobLength uint32 ReadRemaining uint32 Reserved2 uint32 Info []byte `smb:"count:BlobLength"` //写入的数据 }
func NewReadResponse ¶
func NewReadResponse() ReadResponseStruct2
type TreeConnectRequestStruct ¶
type TreeConnectResponseStruct ¶
type TreeConnectResponseStruct struct { smb.SMB2PacketStruct StructureSize uint16 Reserved uint8 //1字节 Capabilities uint32 MaximalAccess uint32 }
func NewTreeConnectResponse ¶
func NewTreeConnectResponse() TreeConnectResponseStruct
type TreeDisconnectRequestStruct ¶
type TreeDisconnectRequestStruct struct { smb.SMB2PacketStruct StructureSize uint16 //2字节,客户端必须设为4,表示请求大小 Reserved uint16 }
type TreeDisconnectResponseStruct ¶
type TreeDisconnectResponseStruct struct { smb.SMB2PacketStruct StructureSize uint16 Reserved uint16 }
func NewTreeDisconnectResponse ¶
func NewTreeDisconnectResponse() TreeDisconnectResponseStruct
type WriteRequestStruct ¶
type WriteRequestStruct struct { smb.SMB2PacketStruct StructureSize uint16 DataOffset uint16 `smb:"offset:Buffer"` WriteLength uint32 `smb:"len:Buffer"` FileOffset uint64 FileId []byte `smb:"fixed:16"` //16字节,服务端返回句柄 Channel uint32 RemainingBytes uint32 WriteChannelInfoOffset uint16 WriteChannelInfoLength uint16 WriteFlags uint32 Buffer interface{} //写入的数据 }
type WriteResponseStruct ¶
Click to show internal directories.
Click to hide internal directories.