Ejemplo n.º 1
0
        /// <summary>
        /// Establish a MultiTransport Connection
        /// </summary>
        private void EstablishTransportConnection()
        {
            // Send the Server Initial multitransport
            byte[] securityCookie = new byte[16];
            Random rnd            = new Random();

            rnd.NextBytes(securityCookie);

            Server_Initiate_Multitransport_Request_PDU requestPDU = rdpbcgrServer.CreateServerInitiateMultitransportRequestPDU(serverSessionContext, ++multitransportId, transportProtocol, securityCookie);

            rdpbcgrServer.SendPdu(serverSessionContext, requestPDU);

            //Create RDP-UDP Connection
            CreateRdpeudpServer(this.serverSessionContext);
            TransportMode transMode = TransportMode.Reliable;

            if (transportProtocol == Multitransport_Protocol_value.INITITATE_REQUEST_PROTOCOL_UDPFECL)
            {
                transMode = TransportMode.Lossy;
            }

            rdpeudpSocket = rdpeudpServer.Accept(((IPEndPoint)serverSessionContext.Identity).Address, transMode, timeout);
            if (rdpeudpSocket == null)
            {
                if (rdpeudpServer != null && rdpeudpServer.Running)
                {
                    rdpeudpServer.Dispose();
                }

                throw new NotSupportedException("RDPEMT Server create rdpedupSocket failed.");
            }
            rdpemtServer           = new RdpemtServer(rdpeudpSocket, rdpbcgrServer.AuthCertificate, true);
            rdpemtServer.Received += ReceivedBytes;

            uint receivedRequestId;

            byte[] receivedCookie;
            if (!rdpemtServer.ExpectConnect(timeout, out receivedRequestId, out receivedCookie))
            {
                throw new ProtocolViolationException("RDPEMT Server Expect Connection failed");
            }
            if (receivedRequestId != multitransportId || receivedCookie == null || receivedCookie.Length != 16)
            {
                throw new ProtocolViolationException("RDPEMT Server received a connection with un-expected request id or Cookie is null (or cookie's length is not 16)!");
            }

            for (int i = 0; i < receivedCookie.Length; i++)
            {
                if (receivedCookie[i] != securityCookie[i])
                {
                    throw new ProtocolViolationException("RDPEMT Server received a connection with un-correct cookie!");
                }
            }
        }
Ejemplo n.º 2
0
        private List <Server_Initiate_Multitransport_Request_PDU> ExpectServerInitiateMultitransportRequestPDUs()
        {
            bool receivedServerInitiateMultitransportRequestForReliable = false;
            bool receivedServerInitiateMultitransportRequestForLossy    = false;
            int  expectedServerInitiateMultitransportRequestNum         = 1;

            if (serverSupportUDPFECR && serverSupportUDPFECL)
            {
                expectedServerInitiateMultitransportRequestNum = 2;
            }

            var serverInitiateMultitransportRequestPDUs = new List <Server_Initiate_Multitransport_Request_PDU>();

            for (int i = 0; i < expectedServerInitiateMultitransportRequestNum; i++)
            {
                Server_Initiate_Multitransport_Request_PDU request = rdpbcgrAdapter.ExpectPacket <Server_Initiate_Multitransport_Request_PDU>(testConfig.timeout);
                Site.Assert.IsNotNull(request, "RDP Server MUST send Server_Initiate_Multitransport_Request_PDU packet to initiate multiple transport.");
                if (request.requestedProtocol == Multitransport_Protocol_value.INITITATE_REQUEST_PROTOCOL_UDPFECR)
                {
                    receivedServerInitiateMultitransportRequestForReliable = true;
                }
                else if (request.requestedProtocol == Multitransport_Protocol_value.INITITATE_REQUEST_PROTOCOL_UDPFECL)
                {
                    receivedServerInitiateMultitransportRequestForLossy = true;
                }
                else
                {
                    Site.Assert.Fail("The value of requestedProtocol 0x{0:04X} is unexpected!", (ushort)request.requestedProtocol);
                }
                serverInitiateMultitransportRequestPDUs.Add(request);
            }

            if (serverSupportUDPFECR)
            {
                Site.Assert.IsTrue(receivedServerInitiateMultitransportRequestForReliable,
                                   "RDP Server MUST send Server_Initiate_Multitransport_Request_PDU packets for reliable multitransport.");
            }
            if (serverSupportUDPFECL)
            {
                Site.Assert.IsTrue(receivedServerInitiateMultitransportRequestForLossy,
                                   "RDP Server MUST send Server_Initiate_Multitransport_Request_PDU packets for lossy multitransport.");
            }

            return(serverInitiateMultitransportRequestPDUs);
        }
Ejemplo n.º 3
0
        public void S7_MultitransportBootstrapping_PositiveTest()
        {
            #region Test Steps
            //1. Initiate an RDP connection to RDP server (SUT) and complete the Connection Initiation phase, Basic Setting Exchange phase, Channel Connection phase, RDP Security Commencement phase, Secure Setting Exchange Phase and Licensing phase. Indicate support for both reliable and lossy multitransport in basic setting exchange phase.
            //2. Test Suite expects a Server Initiate Multitransport Request PDU with requestedProtocol set to INITITATE_REQUEST_PROTOCOL_UDPFECR (0x01). When received, Test Suite verifies this PDU.
            //3. Test Suite expects a Server Initiate Multitransport Request PDU with requestedProtocol set to INITITATE_REQUEST_PROTOCOL_UDPFECL (0x02). When received, Test Suite verifies this PDU.
            #endregion Test Steps

            #region Test Code

            this.Site.Log.Add(LogEntryKind.Comment, "Establish transport connection with RDP Server, encrypted protocol is {0}.", testConfig.transportProtocol.ToString());
            rdpbcgrAdapter.ConnectToServer(testConfig.transportProtocol);

            #region Connection Initiation

            this.Site.Log.Add(LogEntryKind.Comment, "Send a Client X.224 Connection Request PDU to SUT, supported security protocol is {0}.", testConfig.requestProtocol.ToString());
            rdpbcgrAdapter.SendClientX224ConnectionRequest(NegativeType.None, testConfig.requestProtocol);

            this.Site.Log.Add(LogEntryKind.Comment, "Expecting SUT to send a Server X224 Connection Confirm.");
            Server_X_224_Connection_Confirm_Pdu confirmPdu = rdpbcgrAdapter.ExpectPacket <Server_X_224_Connection_Confirm_Pdu>(testConfig.timeout);
            this.Site.Assert.IsNotNull(confirmPdu, "RDP Server MUST response a Server X224 Connection Confirm PDU after receiving a Client X224 Connection Request PDU.");

            #endregion Connection Initiation

            #region Basic Setting Exchange

            string[] SVCNames = new string[] { RdpConstValue.SVCNAME_RDPEDYC };
            bool     supportMultitransportReliable = true;
            bool     supportMultitransportLossy    = true;
            this.Site.Log.Add(LogEntryKind.Comment, "Send a Client MCS Connect Initial PDU with GCC Conference Create Request to SUT, supportMultitransportReliable is {0}, supportMultitransportLossy is {1}.", supportMultitransportReliable, supportMultitransportLossy);
            rdpbcgrAdapter.SendClientMCSConnectInitialPDU(NegativeType.None, SVCNames, false, false, false, supportMultitransportReliable, supportMultitransportLossy, false);

            this.Site.Log.Add(LogEntryKind.Comment, "Expecting SUT to send a Server MCS Connect Response PDU with GCC Conference Create Response.");
            Server_MCS_Connect_Response_Pdu_with_GCC_Conference_Create_Response response = rdpbcgrAdapter.ExpectPacket <Server_MCS_Connect_Response_Pdu_with_GCC_Conference_Create_Response>(testConfig.timeout);
            this.Site.Assert.IsNotNull(confirmPdu, "RDP Server MUST response a Server MCS Connect Response after receiving a Client MCS Connect Initial PDU.");
            bool serverSupportUDPFECR = false;
            bool serverSupportUDPFECL = false;
            if (response.mcsCrsp.gccPdu.serverMultitransportChannelData != null)
            {
                if (response.mcsCrsp.gccPdu.serverMultitransportChannelData.flags.HasFlag(MULTITRANSPORT_TYPE_FLAGS.TRANSPORTTYPE_UDPFECR))
                {
                    serverSupportUDPFECR = true;
                }
                if (response.mcsCrsp.gccPdu.serverMultitransportChannelData.flags.HasFlag(MULTITRANSPORT_TYPE_FLAGS.TRANSPORTTYPE_UDPFECL))
                {
                    serverSupportUDPFECL = true;
                }
            }
            this.Site.Assume.IsTrue(serverSupportUDPFECR || serverSupportUDPFECL, "To run test case for multitransport, the RDP server should be configured to support RDP-UDP: reliable, lossy, or both.");

            #endregion Basic Setting Exchange

            #region Channel Connection

            this.Site.Log.Add(LogEntryKind.Comment, "Send a Client MCS Erect Domain Request PDU to SUT.");
            rdpbcgrAdapter.SendClientMCSErectDomainRequest(NegativeType.None);

            this.Site.Log.Add(LogEntryKind.Comment, "Send a Client MCS Attach User Request PDU to SUT.");
            rdpbcgrAdapter.SendClientMCSAttachUserRequest(NegativeType.None);

            this.Site.Log.Add(LogEntryKind.Comment, "Expecting SUT to send a Server MCS Attach User Confirm PDU.");
            Server_MCS_Attach_User_Confirm_Pdu attachuserConfirm = rdpbcgrAdapter.ExpectPacket <Server_MCS_Attach_User_Confirm_Pdu>(testConfig.timeout);
            this.Site.Assert.IsNotNull(attachuserConfirm, "RDP Server MUST response a Server MCS Attach User Confirm PDU after receiving a Client MCS Attach User Request PDU.");

            this.Site.Log.Add(LogEntryKind.Comment, "The test suite proceeds to join the user channel, the input/output (I/O) channel, and all of the static virtual channels.");
            rdpbcgrAdapter.ChannelJoinRequestAndConfirm();

            #endregion Channel Connection

            if (testConfig.requestProtocol == requestedProtocols_Values.PROTOCOL_RDP_FLAG)
            {
                this.Site.Log.Add(LogEntryKind.Comment, "Standard RDP Security mechanisms are being employed, Test Suite sends a Client Security Exchange PDU to SUT.");
                rdpbcgrAdapter.SendClientSecurityExchangePDU(NegativeType.None);
            }

            this.Site.Log.Add(LogEntryKind.Comment, "Send a Client Info PDU.");
            rdpbcgrAdapter.SendClientInfoPDU(NegativeType.None, CompressionType.PACKET_COMPR_TYPE_RDP61, false);
            rdpbcgrAdapter.ProcessLicenseSequence(testConfig.timeout);

            bool receivedServerInitiateMultitransportRequestForReliable = false;
            bool receivedServerInitiateMultitransportRequestForLossy    = false;
            int  expectedServerInitiateMultitransportRequestNum         = 1;
            if (serverSupportUDPFECR && serverSupportUDPFECL)
            {
                expectedServerInitiateMultitransportRequestNum = 2;
            }

            for (int i = 0; i < expectedServerInitiateMultitransportRequestNum; i++)
            {
                Server_Initiate_Multitransport_Request_PDU request = rdpbcgrAdapter.ExpectPacket <Server_Initiate_Multitransport_Request_PDU>(testConfig.timeout);
                Site.Assert.IsNotNull(request, "RDP Server MUST send Server_Initiate_Multitransport_Request_PDU packet to initiate multiple transport.");
                if (request.requestedProtocol == Multitransport_Protocol_value.INITITATE_REQUEST_PROTOCOL_UDPFECR)
                {
                    receivedServerInitiateMultitransportRequestForReliable = true;
                }
                else if (request.requestedProtocol == Multitransport_Protocol_value.INITITATE_REQUEST_PROTOCOL_UDPFECL)
                {
                    receivedServerInitiateMultitransportRequestForLossy = true;
                }
            }

            if (serverSupportUDPFECR)
            {
                Site.Assert.IsTrue(receivedServerInitiateMultitransportRequestForReliable,
                                   "RDP Server MUST send Server_Initiate_Multitransport_Request_PDU packets for reliable multitransport.");
            }
            if (serverSupportUDPFECL)
            {
                Site.Assert.IsTrue(receivedServerInitiateMultitransportRequestForLossy,
                                   "RDP Server MUST send Server_Initiate_Multitransport_Request_PDU packets for lossy multitransport.");
            }

            #endregion Test Code
        }