/// <summary> /// Verify SMB Header Extensions. /// </summary> /// <param name="smbHeader">The SMB Header.</param> /// <param name="isNtManagerNegotiated">If NT LAN Manager or later is negotiated for the SMB dialect.</param> /// <param name="isExtendedSecuritySupported"> /// If the client or the SUT supports extended security. /// </param> /// <param name="isPathContainsLongNames">If the path contained in the message contains long names.</param> private void VerifyMessageSyntaxSMBHeaderExtension( CIFS.SmbHeader smbHeader, bool isNtManagerNegotiated, bool isExtendedSecuritySupported, bool isPathContainsLongNames) { // isNTManagerNegotiated means if NT LAN Manager or later is negotiated for the SMB dialect. if (isNtManagerNegotiated) { // // Verify requirement MS-SMB_R134 and MS-SMB_R135 // string isR134Implementated = Site.Properties.Get("SHOULDMAYR134Implementation"); bool isR135Satisfied = ((uint)SmbHeader_Flags2_Values.SMB_FLAGS2_REPARSE_PATH == ((uint)smbHeader.Flags2 & (uint)SmbHeader_Flags2_Values.SMB_FLAGS2_REPARSE_PATH)); if (isWindows) { // // The following statement code will be run only when debugging. // Site.Log.Add(LogEntryKind.Debug, @"Verify MS-SMB_R135,SmbHeader.Flags2:{0}", (uint)smbHeader.Flags2); // // Verify MS-SMB requirement: MS-SMB_R135. // Site.CaptureRequirementIfIsTrue( isR135Satisfied, 135, @"[In SMB Header Extensions]This bit field[Flags2: SMB_FLAGS2_REPARSE_PATH 0x0400]is set to one only when NT LAN Manager or later is negotiated for the SMB dialect."); if (null == isR134Implementated) { Site.Properties.Add("SHOULDMAYR134Implementation", Boolean.TrueString); isR134Implementated = Boolean.TrueString; } } if (null != isR134Implementated) { bool implemented = Boolean.Parse(isR134Implementated); bool isSatisfied = isR135Satisfied; // // The following statement code will be run only when debugging. // Site.Log.Add(LogEntryKind.Debug, @"Verify MS-SMB_R134,SmbHeader.Flags2:{0}", (uint)smbHeader.Flags2); // // Verify MS-SMB requirement: MS-SMB_R134. // Site.CaptureRequirementIfAreEqual<Boolean>( implemented, isSatisfied, 134, String.Format("[In SMB Header Extensions]This bit field[Flags2:SMB_FLAGS2_REPARSE_PATH 0x0400] " + "SHOULD be set to one only when NT LAN Manager or later is negotiated for the SMB dialect. This " + "requirement is {0}implemented", implemented ? "" : "not ")); } // isExtendedSecuritySupported means if the client or the SUT supports extended security. if (isExtendedSecuritySupported) { // // Verify requirement MS-SMB_R138 and MS-SMB_R139 // string isR138Implementated = Site.Properties.Get("SHOULDMAYR138Implementation"); bool isR139Satisfied = ((uint)SmbHeader_Flags2_Values.SMB_FLAGS2_EXTENDED_SECURITY == ((uint)smbHeader.Flags2 & (uint)SmbHeader_Flags2_Values.SMB_FLAGS2_EXTENDED_SECURITY)); if (isWindows) { // // The following statement code will be run only when debugging. // Site.Log.Add(LogEntryKind.Debug, @"Verify MS-SMB_R138,SmbHeader.Flags2:{0}", (uint)smbHeader.Flags2); // // Verify MS-SMB requirement: MS-SMB_R139. // Site.CaptureRequirementIfIsTrue( isR139Satisfied, 139, @"[In SMB Header Extensions]This bit field[Flags2: SMB_FLAGS2_EXTENDED_SECURITY 0x0800] is set to onewhen NTLM 0.12 or later is negotiated for the SMB dialect dialect and the client or server supports extended security in Windows ."); if (null == isR138Implementated) { Site.Properties.Add("SHOULDMAYR138Implementation", Boolean.TrueString); isR138Implementated = Boolean.TrueString; } } if (null != isR138Implementated) { bool implemented = Boolean.Parse(isR138Implementated); bool isSatisfied = isR139Satisfied; // // The following statement code will be run only when debugging. // Site.Log.Add(LogEntryKind.Debug, @"Verify MS-SMB_R138,SmbHeader.Flags2:{0}", (uint)smbHeader.Flags2); // // Verify MS-SMB requirement: MS-SMB_R138. // Site.CaptureRequirementIfAreEqual<Boolean>( implemented, isSatisfied, 138, String.Format("[In SMB Header Extensions]This bit field" + "[Flags2:SMB_FLAGS2_EXTENDED_SECURITY 0x0800] SHOULD be set to one only when NTLM 0.12 or " + "later is negotiated for the SMB dialect dialect and the client or server supports extended " + "security. This requirement is {0}implemented", implemented ? "" : "not ")); } } } if (((uint)smbHeader.Flags2 & (uint)SmbHeader_Flags2_Values.SMB_FLAGS2_IS_LONG_NAME) == (uint)SmbHeader_Flags2_Values.SMB_FLAGS2_IS_LONG_NAME) { // // The following statement code will be run only when debugging. // Site.Log.Add(LogEntryKind.Debug, @"Verify MS-SMB_R5300,Flags2:{0}", (uint)smbHeader.Flags2); // // Verify MS-SMB requirement: MS-SMB_R5300. // // isPathContainsLongNames means if the path contained in the message contains long names // [larger than 8.3 names]. Site.CaptureRequirementIfIsTrue( isPathContainsLongNames, 5300, @"[In SMB Header Extensions]If [Flags2: SMB_FLAGS2_IS_LONG_NAME 0x0040] set, the path contained in the message[negotiated SMB dialect] contains long names[larger than 8.3 names]."); } else { // // The following statement code will be run only when debugging. // Site.Log.Add(LogEntryKind.Debug, @"Verify MS-SMB_R5301,Flags2:{0}", (uint)smbHeader.Flags2); // // Verify MS-SMB requirement: MS-SMB_R5301. // // isPathContainsLongNames means if the path contained in the message contains long names // [larger than 8.3 names]. Site.CaptureRequirementIfIsFalse( isPathContainsLongNames, 5301, @"[In SMB Header Extensions]otherwise[if Flags2: SMB_FLAGS2_IS_LONG_NAME 0x0040 is not set], the paths are restricted to 8.3 names."); } }
private void VerifyTransport(CIFS.SmbPacket packet) { if (this.transport == TransportType.DirectTcp) { // // The following statement code will be run only when debugging. // Site.Log.Add(LogEntryKind.Debug, @"Verify MS-SMB_R1"); // If the transport type is DirectTCP, a connection between the SUT and the client on a // TCP port is ensured by the protocol SDK. Here capture it directly. Site.CaptureRequirement( 1, @"[In Direct TCP Transport]When using Direct TCP as the SMB transport, the implementer MUST establish a TCP connection from an SMB client to a TCP port on the server."); // // The following statement code will be run only when debugging. // Site.Log.Add(LogEntryKind.Debug, @"Verify MS-SMB_R5076"); // If the transportType is DirectTCP, it means the protocol supports TCP, so capture the requirement // directly. Site.CaptureRequirement( 5076, @"[In Transport]In addition to the transport protocols listed in section 2.1 of [MS-CIFS], the extended version of the protocol supports the use of TCP as a transport layer."); // // The following statement code will be run only when debugging. // Site.Log.Add(LogEntryKind.Debug, @"Verify MS-SMB_R205076"); // If the transportType is DirectTCP, it means the protocol supports TCP, so capture the requirement // directly. Site.CaptureRequirement( 205076, @"[In Transport]Hereafter, the special TCP-related characteristics that are employed in the application of SMB over TCP are known as the Direct TCP transport.<2>"); if (isWindows) { // // The following statement code will be run only when debugging. // Site.Log.Add(LogEntryKind.Debug, @"Verify MS-SMB_R5"); // // Verify MS-SMB requirement: MS-SMB_R5. // Site.CaptureRequirementIfAreEqual<string>( "445", Site.Properties.Get("SutPort"), 5, @"<3> Section 2.1: Windows-based clients and servers use TCP port 445 as the destination TCP port on the SMB server, the well-known port number assigned by IANA to Microsoft-DS."); } // // Verify requirement MS-SMB_R4 and MS-SMB_R10004 // string isR4Implementated = Site.Properties.Get("SHOULDMAYR4Implementation"); bool isR10004Satisfied = ("445" == Site.Properties.Get("SutPort")); if (isWindows) { // // The following statement code will be run only when debugging. // Site.Log.Add(LogEntryKind.Debug, @"Verify MS-SMB_R10004,port:{0}", Site.Properties.Get("SutPort")); // // Verify MS-SMB requirement: MS-SMB_R10004. // Site.CaptureRequirementIfIsTrue( isR10004Satisfied, 10004, @"[In Direct TCP Transport]The SMB server listens for connections on port 445 in Windows. "); if (null == isR4Implementated) { Site.Properties.Add("SHOULDMAYR4Implementation", Boolean.TrueString); isR4Implementated = Boolean.TrueString; } } if (null != isR4Implementated) { bool implemented = Boolean.Parse(isR4Implementated); bool isSatisfied = isR10004Satisfied; // // The following statement code will be run only when debugging. // Site.Log.Add(LogEntryKind.Debug, @"Verify MS-SMB_R4,port:{0}", Site.Properties.Get("SutPort")); // // Verify MS-SMB requirement: MS-SMB_R4. // Site.CaptureRequirementIfAreEqual<Boolean>( implemented, isSatisfied, 4, String.Format("[In Direct TCP Transport]The SMB server SHOULD listen for connections on port" + "445. This requirement is {0}implemented", implemented ? "" : "not ")); } if (null != packet.TransportHeader.StreamProtocolLength) { // // Verify MS-SMB requirement: MS-SMB_R5095. // Site.CaptureRequirementIfAreEqual<int>( 3, packet.TransportHeader.StreamProtocolLength.Length, 5095, @"[In Message Syntax]Stream Protocol Length (3 bytes): This length is formatted as a 3-byte integer in network byte order). "); // // Verify MS-SMB requirement: MS-SMB_R6. // // TransportHeader length is sum of length of StreamProtocolLength field and Zero field(always 1) int transportHeaderLength = packet.TransportHeader.StreamProtocolLength.Length + 1; Site.CaptureRequirementIfAreEqual<int>( 4, transportHeaderLength, 6, @"[In Direct TCP Transport]When using Direct TCP as the SMB transport, the implementer MUST prepend a 4-byte Direct TCP transport packet header to each SMB message."); // // Verify MS-SMB requirement: MS-SMB_R7. // // TransportHeader.StreamProtocolLength indicates the length of the SMB message // It's parsed by protocol SDK. Site.CaptureRequirementIfAreEqual<int>( 3, packet.TransportHeader.StreamProtocolLength.Length, 7, @"[In Direct TCP Transport]This transport header [the 4-byte Direct TCP Transport packet header] MUST be formatted as a byte of zero (8 zero bits) followed by 3 bytes that indicate the length of the SMB message that is encapsulated."); // // Verify MS-SMB requirement: MS-SMB_R8. // // TransportHeader.Zero is the first byte of TransportHeader // It's parsed by protocol SDK. Site.CaptureRequirementIfAreEqual<int>( 0, packet.TransportHeader.Zero, 8, @"[In Direct TCP Transport]Zero (1 byte): The first byte of the Direct TCP transport packet header MUST be zero (0x00)."); } } }
/// <summary> /// Verify The Common Message Syntax. /// </summary> /// <param name="packet">A smbPacket.</param> private void VerifyCommonMessageSyntax(CIFS.SmbPacket packet) { // // The following statement code will be run only when debugging. // Site.Log.Add(LogEntryKind.Debug, @"Verify MS-SMB_R105076"); // The implement of CIFS is assured by the protocol SDK. Here capture it directly. Site.CaptureRequirement( 105076, @"[In Messages]An SMB version 1.0 Protocol implementation MUST implement CIFS, as specified by section 2 of the [MS-CIFS] specification. "); // // The following statement code will be run only when debugging. // Site.Log.Add(LogEntryKind.Debug, @"Verify MS-SMB_R5219"); // The organization of data is decided by protocol SDK,whether little-endian byte order or big-endian // byte order, protocol SDK has ensured that data is organized in little-endian byte order. So here capture // the requirement directly. Site.CaptureRequirement( 5219, "[In Message Syntax]Unless otherwise specified, multi-byte fields (that is, 16-bit, 32-bit, and 64-bit" + "fields) in an SMB message MUST be transmitted in little-endian byte order" + "(least significant byte first)."); // // The following statement code will be run only when debugging. // Site.Log.Add(LogEntryKind.Debug, @"Verify MS-SMB_R75"); // Once all the length and items of smbHeader are checked, this requirement is covered. Site.CaptureRequirement( 75, @"All SMB messages MUST begin with a fixed-length SMB header (as specified in [MS-CIFS], section 2.2.1). "); // // Verify requirement MS-SMB_R77 and MS-SMB_R100077 // string isR77Implementated = Site.Properties.Get("SHOULDMAYR77Implementation"); bool isR100077Satisfied = (packet.SmbHeader.Reserved == 0); if (isWindows) { // // The following statement code will be run only when debugging. // Site.Log.Add(LogEntryKind.Debug, @"Verify MS-SMB_R100077,Reserved:{0}", packet.SmbHeader.Reserved); // // Verify MS-SMB requirement: MS-SMB_R100077. // Site.CaptureRequirementIfIsTrue( isR100077Satisfied, 100077, @"[In Message Syntax]Unless otherwise noted, fields marked as Reserved is set to 0 when being sent in Windows."); if (null == isR77Implementated) { Site.Properties.Add("SHOULDMAYR77Implementation", Boolean.TrueString); isR77Implementated = Boolean.TrueString; } } if (null != isR77Implementated) { bool implemented = Boolean.Parse(isR77Implementated); bool isSatisfied = isR100077Satisfied; // // The following statement code will be run only when debugging. // Site.Log.Add(LogEntryKind.Debug, @"Verify MS-SMB_R77,Reserved:{0}", packet.SmbHeader.Reserved); // // Verify MS-SMB requirement: MS-SMB_R77. // Site.CaptureRequirementIfAreEqual<Boolean>( implemented, isSatisfied, 77, String.Format("[In Message Syntax]Unless otherwise noted, fields marked as Reserved SHOULD be set" + "to 0 when being sent. This requirement is {0}implemented", implemented ? "" : "not ")); } }
private void VerifyMessageSyntaxSmbComNegotiateNonExtendedSecurityServerResponse( CIFS.SmbHeader smbHeader, SmbNegotiateResponsePacket response) { // If DialectIndex is 5, it means NT LAN Manager or later is negotiated for the SMB dialect. int ntlanManagerNegotiated = int.Parse(Site.Properties["NtLanManagerNegotiated"]); if (response.SmbParameters.DialectIndex == ntlanManagerNegotiated) { // // Verify requirement MS-SMB_R11132 and MS-SMB_R132 // string isR11132Implementated = Site.Properties.Get("SHOULDMAYR11132Implementation"); bool isR132Satisfied = ((((uint)smbHeader.Flags2) & 0x0040) == 0x0040); if (isWindows) { // // The following statement code will be run only when debugging. // Site.Log.Add(LogEntryKind.Debug, @"Verify MS-SMB_R132 , Flags2 is : {0}", smbHeader.Flags2); // // Verify MS-SMB requirement: MS-SMB_R132. // Site.CaptureRequirementIfIsTrue( isR132Satisfied, 132, @"[In SMB Header Extensions]This bit field[Flags2: SMB_FLAGS2_IS_LONG_NAME 0x0040] is set to one when NT LAN Manager or later is negotiated for the SMB dialect in WIndows."); if (null == isR11132Implementated) { Site.Properties.Add("isR11132Implementated", Boolean.TrueString); isR11132Implementated = Boolean.TrueString; } } if (null != isR11132Implementated) { bool implemented = Boolean.Parse(isR11132Implementated); bool isSatisfied = isR132Satisfied; // // The following statement code will be run only when debugging. // Site.Log.Add(LogEntryKind.Debug, @"Verify MS-SMB_R11132"); // // Verify MS-SMB requirement: MS-SMB_R11132. // Site.CaptureRequirementIfAreEqual<Boolean>( implemented, isSatisfied, 11132, String.Format(@"[In SMB Header Extensions]This bit field [Flags2:SMB_FLAGS2_IS_LONG_NAME 0x0040] SHOULD be set to one when NT LAN Manager or later is negotiated for the SMB dialect. This requirement is {0}implemented", implemented ? "" : "not ")); } } }
private void VerifyMessageSyntaxFsctlNameResponse(NamespaceCifs.SmbNtTransactIoctlResponsePacket ioctlResponse) { string typeOfFileSystem = Site.Properties["TypeOfFileSystemForFscc"]; switch (this.fsccFSCTLName) { case "FSCTL_CREATE_OR_GET_OBJECT_ID": VerifyDataTypeFsctlCreateOrObjectIDReply( (NamespaceFscc.FsctlCreateOrGetObjectIdReplyStatus)ioctlResponse.SmbHeader.Status); break; case "FSCTL_DELETE_OBJECT_ID": NamespaceFscc.FsccFsctlDeleteObjectIdResponsePacket deleteObjectIdResponse = new NamespaceFscc.FsccFsctlDeleteObjectIdResponsePacket(); deleteObjectIdResponse.Payload = (NamespaceFscc.FsctlDeleteObjectIdReplyStatus)ioctlResponse.SmbHeader.Status; VerifyFsctlDeleteObjectIDReply(deleteObjectIdResponse); break; case "FSCTL_FILESYSTEM_GET_STATISTICS": NamespaceFscc.FsccFsctlFileSystemGetStatisticsResponsePacket getStatisticsResponse = new NamespaceFscc.FsccFsctlFileSystemGetStatisticsResponsePacket(); getStatisticsResponse.FromBytes(ioctlResponse.SmbData.Data); VerifyMessageSyntaxResonseStatusForFsctlFileSystemGetStatisticsRequest( typeOfFileSystem, (NamespaceFscc.FsctlFilesystemGetStatisticsReplyStatus)ioctlResponse.SmbHeader.Status); VerifyFsctlFileSystemGetStatisticsReply( getStatisticsResponse.FsctlFilesystemGetStatisticsReply); break; case "FSCTL_GET_COMPRESSION": NamespaceFscc.FsccFsctlGetCompressionResponsePacket getCompressionResponse = new NamespaceFscc.FsccFsctlGetCompressionResponsePacket(); getCompressionResponse.FromBytes(ioctlResponse.SmbData.Data); VerifyMessageSyntaxFsctlGetCompressionReply( Site.Properties["TypeOfFileSystemForFscc"], ioctlResponse.SmbHeader.Status); VerifyDataTypeFSCTLGETCOMPRESSIONReply(getCompressionResponse, (uint)ioctlResponse.SmbHeader.Status); break; case "FSCTL_GET_NTFS_VOLUME_DATA": NamespaceFscc.FsccFsctlGetNtfsVolumeDataResponsePacket getNtfsVolumeResponse = new NamespaceFscc.FsccFsctlGetNtfsVolumeDataResponsePacket(); getNtfsVolumeResponse.FromBytes(ioctlResponse.SmbData.Data); NamespaceFscc.NTFS_VOLUME_DATA_BUFFER_Reply NTFSVolumeDataBufferReply = (NamespaceFscc.NTFS_VOLUME_DATA_BUFFER_Reply)getNtfsVolumeResponse.Payload; VerifyMessageSyntaxFsctlGetNtfsVolumeDataReply( NTFSVolumeDataBufferReply, (NamespaceFscc.FsctlGetNtfsVolumeDataReplyStatus)ioctlResponse.SmbHeader.Status); break; case "FSCTL_GET_OBJECT_ID": NamespaceFscc.FsccFsctlGetObjectIdResponsePacket getObjectIdResponse = new NamespaceFscc.FsccFsctlGetObjectIdResponsePacket(); getObjectIdResponse.Payload = ioctlResponse.SmbData.Data; bool isUseofObjectIDSupported = Boolean.Parse(Site.Properties["IsUseofObjectIDSupported"]); VerifyDataTypeFsctlGetObjectIDReply((uint)ioctlResponse.SmbHeader.Status, isUseofObjectIDSupported); break; case "FSCTL_IS_PATHNAME_VALID": VerifyMessageSyntaxFsctlIsPathNameValidReply(typeOfFileSystem, ioctlResponse.SmbHeader.Status); break; case "FSCTL_LMR_SET_LINK_TRACKING_INFORMATION": NamespaceFscc.FsccFsctlLmrSetLinkTrackingInformationResponsePacket lmrSetLinkResponse = new NamespaceFscc.FsccFsctlLmrSetLinkTrackingInformationResponsePacket(); lmrSetLinkResponse.Payload = (NamespaceFscc.FsctlLmrSetLinkTrackingInformationReplyStatus)ioctlResponse.SmbHeader.Status; break; case "FSCTL_QUERY_ALLOCATED_RANGES"://need file have cotent. NamespaceFscc.FsccFsctlQueryAllocatedRangesResponsePacket queryRangeResponse = new NamespaceFscc.FsccFsctlQueryAllocatedRangesResponsePacket(); queryRangeResponse.FromBytes(ioctlResponse.SmbData.Data); VerifyDataTypeFsctlQueryAllocatedRangesReply( queryRangeResponse, (uint)ioctlResponse.SmbHeader.Status); NamespaceFscc.FSCTL_QUERY_ALLOCATED_RANGES_Reply fsctlQueryAllocatedRangesReply = (NamespaceFscc.FSCTL_QUERY_ALLOCATED_RANGES_Reply)queryRangeResponse.Payload; VerifyMessageSyntaxFsctlQueryAllocatedRanges(fsctlQueryAllocatedRangesReply); break; case "FSCTL_QUERY_ON_DISK_VOLUME_INFO": //TODO:sample expect error response NamespaceFscc.FsccFsctlQueryOnDiskVolumeInfoResponsePacket onDiskVolumeInfoResponse = new NamespaceFscc.FsccFsctlQueryOnDiskVolumeInfoResponsePacket(); onDiskVolumeInfoResponse.FromBytes(ioctlResponse.SmbData.Data); //TODO: by stack NamespaceFscc.FSCTL_QUERY_ON_DISK_VOLUME_INFO_Reply FSCTLQueryONDiskVolumnInfoReply = (NamespaceFscc.FSCTL_QUERY_ON_DISK_VOLUME_INFO_Reply)onDiskVolumeInfoResponse.Payload; VerifyMessageSyntaxFsctlQueryOnDiskVolumeInfoReply(FSCTLQueryONDiskVolumnInfoReply); //onDiskVolumeInfoResponse.Payload bool isDirectoryNumberKnown = Boolean.Parse(Site.Properties["IsDirectoryNumberKnownForFSCC"]); bool isMajorVersionKnow = Boolean.Parse(Site.Properties["IsMajorVersionKnowForFSCC"]); VerifyDataTypeFsctlQueryOnDiskVolumeInfoReply( onDiskVolumeInfoResponse, (uint)ioctlResponse.SmbHeader.Status, isDirectoryNumberKnown, isMajorVersionKnow); break; case "FSCTL_QUERY_SPARING_INFO": //TODO:sample expect error NamespaceFscc.FsccFsctlQuerySparingInfoResponsePacket sparingInfoResponse = new NamespaceFscc.FsccFsctlQuerySparingInfoResponsePacket(); sparingInfoResponse.FromBytes(ioctlResponse.SmbData.Data); VerifyDataTypeFSCTLQUERYSPARINGINFOReply(sparingInfoResponse.Payload); break; case "FSCTL_READ_FILE_USN_DATA": NamespaceFscc.FsccFsctlReadFileUsnDataResponsePacket readUsnDataResponse = new NamespaceFscc.FsccFsctlReadFileUsnDataResponsePacket(); readUsnDataResponse.FromBytes(ioctlResponse.SmbData.Data); NamespaceFscc.FSCTL_READ_FILE_USN_DATA_Reply reply = (NamespaceFscc.FSCTL_READ_FILE_USN_DATA_Reply)readUsnDataResponse.Payload; VerifyMessageSyntaxFsctlReadFileUsnDataReply(reply); bool isFileOrDirectoryClosed = Boolean.Parse(Site.Properties["IsFileOrDirectoryClosedFSCC"]); bool isUsnChangeJournalRecordLogged = Boolean.Parse(Site.Properties["IsUsnChangeJournalRecordLoggedForFSCC"]); VerifyMessageSyntaxFsctlReadFileUsnDataReplyForOld( reply, isUsnChangeJournalRecordLogged); VerifyMessageSyntaxFsctlReadFileUsnDataReply( reply, (NamespaceFscc.FsctlReadFileUsnDataReplyStatus)ioctlResponse.SmbHeader.Status, isFileOrDirectoryClosed, isUsnChangeJournalRecordLogged); break; case "FSCTL_RECALL_FILE"://sample expect error, capture code expect error or success response. NamespaceFscc.FsccFsctlRecallFileResponsePacket recallFileResponse = new NamespaceFscc.FsccFsctlRecallFileResponsePacket(); recallFileResponse.Payload = (NamespaceFscc.FsctlRecallFileReplyStatus)ioctlResponse.SmbHeader.Status; VerifyMessageSyntaxFsctlRecallFileReply(recallFileResponse.Payload); break; case "FSCTL_SET_COMPRESSION": NamespaceFscc.FsccFsctlSetCompressionResponsePacket setCompressionResponse = new NamespaceFscc.FsccFsctlSetCompressionResponsePacket(); setCompressionResponse.Payload = (NamespaceFscc.FsctlSetCompressionReplyStatus)ioctlResponse.SmbHeader.Status; VerifyMessageSyntaxFsctlSetCompressionReply( (NamespaceFscc.FsctlSetCompressionReplyStatus)setCompressionResponse.Payload); break; case "FSCTL_SET_DEFECT_MANAGEMENT"://sample expect error, capture code expect error or success response. NamespaceFscc.FsccFsctlSetDefectManagementResponsePacket setDefectManagementResponse = new NamespaceFscc.FsccFsctlSetDefectManagementResponsePacket(); setDefectManagementResponse.Payload = (NamespaceFscc.FsctlSetDefectManagementReplyStatus)ioctlResponse.SmbHeader.Status; VerifyMessageSyntaxFsctlSetDefectManagementReply(setDefectManagementResponse.Payload); break; case "FSCTL_SET_OBJECT_ID_EXTENDED"://second success NamespaceFscc.FsccFsctlSetObjectIdExtendedResponsePacket setObjectIdExtendedResponse = new NamespaceFscc.FsccFsctlSetObjectIdExtendedResponsePacket(); setObjectIdExtendedResponse.Payload = (NamespaceFscc.FsctlSetObjectIdExtendedReplyStatus)ioctlResponse.SmbHeader.Status; bool isFileSysContainSpecFile = Boolean.Parse(Site.Properties["IsFileSysContainSpecFileForFSCC"]); bool isDirectoryNotSupportObjectIdUse = Boolean.Parse(Site.Properties["IsDirectoryNotSupportObjectIdUseForFSCC"]); VerifyMessageSyntaxFsctlSetObjectIdExtendedReply( (MessageStatus)ioctlResponse.SmbHeader.Status, isFileSysContainSpecFile, isDirectoryNotSupportObjectIdUse); break; case "FSCTL_SET_SPARSE": NamespaceFscc.FsccFsctlSetSparseResponsePacket setSparseResponse = new NamespaceFscc.FsccFsctlSetSparseResponsePacket(); setSparseResponse.Payload = (NamespaceFscc.FsctlSetSparseReplyStatus)ioctlResponse.SmbHeader.Status; break; case "FSCTL_SET_ZERO_DATA": NamespaceFscc.FsccFsctlSetZeroDataResponsePacket setZeroDataResponse = new NamespaceFscc.FsccFsctlSetZeroDataResponsePacket(); setZeroDataResponse.Payload = (NamespaceFscc.FsctlSetZeroDataReplyStatus)ioctlResponse.SmbHeader.Status; break; case "FSCTL_SET_ZERO_ON_DEALLOCATION": NamespaceFscc.FsccFsctlSetZeroOnDeallocationResponsePacket setZeroOnDeallocationResponse = new NamespaceFscc.FsccFsctlSetZeroOnDeallocationResponsePacket(); setZeroOnDeallocationResponse.Payload = (NamespaceFscc.FsctlSetZeroOnDeallocationReplyStatus)ioctlResponse.SmbHeader.Status; break; case "FSCTL_WRITE_USN_CLOSE_RECORD": NamespaceFscc.FsccFsctlWriteUsnCloseRecordResponsePacket writeUsnCloseRecordResponse = new NamespaceFscc.FsccFsctlWriteUsnCloseRecordResponsePacket(); writeUsnCloseRecordResponse.Payload = (long)ioctlResponse.SmbHeader.Status; bool isUSNChangeSupport = Boolean.Parse(Site.Properties["IsUSNChangeSupportForFSCC"]); VerifyDataTypeFsctlWriteUsnCloseRecordReply( writeUsnCloseRecordResponse.Payload, isUSNChangeSupport); break; default: break; } }
/// <summary> /// Query session table. /// </summary> /// <param name="packet">Get Uid from the SMB packet. </param> /// <returns>The key in the dictionary. </returns> private ushort QueryUidTable(NamespaceCifs.SmbPacket packet) { ushort uid = packet.SmbHeader.Uid; int uTableLen = this.uId.Count; if (!this.uId.ContainsValue(uid)) { this.uId.Add((uint)uTableLen, (uint)uid); return (ushort)uTableLen; } else { foreach (uint key in this.uId.Keys) { if (this.uId[key] == uid) { return (ushort)key; } } return ushort.MinValue; } }
/// <summary> /// Query tid table. /// </summary> /// <param name="packet">Get Uid from the SMB packet.</param> /// <returns>The key in the dictionary.</returns> private ushort QueryTidTable(NamespaceCifs.SmbPacket packet) { ushort tid = packet.SmbHeader.Tid; int tTableLen = this.tId.Count; if (!this.tId.ContainsValue(tid)) { this.tId.Add((uint)tTableLen, (uint)tid); return (ushort)tTableLen; } else { foreach (uint key in this.tId.Keys) { if (this.tId[key] == tid) { return (ushort)key; } } return 0; } }