private void VerifySequenceDiagram(SmbErrorResponsePacket errorResponsePacket)
        {
            //
            // The following statement code will be run only when debugging.
            //
            Site.Log.Add(LogEntryKind.Debug,
                @"Verify MS-SMB_R4179");

            // The adapter logic has realized the behavior of this RS, it can be captured directly.
            Site.CaptureRequirement(
                4179,
                @"[In Sequence Diagram] Session Setup Roundtrip: If the session setup has to be continued, the security
                package on the client and/or server requires an additional roundtrip before the session setup can be
                established.");

            //
            // The following statement code will be run only when debugging.
            //
            Site.Log.Add(LogEntryKind.Debug,
                @"Verify MS-SMB_R4180");

            //
            // Verify MS-SMB requirement: MS-SMB_R4180
            //
            // If the packet is not null, it means the new security packages were returned.
            Site.CaptureRequirementIfIsNotNull(
                errorResponsePacket,
                4180,
                "[In Sequence Diagram] Session Setup Roundtrip:This[If the session setup has to be continued, the " +
                "security package on the client and or server needs an additional roundtrip before the session setup can " +
                "be established.] is especially true of new security packages that support mutual authentication between " +
                "the client and server.");
        }
        /// <summary>
        /// Create SMB_ERROR response, including only header portion 
        /// </summary>
        /// <param name="connection">the connection identified the client</param>
        /// <param name = "status">Status of the packet </param>
        /// <param name = "command">The operation code that this SMB is requesting or responding to </param>
        /// <returns>The CreateSmbErrorResponsePacket </returns>
        /// <exception cref="ArgumentNullException">connection must not be null</exception>
        public virtual SmbErrorResponsePacket CreateSmbErrorResponse(
            SmbServerConnection connection,
            uint status,
            SmbCommand command)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            SmbErrorResponsePacket packet = new SmbErrorResponsePacket();

            // create smb packet header
            SmbHeader smbHeader = CifsMessageUtils.CreateSmbHeader(
                command, connection.ProcessId, connection.MessageId, 0x00, 0x00,
                (SmbFlags)connection.Capability.Flag, (SmbFlags2)connection.Capability.Flags2);
            smbHeader.Status = status;

            packet.SmbHeader = smbHeader;

            return packet;
        }
        private void VerifyScanPathForPreviousVersionTokenWithoutFile(
            SmbErrorResponsePacket trans2FindFirst2ErrorResponse)
        {
            //
            // The following statement code will be run only when debugging.
            //
            Site.Log.Add(LogEntryKind.Debug,
                @"Verify MS-SMB_R8556");

            //
            // Verify MS-SMB requirement: MS-SMB_R8556.
            //
            Site.CaptureRequirementIfAreEqual<SmbStatus>(
                SmbStatus.STATUS_OBJECT_NAME_NOT_FOUND,
                (SmbStatus)trans2FindFirst2ErrorResponse.SmbHeader.Status,
                8556,
                @"[In Scanning a Path for a Previous Version Token] If a previous version token is found in the
                pathname, but the file does not exist for the given snapshot, then the server MUST fail the operation
                with STATUS_OBJECT_NAME_NOT_FOUND.");
        }
 /// <summary>
 /// Deep copy constructor. 
 /// </summary>
 public SmbErrorResponsePacket(SmbErrorResponsePacket packet)
     : base(packet)
 {
     this.smbParameters.WordCount = packet.SmbParameters.WordCount;
     this.smbData.ByteCount = packet.SmbData.ByteCount;
 }
        protected override SmbPacket CreateSmbResponsePacket(
            SmbPacket request,
            SmbHeader smbHeader,
            Channel channel)
        {
            SmbPacket smbPacket = null;

            // error packet
            SmbStatus packetStatus = (SmbStatus)smbHeader.Status;

            // error packet
            if (packetStatus != SmbStatus.STATUS_SUCCESS &&
                    packetStatus != SmbStatus.STATUS_MORE_PROCESSING_REQUIRED &&
                    packetStatus != SmbStatus.STATUS_BUFFER_OVERFLOW)
            {
                smbPacket = new SmbErrorResponsePacket();
                smbPacket.SmbHeader = smbHeader;

                return smbPacket;
            }

            // success packet
            switch (smbHeader.Command)
            {
                case SmbCommand.SMB_COM_NEGOTIATE:
                    if (smbClient.Capability.IsSupportsExtendedSecurity)
                    {
                        smbPacket = new SmbNegotiateResponsePacket();
                    }
                    else
                    {
                        smbPacket = new SmbNegotiateImplicitNtlmResponsePacket();
                    }
                    break;

                case SmbCommand.SMB_COM_SESSION_SETUP_ANDX:
                    if (smbClient.Capability.IsSupportsExtendedSecurity)
                    {
                        smbPacket = new SmbSessionSetupAndxResponsePacket();
                    }
                    else
                    {
                        smbPacket = new SmbSessionSetupImplicitNtlmAndxResponsePacket();
                    }
                    break;

                case SmbCommand.SMB_COM_TREE_CONNECT_ANDX:
                    smbPacket = new SmbTreeConnectAndxResponsePacket();
                    break;

                case SmbCommand.SMB_COM_TREE_DISCONNECT:
                    smbPacket = new SmbTreeDisconnectResponsePacket();
                    break;

                case SmbCommand.SMB_COM_LOGOFF_ANDX:
                    smbPacket = new SmbLogoffAndxResponsePacket();
                    break;

                case SmbCommand.SMB_COM_NT_CREATE_ANDX:
                    smbPacket = new SmbNtCreateAndxResponsePacket();
                    break;

                case SmbCommand.SMB_COM_CLOSE:
                    smbPacket = new SmbCloseResponsePacket();
                    break;

                case SmbCommand.SMB_COM_OPEN_ANDX:
                    smbPacket = new SmbOpenAndxResponsePacket();
                    break;

                case SmbCommand.SMB_COM_WRITE_ANDX:
                    smbPacket = new SmbWriteAndxResponsePacket();
                    break;

                case SmbCommand.SMB_COM_READ_ANDX:
                    smbPacket = new SmbReadAndxResponsePacket();
                    break;

                case SmbCommand.SMB_COM_TRANSACTION:
                    smbPacket = this.CreateTransactionResponsePacket(request, smbHeader, channel);

                    break;

                case SmbCommand.SMB_COM_TRANSACTION2:
                    smbPacket = this.CreateTransaction2ResponsePacket(request, smbHeader, channel);

                    break;

                case SmbCommand.SMB_COM_NT_TRANSACT:
                    smbPacket = this.CreateNtTransactionResponsePacket(request, smbHeader, channel);

                    break;

                default:
                    break;

            }
            if (smbPacket != null)
            {
                smbPacket.SmbHeader = smbHeader;
                return smbPacket;
            }

            return base.CreateSmbResponsePacket(request, smbHeader, channel);
        }
        protected override SmbPacket CreateSmbResponsePacket(
            SmbPacket request,
            SmbHeader smbHeader,
            Channel channel)
        {
            SmbPacket smbPacket = null;

            // error packet
            SmbStatus packetStatus = (SmbStatus)smbHeader.Status;

            // error packet
            if (packetStatus != SmbStatus.STATUS_SUCCESS &&
                packetStatus != SmbStatus.STATUS_MORE_PROCESSING_REQUIRED &&
                packetStatus != SmbStatus.STATUS_BUFFER_OVERFLOW)
            {
                smbPacket           = new SmbErrorResponsePacket();
                smbPacket.SmbHeader = smbHeader;

                return(smbPacket);
            }

            // success packet
            switch (smbHeader.Command)
            {
            case SmbCommand.SMB_COM_NEGOTIATE:
                if (smbClient.Capability.IsSupportsExtendedSecurity)
                {
                    smbPacket = new SmbNegotiateResponsePacket();
                }
                else
                {
                    smbPacket = new SmbNegotiateImplicitNtlmResponsePacket();
                }
                break;

            case SmbCommand.SMB_COM_SESSION_SETUP_ANDX:
                if (smbClient.Capability.IsSupportsExtendedSecurity)
                {
                    smbPacket = new SmbSessionSetupAndxResponsePacket();
                }
                else
                {
                    smbPacket = new SmbSessionSetupImplicitNtlmAndxResponsePacket();
                }
                break;

            case SmbCommand.SMB_COM_TREE_CONNECT_ANDX:
                smbPacket = new SmbTreeConnectAndxResponsePacket();
                break;

            case SmbCommand.SMB_COM_TREE_DISCONNECT:
                smbPacket = new SmbTreeDisconnectResponsePacket();
                break;

            case SmbCommand.SMB_COM_LOGOFF_ANDX:
                smbPacket = new SmbLogoffAndxResponsePacket();
                break;

            case SmbCommand.SMB_COM_NT_CREATE_ANDX:
                smbPacket = new SmbNtCreateAndxResponsePacket();
                break;

            case SmbCommand.SMB_COM_CLOSE:
                smbPacket = new SmbCloseResponsePacket();
                break;

            case SmbCommand.SMB_COM_OPEN_ANDX:
                smbPacket = new SmbOpenAndxResponsePacket();
                break;

            case SmbCommand.SMB_COM_WRITE_ANDX:
                smbPacket = new SmbWriteAndxResponsePacket();
                break;

            case SmbCommand.SMB_COM_READ_ANDX:
                smbPacket = new SmbReadAndxResponsePacket();
                break;

            case SmbCommand.SMB_COM_TRANSACTION:
                smbPacket = this.CreateTransactionResponsePacket(request, smbHeader, channel);

                break;

            case SmbCommand.SMB_COM_TRANSACTION2:
                smbPacket = this.CreateTransaction2ResponsePacket(request, smbHeader, channel);

                break;

            case SmbCommand.SMB_COM_NT_TRANSACT:
                smbPacket = this.CreateNtTransactionResponsePacket(request, smbHeader, channel);

                break;

            default:
                break;
            }
            if (smbPacket != null)
            {
                smbPacket.SmbHeader = smbHeader;
                return(smbPacket);
            }

            return(base.CreateSmbResponsePacket(request, smbHeader, channel));
        }
Esempio n. 7
0
 /// <summary>
 /// Deep copy constructor.
 /// </summary>
 public SmbErrorResponsePacket(SmbErrorResponsePacket packet)
     : base(packet)
 {
     this.smbParameters.WordCount = packet.SmbParameters.WordCount;
     this.smbData.ByteCount       = packet.SmbData.ByteCount;
 }