Ejemplo n.º 1
0
        static void EncodeString(byte[] buf, ref int index, NtlmAttribute attr, string value, bool unicode)
        {
            var encoding = unicode ? Encoding.Unicode : Encoding.UTF8;
            int length   = encoding.GetByteCount(value);

            EncodeTypeAndLength(buf, ref index, attr, (short)length);
            encoding.GetBytes(value, 0, value.Length, buf, index);
            index += length;
        }
Ejemplo n.º 2
0
        static void EncodeFlags(byte[] buf, ref int index, NtlmAttribute attr, int value, short size)
        {
            EncodeTypeAndLength(buf, ref index, attr, size);

            switch (size)
            {
            case 2: EncodeInt16(buf, ref index, (short)value); break;

            default: EncodeInt32(buf, ref index, value); break;
            }
        }
Ejemplo n.º 3
0
        NtlmAttributeValuePair GetAvPair(NtlmAttribute attr)
        {
            for (int i = 0; i < attributes.Count; i++)
            {
                if (attributes[i].Attribute == attr)
                {
                    return(attributes[i]);
                }
            }

            return(null);
        }
Ejemplo n.º 4
0
        static void EncodeTimestamp(byte[] buf, ref int index, NtlmAttribute attr, long value, short size)
        {
            EncodeTypeAndLength(buf, ref index, attr, size);

            switch (size)
            {
            case 2: EncodeInt16(buf, ref index, (short)(value & 0xffff)); break;

            case 4: EncodeInt32(buf, ref index, (int)(value & 0xffffffff)); break;

            default:
                EncodeInt32(buf, ref index, (int)(value & 0xffffffff));
                EncodeInt32(buf, ref index, (int)(value >> 32));
                break;
            }
        }
Ejemplo n.º 5
0
        void SetAvPairString(NtlmAttribute attr, string value)
        {
            var pair = (NtlmAttributeStringValuePair)GetAvPair(attr);

            if (pair == null)
            {
                if (value != null)
                {
                    attributes.Add(new NtlmAttributeStringValuePair(attr, value));
                }
            }
            else if (value != null)
            {
                pair.Value = value;
            }
            else
            {
                attributes.Remove(pair);
            }
        }
Ejemplo n.º 6
0
        void SetAvPairByteArray(NtlmAttribute attr, byte[] value)
        {
            var pair = (NtlmAttributeByteArrayValuePair)GetAvPair(attr);

            if (pair == null)
            {
                if (value != null)
                {
                    attributes.Add(new NtlmAttributeByteArrayValuePair(attr, value));
                }
            }
            else if (value != null)
            {
                pair.Value = value;
            }
            else
            {
                attributes.Remove(pair);
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NtlmAttributeFlagsValuePair"/> class.
 /// </summary>
 /// <remarks>
 /// Creates a new NTLM attribute and value pair consisting of a flags value.
 /// </remarks>
 /// <param name="attr">The NTLM attribute.</param>
 /// <param name="value">The NTLM attribute value.</param>
 /// <param name="size">The size of the encoded flags value.</param>
 internal NtlmAttributeFlagsValuePair(NtlmAttribute attr, int value, short size) : base(attr)
 {
     Value = value;
     Size  = size;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NtlmAttributeTimestampValuePair"/> class.
 /// </summary>
 /// <remarks>
 /// Creates a new NTLM attribute and value pair consisting of a timestamp value.
 /// </remarks>
 /// <param name="attr">The NTLM attribute.</param>
 /// <param name="value">The NTLM attribute value.</param>
 /// <param name="size">The size of the encoded flags value.</param>
 internal NtlmAttributeTimestampValuePair(NtlmAttribute attr, long value, short size) : base(attr)
 {
     Value = value;
     Size  = size;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NtlmAttributeTimestampValuePair"/> class.
 /// </summary>
 /// <remarks>
 /// Creates a new NTLM attribute and value pair consisting of a timestamp value.
 /// </remarks>
 /// <param name="attr">The NTLM attribute.</param>
 /// <param name="value">The NTLM attribute value.</param>
 public NtlmAttributeTimestampValuePair(NtlmAttribute attr, long value) : this(attr, value, 8)
 {
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NtlmAttributeByteArrayValuePair"/> class.
 /// </summary>
 /// <remarks>
 /// Creates a new NTLM attribute and value pair consisting of a byte array value.
 /// </remarks>
 /// <param name="attr">The NTLM attribute.</param>
 /// <param name="value">The NTLM attribute value.</param>
 public NtlmAttributeByteArrayValuePair(NtlmAttribute attr, byte[] value) : base(attr)
 {
     Value = value;
 }
Ejemplo n.º 11
0
 static void EncodeByteArray(byte[] buf, ref int index, NtlmAttribute attr, byte[] value)
 {
     EncodeTypeAndLength(buf, ref index, attr, (short)value.Length);
     Buffer.BlockCopy(value, 0, buf, index, value.Length);
     index += value.Length;
 }
Ejemplo n.º 12
0
 static void EncodeTypeAndLength(byte[] buf, ref int index, NtlmAttribute attr, short length)
 {
     EncodeInt16(buf, ref index, (short)attr);
     EncodeInt16(buf, ref index, length);
 }
Ejemplo n.º 13
0
 byte[] GetAvPairByteArray(NtlmAttribute attr)
 {
     return(((NtlmAttributeByteArrayValuePair)GetAvPair(attr))?.Value);
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NtlmAttributeFlagsValuePair"/> class.
 /// </summary>
 /// <remarks>
 /// Creates a new NTLM attribute and value pair consisting of a flags value.
 /// </remarks>
 /// <param name="attr">The NTLM attribute.</param>
 /// <param name="value">The NTLM attribute value.</param>
 public NtlmAttributeFlagsValuePair(NtlmAttribute attr, int value) : this(attr, value, 4)
 {
 }
Ejemplo n.º 15
0
 string GetAvPairString(NtlmAttribute attr)
 {
     return(((NtlmAttributeStringValuePair)GetAvPair(attr))?.Value);
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NtlmAttributeStringValuePair"/> class.
 /// </summary>
 /// <remarks>
 /// Creates a new NTLM attribute and value pair consisting of a string value.
 /// </remarks>
 /// <param name="attr">The NTLM attribute.</param>
 /// <param name="value">The NTLM attribute value.</param>
 public NtlmAttributeStringValuePair(NtlmAttribute attr, string value) : base(attr)
 {
     Value = value;
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NtlmAttributeValuePair"/> class.
 /// </summary>
 /// <remarks>
 /// Creates a new NTLM attribute and value pair.
 /// </remarks>
 /// <param name="attr">The NTLM attribute.</param>
 protected NtlmAttributeValuePair(NtlmAttribute attr)
 {
     Attribute = attr;
 }