예제 #1
0
        public static byte[] GetAVPairSequence(string domainName, string computerName)
        {
            KeyValuePairList <AVPairKey, byte[]> pairs = new KeyValuePairList <AVPairKey, byte[]>();

            pairs.Add(AVPairKey.NbDomainName, UnicodeEncoding.Unicode.GetBytes(domainName));
            pairs.Add(AVPairKey.NbComputerName, UnicodeEncoding.Unicode.GetBytes(computerName));
            return(AVPairUtils.GetAVPairSequenceBytes(pairs));
        }
예제 #2
0
        public byte[] GetBytes()
        {
            byte[] sequenceBytes = AVPairUtils.GetAVPairSequenceBytes(AVPairs);

            byte[] buffer = new byte[28 + sequenceBytes.Length];
            ByteWriter.WriteByte(buffer, 0, CurrentVersion);
            ByteWriter.WriteByte(buffer, 1, MaximumSupportedVersion);
            LittleEndianWriter.WriteUInt16(buffer, 2, Reserved1);
            LittleEndianWriter.WriteUInt32(buffer, 4, Reserved2);
            FileTimeHelper.WriteFileTime(buffer, 8, TimeStamp);
            ByteWriter.WriteBytes(buffer, 16, ClientChallenge, 8);
            LittleEndianWriter.WriteUInt32(buffer, 24, Reserved3);
            ByteWriter.WriteBytes(buffer, 28, sequenceBytes);
            return(buffer);
        }
예제 #3
0
        public byte[] GetBytes()
        {
            if ((NegotiateFlags & NegotiateFlags.TargetNameSupplied) == 0)
            {
                TargetName = string.Empty;
            }

            byte[] targetInfoBytes = AVPairUtils.GetAVPairSequenceBytes(TargetInfo);
            if ((NegotiateFlags & NegotiateFlags.TargetInfo) == 0)
            {
                targetInfoBytes = new byte[0];
            }

            int fixedLength = 48;

            if ((NegotiateFlags & NegotiateFlags.Version) > 0)
            {
                fixedLength += 8;
            }
            int payloadLength = TargetName.Length * 2 + targetInfoBytes.Length;

            byte[] buffer = new byte[fixedLength + payloadLength];
            ByteWriter.WriteAnsiString(buffer, 0, AuthenticateMessage.ValidSignature, 8);
            LittleEndianWriter.WriteUInt32(buffer, 8, (uint)MessageType);
            LittleEndianWriter.WriteUInt32(buffer, 20, (uint)NegotiateFlags);
            ByteWriter.WriteBytes(buffer, 24, ServerChallenge);
            if ((NegotiateFlags & NegotiateFlags.Version) > 0)
            {
                Version.WriteBytes(buffer, 48);
            }

            int offset = fixedLength;

            AuthenticationMessageUtils.WriteBufferPointer(buffer, 12, (ushort)(TargetName.Length * 2), (uint)offset);
            ByteWriter.WriteUTF16String(buffer, ref offset, TargetName);
            AuthenticationMessageUtils.WriteBufferPointer(buffer, 40, (ushort)targetInfoBytes.Length, (uint)offset);
            ByteWriter.WriteBytes(buffer, ref offset, targetInfoBytes);

            return(buffer);
        }