/// <summary> /// Get selected rules /// </summary> /// <returns>Selected rules</returns> public List <CaseSelectRule> GetSelectedRules() { List <CaseSelectRule> caseList = new List <CaseSelectRule>(); caseList.Add(CreateRule("Priority.BVT", true)); caseList.Add(CreateRule("Priority.NonBVT", true)); #region RDP Version TS_UD_SC_CORE_version_Values rdpVersion = getRdpVersion(config.Version); if (rdpVersion > TS_UD_SC_CORE_version_Values.V1) { caseList.Add(CreateRule("RDP Version.RDP 70", true)); caseList.Add(CreateRule("RDP Version.RDP 80", true)); caseList.Add(CreateRule("RDP Version.RDP 81", true)); } #endregion RDP Version #region Protocols caseList.Add(CreateRule("Protocol.RDPBCGR", true)); caseList.Add(CreateRule("Protocol.RDPEDYC", detectionInfo.IsSupportRDPEDYC)); caseList.Add(CreateRule("Protocol.RDPEMT", detectionInfo.IsSupportRDPEMT)); #endregion Protocols return(caseList); }
private void SetRdpVersion(Configs config) { DetectorUtil.WriteLog("Detect RDP version..."); config.Version = DetectorUtil.GetPropertyValue("RDP.Version"); if (connectResponsePdu.mcsCrsp.gccPdu.serverCoreData != null) { TS_UD_SC_CORE_version_Values rdpVersion = connectResponsePdu.mcsCrsp.gccPdu.serverCoreData.version; if (rdpVersion == TS_UD_SC_CORE_version_Values.V1) { config.Version = "4.0"; } else if (rdpVersion == TS_UD_SC_CORE_version_Values.V2) { config.Version = "8.1"; } else if (rdpVersion == TS_UD_SC_CORE_version_Values.V3) { config.Version = "10.0"; } else if (rdpVersion == TS_UD_SC_CORE_version_Values.V4) { config.Version = "10.1"; } else if (rdpVersion == TS_UD_SC_CORE_version_Values.V5) { config.Version = "10.2"; } else if (rdpVersion == TS_UD_SC_CORE_version_Values.V6) { config.Version = "10.3"; } else if (rdpVersion == TS_UD_SC_CORE_version_Values.V7) { config.Version = "10.4"; } else if (rdpVersion == TS_UD_SC_CORE_version_Values.V8) { config.Version = "10.5"; } else if (rdpVersion == TS_UD_SC_CORE_version_Values.V9) { config.Version = "10.6"; } } DetectorUtil.WriteLog("Passed", false, LogStyle.StepPassed); DetectorUtil.WriteLog("Detect RDP version finished."); }
private void SetRdpVersion(Configs config) { DetectorUtil.WriteLog("Detect RDP version..."); config.Version = DetectorUtil.GetPropertyValue("RDP.Version"); if (connectResponsePdu.mcsCrsp.gccPdu.serverCoreData == null) { DetectorUtil.WriteLog("Failed", false, LogStyle.StepFailed); DetectorUtil.WriteLog("Detect RDP version failed, serverCoreData in Server_MCS_Connect_Response_Pdu_with_GCC_Conference_Create_Response does not exist!"); } TS_UD_SC_CORE_version_Values rdpVersion = connectResponsePdu.mcsCrsp.gccPdu.serverCoreData.version; if (rdpVersion == TS_UD_SC_CORE_version_Values.V1) { config.Version = "4.0"; } else if (rdpVersion == TS_UD_SC_CORE_version_Values.V2) { config.Version = "8.1"; // RDP 5.0, 5.1, 5.2, 6.0, 6.1, 7.0, 7.1, 8.0, and 8.1 servers } else if (rdpVersion == TS_UD_SC_CORE_version_Values.V3) { config.Version = "10.0"; } else if (rdpVersion == TS_UD_SC_CORE_version_Values.V4) { config.Version = "10.1"; } else if (rdpVersion == TS_UD_SC_CORE_version_Values.V5) { config.Version = "10.2"; } else if (rdpVersion == TS_UD_SC_CORE_version_Values.V6) { config.Version = "10.3"; } else if (rdpVersion == TS_UD_SC_CORE_version_Values.V7) { config.Version = "10.4"; } else if (rdpVersion == TS_UD_SC_CORE_version_Values.V8) { config.Version = "10.5"; } else if (rdpVersion == TS_UD_SC_CORE_version_Values.V9) { config.Version = "10.6"; } else if (rdpVersion == TS_UD_SC_CORE_version_Values.V10) { config.Version = "10.7"; } else { DetectorUtil.WriteLog("Failed", false, LogStyle.StepFailed); DetectorUtil.WriteLog("Detect RDP version failed, unknown version detected!"); } detectInfo.Version = connectResponsePdu.mcsCrsp.gccPdu.serverCoreData.version; DetectorUtil.WriteLog("Passed", false, LogStyle.StepPassed); DetectorUtil.WriteLog("Detect RDP version finished."); }
protected void LoadConfig() { #region Read and convert properties from PTFCONFIG file #region Security Approach and Protocol string strRDPSecurityProtocol; bool isNegotiationBased = true; if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RdpSecurityNegotiation, out isNegotiationBased)) { assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityNegotiation); } selectedProtocol = selectedProtocols_Values.PROTOCOL_RDP_FLAG; if (!PtfPropUtility.GetStringPtfProperty(TestSite, RdpPtfPropNames.RdpSecurityProtocol, out strRDPSecurityProtocol)) { assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityProtocol); } // Check the combination of RdpSecurityNegotiation and RdpSecurityProtocol if (strRDPSecurityProtocol.Equals("TLS", StringComparison.CurrentCultureIgnoreCase)) { selectedProtocol = selectedProtocols_Values.PROTOCOL_SSL_FLAG; this.TestSite.Assume.IsTrue( isNegotiationBased, "When TLS is used as the security protocol, {0} is set to 'TLS', {1} must be true.", RdpPtfPropNames.RdpSecurityProtocol, RdpPtfPropNames.RdpSecurityNegotiation); transportProtocol = EncryptedProtocol.NegotiationTls; } else if (strRDPSecurityProtocol.Equals("CredSSP", StringComparison.CurrentCultureIgnoreCase)) { selectedProtocol = selectedProtocols_Values.PROTOCOL_HYBRID_FLAG; if (isNegotiationBased) { transportProtocol = EncryptedProtocol.NegotiationCredSsp; } else { transportProtocol = EncryptedProtocol.DirectCredSsp; } } else if (strRDPSecurityProtocol.Equals("RDP", StringComparison.CurrentCultureIgnoreCase)) { selectedProtocol = selectedProtocols_Values.PROTOCOL_RDP_FLAG; transportProtocol = EncryptedProtocol.Rdp; } else { assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityProtocol); } #endregion #region Encryption Level string strRDPSecurityEncryptionLevel; enLevel = EncryptionLevel.ENCRYPTION_LEVEL_LOW; if (!PtfPropUtility.GetStringPtfProperty(TestSite, RdpPtfPropNames.RdpSecurityEncryptionLevel, out strRDPSecurityEncryptionLevel)) { assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityEncryptionLevel); } else {//None, Low, Client, High, FIPS if (strRDPSecurityEncryptionLevel.Equals("None", StringComparison.CurrentCultureIgnoreCase)) { enLevel = EncryptionLevel.ENCRYPTION_LEVEL_NONE; } else if (strRDPSecurityEncryptionLevel.Equals("Low", StringComparison.CurrentCultureIgnoreCase)) { enLevel = EncryptionLevel.ENCRYPTION_LEVEL_LOW; } else if (strRDPSecurityEncryptionLevel.Equals("Client", StringComparison.CurrentCultureIgnoreCase)) { enLevel = EncryptionLevel.ENCRYPTION_LEVEL_CLIENT_COMPATIBLE; } else if (strRDPSecurityEncryptionLevel.Equals("High", StringComparison.CurrentCultureIgnoreCase)) { enLevel = EncryptionLevel.ENCRYPTION_LEVEL_HIGH; } else if (strRDPSecurityEncryptionLevel.Equals("FIPS", StringComparison.CurrentCultureIgnoreCase)) { enLevel = EncryptionLevel.ENCRYPTION_LEVEL_FIPS; } else { assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityEncryptionLevel); } } if (transportProtocol == EncryptedProtocol.Rdp && enLevel == EncryptionLevel.ENCRYPTION_LEVEL_NONE) { this.TestSite.Assert.Fail("When use Standard RDP Security, the encryption level must be greater than None."); } if (transportProtocol != EncryptedProtocol.Rdp && enLevel != EncryptionLevel.ENCRYPTION_LEVEL_NONE) { this.TestSite.Assert.Fail("When use enhanced security protocls (TLS or CredSSP), the encryption level MUST be None."); } #endregion #region Encryption Method string strRDPSecurityEncryptionMethod; enMethod = EncryptionMethods.ENCRYPTION_METHOD_128BIT; if (!PtfPropUtility.GetStringPtfProperty(TestSite, RdpPtfPropNames.RdpSecurityEncryptionMethod, out strRDPSecurityEncryptionMethod)) { assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityEncryptionMethod); } else {//None, 40bit, 56bit, 128bit, FIPS if (strRDPSecurityEncryptionMethod.Equals("None", StringComparison.CurrentCultureIgnoreCase)) { enMethod = EncryptionMethods.ENCRYPTION_METHOD_NONE; } else if (strRDPSecurityEncryptionMethod.Equals("40bit", StringComparison.CurrentCultureIgnoreCase)) { enMethod = EncryptionMethods.ENCRYPTION_METHOD_40BIT; } else if (strRDPSecurityEncryptionMethod.Equals("56bit", StringComparison.CurrentCultureIgnoreCase)) { enMethod = EncryptionMethods.ENCRYPTION_METHOD_56BIT; } else if (strRDPSecurityEncryptionMethod.Equals("128bit", StringComparison.CurrentCultureIgnoreCase)) { enMethod = EncryptionMethods.ENCRYPTION_METHOD_128BIT; } else if (strRDPSecurityEncryptionMethod.Equals("FIPS", StringComparison.CurrentCultureIgnoreCase)) { enMethod = EncryptionMethods.ENCRYPTION_METHOD_FIPS; } else { assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityEncryptionMethod); } } if (enLevel == EncryptionLevel.ENCRYPTION_LEVEL_NONE && enMethod != EncryptionMethods.ENCRYPTION_METHOD_NONE) { this.TestSite.Assume.Fail("When Encryption Level is set to None, the Encryption Method should also set to None."); } if (enLevel == EncryptionLevel.ENCRYPTION_LEVEL_FIPS && enMethod != EncryptionMethods.ENCRYPTION_METHOD_FIPS) { this.TestSite.Assume.Fail("When Encryption Level is set to FIPS, the Encryption Method should also set to FIPS."); } #endregion #region RDP Version rdpServerVersion = TS_UD_SC_CORE_version_Values.V2; #endregion #region WaitTime int waitSeconds; if (!PtfPropUtility.GetIntPtfProperty(TestSite, RdpPtfPropNames.Timeout, out waitSeconds)) { assumeFailForInvalidPtfProp(RdpPtfPropNames.Timeout); } else { waitTime = new TimeSpan(0, 0, waitSeconds); } #endregion #region SUT Display Verification if (!PtfPropUtility.GetBoolPtfProperty(TestSite, "VerifySUTDisplay.Enable", out verifySUTDisplay)) { verifySUTDisplay = false; } int shiftX, shiftY; if (!PtfPropUtility.GetIntPtfProperty(TestSite, "VerifySUTDisplay.Shift.X", out shiftX)) { shiftX = 0; } if (!PtfPropUtility.GetIntPtfProperty(TestSite, "VerifySUTDisplay.Shift.Y", out shiftY)) { shiftY = 0; } sutDisplayShift = new Point(shiftX, shiftY); if (!PtfPropUtility.GetStringPtfProperty(TestSite, "VerifySUTDisplay.BitmapSavePath", out bitmapSavePath)) { bitmapSavePath = @".\"; } // If the bitmap save path is not existed, create it. if (!Directory.Exists(bitmapSavePath)) { Directory.CreateDirectory(bitmapSavePath); } #endregion SUT Display Verification #region Other configrations if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RDPClientSupportFastPathInput, out isClientSupportFastPathInput)) { isClientSupportFastPathInput = false; //if property not found, set to false as default value } if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RDPClientSupportAutoReconnect, out isClientSuportAutoReconnect)) { isClientSuportAutoReconnect = false; //if property not found, set to false as default value } if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RDPClientSupportRDPEFS, out isClientSupportRDPEFS)) { isClientSupportRDPEFS = false; //if property not found, set to false as default value } if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RDPClientSupportServerRedirection, out isClientSupportServerRedirection)) { isClientSupportServerRedirection = false; //if property not found, set to false as default value } if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RDPClientSupportSoftSync, out isClientSupportSoftSync)) { isClientSupportSoftSync = false; //if property not found, set to false as default value } if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RDPClientSupportTunnelingStaticVCTraffic, out isClientSupportTunnelingStaticVCTraffic)) { isClientSupportTunnelingStaticVCTraffic = false; //if property not found, set to false as default value } if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RDPClientSupportRdpNegDataEmpty, out isClientSupportEmptyRdpNegData)) { isClientSupportEmptyRdpNegData = false; //if property not found, set to false as default value } if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.IsWindowsImplementation, out isWindowsImplementation)) { isWindowsImplementation = true; //if property not found, set to true as default value } if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.DropConnectionForInvalidRequest, out DropConnectionForInvalidRequest)) { DropConnectionForInvalidRequest = true; //if property not found, set to true as default value } if (!PtfPropUtility.GetBoolPtfProperty(TestSite, "VerifyRdpbcgrMessage", out bVerifyRdpbcgrMessage)) { bVerifyRdpbcgrMessage = true; //if property not found, set to true as default value } String rdprfxImageFile; if (!PtfPropUtility.GetStringPtfProperty(TestSite, "RDPRFX.Image", out rdprfxImageFile)) { rdprfxImageFile = ""; //if property not found, set to true as default value } String rdprfxVideoModeImageFile; if (!PtfPropUtility.GetStringPtfProperty(TestSite, "RDPRFXVideoMode.Image", out rdprfxVideoModeImageFile)) { rdprfxVideoModeImageFile = ""; //if property not found, set to true as default value } try { //Get image from file image_64X64 = Image.FromFile(rdprfxImageFile); imageForVideoMode = Image.FromFile(rdprfxVideoModeImageFile); } catch (System.IO.FileNotFoundException) { //capture screen if failed to get image from file //Capture 64*64 bitmap for Image Mode image_64X64 = captureScreenImage(0, 0, TileSize, TileSize); //Capture screen bitmap for Vedio Mode imageForVideoMode = captureScreenImage(0, 0, TileSize * VideoMode_TileRowNum, TileSize * VideoMode_TileColNum); } #endregion #endregion #region Logging this.TestSite.Log.Add(LogEntryKind.Debug, @"isClientSupportFastPathInput = {0}; isClientSuportAutoReconnect = {1}; isClientSupportRDPEFS = {2}; isClientSupportServerRedirection = {3}; isClientSupportEmptyRdpNegData = {4}; isClientSupportSoftSync = {5} isClientSupportTunnelingStaticVCTraffic = {6}", isClientSupportFastPathInput, isClientSuportAutoReconnect, isClientSupportRDPEFS, isClientSupportServerRedirection, isClientSupportEmptyRdpNegData, isClientSupportSoftSync, isClientSupportTunnelingStaticVCTraffic); #endregion }
/// <summary> /// Expect a client initiated RDP connection sequence. /// </summary> /// <param name="serverSelectedProtocol">The server selected security protocol.</param> /// <param name="enMethod">The server selected security method.</param> /// <param name="enLevel">The server selected security level.</param> /// <param name="isExtendedClientDataSupported">Indicates if server supports Extended Client Data Blocks.</param> /// <param name="expectAutoReconnect">Indicates if expect an Auto-Connect sequence.</param> /// <param name="rdpServerVersion">The RDP Sever version</param> /// <param name="isMultitransportSupported">Whether support multitransport</param> /// <param name="supportRDPEGFX">Whether support RDPEGFX</param> /// <param name="supportRestrictedAdminMode">Whether support restricted admin mode</param> public void EstablishRDPConnection( selectedProtocols_Values serverSelectedProtocol, EncryptionMethods enMethod, EncryptionLevel enLevel, bool isExtendedClientDataSupported, bool expectAutoReconnect, TS_UD_SC_CORE_version_Values rdpServerVersion, bool isMultitransportSupported = false, bool supportRDPEGFX = false, bool supportRestrictedAdminMode = false) { #region Logging this.site.Log.Add(LogEntryKind.Comment, @"EstablishRDPConnection( Selected Protocol = {0}, Encyrption Method = {1}, Encyrption Level = {2}, Extended Client Data Supported = {3}, Auto-Reconnection Expected = {4}, RDP Version Code= {5}).", serverSelectedProtocol.ToString(), enMethod.ToString(), enLevel.ToString(), isExtendedClientDataSupported, expectAutoReconnect, rdpServerVersion.ToString()); #endregion //Update server config context. serverConfig.selectedProtocol = serverSelectedProtocol; serverConfig.encryptionMethod = enMethod; serverConfig.encryptionLevel = enLevel; serverConfig.isExtendedClientDataSupported = isExtendedClientDataSupported; #region Connection Initiation //5.4.2.1 Negotiation-Based Approach //Once the External Security Protocol (section 5.4.5) handshake has successfully run to completion, //the RDP messages resume, continuing with the MCS Connect Initial PDU (section 2.2.1.3). //if (serverConfig.encryptedProtocol != EncryptedProtocol.NegotiationCredSsp) //{ ExpectPacket <Client_X_224_Connection_Request_Pdu>(sessionContext, pduWaitTimeSpan); RDP_NEG_RSP_flags_Values RDP_NEG_RSP_flags = RDP_NEG_RSP_flags_Values.None; if (serverConfig.isExtendedClientDataSupported) { RDP_NEG_RSP_flags |= RDP_NEG_RSP_flags_Values.EXTENDED_CLIENT_DATA_SUPPORTED; } if (supportRDPEGFX) { RDP_NEG_RSP_flags |= RDP_NEG_RSP_flags_Values.DYNVC_GFX_PROTOCOL_SUPPORTED; } if (supportRestrictedAdminMode) { RDP_NEG_RSP_flags |= RDP_NEG_RSP_flags_Values.RESTRICTED_ADMIN_MODE_SUPPORTED; } Server_X_224_Connection_Confirm(serverConfig.selectedProtocol, RDP_NEG_RSP_flags); //} #endregion #region Basic Setting Exchange ExpectPacket <Client_MCS_Connect_Initial_Pdu_with_GCC_Conference_Create_Request>(sessionContext, pduWaitTimeSpan); Server_MCS_Connect_Response(enMethod, enLevel, rdpServerVersion, NegativeType.None, isMultitransportSupported); #endregion #region Channel Connection ExpectPacket <Client_MCS_Erect_Domain_Request>(sessionContext, pduWaitTimeSpan); ExpectPacket <Client_MCS_Attach_User_Request>(sessionContext, pduWaitTimeSpan); MCSAttachUserConfirm(NegativeType.None); //Join Channel int channelNum = 2; if (sessionContext.VirtualChannelIdStore != null) { channelNum += sessionContext.VirtualChannelIdStore.Length; } if (sessionContext.IsServerMessageChannelDataSend) { channelNum++; } for (int i = 0; i < channelNum; i++) { ExpectPacket <Client_MCS_Channel_Join_Request>(sessionContext, pduWaitTimeSpan); MCSChannelJoinConfirm(lastRequestJoinChannelId, NegativeType.None); } #endregion #region RDP Security Commencement if (serverConfig.encryptedProtocol == EncryptedProtocol.Rdp) { ExpectPacket <Client_Security_Exchange_Pdu>(sessionContext, pduWaitTimeSpan); } #endregion #region Secure Setting Exchange ExpectPacket <Client_Info_Pdu>(sessionContext, pduWaitTimeSpan); if (expectAutoReconnect) { site.Assert.IsNotNull(tsInfoPacket.extraInfo, "TS_EXTENDED_INFO_PACKET should be provided in Auto-Reconnect sequence."); site.Assert.AreNotEqual <ushort>(0, tsInfoPacket.extraInfo.cbAutoReconnectLen, "The autoReconnectCookie should be provided in Auto-Reconnect sequence."); } #endregion #region Licensing Server_License_Error_Pdu_Valid_Client(NegativeType.None); #endregion #region Capabilities Exchange Server_Demand_Active(NegativeType.None); //Once the Confirm Active PDU has been sent, the client can start sending input PDUs (see section 2.2.8) to the server. ExpectPacket <Client_Confirm_Active_Pdu>(sessionContext, pduWaitTimeSpan); #endregion #region Connection Finalization WaitForPacket <Client_Synchronize_Pdu>(sessionContext, pduWaitTimeSpan); ServerSynchronize(); ServerControlCooperate(); WaitForPacket <Client_Control_Pdu_Cooperate>(sessionContext, pduWaitTimeSpan); WaitForPacket <Client_Control_Pdu_Request_Control>(sessionContext, pduWaitTimeSpan); ServerControlGrantedControl(); if (serverConfig.CapabilitySetting.BitmapCacheHostSupportCapabilitySet) { ITsCapsSet cap = this.clientCapSet.FindCapSet(capabilitySetType_Values.CAPSTYPE_BITMAPCACHE_REV2); if (cap != null) { TS_BITMAPCACHE_CAPABILITYSET_REV2 bitmapCacheV2 = (TS_BITMAPCACHE_CAPABILITYSET_REV2)cap; if ((bitmapCacheV2.CacheFlags & CacheFlags_Values.PERSISTENT_KEYS_EXPECTED_FLAG) != 0) { WaitForPacket <Client_Persistent_Key_List_Pdu>(sessionContext, pduWaitTimeSpan); } } } WaitForPacket <Client_Font_List_Pdu>(sessionContext, pduWaitTimeSpan); ServerFontMap(); #endregion }
/// <summary> /// Expect a client initiated RDP connection sequence. /// </summary> /// <param name="serverSelectedProtocol">The server selected security protocol.</param> /// <param name="enMethod">The server selected security method.</param> /// <param name="enLevel">The server selected security level.</param> /// <param name="isExtendedClientDataSupported">Indicates if server supports Extended Client Data Blocks.</param> /// <param name="expectAutoReconnect">Indicates if expect an Auto-Connect sequence.</param> /// <param name="rdpServerVersion">The RDP Sever version</param> /// <param name="multiTransportTypeFlags">Flags of Multitransport Channel Data</param> /// <param name="supportRDPEGFX">Whether support RDPEGFX</param> /// <param name="supportRestrictedAdminMode">Whether support restricted admin mode</param> public void EstablishRDPConnection( selectedProtocols_Values serverSelectedProtocol, EncryptionMethods enMethod, EncryptionLevel enLevel , bool isExtendedClientDataSupported, bool expectAutoReconnect, TS_UD_SC_CORE_version_Values rdpServerVersion, MULTITRANSPORT_TYPE_FLAGS multiTransportTypeFlags = MULTITRANSPORT_TYPE_FLAGS.None, bool supportRDPEGFX = false, bool supportRestrictedAdminMode = false) { #region Logging this.site.Log.Add(LogEntryKind.Comment, @"EstablishRDPConnection( Selected Protocol = {0}, Encyrption Method = {1}, Encyrption Level = {2}, Extended Client Data Supported = {3}, Auto-Reconnection Expected = {4}, RDP Version Code= {5}).", serverSelectedProtocol.ToString(), enMethod.ToString(), enLevel.ToString(), isExtendedClientDataSupported, expectAutoReconnect, rdpServerVersion.ToString()); #endregion //Update server config context. serverConfig.selectedProtocol = serverSelectedProtocol; serverConfig.encryptionMethod = enMethod; serverConfig.encryptionLevel = enLevel; serverConfig.isExtendedClientDataSupported = isExtendedClientDataSupported; #region Connection Initiation //5.4.2.1 Negotiation-Based Approach //Once the External Security Protocol (section 5.4.5) handshake has successfully run to completion, //the RDP messages resume, continuing with the MCS Connect Initial PDU (section 2.2.1.3). //if (serverConfig.encryptedProtocol != EncryptedProtocol.NegotiationCredSsp) //{ ExpectPacket<Client_X_224_Connection_Request_Pdu>(sessionContext, pduWaitTimeSpan); RDP_NEG_RSP_flags_Values RDP_NEG_RSP_flags = RDP_NEG_RSP_flags_Values.None; if (serverConfig.isExtendedClientDataSupported) { RDP_NEG_RSP_flags |= RDP_NEG_RSP_flags_Values.EXTENDED_CLIENT_DATA_SUPPORTED; } if (supportRDPEGFX) { RDP_NEG_RSP_flags |= RDP_NEG_RSP_flags_Values.DYNVC_GFX_PROTOCOL_SUPPORTED; } if (supportRestrictedAdminMode) { RDP_NEG_RSP_flags |= RDP_NEG_RSP_flags_Values.RESTRICTED_ADMIN_MODE_SUPPORTED; } Server_X_224_Connection_Confirm(serverConfig.selectedProtocol, RDP_NEG_RSP_flags); //} #endregion #region Basic Setting Exchange ExpectPacket<Client_MCS_Connect_Initial_Pdu_with_GCC_Conference_Create_Request>(sessionContext, pduWaitTimeSpan); Server_MCS_Connect_Response( enMethod, enLevel, rdpServerVersion, NegativeType.None, multiTransportTypeFlags, false, SC_earlyCapabilityFlags_Values.RNS_UD_SC_EDGE_ACTIONS_SUPPORTED, ConstValue.IO_CHANNEL_ID, ConstValue.MCS_MESSAGE_CHANNEL_ID); #endregion #region Channel Connection ExpectPacket<Client_MCS_Erect_Domain_Request>(sessionContext, pduWaitTimeSpan); ExpectPacket<Client_MCS_Attach_User_Request>(sessionContext, pduWaitTimeSpan); MCSAttachUserConfirm(NegativeType.None); //Join Channel int channelNum = 2; if (sessionContext.VirtualChannelIdStore != null) { channelNum += sessionContext.VirtualChannelIdStore.Length; } if (sessionContext.IsServerMessageChannelDataSend) channelNum++; for (int i = 0; i < channelNum; i++) { ExpectPacket<Client_MCS_Channel_Join_Request>(sessionContext, pduWaitTimeSpan); MCSChannelJoinConfirm(lastRequestJoinChannelId, NegativeType.None); } #endregion #region RDP Security Commencement if (serverConfig.encryptedProtocol == EncryptedProtocol.Rdp) { ExpectPacket<Client_Security_Exchange_Pdu>(sessionContext, pduWaitTimeSpan); } #endregion #region Secure Setting Exchange ExpectPacket<Client_Info_Pdu>(sessionContext, pduWaitTimeSpan); if (expectAutoReconnect) { site.Assert.IsNotNull(tsInfoPacket.extraInfo, "TS_EXTENDED_INFO_PACKET should be provided in Auto-Reconnect sequence."); site.Assert.AreNotEqual<ushort>(0, tsInfoPacket.extraInfo.cbAutoReconnectLen, "The autoReconnectCookie should be provided in Auto-Reconnect sequence."); } #endregion #region Licensing Server_License_Error_Pdu_Valid_Client(NegativeType.None); #endregion #region Capabilities Exchange Server_Demand_Active(NegativeType.None); //Once the Confirm Active PDU has been sent, the client can start sending input PDUs (see section 2.2.8) to the server. ExpectPacket<Client_Confirm_Active_Pdu>(sessionContext, pduWaitTimeSpan); #endregion #region Connection Finalization WaitForPacket<Client_Synchronize_Pdu>(sessionContext, pduWaitTimeSpan); ServerSynchronize(); ServerControlCooperate(); WaitForPacket<Client_Control_Pdu_Cooperate>(sessionContext, pduWaitTimeSpan); WaitForPacket<Client_Control_Pdu_Request_Control>(sessionContext, pduWaitTimeSpan); ServerControlGrantedControl(); if (serverConfig.CapabilitySetting.BitmapCacheHostSupportCapabilitySet) { ITsCapsSet cap = this.clientCapSet.FindCapSet(capabilitySetType_Values.CAPSTYPE_BITMAPCACHE_REV2); if (cap != null) { TS_BITMAPCACHE_CAPABILITYSET_REV2 bitmapCacheV2 = (TS_BITMAPCACHE_CAPABILITYSET_REV2)cap; if ((bitmapCacheV2.CacheFlags & CacheFlags_Values.PERSISTENT_KEYS_EXPECTED_FLAG) != 0) { WaitForPacket<Client_Persistent_Key_List_Pdu>(sessionContext, pduWaitTimeSpan); } } } WaitForPacket<Client_Font_List_Pdu>(sessionContext, pduWaitTimeSpan); ServerFontMap(); #endregion }
protected void LoadConfig() { #region Read and convert properties from PTFCONFIG file #region Security Approach and Protocol string strRDPSecurityProtocol; bool isNegotiationBased = true; if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RdpSecurityNegotiation, out isNegotiationBased)) { assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityNegotiation); } selectedProtocol = selectedProtocols_Values.PROTOCOL_RDP_FLAG; if (!PtfPropUtility.GetStringPtfProperty(TestSite, RdpPtfPropNames.RdpSecurityProtocol, out strRDPSecurityProtocol)) { assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityProtocol); } else {//TLS, CredSSP, or RDP if (strRDPSecurityProtocol.Equals("TLS", StringComparison.CurrentCultureIgnoreCase)) { selectedProtocol = selectedProtocols_Values.PROTOCOL_SSL_FLAG; if (isNegotiationBased) { transportProtocol = EncryptedProtocol.NegotiationTls; } else { transportProtocol = EncryptedProtocol.DirectTls; } } else if (strRDPSecurityProtocol.Equals("CredSSP", StringComparison.CurrentCultureIgnoreCase)) { selectedProtocol = selectedProtocols_Values.PROTOCOL_HYBRID_FLAG; if (isNegotiationBased) { transportProtocol = EncryptedProtocol.NegotiationCredSsp; } else { transportProtocol = EncryptedProtocol.DirectCredSsp; } } else if (strRDPSecurityProtocol.Equals("RDP", StringComparison.CurrentCultureIgnoreCase)) { selectedProtocol = selectedProtocols_Values.PROTOCOL_RDP_FLAG; if (!isNegotiationBased) { this.TestSite.Log.Add(LogEntryKind.Warning, "The property \"RDP.Security.Protocol\" is not valid and will be ingored. (When use RDP as security protocol, the negotiation-based approch MUST be used."); } } else { assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityProtocol); } } #endregion #region Encryption Level string strRDPSecurityEncryptionLevel; enLevel = EncryptionLevel.ENCRYPTION_LEVEL_LOW; if (!PtfPropUtility.GetStringPtfProperty(TestSite, RdpPtfPropNames.RdpSecurityEncryptionLevel, out strRDPSecurityEncryptionLevel)) { assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityEncryptionLevel); } else {//None, Low, Client, High, FIPS if (strRDPSecurityEncryptionLevel.Equals("None", StringComparison.CurrentCultureIgnoreCase)) { enLevel = EncryptionLevel.ENCRYPTION_LEVEL_NONE; } else if (strRDPSecurityEncryptionLevel.Equals("Low", StringComparison.CurrentCultureIgnoreCase)) { enLevel = EncryptionLevel.ENCRYPTION_LEVEL_LOW; } else if (strRDPSecurityEncryptionLevel.Equals("Client", StringComparison.CurrentCultureIgnoreCase)) { enLevel = EncryptionLevel.ENCRYPTION_LEVEL_CLIENT_COMPATIBLE; } else if (strRDPSecurityEncryptionLevel.Equals("High", StringComparison.CurrentCultureIgnoreCase)) { enLevel = EncryptionLevel.ENCRYPTION_LEVEL_HIGH; } else if (strRDPSecurityEncryptionLevel.Equals("FIPS", StringComparison.CurrentCultureIgnoreCase)) { enLevel = EncryptionLevel.ENCRYPTION_LEVEL_FIPS; } else { assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityEncryptionLevel); } } if (transportProtocol == EncryptedProtocol.Rdp && enLevel == EncryptionLevel.ENCRYPTION_LEVEL_NONE) { this.TestSite.Assert.Fail("When use Standard RDP Security, the encryption level must be greater than None."); } if (transportProtocol != EncryptedProtocol.Rdp && enLevel != EncryptionLevel.ENCRYPTION_LEVEL_NONE) { this.TestSite.Assert.Fail("When use enhanced security protocls (TLS or CredSSP), the encryption level MUST be None."); } #endregion #region Encryption Method string strRDPSecurityEncryptionMethod; enMethod = EncryptionMethods.ENCRYPTION_METHOD_128BIT; if (!PtfPropUtility.GetStringPtfProperty(TestSite, RdpPtfPropNames.RdpSecurityEncryptionMethod, out strRDPSecurityEncryptionMethod)) { assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityEncryptionMethod); } else {//None, 40bit, 56bit, 128bit, FIPS if (strRDPSecurityEncryptionMethod.Equals("None", StringComparison.CurrentCultureIgnoreCase)) { enMethod = EncryptionMethods.ENCRYPTION_METHOD_NONE; } else if (strRDPSecurityEncryptionMethod.Equals("40bit", StringComparison.CurrentCultureIgnoreCase)) { enMethod = EncryptionMethods.ENCRYPTION_METHOD_40BIT; } else if (strRDPSecurityEncryptionMethod.Equals("56bit", StringComparison.CurrentCultureIgnoreCase)) { enMethod = EncryptionMethods.ENCRYPTION_METHOD_56BIT; } else if (strRDPSecurityEncryptionMethod.Equals("128bit", StringComparison.CurrentCultureIgnoreCase)) { enMethod = EncryptionMethods.ENCRYPTION_METHOD_128BIT; } else if (strRDPSecurityEncryptionMethod.Equals("FIPS", StringComparison.CurrentCultureIgnoreCase)) { enMethod = EncryptionMethods.ENCRYPTION_METHOD_FIPS; } else { assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityEncryptionMethod); } } if (enLevel == EncryptionLevel.ENCRYPTION_LEVEL_NONE && enMethod != EncryptionMethods.ENCRYPTION_METHOD_NONE) { this.TestSite.Assume.Fail("When Encryption Level is set to None, the Encryption Method should also set to None."); } if (enLevel == EncryptionLevel.ENCRYPTION_LEVEL_FIPS && enMethod != EncryptionMethods.ENCRYPTION_METHOD_FIPS) { this.TestSite.Assume.Fail("When Encryption Level is set to FIPS, the Encryption Method should also set to FIPS."); } #endregion #region RDP Version rdpServerVersion = TS_UD_SC_CORE_version_Values.V2; #endregion #region WaitTime int waitSeconds; if (!PtfPropUtility.GetIntPtfProperty(TestSite, RdpPtfPropNames.Timeout, out waitSeconds)) { assumeFailForInvalidPtfProp(RdpPtfPropNames.Timeout); } else { waitTime = new TimeSpan(0, 0, waitSeconds); } #endregion #region SUT Display Verification if (!PtfPropUtility.GetBoolPtfProperty(TestSite, "VerifySUTDisplay.Enable", out verifySUTDisplay)) { verifySUTDisplay = false; } int shiftX, shiftY; if (!PtfPropUtility.GetIntPtfProperty(TestSite, "VerifySUTDisplay.Shift.X", out shiftX)) { shiftX = 0; } if (!PtfPropUtility.GetIntPtfProperty(TestSite, "VerifySUTDisplay.Shift.Y", out shiftY)) { shiftY = 0; } sutDisplayShift = new Point(shiftX, shiftY); if (!PtfPropUtility.GetStringPtfProperty(TestSite, "VerifySUTDisplay.BitmapSavePath", out bitmapSavePath)) { bitmapSavePath = @".\"; } // If the bitmap save path is not existed, create it. if (!Directory.Exists(bitmapSavePath)) { Directory.CreateDirectory(bitmapSavePath); } #endregion SUT Display Verification #region Other configrations if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RDPClientSupportFastPathInput, out isClientSupportFastPathInput)) { isClientSupportFastPathInput = false; //if property not found, set to false as default value } if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RDPClientSupportAutoReconnect, out isClientSuportAutoReconnect)) { isClientSuportAutoReconnect = false; //if property not found, set to false as default value } if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RDPClientSupportRDPEFS, out isClientSupportRDPEFS)) { isClientSupportRDPEFS = false; //if property not found, set to false as default value } if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RDPClientSupportServerRedirection, out isClientSupportServerRedirection)) { isClientSupportServerRedirection = false; //if property not found, set to false as default value } if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RDPClientSupportSoftSync, out isClientSupportSoftSync)) { isClientSupportSoftSync = false; //if property not found, set to false as default value } if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RDPClientSupportTunnelingStaticVCTraffic, out isClientSupportTunnelingStaticVCTraffic)) { isClientSupportTunnelingStaticVCTraffic = false; //if property not found, set to false as default value } if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RDPClientSupportRdpNegDataEmpty, out isClientSupportEmptyRdpNegData)) { isClientSupportEmptyRdpNegData = false; //if property not found, set to false as default value } if (!PtfPropUtility.GetBoolPtfProperty(TestSite, "IsWindowsImplementation", out isWindowsImplementation)) { isWindowsImplementation = true; //if property not found, set to true as default value } if (!PtfPropUtility.GetBoolPtfProperty(TestSite, "VerifyRdpbcgrMessage", out bVerifyRdpbcgrMessage)) { bVerifyRdpbcgrMessage = true; //if property not found, set to true as default value } String rdprfxImageFile; if (!PtfPropUtility.GetStringPtfProperty(TestSite, "RDPRFX.Image", out rdprfxImageFile)) { rdprfxImageFile = ""; //if property not found, set to true as default value } String rdprfxVideoModeImageFile; if (!PtfPropUtility.GetStringPtfProperty(TestSite, "RDPRFXVideoMode.Image", out rdprfxVideoModeImageFile)) { rdprfxVideoModeImageFile = ""; //if property not found, set to true as default value } try { //Get image from file image_64X64 = Image.FromFile(rdprfxImageFile); imageForVideoMode = Image.FromFile(rdprfxVideoModeImageFile); } catch (System.IO.FileNotFoundException) { //capture screen if failed to get image from file //Capture 64*64 bitmap for Image Mode image_64X64 = captureScreenImage(0, 0, TileSize, TileSize); //Capture screen bitmap for Vedio Mode imageForVideoMode = captureScreenImage(0, 0, TileSize * VideoMode_TileRowNum, TileSize * VideoMode_TileColNum); } #endregion #endregion #region Logging this.TestSite.Log.Add(LogEntryKind.Debug, @"isClientSupportFastPathInput = {0}; isClientSuportAutoReconnect = {1}; isClientSupportRDPEFS = {2}; isClientSupportServerRedirection = {3}; isClientSupportEmptyRdpNegData = {4}; isClientSupportSoftSync = {5} isClientSupportTunnelingStaticVCTraffic = {6}", isClientSupportFastPathInput, isClientSuportAutoReconnect, isClientSupportRDPEFS, isClientSupportServerRedirection, isClientSupportEmptyRdpNegData, isClientSupportSoftSync, isClientSupportTunnelingStaticVCTraffic); #endregion }
public static void LoadConfig(ITestSite site) { Timeout = TimeSpan.FromSeconds(CommonUtility.GetIntProperty(site, ConfigPropNames.Timeout)); IsWindowsImplementation = CommonUtility.GetBoolProperty(site, ConfigPropNames.IsWindowsImplementation); IsNegotiationBased = CommonUtility.GetBoolProperty(site, ConfigPropNames.RdpSecurityNegotiation); RdpSecurityProtocolValues rsp = CommonUtility.GetEnumProperty <RdpSecurityProtocolValues>(site, ConfigPropNames.RdpSecurityProtocol); switch (rsp) { case RdpSecurityProtocolValues.TLS: SelectedProtocol = selectedProtocols_Values.PROTOCOL_SSL_FLAG; site.Assume.IsTrue( IsNegotiationBased, "When TLS is used as the security protocol, {0} is set to 'TLS', {1} must be true.", ConfigPropNames.RdpSecurityProtocol, ConfigPropNames.RdpSecurityNegotiation); TransportProtocol = EncryptedProtocol.NegotiationTls; break; case RdpSecurityProtocolValues.CredSSP: SelectedProtocol = selectedProtocols_Values.PROTOCOL_HYBRID_FLAG; TransportProtocol = IsNegotiationBased ? EncryptedProtocol.NegotiationCredSsp : EncryptedProtocol.DirectCredSsp; break; case RdpSecurityProtocolValues.RDP: SelectedProtocol = selectedProtocols_Values.PROTOCOL_RDP_FLAG; TransportProtocol = EncryptedProtocol.Rdp; break; default: site.Assume.Fail("The property '{0}' is not valid, it must be set to one of TLS, CredSSP or RDP.", ConfigPropNames.RdpSecurityProtocol); break; } EncryptionLevelValues ev = CommonUtility.GetEnumProperty <EncryptionLevelValues>(site, ConfigPropNames.RdpSecurityEncryptionLevel); switch (ev) { case EncryptionLevelValues.None: EncLevel = EncryptionLevel.ENCRYPTION_LEVEL_NONE; break; case EncryptionLevelValues.Low: EncLevel = EncryptionLevel.ENCRYPTION_LEVEL_LOW; break; case EncryptionLevelValues.Client: EncLevel = EncryptionLevel.ENCRYPTION_LEVEL_CLIENT_COMPATIBLE; break; case EncryptionLevelValues.High: EncLevel = EncryptionLevel.ENCRYPTION_LEVEL_HIGH; break; case EncryptionLevelValues.FIPS: EncLevel = EncryptionLevel.ENCRYPTION_LEVEL_FIPS; break; default: site.Assume.Fail("The property '{0}' is not valid, it MUST be one of None, Low, Client, High, FIPS.", ConfigPropNames.RdpSecurityEncryptionLevel); break; } Dictionary <string, EncryptionMethods> encMethodValues = new Dictionary <string, EncryptionMethods>(); encMethodValues.Add("None", EncryptionMethods.ENCRYPTION_METHOD_NONE); encMethodValues.Add("40bit", EncryptionMethods.ENCRYPTION_METHOD_40BIT); encMethodValues.Add("56bit", EncryptionMethods.ENCRYPTION_METHOD_56BIT); encMethodValues.Add("128bit", EncryptionMethods.ENCRYPTION_METHOD_128BIT); encMethodValues.Add("FIPS", EncryptionMethods.ENCRYPTION_METHOD_FIPS); string str = CommonUtility.GetProperty(site, ConfigPropNames.RdpSecurityEncryptionMethod); site.Assume.IsTrue( encMethodValues.ContainsKey(str), "The property '{0}' must be 'None', '40bit', '56bit', '128bit', or 'FIPS'.", ConfigPropNames.RdpSecurityEncryptionMethod); EncMethod = encMethodValues[str]; RdpVersion = TS_UD_SC_CORE_version_Values.V2; ValidateConfig(site.Assume); }