Exemple #1
0
        /// <summary>
        /// Client MCS Connect Initial PDU
        /// Part 1
        ///
        /// BER Encode packet and send
        /// </summary>
        internal static RdpPacket sendConnectInitial(RdpPacket data)
        {
            int length = (int)data.Length;
            int num2   = ((((9 + BER.domainParamSize(0x22, 2, 0, 0xffff))
                            + BER.domainParamSize(1, 1, 1, 0x420))
                           + BER.domainParamSize(0xffff, 0xfc17, 0xffff, 0xffff)) + 4) + length;

            RdpPacket packet = new RdpPacket();

            BER.sendBerHeader(packet, BER.BER_Header.CONNECT_INITIAL, num2);
            BER.sendBerHeader(packet, BER.BER_Header.BER_TAG_OCTET_STRING, 1);
            packet.WriteByte(1);
            BER.sendBerHeader(packet, BER.BER_Header.BER_TAG_OCTET_STRING, 1);
            packet.WriteByte(1);
            BER.sendBerHeader(packet, BER.BER_Header.BER_TAG_BOOLEAN, 1);
            packet.WriteByte(0xff);

            sendDomainParams(packet, 0x22, 2, 0, 0xffff);
            sendDomainParams(packet, 1, 1, 1, 0x420);
            sendDomainParams(packet, 0xffff, 0xffff, 0xffff, 0xffff);

            BER.sendBerHeader(packet, BER.BER_Header.BER_TAG_OCTET_STRING, length);
            packet.copyToByteArray(data);

            return(packet);
        }
        private void send(RdpPacket data)
        {
            data.Position = 0L;
            int length = (int)data.Length;
            int count  = Math.Min(length, 1600);
            int num    = length - count;

            if (num == 0)
            {
                RdpPacket packet = new RdpPacket();
                packet.WriteLittleEndian32((int)length);
                packet.WriteLittleEndian32((int)(CHANNEL_FLAG.CHANNEL_FLAG_FIRST | CHANNEL_FLAG.CHANNEL_FLAG_LAST | CHANNEL_FLAG.CHANNEL_FLAG_SHOW_PROTOCOL));
                packet.copyToByteArray(data);

                IsoLayer.SendToCannel(packet, Secure.RDPEncrypted() ? (int)(MCS.TS_SECURITY_HEADER.SEC_ENCRYPT) : 0, this.ChannelID);
            }
            else
            {
                RdpPacket packet2 = new RdpPacket();
                packet2.WriteLittleEndian32((int)length);
                packet2.WriteLittleEndian32((int)(CHANNEL_FLAG.CHANNEL_FLAG_FIRST | CHANNEL_FLAG.CHANNEL_FLAG_SHOW_PROTOCOL));
                byte[] buffer = new byte[count];
                data.Read(buffer, 0, count);
                packet2.Write(buffer, 0, count);

                IsoLayer.SendToCannel(packet2, Secure.RDPEncrypted() ? (int)(MCS.TS_SECURITY_HEADER.SEC_ENCRYPT) : 0, this.ChannelID);
            }

            while (num > 0)
            {
                count = Math.Min(num, 1600);
                num  -= count;
                RdpPacket packet3 = new RdpPacket();
                packet3.WriteLittleEndian32((int)length);

                if (num == 0)
                {
                    packet3.WriteLittleEndian32((int)(CHANNEL_FLAG.CHANNEL_FLAG_LAST | CHANNEL_FLAG.CHANNEL_FLAG_SHOW_PROTOCOL));
                }
                else
                {
                    packet3.WriteLittleEndian32((int)(CHANNEL_FLAG.CHANNEL_FLAG_SHOW_PROTOCOL));
                }

                byte[] buffer2 = new byte[count];
                data.Read(buffer2, 0, count);
                packet3.Write(buffer2, 0, count);

                IsoLayer.SendToCannel(packet3, Secure.RDPEncrypted() ? (int)(MCS.TS_SECURITY_HEADER.SEC_ENCRYPT) : 0, this.ChannelID);
            }
        }
Exemple #3
0
        internal static void SendMCS(RdpPacket packet, int channel)
        {
            int       length = (int)(packet.Length | 0x8000);
            RdpPacket data   = new RdpPacket();

            data.WriteByte((byte)(MCS.SDRQ << 2));
            data.WriteBigEndian16((short)MCS.McsUserID);
            data.WriteBigEndian16((short)channel);
            data.WriteByte(0x70);
            data.WriteBigEndian16((short)length);
            data.copyToByteArray(packet);

            SendTPKT(data);
        }
Exemple #4
0
        public static void SendTPKT(RdpPacket data)
        {
            short num = (short)(data.Length + 7L);

            data.Position = 0L;
            RdpPacket packet = new RdpPacket();

            packet.WriteByte(3);
            packet.WriteByte(0);
            packet.WriteBigEndian16(num);
            packet.WriteByte(2);
            packet.WriteByte((byte)Main.SecureValue8);
            packet.WriteByte(0x80);
            packet.copyToByteArray(data);
            Write(packet);
        }
Exemple #5
0
        private static void SendTSRequest(RdpPacket negoTokens, byte[] auth_info, byte[] pub_key_auth)
        {
            RdpPacket packet = new RdpPacket();

            ASN1.WriteTag(packet, ASN1.SequenceTag(0), "TSRequest");
            ASN1.WriteTag(packet, ASN1.ContextTag(0), "CTX_Version");
            ASN1.WriteInteger(packet, 2);
            ASN1.CloseTag(packet, "CTX_Version");

            if (negoTokens != null)
            {
                ASN1.WriteTag(packet, ASN1.ContextTag(1), "CTX_NegTokens");
                ASN1.WriteTag(packet, ASN1.SequenceTag(0), "NegTokens");
                ASN1.WriteTag(packet, ASN1.SequenceTag(0), "NegTokens2");
                ASN1.WriteTag(packet, ASN1.ContextTag(0), "CTX_OctetString");
                ASN1.WriteTag(packet, ASN1.OctetStringTag(), "OctetString");
                packet.copyToByteArray(negoTokens);
                ASN1.CloseTag(packet, "OctetString");
                ASN1.CloseTag(packet, "CTX_OctetString");
                ASN1.CloseTag(packet, "NegTokens2");
                ASN1.CloseTag(packet, "NegTokens");
                ASN1.CloseTag(packet, "CTX_NegTokens");
            }

            if (auth_info != null)
            {
                ASN1.WriteTag(packet, ASN1.ContextTag(2), "CTX_AuthInfo");
                ASN1.WriteTag(packet, ASN1.OctetStringTag(), "OctetString");
                packet.Write(auth_info, 0, auth_info.Length);
                ASN1.CloseTag(packet, "OctetString");
                ASN1.CloseTag(packet, "CTX_AuthInfo");
            }

            if (pub_key_auth != null)
            {
                ASN1.WriteTag(packet, ASN1.ContextTag(3), "CTX_PubKeyAuth");
                ASN1.WriteTag(packet, ASN1.OctetStringTag(), "OctetString");
                packet.Write(pub_key_auth, 0, pub_key_auth.Length);
                ASN1.CloseTag(packet, "OctetString");
                ASN1.CloseTag(packet, "CTX_PubKeyAuth");
            }

            ASN1.CloseTag(packet, "TSRequest");

            Send(packet);
        }
Exemple #6
0
        internal static void SendPDU(RdpPacket packet, PDUType2 type, int sec_flags)
        {
            RdpPacket packet2 = new RdpPacket();

            packet.Position = 0L;
            int num = ((int)packet.Length) + 0x12;

            packet2.WriteLittleEndian16((short)num);
            packet2.WriteLittleEndian16((short)Main.SecureValue7);
            packet2.WriteLittleEndian16((short)(MCS.McsUserID + 0x3e9));
            packet2.WriteLittleEndian32(ControlFlow.rdp_shareid);
            packet2.WriteByte(0);
            packet2.WriteByte(1);
            packet2.WriteLittleEndian16((short)(num - 14));
            packet2.WriteByte((byte)type);
            packet2.WriteByte(0);
            packet2.WriteLittleEndian16((short)0);
            packet2.copyToByteArray(packet);

            SendToGlobalChannel(packet2, sec_flags);
        }