smbv1

package
v0.0.0-...-e973567 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

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 NewNegotiateResponse

func NewNegotiateResponse() smb.SMBV1NegotiateResponseStruct

协商版本响应初始化

func NewSMBPacket

func NewSMBPacket() smb.SMBV1PacketStruct

func NewSessionSetupResponse

func NewSessionSetupResponse() (smb.SMBV1SessionSetupResponseStruct, error)

质询响应初始化

Types

type Client

type Client struct {
	common.Client
}

func NewSession

func NewSession(opt common.ClientOptions, debug bool) (client *Client, err error)

SMB2连接封装

func (*Client) NegotiateProtocol

func (c *Client) NegotiateProtocol() (err error)

func (*Client) NewNegotiateRequest

func (c *Client) NewNegotiateRequest() smb.SMBV1NegotiateRequestStruct

协商版本请求初始化

func (*Client) NewSessionSetupRequest

func (c *Client) NewSessionSetupRequest() (smb.SMBV1SessionSetupRequestStruct, error)

质询请求初始化

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字节,文件属性
	ShareAccess          uint32 //4字节,共享模式
	CreateDisposition    uint32
	CreateOptions        uint32
	FilenameBufferOffset uint16 `smb:"offset:Filename"`
	FilenameBufferLength uint16 `smb:"len:Filename"`
	CreateContextsOffset uint32
	CreateContextsLength uint32
	Filename             []byte `smb:"unicode"`
}

https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/e8fb45c1-a03d-44ca-b7ae-47385cfd7997 创建请求结构

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
}

https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/d166aa9e-0b53-410e-b35e-3933d8131927 创建请求响应结构

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{}
}

https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/5c03c9d6-15de-48a2-9835-8fb37f8a79d8

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{} //写入的数据
}

https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/e7046961-3318-4350-be2a-a8d69bb59ce8

type WriteResponseStruct

type WriteResponseStruct struct {
	smb.SMB2PacketStruct
	StructureSize          uint16
	Reserved               uint16
	WriteCount             uint32
	WriteRemaining         uint32
	WriteChannelInfoOffset uint16
	WriteChannelInfoLength uint16
}

https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/7b80a339-f4d3-4575-8ce2-70a06f24f133

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL