Documentation ¶
Index ¶
- Constants
- func HandleConnection(conn net.Conn, openUserCallback func(user *User) ([]Tree, error))
- type Connection
- type FileId
- type GUID
- type SMB2_CLOSE_Response
- type SMB2_CREATE_Response_Header
- type SMB2_ECHO_Response
- type SMB2_ERROR_Context_Response
- type SMB2_ERROR_Response
- type SMB2_FLUSH_Response
- type SMB2_LOGOFF_Response
- type SMB2_NEGOTIATE_Response_Header
- type SMB2_QUERY_DIRECTORY_Response_Header
- type SMB2_QUERY_INFO_Response_Header
- type SMB2_READ_Response_Header
- type SMB2_Response_Header
- type SMB2_SESSION_SETUP_Response_Header
- type SMB2_TREE_CONNECT_Response_Header
- type SMB2_TREE_DISCONNECT_Response
- type SMB2_WRITE_Response
- type Session
- type Stat
- type Tree
- type User
Constants ¶
View Source
const ( SMB_PROTO_ID = 0x424d53ff SMB2_PROTO_ID = 0x424d53fe SMB2_HEADER_SIZE = 64 )
View Source
const ( SMB2_NEGOTIATE = 0x0000 SMB2_SESSION_SETUP = 0x0001 SMB2_LOGOFF = 0x0002 SMB2_TREE_CONNECT = 0x0003 SMB2_TREE_DISCONNECT = 0x0004 SMB2_CREATE = 0x0005 SMB2_CLOSE = 0x0006 SMB2_FLUSH = 0x0007 SMB2_READ = 0x0008 SMB2_WRITE = 0x0009 SMB2_LOCK = 0x000A SMB2_IOCTL = 0x000B SMB2_CANCEL = 0x000C SMB2_ECHO = 0x000D SMB2_QUERY_DIRECTORY = 0x000E SMB2_CHANGE_NOTIFY = 0x000F SMB2_QUERY_INFO = 0x0010 SMB2_SET_INFO = 0x0011 SMB2_OPLOCK_BREAK = 0x0012 )
View Source
const ( SMB2_FLAGS_SERVER_TO_REDIR = 0x00000001 SMB2_FLAGS_ASYNC_COMMAND = 0x00000002 SMB2_FLAGS_RELATED_OPERATIONS = 0x00000004 SMB2_FLAGS_SIGNED = 0x00000008 SMB2_FLAGS_PRIORITY_MASK = 0x00000070 SMB2_FLAGS_DFS_OPERATIONS = 0x10000000 SMB2_FLAGS_REPLAY_OPERATION = 0x20000000 )
View Source
const ( SMB2_NEGOTIATE_SIGNING_ENABLED = 0x0001 SMB2_NEGOTIATE_SIGNING_REQUIRED = 0x0002 )
View Source
const ( SMB2_GLOBAL_CAP_DFS = 0x00000001 SMB2_GLOBAL_CAP_LEASING = 0x00000002 SMB2_GLOBAL_CAP_LARGE_MTU = 0x00000004 SMB2_GLOBAL_CAP_MULTI_CHANNEL = 0x00000008 SMB2_GLOBAL_CAP_PERSISTENT_HANDLES = 0x00000010 SMB2_GLOBAL_CAP_DIRECTORY_LEASING = 0x00000020 SMB2_GLOBAL_CAP_ENCRYPTION = 0x00000040 )
View Source
const ( NTLMSSP_NEGOTIATE_128 = 1 << 29 NTLMSSP_NEGOTIATE_VERSION = 1 << 25 NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY = 1 << 19 NTLMSSP_NEGOTIATE_ALWAYS_SIGN = 1 << 15 NTLMSSP_NEGOTIATE_NTLM = 1 << 9 // If set, requests usage of the NTLM v1 session security protocol. NTLMSSP_NEGOTIATE_SIGN = 1 << 4 NTLMSSP_REQUEST_TARGET = 1 << 2 NTLMSSP_NEGOTIATE_UNICODE = 1 )
See [MS-NLMP].pdf 2.2.2.5
View Source
const ( FILE_READ_DATA = 0x00000001 FILE_WRITE_DATA = 0x00000002 FILE_APPEND_DATA = 0x00000004 FILE_READ_EA = 0x00000008 FILE_WRITE_EA = 0x00000010 GENERIC_READ = 0x80000000 GENERIC_WRITE = 0x40000000 GENERIC_EXECUTE = 0x20000000 GENERIC_ALL = 0x10000000 )
See [MS-SMB2].pdf 2.2.13.1
View Source
const ( FILE_SHARE_READ = 0x00000001 FILE_SHARE_WRITE = 0x00000002 FILE_SHARE_DELETE = 0x00000004 )
View Source
const ( FILE_SUPERSEDE = 0 // If the file already exists, supersede it. Otherwise, create the file. FILE_OPEN = 1 // If the file already exists, return success; otherwise, fail the operation. FILE_CREATE = 2 // If the file already exists, fail the operation; otherwise, create the file. FILE_OPEN_IF = 3 // Open the file if it already exists; otherwise, create the file. FILE_OVERWRITE = 4 // Overwrite the file if it already exists; otherwise, fail the operation. FILE_OVERWRITE_IF = 5 // Overwrite the file if it already exists; otherwise, create the file. )
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 )
View Source
const ( FILE_SUPPORTS_SPARSE_VDL = 0x10000000 // faster nonsparse extend FILE_SUPPORTS_BLOCK_REFCOUNTING = 0x08000000 // allow ioctl dup extents FILE_SUPPORT_INTEGRITY_STREAMS = 0x04000000 FILE_SUPPORTS_USN_JOURNAL = 0x02000000 FILE_SUPPORTS_OPEN_BY_FILE_ID = 0x01000000 FILE_SUPPORTS_EXTENDED_ATTRIBUTES = 0x00800000 FILE_SUPPORTS_HARD_LINKS = 0x00400000 FILE_SUPPORTS_TRANSACTIONS = 0x00200000 FILE_SEQUENTIAL_WRITE_ONCE = 0x00100000 FILE_READ_ONLY_VOLUME = 0x00080000 FILE_NAMED_STREAMS = 0x00040000 FILE_SUPPORTS_ENCRYPTION = 0x00020000 FILE_SUPPORTS_OBJECT_IDS = 0x00010000 FILE_VOLUME_IS_COMPRESSED = 0x00008000 FILE_SUPPORTS_REMOTE_STORAGE = 0x00000100 FILE_SUPPORTS_REPARSE_POINTS = 0x00000080 FILE_SUPPORTS_SPARSE_FILES = 0x00000040 FILE_VOLUME_QUOTAS = 0x00000020 FILE_FILE_COMPRESSION = 0x00000010 FILE_PERSISTENT_ACLS = 0x00000008 FILE_UNICODE_ON_DISK = 0x00000004 FILE_CASE_PRESERVED_NAMES = 0x00000002 FILE_CASE_SENSITIVE_SEARCH = 0x00000001 )
List of FileSystemAttributes - see 2.5.1 of MS-FSCC
View Source
const ( SMB2_O_INFO_FILE = 0x01 SMB2_O_INFO_FILESYSTEM = 0x02 SMB2_O_INFO_SECURITY = 0x03 SMB2_O_INFO_QUOTA = 0x04 )
Possible InfoType values of SMB2_QUERY_INFO
View Source
const ( SMB2_RESTART_SCANS = 0x01 SMB2_RETURN_SINGLE_ENTRY = 0x02 SMB2_INDEX_SPECIFIED = 0x04 SMB2_REOPEN = 0x10 )
Possible values of SMB2_QUERY_DIRECTORY.Flags
View Source
const ( FS_VOLUME_INFORMATION = 1 // Query FS_LABEL_INFORMATION = 2 // Local only FS_SIZE_INFORMATION = 3 // Query FS_DEVICE_INFORMATION = 4 // Query FS_ATTRIBUTE_INFORMATION = 5 // Query FS_CONTROL_INFORMATION = 6 // Query, Set FS_FULL_SIZE_INFORMATION = 7 // Query FS_OBJECT_ID_INFORMATION = 8 // Query, Set FS_DRIVER_PATH_INFORMATION = 9 // Local only FS_VOLUME_FLAGS_INFORMATION = 10 // Local only FS_SECTOR_SIZE_INFORMATION = 11 // SMB3+. Query )
For SMB2_QUERY_INFO.InfoType == SMB2_O_INFO_FILESYSTEM File System Information Classes
View Source
const ( FILE_ALL_INFORMATION = 0x12 FILE_BASIC_INFORMATION = 0x04 FILE_ACCESS_INFORMATION = 0x08 FILE_EA_INFORMATION = 0x07 )
For SMB2_QUERY_INFO.InfoType == SMB2_O_INFO_FILE
View Source
const ( FILE_DIRECTORY_INFORMATION = 0x01 FILE_FULL_DIRECTORY_INFORMATION = 0x02 FILE_BOTH_DIRECTORY_INFORMATION = 0x03 FILE_NAMES_INFORMATION = 0x0c FILE_ID_BOTH_DIRECTORY_INFORMATION = 0x25 FILE_ID_FULL_DIRECTORY_INFORMATION = 0x26 )
Possible values of SMB2_QUERY_DIRECTORY.FileInformationClass
View Source
const ( STATUS_NO_MORE_FILES = 0x80000006 STATUS_UNSUCCESSFUL = 0xC0000001 STATUS_NOT_IMPLEMENTED = 0xC0000002 STATUS_INVALID_INFO_CLASS = 0xC0000003 STATUS_INFO_LENGTH_MISMATCH = 0xC0000004 STATUS_INVALID_PARAMETER = 0xC000000D STATUS_NO_SUCH_FILE = 0xC000000F STATUS_END_OF_FILE = 0xC0000011 STATUS_OBJECT_NAME_NOT_FOUND = 0xC0000034 STATUS_NOT_SUPPORTED = 0xC00000BB STATUS_NETWORK_NAME_DELETED = 0xC00000C9 STATUS_FILE_CLOSED = 0xC0000128 STATUS_USER_SESSION_DELETED = 0xC0000203 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
type SMB2_CLOSE_Response ¶
type SMB2_CREATE_Response_Header ¶
type SMB2_CREATE_Response_Header struct { Header SMB2_Response_Header StructureSize uint16 OplockLevel uint8 Flags uint8 CreateAction uint32 CreationTime int64 LastAccessTime int64 LastWriteTime int64 ChangeTime int64 AllocationSize uint64 EndOfFile uint64 FileAttributes uint32 Reserved2 uint32 FileId GUID CreateContextsOffset uint32 CreateContextsLength uint32 }
type SMB2_ECHO_Response ¶
type SMB2_ECHO_Response struct { Header SMB2_Response_Header StructureSize uint16 Reserved uint16 }
type SMB2_ERROR_Response ¶
type SMB2_ERROR_Response struct { Header SMB2_Response_Header StructureSize uint16 ErrorContextCount uint8 Reserved uint8 ByteCount uint32 ErrorData []SMB2_ERROR_Context_Response }
type SMB2_FLUSH_Response ¶
type SMB2_FLUSH_Response struct { Header SMB2_Response_Header StructureSize uint16 Reserved uint16 }
type SMB2_LOGOFF_Response ¶
type SMB2_LOGOFF_Response struct { Header SMB2_Response_Header StructureSize uint16 Reserved uint16 }
type SMB2_NEGOTIATE_Response_Header ¶
type SMB2_NEGOTIATE_Response_Header struct { Header SMB2_Response_Header StructureSize uint16 SecurityMode uint16 // SMB2_NEGOTIATE_SIGNING_ENABLED, SMB2_NEGOTIATE_SIGNING_REQUIRED DialectRevision uint16 NegotiateContextCount uint16 ServerGuid GUID Capabilities uint32 MaxTransactSize uint32 MaxReadSize uint32 MaxWriteSize uint32 SystemTime int64 ServerStartTime int64 SecurityBufferOffset uint16 SecurityBufferLength uint16 NegotiateContextOffset uint32 }
type SMB2_QUERY_DIRECTORY_Response_Header ¶
type SMB2_QUERY_DIRECTORY_Response_Header struct { Header SMB2_Response_Header StructureSize uint16 OutputBufferOffset uint16 OutputBufferLength uint32 }
type SMB2_QUERY_INFO_Response_Header ¶
type SMB2_QUERY_INFO_Response_Header struct { Header SMB2_Response_Header StructureSize uint16 OutputBufferOffset uint16 OutputBufferLength uint32 }
type SMB2_Response_Header ¶
type SMB2_Response_Header struct { // First two fields are written by Connection.writeResponse //ProtocolId uint32 // The value MUST be (in network order) 0xFE, 'S', 'M' and 'B'. //StructureSize uint16 // must be 64 CreditCharge uint16 Status uint32 Command uint16 CreditResponse uint16 Flags uint32 NextCommand uint32 MessageId int64 Reserved uint32 // AsyncId TreeId uint32 // AsyncId SessionId uint64 Signature [2]uint64 }
type SMB2_SESSION_SETUP_Response_Header ¶
type SMB2_SESSION_SETUP_Response_Header struct { Header SMB2_Response_Header StructureSize uint16 SessionFlags uint16 SecurityBufferOffset uint16 SecurityBufferLength uint16 }
type SMB2_TREE_CONNECT_Response_Header ¶
type SMB2_TREE_CONNECT_Response_Header struct { Header SMB2_Response_Header StructureSize uint16 Reserved uint8 Capabilities uint32 MaximalAccess uint32 }
type SMB2_TREE_DISCONNECT_Response ¶
type SMB2_TREE_DISCONNECT_Response struct { Header SMB2_Response_Header StructureSize uint16 Reserved uint16 }
type SMB2_WRITE_Response ¶
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
See 3.2.1.3 page 137
func NewSession ¶
func NewSession() *Session
type Tree ¶
type Tree interface { Name() string Id() uint32 Close() error OpenFile(path string, flags int) (FileId, error) CloseFile(FileId) error NameOfFile(FileId) string // full path //StatByPath(path string, followLinks bool) (Stat, error) StatById(id FileId, followLinks bool) (Stat, error) // For file only Read(id FileId, p []byte) (n int, err error) Write(id FileId, p []byte) (n int, err error) Seek(id FileId, offset int64) error CurrentPosition(id FileId) int64 // For directory only ReadDir(id FileId, n int) ([]Stat, error) Mkdir(path string) error Symlink(oldname, newname string) error Remove(path string, recursive bool) error Truncate(id FileId, size int64) error ChangeMode(id FileId, allowWrite bool, allowExecute bool) error // allowExecute only for files Sync(FileId) error SyncAll() error }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.