/// <summary>
 /// Deep copy constructor. 
 /// </summary>
 public SmbSessionSetupImplicitNtlmAndxRequestPacket(SmbSessionSetupImplicitNtlmAndxRequestPacket packet)
     : base(packet)
 {
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Non Extended Security for session setup request.
        /// </summary>
        /// <param name="account">Indicate the account type to establish the session.</param>
        /// <param name="messageId">This is used to associate a response with a request.</param>
        /// <param name="sessionId">
        /// Set this value to 0 to request a new session setup, or set this value to a previously established session 
        /// identifier to request reauthenticate to an existing session.
        /// </param>
        /// <param name="securitySignature">
        /// Delegate the security signature used in session setup request header.
        /// </param>
        /// <param name="isSigned">
        /// Indicate whether the SUT has message signing enabled or required.
        /// </param>
        /// <param name="capabilities">A set of client capabilities. </param>
        /// <param name="isSendBufferSizeExceedMaxBufferSize">
        /// Indicate whether the bufferSize sent by the SUT exceeds the max buffer size or not.
        /// </param>
        /// <param name="isWriteBufferSizeExceedMaxBufferSize">
        /// Indicate whether the bufferSize written by the SUT exceeds the max buffer size or not.
        /// </param>
        /// <param name="flag2">Whether the Flag2 field of the SMB header is valid or not.</param>
        public void NonExtendedSessionSetupRequest(
            AccountType account,
            int messageId,
            int sessionId,
            int securitySignature,
            bool isSigned,
            [Domain("clientCapabilitiesForNonextendedSecurity")] Microsoft.Modeling.Set<Capabilities> capabilities,
            bool isSendBufferSizeExceedMaxBufferSize,
            bool isWriteBufferSizeExceedMaxBufferSize,
            bool flag2)
        {
            #region Create Package

            SmbSessionSetupImplicitNtlmAndxRequestPacket smbPacket = new SmbSessionSetupImplicitNtlmAndxRequestPacket();

            string domain = Site.Properties["SutLoginDomain"];
            string userName;
            string password;

            if (account == AccountType.Admin)
            {
                userName = Site.Properties["SutLoginAdminUserName"];
                password = Site.Properties["SutLoginAdminPwd"];
            }
            else
            {
                userName = Site.Properties["SutLoginGuestUserName"];
                password = Site.Properties["SutLoginGuestPwd"];
            }

            ImplicitNtlmVersion version = (ImplicitNtlmVersion)Enum.Parse(
                typeof(ImplicitNtlmVersion),
                Site.Properties["SmbSecurityPackageNlmpVersion"],
                true);

            ImplicitNtlmVersion implicitNtlmVersion = ImplicitNtlmVersion.PlainTextPassword;

            switch (version)
            {
                case ImplicitNtlmVersion.PlainTextPassword:
                    implicitNtlmVersion = ImplicitNtlmVersion.PlainTextPassword;
                    break;
                case ImplicitNtlmVersion.NtlmVersion1:
                    implicitNtlmVersion = ImplicitNtlmVersion.NtlmVersion1;
                    break;
                case ImplicitNtlmVersion.NtlmVersion2:
                    implicitNtlmVersion = ImplicitNtlmVersion.NtlmVersion2;
                    break;
                default:
                    break;
            }

            smbPacket = this.smbClientStack.CreateSessionSetupImplicitNtlmRequest(
                implicitNtlmVersion,
                domain,
                userName,
                password);

            #endregion

            #region Send and Receive ExpectPacket

            this.smbClientStack.SendPacket(smbPacket);
            StackPacket response = this.smbClientStack.ExpectPacket(this.timeout);

            NamespaceCifs.SmbPacket smbPacketResponse = (NamespaceCifs.SmbPacket)response;

            ushort uid = this.QueryUidTable(smbPacketResponse);
            this.QueryTidTable(smbPacketResponse);

            VerifyTransport(smbPacketResponse);
            VerifyCommonMessageSyntax(smbPacketResponse);

            if (response.GetType() == typeof(SmbErrorResponsePacket))
            {
                SmbErrorResponsePacket smbErrorResponsePacket = response as SmbErrorResponsePacket;
                NamespaceCifs.SmbHeader smbErrorHeader = smbErrorResponsePacket.SmbHeader;
                this.ErrorResponse(smbErrorHeader.Mid + this.addMidMark, (MessageStatus)smbErrorHeader.Status);
            }
            else
            {
                SmbSessionSetupImplicitNtlmAndxResponsePacket smbSessionSetupImplicitNtlmPacket = response
                    as SmbSessionSetupImplicitNtlmAndxResponsePacket;

                NamespaceCifs.SmbHeader sessionSetupImplicitNtlmResponseHeader =
                    smbSessionSetupImplicitNtlmPacket.SmbHeader;

                bool isGuestAccount = false;

                if (account == AccountType.Guest)
                {
                    isGuestAccount = true;
                }

                int returnSig = (int)uint.MinValue;

                if (sessionSetupImplicitNtlmResponseHeader.SecurityFeatures != ulong.MinValue)
                {
                    returnSig++;
                }

                this.NonExtendedSessionSetupResponse(
                    sessionSetupImplicitNtlmResponseHeader.Mid + this.addMidMark,
                    uid,
                    returnSig,
                    isSigned,
                    isGuestAccount,
                    Boolean.Parse(this.Site.Properties["SHOULDMAYR2322Implementation"]),
                    (MessageStatus)sessionSetupImplicitNtlmResponseHeader.Status);
            }

            #endregion
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Deep copy constructor.
 /// </summary>
 public SmbSessionSetupImplicitNtlmAndxRequestPacket(SmbSessionSetupImplicitNtlmAndxRequestPacket packet)
     : base(packet)
 {
 }