Represents an NTLMSSP Type-1 message.
Represents an NTLMSSP Type-1 message.
Наследование: NtlmMessage
Пример #1
0
 /// <summary>Creates a Type-2 message in response to the given Type-1 message.</summary>
 /// <remarks>Creates a Type-2 message in response to the given Type-1 message.</remarks>
 /// <param name="type1">The Type-1 message which this represents a response to.</param>
 /// <param name="challenge">The challenge from the domain controller/server.</param>
 /// <param name="target">The authentication target.</param>
 public Type2Message(Type1Message type1,
                     byte[] challenge,
                     string target)
     : this(GetDefaultFlags(type1),
            challenge,
            (type1 != null && target == null && type1.GetFlag(NtlmsspRequestTarget))
                 ? GetDefaultDomain()
                 : target)
 {
 }
Пример #2
0
        /// <summary>
        /// Returns the default flags for a Type-2 message created in response
        /// to the given Type-1 message in the current environment.
        /// </summary>
        /// <remarks>
        /// Returns the default flags for a Type-2 message created in response
        /// to the given Type-1 message in the current environment.
        /// </remarks>
        /// <returns>An <code>int</code> containing the default flags.</returns>
        public static int GetDefaultFlags(Type1Message type1)
        {
            if (type1 == null)
            {
                return(DefaultFlags);
            }
            int flags      = NtlmsspNegotiateNtlm;
            int type1Flags = type1.GetFlags();

            flags |= ((type1Flags & NtlmsspNegotiateUnicode) != 0) ? NtlmsspNegotiateUnicode
                                 : NtlmsspNegotiateOem;
            if ((type1Flags & NtlmsspRequestTarget) != 0)
            {
                string domain = GetDefaultDomain();
                if (domain != null)
                {
                    flags |= NtlmsspRequestTarget | NtlmsspTargetTypeDomain;
                }
            }
            return(flags);
        }
Пример #3
0
        /// <exception cref="SharpCifs.Smb.SmbException"></exception>
        public virtual byte[] InitSecContext(byte[] token, int offset, int len)
        {
            switch (State)
            {
                case 1:
                {
                    Type1Message msg1 = new Type1Message(NtlmsspFlags, Auth.GetDomain(), Workstation);
                    token = msg1.ToByteArray();
                    if (Log.Level >= 4)
                    {
                        Log.WriteLine(msg1);
                        if (Log.Level >= 6)
                        {
                            Hexdump.ToHexdump(Log, token, 0, token.Length);
                        }
                    }
                    State++;
                    break;
                }

                case 2:
                {
                    try
                    {
                        Type2Message msg2 = new Type2Message(token);
                        if (Log.Level >= 4)
                        {
                            Log.WriteLine(msg2);
                            if (Log.Level >= 6)
                            {
                                Hexdump.ToHexdump(Log, token, 0, token.Length);
                            }
                        }
                        ServerChallenge = msg2.GetChallenge();
                        NtlmsspFlags &= msg2.GetFlags();
                        //                  netbiosName = getNtlmsspListItem(token, 0x0001);
                        Type3Message msg3 = new Type3Message(msg2, Auth.GetPassword(), Auth.GetDomain(),
                            Auth.GetUsername(), Workstation, NtlmsspFlags);
                        token = msg3.ToByteArray();
                        if (Log.Level >= 4)
                        {
                            Log.WriteLine(msg3);
                            if (Log.Level >= 6)
                            {
                                Hexdump.ToHexdump(Log, token, 0, token.Length);
                            }
                        }
                        if ((NtlmsspFlags & NtlmFlags.NtlmsspNegotiateSign) != 0)
                        {
                            SigningKey = msg3.GetMasterKey();
                        }
                        isEstablished = true;
                        State++;
                        break;
                    }
                    catch (Exception e)
                    {
                        throw new SmbException(e.Message, e);
                    }
                }

                default:
                {
                    throw new SmbException("Invalid state");
                }
            }
            return token;
        }
Пример #4
0
 /// <summary>
 /// Creates a Type-2 message in response to the given Type-1 message
 /// using default values from the current environment.
 /// </summary>
 /// <remarks>
 /// Creates a Type-2 message in response to the given Type-1 message
 /// using default values from the current environment.
 /// </remarks>
 /// <param name="type1">The Type-1 message which this represents a response to.</param>
 public Type2Message(Type1Message type1) : this(type1, null, null)
 {
 }
Пример #5
0
		/// <summary>
		/// Returns the default flags for a Type-2 message created in response
		/// to the given Type-1 message in the current environment.
		/// </summary>
		/// <remarks>
		/// Returns the default flags for a Type-2 message created in response
		/// to the given Type-1 message in the current environment.
		/// </remarks>
		/// <returns>An <code>int</code> containing the default flags.</returns>
		public static int GetDefaultFlags(Type1Message type1)
		{
			if (type1 == null)
			{
				return DefaultFlags;
			}
			int flags = NtlmsspNegotiateNtlm;
			int type1Flags = type1.GetFlags();
			flags |= ((type1Flags & NtlmsspNegotiateUnicode) != 0) ? NtlmsspNegotiateUnicode
				 : NtlmsspNegotiateOem;
			if ((type1Flags & NtlmsspRequestTarget) != 0)
			{
				string domain = GetDefaultDomain();
				if (domain != null)
				{
					flags |= NtlmsspRequestTarget | NtlmsspTargetTypeDomain;
				}
			}
			return flags;
		}
Пример #6
0
		/// <summary>Creates a Type-2 message in response to the given Type-1 message.</summary>
		/// <remarks>Creates a Type-2 message in response to the given Type-1 message.</remarks>
		/// <param name="type1">The Type-1 message which this represents a response to.</param>
		/// <param name="challenge">The challenge from the domain controller/server.</param>
		/// <param name="target">The authentication target.</param>
		public Type2Message(Type1Message type1, byte[] challenge, string target) : this(GetDefaultFlags
			(type1), challenge, (type1 != null && target == null && type1.GetFlag(NtlmsspRequestTarget
			)) ? GetDefaultDomain() : target)
		{
		}
Пример #7
0
		/// <summary>
		/// Creates a Type-2 message in response to the given Type-1 message
		/// using default values from the current environment.
		/// </summary>
		/// <remarks>
		/// Creates a Type-2 message in response to the given Type-1 message
		/// using default values from the current environment.
		/// </remarks>
		/// <param name="type1">The Type-1 message which this represents a response to.</param>
		public Type2Message(Type1Message type1) : this(type1, null, null)
		{
		}