Example #1
0
        private static void Send(RdpPacket packet)
        {
            packet.Position = 0L;
            byte[] buffer = new byte[packet.Length];
            packet.Read(buffer, 0, (int)packet.Length);
            NTLM.DumpHex(buffer, (int)packet.Length, "Send");

            Network.Send(buffer);
        }
Example #2
0
        public static RdpPacket WriteNegoToken()
        {
            m_NTLMAuthenticate = new NTLM(Network.OpenSocket, Options.Username, Options.Password, Options.Domain);
            byte[]    buffer = m_NTLMAuthenticate.Negotiate();
            RdpPacket packet = new RdpPacket();

            packet.Write(buffer, 0, buffer.Length);
            packet.Position = 0L;

            return(packet);
        }
Example #3
0
        private static void ProcesssResponse(RdpPacket packet, byte[] ServerPublicKey)
        {
            ASN1.ReadTag(packet, ASN1.SequenceTag(0), "TSRequest");
            ASN1.ReadTag(packet, ASN1.ContextTag(0), "CTX_Version");

            if (ASN1.ReadInteger(packet) < 2)
            {
                throw new Exception("TSRequest version not supported!");
            }

            ASN1.CloseTag(packet, "CTX_Version");
            byte[] buffer = null;
            int    num2   = ASN1.ReadTag(packet, "Tag");

            if (num2 == ASN1.ContextTag(1))
            {
                ASN1.ReadTag(packet, ASN1.SequenceTag(0), "NegTokens");
                ASN1.ReadTag(packet, ASN1.SequenceTag(0), "NegTokens2");
                ASN1.ReadTag(packet, ASN1.ContextTag(0), "CTX_OctetString");
                m_ChallengeMsg = new byte[ASN1.ReadTag(packet, ASN1.OctetStringTag(), "OctetString")];
                packet.Read(m_ChallengeMsg, 0, m_ChallengeMsg.Length);
                ASN1.CloseTag(packet, "OctetString");
                ASN1.CloseTag(packet, "CTX_OctetString");
                ASN1.CloseTag(packet, "NegTokens2");
                ASN1.CloseTag(packet, "NegTokens");
            }
            else if (num2 == ASN1.ContextTag(3))
            {
                buffer = new byte[ASN1.ReadTag(packet, ASN1.OctetStringTag(), "OctetString")];
                packet.Read(buffer, 0, buffer.Length);
                ASN1.CloseTag(packet, "OctetString");
            }

            ASN1.CloseTag(packet, "Tag");
            ASN1.CloseTag(packet, "TSRequest");

            if (buffer != null)
            {
                byte[] buffer2 = m_NTLMAuthenticate.DecryptMessage(buffer);
                buffer2[0] = (byte)(buffer2[0] - 1);
                if (!NTLM.CompareArray(buffer2, ServerPublicKey))
                {
                    throw new Exception("Unable to verify the server's public key!");
                }
                buffer2[0] = (byte)(buffer2[0] + 1);
                SendTSRequest(null, WriteTSCredentials(), null);
                m_bAuthenticated = true;
            }
            else
            {
                ReadNegoToken(m_ChallengeMsg, ServerPublicKey);
            }
        }
Example #4
0
        private static RdpPacket Receive()
        {
            byte[] buffer = new byte[0x2000];
            int    length = Network.Receive(buffer);

            NTLM.DumpHex(buffer, length, "Receive");
            RdpPacket packet = new RdpPacket();

            packet.Write(buffer, 0, length);
            packet.Position = 0L;

            return(packet);
        }