Пример #1
0
        /// <summary>
        /// Reads the target information data present in version 2 and 3 of
        /// an NTLM type 2 message from the specified BinaryReader.
        /// </summary>
        /// <param name="r">The BinaryReader instance to read from.</param>
        /// <returns>An initialized instance of the Type2TargetInformation
        /// class.</returns>
        static Type2TargetInformation ReadTargetInformation(BinaryReader r)
        {
            Type2TargetInformation info = new Type2TargetInformation();

            while (true)
            {
                var _type = (Type2InformationType)r.ReadInt16();
                if (_type == Type2InformationType.TerminatorBlock)
                {
                    break;
                }
                short  length  = r.ReadInt16();
                string content = Encoding.Unicode.GetString(r.ReadBytes(length));
                switch (_type)
                {
                case Type2InformationType.ServerName:
                    info.ServerName = content;
                    break;

                case Type2InformationType.DomainName:
                    info.DomainName = content;
                    break;

                case Type2InformationType.DnsHostname:
                    info.DnsHostname = content;
                    break;

                case Type2InformationType.DnsDomainName:
                    info.DnsDomainName = content;
                    break;
                }
            }
            return(info);
        }
Пример #2
0
 /// <summary>
 /// Private constructor.
 /// </summary>
 private Type2Message()
 {
     TargetInformation = new Type2TargetInformation();
     OSVersion         = new OSVersion();
 }
Пример #3
0
		/// <summary>
		/// Private constructor.
		/// </summary>
		private Type2Message() {
			TargetInformation = new Type2TargetInformation();
			OSVersion = new OSVersion();
		}
Пример #4
0
		/// <summary>
		/// Reads the target information data present in version 2 and 3 of
		/// an NTLM type 2 message from the specified BinaryReader.
		/// </summary>
		/// <param name="r">The BinaryReader instance to read from.</param>
		/// <returns>An initialized instance of the Type2TargetInformation
		/// class.</returns>
		static Type2TargetInformation ReadTargetInformation(BinaryReader r) {
			Type2TargetInformation info = new Type2TargetInformation();
			while (true) {
				var _type = (Type2InformationType) r.ReadInt16();
				if (_type == Type2InformationType.TerminatorBlock)
					break;
				short length = r.ReadInt16();
				string content = Encoding.Unicode.GetString(r.ReadBytes(length));
				switch (_type) {
					case Type2InformationType.ServerName:
						info.ServerName = content;
						break;
					case Type2InformationType.DomainName:
						info.DomainName = content;
						break;
					case Type2InformationType.DnsHostname:
						info.DnsHostname = content;
						break;
					case Type2InformationType.DnsDomainName:
						info.DnsDomainName = content;
						break;
				}
			}
			return info;
		}