private void SetRdpVersion() { detectInfo.RdpVersion = DetectorUtil.GetPropertyValue("Version"); if (mscConnectionInitialPDU.mcsCi.gccPdu.clientCoreData != null) { var rdpVersion = mscConnectionInitialPDU.mcsCi.gccPdu.clientCoreData.version; if (rdpVersion == TS_UD_CS_CORE_version_Values.V1) { detectInfo.RdpVersion = "4.0"; } else if (rdpVersion == TS_UD_CS_CORE_version_Values.V2) { detectInfo.RdpVersion = "8.1"; } else if (rdpVersion == TS_UD_CS_CORE_version_Values.V3) { detectInfo.RdpVersion = "10.0"; } else if (rdpVersion == TS_UD_CS_CORE_version_Values.V4) { detectInfo.RdpVersion = "10.1"; } else if (rdpVersion == TS_UD_CS_CORE_version_Values.V5) { detectInfo.RdpVersion = "10.2"; } else if (rdpVersion == TS_UD_CS_CORE_version_Values.V6) { detectInfo.RdpVersion = "10.3"; } else if (rdpVersion == TS_UD_CS_CORE_version_Values.V7) { detectInfo.RdpVersion = "10.4"; } else if (rdpVersion == TS_UD_CS_CORE_version_Values.V8) { detectInfo.RdpVersion = "10.5"; } else if (rdpVersion == TS_UD_CS_CORE_version_Values.V9) { detectInfo.RdpVersion = "10.6"; } else if (rdpVersion == TS_UD_CS_CORE_version_Values.V10) { detectInfo.RdpVersion = "10.7"; } else if (rdpVersion == TS_UD_CS_CORE_version_Values.V11) { detectInfo.RdpVersion = "10.8"; } } }
public void LoadDefaultValues() { Type cfg = typeof(Configs); foreach (var p in cfg.GetProperties()) { string name = p.Name.Replace("__", "."); var val = DetectorUtil.GetPropertyValue(name); if (val != null) { p.SetValue(this, val, null); } } }
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 Dictionary <string, string> GetTestSiteConfigureValues() { return(new Dictionary <string, string>() { { "PtfProp_SUTName", detectInfo.SUTName }, { "PtfProp_SUTUserName", detectInfo.UserNameInTC }, { "PtfProp_SUTUserPassword", detectInfo.UserPwdInTC }, { "PtfProp_RDPConnectWithNegotiationApproachFullScreen_Task", DetectorUtil.GetPropertyValue("RDPConnectWithNegotiationApproachFullScreen_Task") }, { "PtfProp_RDPConnectWithDirectCredSSPFullScreen_Task", DetectorUtil.GetPropertyValue("RDPConnectWithDirectCredSSPFullScreen_Task") }, { "PtfProp_RDPConnectWithDirectCredSSP_Task", DetectorUtil.GetPropertyValue("RDPConnectWithDirectCredSSP_Task") }, { "PtfProp_RDPConnectWithNegotiationApproach_Task", DetectorUtil.GetPropertyValue("RDPConnectWithNegotiationApproach_Task") }, { "PtfProp_TriggerClientDisconnectAll_Task", DetectorUtil.GetPropertyValue("TriggerClientDisconnectAll_Task") }, { "PtfProp_TriggerClientAutoReconnect_Task", DetectorUtil.GetPropertyValue("TriggerClientAutoReconnect_Task") }, { "PtfProp_SUTSystemDrive", DetectorUtil.GetPropertyValue("SUTSystemDrive") }, { "PtfProp_TriggerInputEvents_Task", DetectorUtil.GetPropertyValue("TriggerInputEvents_Task") }, }); }
public void LoadDefaultValues() { Type cfg = typeof(PtfConfig); foreach (var p in cfg.GetProperties()) { PtfConfigAttribute configAttribute = p.GetCustomAttributes(typeof(PtfConfigAttribute), false).FirstOrDefault() as PtfConfigAttribute; if (configAttribute == null) { continue; } var val = DetectorUtil.GetPropertyValue(configAttribute.Name); if (val != null) { p.SetValue(this, val, null); } } }
public void LoadDefaultValues() { Type cfg = typeof(Configs); foreach (var p in cfg.GetProperties()) { string name = ""; if (String.Compare(p.Name.ToLower(), "tlsversion") == 0) { name = "RDP.Security.TLS.Version"; } else if (String.Compare(p.Name.ToLower(), "securityprotocol") == 0) { name = "RDP.Security.Protocol"; } else if (String.Compare(p.Name.ToLower(), "negotiation") == 0) { name = "RDP.Security.Negotiation"; } else if (String.Compare(p.Name.ToLower(), "rdpelesupported") == 0) { name = "RDPELESupported"; } else if (String.Compare(p.Name.ToLower(), "rdpedycsupported") == 0) { name = "RDPEDYCSupported"; } else { name = "RDP." + p.Name.Replace("__", "."); } var val = DetectorUtil.GetPropertyValue(name); if (val != null) { p.SetValue(this, val, null); } } }
private bool LoadConfig() { if (!IPAddress.TryParse(clientName, out clientAddress)) { clientAddress = Dns.GetHostEntry(clientName).AddressList.First(); } requestedProtocol = requestedProtocols_Values.PROTOCOL_RDP_FLAG; encryptedProtocol = EncryptedProtocol.Rdp; string strWaitTime = DetectorUtil.GetPropertyValue("WaitTime"); if (strWaitTime != null) { int waitTime = Int32.Parse(strWaitTime); timeout = new TimeSpan(0, 0, waitTime); } else { timeout = new TimeSpan(0, 0, 10); } return(true); }
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."); }
/// <summary> /// Execute a powershell script file /// </summary> /// <param name="scriptFile"></param> /// <returns></returns> private int ExecutePowerShellCommand(string scriptFile) { string scriptPath = SUTControlScriptLocation + scriptFile; Assembly sysMgmtAutoAssembly = null; BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod; try { sysMgmtAutoAssembly = Assembly.Load(SystemManagementAutomationAssemblyNameV3); } catch { } // If loading System.Management.Automation, Version=3.0.0.0 failed, try Version=1.0.0.0 if (sysMgmtAutoAssembly == null) { try { sysMgmtAutoAssembly = Assembly.Load(SystemManagementAutomationAssemblyNameV1); } catch { throw new InvalidOperationException("Can not find system management automation assembly from GAC." + "Please make sure your PowerShell installation is valid." + "Or you need to reinstall PowerShell."); } } Type runspaceConfigurationType = sysMgmtAutoAssembly.GetType("System.Management.Automation.Runspaces.RunspaceConfiguration"); object runspaceConfigurationInstance = runspaceConfigurationType.InvokeMember("Create", BindingFlags.InvokeMethod, null, null, null); Type runspaceFactoryType = sysMgmtAutoAssembly.GetType("System.Management.Automation.Runspaces.RunspaceFactory"); Type runspaceType = sysMgmtAutoAssembly.GetType("System.Management.Automation.Runspaces.Runspace"); object runspaceInstance = runspaceFactoryType.InvokeMember("CreateRunspace", BindingFlags.InvokeMethod, null, null, new object[] { runspaceConfigurationInstance }); runspaceType.InvokeMember("Open", flag, null, runspaceInstance, null); Type sessionStateProxyType = sysMgmtAutoAssembly.GetType("System.Management.Automation.Runspaces.SessionStateProxy"); object proxyInstance = runspaceType.InvokeMember( "SessionStateProxy", BindingFlags.GetProperty, null, runspaceInstance, null); // Set Variables MethodInfo methodSetVariable = sessionStateProxyType.GetMethod( "SetVariable", BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod, null, new Type[] { typeof(string), typeof(object) }, null ); methodSetVariable.Invoke(proxyInstance, new object[] { "PtfProp_SUTName", detectInfo.SUTName }); methodSetVariable.Invoke(proxyInstance, new object[] { "PtfProp_SUTUserName", detectInfo.UserNameInTC }); methodSetVariable.Invoke(proxyInstance, new object[] { "PtfProp_SUTUserPassword", detectInfo.UserPwdInTC }); methodSetVariable.Invoke(proxyInstance, new object[] { "PtfProp_RDPConnectWithNegotiationAppoachFullScreen_Task", DetectorUtil.GetPropertyValue("RDPConnectWithNegotiationAppoachFullScreen_Task") }); methodSetVariable.Invoke(proxyInstance, new object[] { "PtfProp_RDPConnectWithDrectCredSSPFullScreen_Task", DetectorUtil.GetPropertyValue("RDPConnectWithDrectCredSSPFullScreen_Task") }); methodSetVariable.Invoke(proxyInstance, new object[] { "PtfProp_RDPConnectWithDrectCredSSP_Task", DetectorUtil.GetPropertyValue("RDPConnectWithDrectCredSSP_Task") }); methodSetVariable.Invoke(proxyInstance, new object[] { "PtfProp_RDPConnectWithDrectTLS_Task", DetectorUtil.GetPropertyValue("RDPConnectWithDrectTLS_Task") }); methodSetVariable.Invoke(proxyInstance, new object[] { "PtfProp_RDPConnectWithDrectTLSFullScreen_Task", DetectorUtil.GetPropertyValue("RDPConnectWithDrectTLSFullScreen_Task") }); methodSetVariable.Invoke(proxyInstance, new object[] { "PtfProp_RDPConnectWithNegotiationApproach_Task", DetectorUtil.GetPropertyValue("RDPConnectWithNegotiationApproach_Task") }); methodSetVariable.Invoke(proxyInstance, new object[] { "PtfProp_TriggerClientDisconnectAll_Task", DetectorUtil.GetPropertyValue("TriggerClientDisconnectAll_Task") }); methodSetVariable.Invoke(proxyInstance, new object[] { "PtfProp_TriggerClientAutoReconnect_Task", DetectorUtil.GetPropertyValue("TriggerClientAutoReconnect_Task") }); methodSetVariable.Invoke(proxyInstance, new object[] { "PtfProp_SUTSystemDrive", DetectorUtil.GetPropertyValue("SUTSystemDrive") }); methodSetVariable.Invoke(proxyInstance, new object[] { "PtfProp_TriggerInputEvents_Task", DetectorUtil.GetPropertyValue("TriggerInputEvents_Task") }); Type pipelineType = sysMgmtAutoAssembly.GetType("System.Management.Automation.Runspaces.Pipeline"); object pipelineInstance = runspaceType.InvokeMember( "CreatePipeline", flag, null, runspaceInstance, null); Type RunspaceInvokeType = sysMgmtAutoAssembly.GetType("System.Management.Automation.RunspaceInvoke"); object scriptInvoker = Activator.CreateInstance(RunspaceInvokeType); string baseDirectory = AppDomain.CurrentDomain.BaseDirectory; RunspaceInvokeType.InvokeMember("Invoke", flag, null, scriptInvoker, new object[] { "Set-ExecutionPolicy Unrestricted" }); object CommandCollectionInstance = pipelineType.InvokeMember("Commands", BindingFlags.GetProperty, null, pipelineInstance, null); Type CommandCollectionType = sysMgmtAutoAssembly.GetType("System.Management.Automation.Runspaces.CommandCollection"); CommandCollectionType.InvokeMember( "AddScript", flag, null, CommandCollectionInstance, new object[] { "cd " + SUTControlScriptLocation }); Type CommandType = sysMgmtAutoAssembly.GetType("System.Management.Automation.Runspaces.Command"); object myCommand = Activator.CreateInstance(CommandType, scriptPath); CommandCollectionType.InvokeMember( "Add", flag, null, CommandCollectionInstance, new object[] { myCommand }); pipelineType.InvokeMember("Invoke", flag, null, pipelineInstance, null); runspaceType.InvokeMember("Close", flag, null, runspaceInstance, null); return(0); }
private bool LoadConfig() { if (!IPAddress.TryParse(clientName, out clientAddress)) { clientAddress = Dns.GetHostEntry(clientName).AddressList.First(); } bool isNegotiationBased = true; string negotiation = DetectorUtil.GetPropertyValue("RDP.Security.Negotiation"); if (negotiation.Equals("true", StringComparison.CurrentCultureIgnoreCase)) { isNegotiationBased = true; } else if (negotiation.Equals("false", StringComparison.CurrentCultureIgnoreCase)) { isNegotiationBased = false; } else { throw new Exception( String.Format("The property value \"{0}\" is invalid or not present in RDP.Security.Negotiation in ptfconfig", negotiation)); } string protocol = DetectorUtil.GetPropertyValue("RDP.Security.Protocol"); if (protocol.Equals("TLS", StringComparison.CurrentCultureIgnoreCase)) { requestedProtocol = requestedProtocols_Values.PROTOCOL_SSL_FLAG; if (!isNegotiationBased) { throw new Exception( String.Format("When TLS is used as the security protocol, RDP.Security.Negotiation must be true;" + "actually RDP.Security.Negotiation is set to \"{0}\".", negotiation)); } encryptedProtocol = EncryptedProtocol.NegotiationTls; } else if (protocol.Equals("CredSSP", StringComparison.CurrentCultureIgnoreCase)) { requestedProtocol = requestedProtocols_Values.PROTOCOL_HYBRID_FLAG; if (isNegotiationBased) { encryptedProtocol = EncryptedProtocol.NegotiationCredSsp; } else { encryptedProtocol = EncryptedProtocol.NegotiationTls; } } else if (protocol.Equals("RDP", StringComparison.CurrentCultureIgnoreCase)) { requestedProtocol = requestedProtocols_Values.PROTOCOL_RDP_FLAG; encryptedProtocol = EncryptedProtocol.Rdp; } else { throw new Exception( String.Format("The property value \"{0}\" is invalid or not present in RDP.Security.Protocol in ptfconfig", protocol)); } string strWaitTime = DetectorUtil.GetPropertyValue("WaitTime"); if (strWaitTime != null) { int waitTime = Int32.Parse(strWaitTime); timeout = new TimeSpan(0, 0, waitTime); } else { timeout = new TimeSpan(0, 0, 10); } return(true); }
/// <summary> /// Gets the prerequisites for auto-detection. /// </summary> /// <returns>A instance of Prerequisites class.</returns> public Prerequisites GetPrerequisites() { Prerequisites prerequisites = new Prerequisites(); prerequisites.Title = "Remote Desktop"; prerequisites.Summary = "Please input the below info to detect SUT."; Dictionary <string, List <string> > propertiesDic = new Dictionary <string, List <string> >(); //Retrieve values from *.ptfconfig file string sutName = DetectorUtil.GetPropertyValue("SUTName"); string userNameInTC = DetectorUtil.GetPropertyValue("SUTUserName"); string userPwdInTC = DetectorUtil.GetPropertyValue("SUTUserPassword"); string isWindowsImplementation = DetectorUtil.GetPropertyValue("IsWindowsImplementation"); string DropConnectionForInvalidRequest = isWindowsImplementation.ToUpper().Equals("TRUE") ? "true" : DetectorUtil.GetPropertyValue("DropConnectionForInvalidRequest"); // The value is always true for Windows implementation. List <string> sutNames = new List <string>(); List <string> userNamesInTC = new List <string>(); List <string> userPwdsInTC = new List <string>(); List <string> isWindowsImplementationList = new List <string>(); List <string> dropConnectionForInvalidRequestList = new List <string>(); if (string.IsNullOrWhiteSpace(sutName) || string.IsNullOrWhiteSpace(userNameInTC) || string.IsNullOrWhiteSpace(userPwdInTC) || string.IsNullOrWhiteSpace(isWindowsImplementation)) { sutNames.Add("SUT01"); userNamesInTC.Add("administrator"); userPwdsInTC.Add("Password01!"); isWindowsImplementationList.Add("true"); isWindowsImplementationList.Add("false"); } else { sutNames.Add(sutName); userNamesInTC.Add(userNameInTC); userPwdsInTC.Add(userPwdInTC); isWindowsImplementationList.Add(isWindowsImplementation); if (isWindowsImplementation.ToUpper().Equals("TRUE")) { isWindowsImplementationList.Add("false"); } else { isWindowsImplementationList.Add("true"); } } dropConnectionForInvalidRequestList.Add("true"); dropConnectionForInvalidRequestList.Add("false"); propertiesDic.Add(tcComputerNameTitle, sutNames); propertiesDic.Add(isWindowsImplementationTitle, isWindowsImplementationList); propertiesDic.Add(dropConnectionForInvalidRequestTitle, dropConnectionForInvalidRequestList); propertiesDic.Add(triggerMethodTitle, new List <string>() { "Powershell", "Managed", "Interactive" }); propertiesDic.Add(userNameInTCTitle, userNamesInTC); propertiesDic.Add(userPwdInTCTitle, userPwdsInTC); propertiesDic.Add(agentPortTitle, new List <string>() { "4488" }); prerequisites.Properties = propertiesDic; return(prerequisites); }
/// <summary> /// Gets the prerequisites for auto-detection. /// </summary> /// <returns>A instance of Prerequisites class.</returns> public Prerequisites GetPrerequisites() { Prerequisites prerequisites = new Prerequisites(); prerequisites.Title = "Remote Desktop"; prerequisites.Summary = "Please input the below info to detect SUT."; Dictionary <string, List <string> > propertiesDic = new Dictionary <string, List <string> >(); //Retrieve values from *.ptfconfig file string sutName = DetectorUtil.GetPropertyValue(propSutName); string userNameInTC = DetectorUtil.GetPropertyValue(propSUTUserName); string userPwdInTC = DetectorUtil.GetPropertyValue(propSUTUserPassword); string rdpServerPort = DetectorUtil.GetPropertyValue(propRDPServerPort); //The RDP proxy IP, which should be set when a proxy is used. //Leave it blank if there's no proxy in the env string proxyIP = DetectorUtil.GetPropertyValue(propProxyIP); string isWindowsImplementation = DetectorUtil.GetPropertyValue(propIsWindowsImplementation); string DropConnectionForInvalidRequest = isWindowsImplementation.ToUpper().Equals("TRUE") ? "true" : DetectorUtil.GetPropertyValue(propDropConnectionForInvalidRequest); // The value is always true for Windows implementation. List <string> sutNames = new List <string>(); List <string> userNamesInTC = new List <string>(); List <string> userPwdsInTC = new List <string>(); List <string> proxyIPs = new List <string>(); List <string> isWindowsImplementationList = new List <string>(); List <string> dropConnectionForInvalidRequestList = new List <string>(); if (string.IsNullOrWhiteSpace(sutName) || string.IsNullOrWhiteSpace(userNameInTC) || string.IsNullOrWhiteSpace(userPwdInTC) || string.IsNullOrWhiteSpace(isWindowsImplementation)) { sutNames.Add("SUT01"); userNamesInTC.Add("administrator"); userPwdsInTC.Add("Password01!"); isWindowsImplementationList.Add("true"); isWindowsImplementationList.Add("false"); } else { sutNames.Add(sutName); userNamesInTC.Add(userNameInTC); userPwdsInTC.Add(userPwdInTC); isWindowsImplementationList.Add(isWindowsImplementation); if (isWindowsImplementation.ToUpper().Equals("TRUE")) { isWindowsImplementationList.Add("false"); } else { isWindowsImplementationList.Add("true"); } } proxyIPs.Add(proxyIP); dropConnectionForInvalidRequestList.Add("true"); dropConnectionForInvalidRequestList.Add("false"); propertiesDic.Add(tcComputerNameTitle, sutNames); propertiesDic.Add(proxyIPTitle, proxyIPs); propertiesDic.Add(isWindowsImplementationTitle, isWindowsImplementationList); propertiesDic.Add(dropConnectionForInvalidRequestTitle, dropConnectionForInvalidRequestList); propertiesDic.Add(triggerMethodTitle, new List <string>() { "Powershell", "Managed", "Interactive" }); propertiesDic.Add(userNameInTCTitle, userNamesInTC); propertiesDic.Add(userPwdInTCTitle, userPwdsInTC); propertiesDic.Add(agentPortTitle, new List <string>() { "4488" }); propertiesDic.Add(rdpServerPortTitle, new List <string>() { string.IsNullOrWhiteSpace(rdpServerPort) ? "3389" : rdpServerPort }); prerequisites.Properties = propertiesDic; return(prerequisites); }