Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362/** * SMB2/3 Protocol Constants and Enumerations * Based on MS-SMB2 specification */
// SMB2 Protocol Magic Numberexport const SMB2_PROTOCOL_ID = 0x424D53FE; // "\xfeSMB" in little endian
// SMB2 Header Sizeexport const SMB2_HEADER_SIZE = 64;
// SMB2 Dialect Revisionsexport enum SMB2_DIALECTS { SMB2_0_2 = 0x0202, SMB2_1_0 = 0x0210, SMB3_0_0 = 0x0300, SMB3_0_2 = 0x0302, SMB3_1_1 = 0x0311,}
// SMB2 Command Codesexport enum SMB2_COMMANDS { NEGOTIATE = 0x0000, SESSION_SETUP = 0x0001, LOGOFF = 0x0002, TREE_CONNECT = 0x0003, TREE_DISCONNECT = 0x0004, CREATE = 0x0005, CLOSE = 0x0006, FLUSH = 0x0007, READ = 0x0008, WRITE = 0x0009, LOCK = 0x000A, IOCTL = 0x000B, CANCEL = 0x000C, ECHO = 0x000D, QUERY_DIRECTORY = 0x000E, CHANGE_NOTIFY = 0x000F, QUERY_INFO = 0x0010, SET_INFO = 0x0011, OPLOCK_BREAK = 0x0012,}
// SMB2 Status Codesexport enum SMB2_STATUS { SUCCESS = 0x00000000, INVALID_PARAMETER = 0xC000000D, NO_SUCH_FILE = 0xC000000F, ACCESS_DENIED = 0xC0000022, BUFFER_TOO_SMALL = 0xC0000023, OBJECT_NAME_INVALID = 0xC0000033, OBJECT_NAME_NOT_FOUND = 0xC0000034, OBJECT_NAME_COLLISION = 0xC0000035, OBJECT_PATH_INVALID = 0xC0000039, OBJECT_PATH_NOT_FOUND = 0xC000003A, SHARING_VIOLATION = 0xC0000043, DELETE_PENDING = 0xC0000056, DIRECTORY_NOT_EMPTY = 0xC0000066, NOT_A_DIRECTORY = 0xC0000103, FILE_IS_A_DIRECTORY = 0xC00000BA, NETWORK_NAME_DELETED = 0xC00000C9, BAD_NETWORK_NAME = 0xC00000CC, REQUEST_NOT_ACCEPTED = 0xC00000D0, MORE_PROCESSING_REQUIRED = 0xC0000016, LOGON_FAILURE = 0xC000006D, LOGON_TYPE_NOT_GRANTED = 0xC000015B,}
// SMB2 Header Flagsexport enum SMB2_FLAGS { SERVER_TO_REDIR = 0x00000001, ASYNC_COMMAND = 0x00000002, RELATED_OPERATIONS = 0x00000004, SIGNED = 0x00000008, PRIORITY_MASK = 0x00000070, DFS_OPERATIONS = 0x10000000, REPLAY_OPERATION = 0x20000000,}
// SMB2 Security Modesexport enum SMB2_NEGOTIATE_SIGNING { ENABLED = 0x0001, REQUIRED = 0x0002,}
// SMB2 Capabilitiesexport enum SMB2_GLOBAL_CAP { DFS = 0x00000001, LEASING = 0x00000002, LARGE_MTU = 0x00000004, MULTI_CHANNEL = 0x00000008, PERSISTENT_HANDLES = 0x00000010, DIRECTORY_LEASING = 0x00000020, ENCRYPTION = 0x00000040,}
// File Attributesexport enum FILE_ATTRIBUTES { READONLY = 0x00000001, HIDDEN = 0x00000002, SYSTEM = 0x00000004, DIRECTORY = 0x00000010, ARCHIVE = 0x00000020, NORMAL = 0x00000080, TEMPORARY = 0x00000100, SPARSE_FILE = 0x00000200, REPARSE_POINT = 0x00000400, COMPRESSED = 0x00000800, OFFLINE = 0x00001000, NOT_CONTENT_INDEXED = 0x00002000, ENCRYPTED = 0x00004000, INTEGRITY_STREAM = 0x00008000, NO_SCRUB_DATA = 0x00020000,}
// Access Rightsexport enum ACCESS_MASK { FILE_READ_DATA = 0x00000001, FILE_WRITE_DATA = 0x00000002, FILE_APPEND_DATA = 0x00000004, FILE_READ_EA = 0x00000008, FILE_WRITE_EA = 0x00000010, 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,}
// Share Access Rightsexport enum SHARE_ACCESS { NONE = 0x00000000, READ = 0x00000001, WRITE = 0x00000002, DELETE = 0x00000004,}
// Create Dispositionexport enum CREATE_DISPOSITION { SUPERSEDE = 0x00000000, OPEN = 0x00000001, CREATE = 0x00000002, OPEN_IF = 0x00000003, OVERWRITE = 0x00000004, OVERWRITE_IF = 0x00000005,}
// Create Optionsexport enum CREATE_OPTIONS { DIRECTORY_FILE = 0x00000001, WRITE_THROUGH = 0x00000002, SEQUENTIAL_ONLY = 0x00000004, NO_INTERMEDIATE_BUFFERING = 0x00000008, SYNCHRONOUS_IO_ALERT = 0x00000010, SYNCHRONOUS_IO_NONALERT = 0x00000020, NON_DIRECTORY_FILE = 0x00000040, COMPLETE_IF_OPLOCKED = 0x00000100, NO_EA_KNOWLEDGE = 0x00000200, RANDOM_ACCESS = 0x00000800, DELETE_ON_CLOSE = 0x00001000, OPEN_BY_FILE_ID = 0x00002000, OPEN_FOR_BACKUP_INTENT = 0x00004000, NO_COMPRESSION = 0x00008000, OPEN_REMOTE_INSTANCE = 0x00000400, OPEN_REQUIRING_OPLOCK = 0x00010000, DISALLOW_EXCLUSIVE = 0x00020000, RESERVE_OPFILTER = 0x00100000, OPEN_REPARSE_POINT = 0x00200000, OPEN_NO_RECALL = 0x00400000, OPEN_FOR_FREE_SPACE_QUERY = 0x00800000,}
// Oplock Levelsexport enum OPLOCK_LEVEL { NONE = 0x00, II = 0x01, EXCLUSIVE = 0x08, BATCH = 0x09, LEASE = 0xFF,}
// Information Classesexport enum FILE_INFORMATION_CLASS { FileDirectoryInformation = 1, FileFullDirectoryInformation = 2, FileBothDirectoryInformation = 3, FileBasicInformation = 4, FileStandardInformation = 5, FileInternalInformation = 6, FileEaInformation = 7, FileAccessInformation = 8, FileNameInformation = 9, FileRenameInformation = 10, FileLinkInformation = 11, FileNamesInformation = 12, FileDispositionInformation = 13, FilePositionInformation = 14, FileFullEaInformation = 15, FileModeInformation = 16, FileAlignmentInformation = 17, FileAllInformation = 18, FileAllocationInformation = 19, FileEndOfFileInformation = 20, FileAlternateNameInformation = 21, FileStreamInformation = 22, FilePipeInformation = 23, FilePipeLocalInformation = 24, FilePipeRemoteInformation = 25, FileMailslotQueryInformation = 26, FileMailslotSetInformation = 27, FileCompressionInformation = 28, FileObjectIdInformation = 29, FileCompletionInformation = 30, FileMoveClusterInformation = 31, FileQuotaInformation = 32, FileReparsePointInformation = 33, FileNetworkOpenInformation = 34, FileAttributeTagInformation = 35, FileTrackingInformation = 36, FileIdBothDirectoryInformation = 37, FileIdFullDirectoryInformation = 38, FileValidDataLengthInformation = 39, FileShortNameInformation = 40, FileIoCompletionNotificationInformation = 41, FileIoStatusBlockRangeInformation = 42, FileIoPriorityHintInformation = 43, FileSfioReserveInformation = 44, FileSfioVolumeInformation = 45, FileHardLinkInformation = 46, FileProcessIdsUsingFileInformation = 47, FileNormalizedNameInformation = 48, FileNetworkPhysicalNameInformation = 49, FileIdGlobalTxDirectoryInformation = 50, FileIsRemoteDeviceInformation = 51, FileUnusedInformation = 52, FileNumaNodeInformation = 53, FileStandardLinkInformation = 54, FileRemoteProtocolInformation = 55, FileRenameInformationBypassAccessCheck = 56, FileLinkInformationBypassAccessCheck = 57, FileVolumeNameInformation = 58, FileIdInformation = 59, FileIdExtdDirectoryInformation = 60, FileReplaceCompletionInformation = 61, FileHardLinkFullIdInformation = 62, FileIdExtdBothDirectoryInformation = 63,}
// Security Informationexport enum SECURITY_INFORMATION { OWNER = 0x00000001, GROUP = 0x00000002, DACL = 0x00000004, SACL = 0x00000008, LABEL = 0x00000010, ATTRIBUTE = 0x00000020, SCOPE = 0x00000040, BACKUP = 0x00010000,}
// Tree Connect Flagsexport enum TREE_CONNECT_FLAGS { CLUSTER_RECONNECT = 0x0001, REDIRECT_TO_OWNER = 0x0002, EXTENSION_PRESENT = 0x0004,}
// Share Typeexport enum SHARE_TYPE { DISK = 0x01, PIPE = 0x02, PRINT = 0x03,}
// Share Flagsexport enum SHARE_FLAGS { MANUAL_CACHING = 0x00000000, AUTO_CACHING = 0x00000010, VDO_CACHING = 0x00000020, NO_CACHING = 0x00000030, DFS = 0x00000001, DFS_ROOT = 0x00000002, RESTRICT_EXCLUSIVE_OPENS = 0x00000100, FORCE_SHARED_DELETE = 0x00000200, ALLOW_NAMESPACE_CACHING = 0x00000400, ACCESS_BASED_DIRECTORY_ENUM = 0x00000800, FORCE_LEVELII_OPLOCK = 0x00001000, ENABLE_HASH_V1 = 0x00002000, ENABLE_HASH_V2 = 0x00004000, ENCRYPT_DATA = 0x00008000,}
// Share Capabilitiesexport enum SHARE_CAPABILITIES { DFS = 0x00000008, CONTINUOUS_AVAILABILITY = 0x00000010, SCALEOUT = 0x00000020, CLUSTER = 0x00000040, ASYMMETRIC = 0x00000080, REDIRECT_TO_OWNER = 0x00000100,}
// SMB2 Transform Headerexport const SMB2_TRANSFORM_PROTOCOL_ID = 0x424D53FD; // "\xfdSMB"export const SMB2_TRANSFORM_HEADER_SIZE = 52;
// Encryption Algorithmsexport enum SMB2_ENCRYPTION_ALGORITHMS { AES128_CCM = 0x0001, AES128_GCM = 0x0002, AES256_CCM = 0x0003, AES256_GCM = 0x0004,}
// Signing Algorithmsexport enum SMB2_SIGNING_ALGORITHMS { HMAC_SHA256 = 0x0000, AES_CMAC = 0x0001, AES_GMAC = 0x0002,}
// Preauth Integrity Hash IDsexport enum SMB2_PREAUTH_INTEGRITY_HASH_ID { SHA512 = 0x0001,}
// Compression Algorithmsexport enum SMB2_COMPRESSION_ALGORITHMS { NONE = 0x0000, LZNT1 = 0x0001, LZ77 = 0x0002, LZ77_HUFFMAN = 0x0003, PATTERN_V1 = 0x0004,}
// Default Valuesexport const DEFAULT_MAX_TRANSACT_SIZE = 65536;export const DEFAULT_MAX_READ_SIZE = 65536;export const DEFAULT_MAX_WRITE_SIZE = 65536;export const DEFAULT_SESSION_TIMEOUT = 60; // secondsexport const DEFAULT_CREDIT_CHARGE = 1;export const MIN_CREDIT_CHARGE = 1;export const MAX_CREDIT_CHARGE = 65535;
// Buffer sizesexport const MAX_BUFFER_SIZE = 16 * 1024 * 1024; // 16MBexport const MIN_BUFFER_SIZE = 512;export const PREFERRED_BUFFER_SIZE = 64 * 1024; // 64KB
// Timeoutsexport const NETWORK_TIMEOUT = 30000; // 30 secondsexport const SESSION_TIMEOUT = 300000; // 5 minutesexport const TREE_CONNECT_TIMEOUT = 60000; // 1 minute