Exemple #1
0
        internal static void process_authreq(RdpPacket data)
        {
            byte[] destinationArray = new byte[10];
            byte[] outData          = new byte[10];
            byte[] buffer3          = new byte[20];
            byte[] buffer4          = new byte[30];
            byte[] signature        = new byte[0x10];
            RC4    rc = new RC4();

            byte[] buffer6 = null;

            if (!parse_authreq(data))
            {
                throw new RDFatalException("Authentication request is incorrect!");
            }

            Array.Copy(m_In_Token, 0, destinationArray, 0, 10);
            buffer6 = new byte[m_LicenceKey.Length];
            Array.Copy(m_LicenceKey, 0, buffer6, 0, m_LicenceKey.Length);
            rc.engineInitDecrypt(buffer6);
            rc.crypt(m_In_Token, 0, 10, outData, 0);
            byte[] sourceArray = generate_hwid();
            Array.Copy(outData, 0, buffer4, 0, 10);
            Array.Copy(sourceArray, 0, buffer4, 10, 20);
            signature = Secure.sign(m_Licence_Sign_Key, 0x10, 0x10, buffer4, buffer4.Length);
            Array.Copy(m_LicenceKey, 0, buffer6, 0, m_LicenceKey.Length);
            rc.engineInitEncrypt(buffer6);
            rc.crypt(sourceArray, 0, 20, buffer3, 0);

            send_authresp(destinationArray, buffer3, signature);
        }
Exemple #2
0
        internal static void SendToCannel(RdpPacket secData, int flags, int channel)
        {
            secData.Position = 0L;
            byte[] buffer = new byte[secData.Length];
            secData.Read(buffer, 0, buffer.Length);

            if ((Secure.enc_count == 0x1000) && Secure.RDPEncrypted())
            {
                Secure.m_Encrypt_Key = Secure.update(Secure.m_Encrypt_Key, Secure._r);
                byte[] destinationArray = new byte[Secure.m_KeyLength];
                Array.Copy(Secure.m_Encrypt_Key, 0, destinationArray, 0, Secure.m_KeyLength);
                Secure.m_RC4_Enc.engineInitEncrypt(destinationArray);
                Secure.enc_count = 0;
            }

            if (Secure.RDPEncrypted())
            {
                byte[] buffer1 = Secure.sign(Secure.m_Sec_Sign_Key, 8, Secure.m_KeyLength, buffer, buffer.Length);
                byte[] buffer2 = Secure.m_RC4_Enc.crypt(buffer);
                secData = new RdpPacket();
                secData.WriteLittleEndian32(flags);
                secData.Write(buffer1, 0, buffer1.Length);
                secData.Write(buffer2, 0, buffer2.Length);
            }
            else
            {
                flags  &= -9;
                secData = new RdpPacket();

                if (flags != 0)
                {
                    secData.WriteLittleEndian32(flags);
                }

                secData.Write(buffer, 0, buffer.Length);
            }

            SendMCS(secData, channel);

            Secure.enc_count++;
        }