private void IsMessageAnalyzerInstalled() { try { RegistryKey HKLM = Registry.LocalMachine; RegistryKey key = HKLM.OpenSubKey(@"SOFTWARE\Microsoft\MessageAnalyzer\Capabilities"); string appDesc = key.GetValue("ApplicationDescription").ToString(); string appName = key.GetValue("ApplicationName").ToString(); if (appDesc.Equals("Microsoft Message Analyzer") && appName.Equals("Microsoft Message Analyzer")) { DetectorUtil.WriteLog("Check MMA Installation successful.", false, LogStyle.StepPassed); } else { DetectorUtil.WriteLog( string.Format("Check MMA Installation failed: ApplicationDescription={0}, ApplicationName={1}.", appDesc, appName), false, LogStyle.StepFailed); } } catch (Exception e) { DetectorUtil.WriteLog("Check MMA Installation failed: Message Analyzer not properly installed!", false, LogStyle.StepFailed); throw new Exception(string.Format("Message Analyzer not properly installed: {0}", e.Message)); } }
private bool CheckSMBDNegotiate() { try { using (var client = new SMBDClient(DetectionInfo.ConnectionTimeout)) { var config = DetectionInfo.SMBDClientCapability; client.ConnectOverRDMA(DetectionInfo.DriverRdmaNICIPAddress, DetectionInfo.SUTRdmaNICIPAddress, DetectionInfo.SMBDPort, config.MaxReceiveSize); client.SMBDNegotiate( config.CreditsRequested, config.ReceiveCreditMax, config.PreferredSendSize, config.MaxReceiveSize, config.MaxFragmentedSize ); return(true); } } catch (Exception ex) { DetectorUtil.WriteLog(String.Format("CheckSMBDNegotiate threw exception: {0}", ex)); return(false); } }
public static bool VerifyLocalAccount(string machine, string username, string password, string stepname) { DetectorUtil.WriteLog( string.Format("{0}: {1}\n{2}$ Password: {3}", stepname, machine, username, password), true, LogStyle.Default); ConnectionOptions options = new ConnectionOptions(); options.Impersonation = System.Management.ImpersonationLevel.Impersonate; options.Username = username; options.Password = password; ManagementScope scope = new ManagementScope(@"\\" + machine + @"\root\cimv2", options); try { scope.Connect(); DetectorUtil.WriteLog(string.Format("{0} passed", stepname), true, LogStyle.StepPassed); //Query system for Operating System information ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_OperatingSystem"); ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query); } catch (Exception e) { DetectorUtil.WriteLog( string.Format("{0} failed: {1}", stepname, e.Message), true, LogStyle.StepFailed); return(false); } return(true); }
private string Pinghost(string hostname, string stepname) { Ping ping = new Ping(); IPAddress[] ipAddr = null; try { ipAddr = Dns.GetHostAddresses(hostname); } catch (SocketException e) { DetectorUtil.WriteLog(stepname + " failed!", false, LogStyle.StepFailed); throw new Exception(string.Format("Cannot resolve host name {0}.\r\n{1}", hostname, e.Message)); } try { ping.Send(ipAddr[0]); } catch (PingException e) { DetectorUtil.WriteLog(stepname + " failed!", false, LogStyle.StepFailed); throw new Exception(string.Format("Ping {0} error.\r\n{1}", hostname, e.Message)); } DetectorUtil.WriteLog(stepname + " successful.", false, LogStyle.StepPassed); return(ipAddr[0].ToString()); }
/// <summary> /// Check whether the credential of SUT is valid. /// </summary> /// <returns>true/false indicating valid/invalid.</returns> public bool GetOSVersion() { if (!DetectionInfo.IsWindowsImplementation) { DetectorUtil.WriteLog("Skip for non-Windows", false, LogStyle.StepSkipped); DetectionInfo.Platform = Platform.NonWindows; return(true); } DetectorUtil.WriteLog("Check the OS version..."); string[] error; var output = ExecutePowerShellCommand(@"..\etc\MS-SMBD\Scripts\GetRemoteOSVersion.ps1", out error); if (error != null) { foreach (var item in error) { DetectorUtil.WriteLog(item.ToString()); } } bool result = false; if (output.Length == 1) { try { var ret = ParseOSVersion(output[0]); if (ret != null) { if (MapOSVersion(ret)) { result = true; } } } catch { DetectorUtil.WriteLog("The format of return value is invalid!"); } } else { DetectorUtil.WriteLog(string.Format("Set platform to {0}.", DetectionInfo.Platform)); DetectorUtil.WriteLog("The format of return value is invalid!"); } if (result) { DetectorUtil.WriteLog("Finished", false, LogStyle.StepPassed); return(true); } else { DetectorUtil.WriteLog("Failed", false, LogStyle.StepFailed); return(false); } }
private IPAddress GetHostIP(string hostname) { try { foreach (IPAddress ip in Dns.GetHostAddresses(hostname)) { if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { DetectorUtil.WriteLog("Parse the host name or the ip address as: " + ip.ToString()); return(ip); } } } catch (Exception e) { DetectorUtil.WriteLog("Exception occured when parsing the host name or the ip address: " + e.Message); DetectorUtil.WriteLog("" + e.StackTrace); if (e.InnerException != null) { DetectorUtil.WriteLog("**" + e.InnerException.Message); DetectorUtil.WriteLog("**" + e.InnerException.StackTrace); } DetectorUtil.WriteLog("Failed", false, LogStyle.StepFailed); } return(null); }
public bool GetRemoteAdapters() { DetectorUtil.WriteLog("Get the remote adapters..."); bool result = false; var ipList = GetIPAdressOfSut(); // try all reachable SUT IP address foreach (var ip in ipList) { result = GetRemoteNetworkInterfaceInformation(ip); if (result) { break; } } if (result) { DetectorUtil.WriteLog("Finished", false, LogStyle.StepPassed); return(true); } else { DetectorUtil.WriteLog("Failed", false, LogStyle.StepFailed); return(false); } }
public bool CheckSmbDialect() { DetectorUtil.WriteLog("Check the supported SMB dialects of SUT..."); bool result = false; var dialects = new DialectRevision[] { DialectRevision.Smb30, DialectRevision.Smb302, DialectRevision.Smb311 }; var ipList = GetIPAdressOfSut(); // try all reachable SUT IP address foreach (var ip in ipList) { var supportedDialects = TryNegotiateDialects(ip, dialects); if (supportedDialects.Length > 0) { DetectionInfo.SupportedSmbDialects = supportedDialects; DetectorUtil.WriteLog(String.Format("SMB dialects supported by SUT: {0}", String.Join(",", supportedDialects))); result = true; break; } } if (result) { DetectorUtil.WriteLog("Finished", false, LogStyle.StepPassed); return(true); } else { DetectorUtil.WriteLog("Failed", false, LogStyle.StepFailed); return(false); } }
private bool CheckSMBDReadWrite(DialectRevision[] dialects, Channel_Values channel) { try { using (var client = new SMBDClient(DetectionInfo.ConnectionTimeout)) { var config = DetectionInfo.SMBDClientCapability; RdmaAdapterInfo rdmaAdapterInfo; client.ConnectOverRDMA(DetectionInfo.DriverRdmaNICIPAddress, DetectionInfo.SUTRdmaNICIPAddress, DetectionInfo.SMBDPort, config.MaxReceiveSize, out rdmaAdapterInfo); client.SMBDNegotiate( config.CreditsRequested, config.ReceiveCreditMax, config.PreferredSendSize, config.MaxReceiveSize, config.MaxFragmentedSize ); client.Smb2Negotiate(dialects); client.Smb2SessionSetup(DetectionInfo.Authentication, DetectionInfo.DomainName, DetectionInfo.SUTName, DetectionInfo.UserName, DetectionInfo.Password); string path = Smb2Utility.GetUncPath(DetectionInfo.SUTName, DetectionInfo.ShareFolder); uint treeId; client.Smb2TreeConnect(path, out treeId); FILEID fileId; client.CreateRandomFile(treeId, out fileId); uint length = client.CalculateSMBDMaxReadWriteSize(); var buffer = Smb2Utility.CreateRandomByteArray((int)length); client.SMBDWrite(treeId, fileId, channel, buffer, 0, DetectionInfo.Endian); var readBuffer = new byte[length]; client.SMBDRead(treeId, fileId, channel, out readBuffer, 0, length, DetectionInfo.Endian); if (!Enumerable.SequenceEqual(buffer, readBuffer)) { throw new InvalidOperationException("The data is inconsistent for write and read!"); } return(true); } } catch (Exception ex) { DetectorUtil.WriteLog(String.Format("CheckSMBDReadWrite threw exception: {0}", ex)); return(false); } }
private bool ProcessLicenseSequence(Configs config, TimeSpan timeout) { try { TS_LICENSE_PDU licensePdu = rdpeleClient.ExpectPdu(timeout); if (licensePdu.preamble.bMsgType == bMsgType_Values.ERROR_ALERT) { // If the target machine is a personal terminal server, whether the client sends the license or not, // the server always sends a license error message with the error code STATUS_VALID_CLIENT and the state transition code ST_NO_TRANSITION. if (dwErrorCode_Values.STATUS_VALID_CLIENT != licensePdu.LicensingMessage.LicenseError.Value.dwErrorCode) { DetectorUtil.WriteLog($"A license error message with the error code STATUS_VALID_CLIENT should be received, but the real error code is {licensePdu.LicensingMessage.LicenseError.Value.dwErrorCode}."); } return(false); } DetectorUtil.WriteLog("Start RDP license procedure"); if (bMsgType_Values.LICENSE_REQUEST != licensePdu.preamble.bMsgType) { DetectorUtil.WriteLog($"A LICENSE_REQUEST message should be received from server, but the real message type is {licensePdu.preamble.bMsgType}"); } rdpeleClient.SendClientNewLicenseRequest( KeyExchangeAlg.KEY_EXCHANGE_ALG_RSA, (uint)Client_OS_ID.CLIENT_OS_ID_WINNT_POST_52 | (uint)Client_Image_ID.CLIENT_IMAGE_ID_MICROSOFT, config.ServerUserName, config.ClientName); licensePdu = rdpeleClient.ExpectPdu(timeout); if (bMsgType_Values.PLATFORM_CHALLENGE != licensePdu.preamble.bMsgType) { DetectorUtil.WriteLog($"A PLATFORM_CHALLENGE message should be received from server, but the real message type is {licensePdu.preamble.bMsgType}"); return(false); } Random random = new Random(); CLIENT_HARDWARE_ID clientHWID = new CLIENT_HARDWARE_ID { PlatformId = (uint)Client_OS_ID.CLIENT_OS_ID_WINNT_POST_52 | (uint)Client_Image_ID.CLIENT_IMAGE_ID_MICROSOFT, Data1 = (uint)random.Next(), Data2 = (uint)random.Next(), Data3 = (uint)random.Next(), Data4 = (uint)random.Next() }; rdpeleClient.SendClientPlatformChallengeResponse(clientHWID); licensePdu = rdpeleClient.ExpectPdu(timeout); if (bMsgType_Values.NEW_LICENSE != licensePdu.preamble.bMsgType) { DetectorUtil.WriteLog($"A NEW_LICENSE message should be received from server, but the real message type is {licensePdu.preamble.bMsgType}"); return(false); } DetectorUtil.WriteLog("End RDP license procedure"); return(true); } catch (Exception e) { DetectorUtil.WriteLog("RDP license procedure throws exception: " + e.Message); return(false); } }
private void CheckSupportedProtocols() { // Notify the UI for detecting protocol supported finished DetectorUtil.WriteLog("Check specified protocols support..."); bool serverSupportUDPFECR = false; bool serverSupportUDPFECL = false; if (connectResponsePdu.mcsCrsp.gccPdu.serverMultitransportChannelData != null) { if (connectResponsePdu.mcsCrsp.gccPdu.serverMultitransportChannelData.flags.HasFlag(MULTITRANSPORT_TYPE_FLAGS.TRANSPORTTYPE_UDPFECR)) { serverSupportUDPFECR = true; } if (connectResponsePdu.mcsCrsp.gccPdu.serverMultitransportChannelData.flags.HasFlag(MULTITRANSPORT_TYPE_FLAGS.TRANSPORTTYPE_UDPFECL)) { serverSupportUDPFECL = true; } } detectInfo.IsSupportRDPEMT = serverSupportUDPFECR || serverSupportUDPFECL; if (detectInfo.IsSupportRDPEMT) { DetectorUtil.WriteLog("Detect RDPEMT supported"); } else { DetectorUtil.WriteLog("Detect RDPEMT unsupported"); } rdpedycClient = new RdpedycClient(rdpbcgrClient, rdpbcgrClient.Context, false); try { DynamicVirtualChannel channel = rdpedycClient.ExpectChannel(timeout, DYVNAME_RDPEDYC, DynamicVC_TransportType.RDP_TCP); if (channel != null) { detectInfo.IsSupportRDPEDYC = true; } rdpedycClient.CloseChannel((ushort)channel.ChannelId); } catch { detectInfo.IsSupportRDPEDYC = false; } if (detectInfo.IsSupportRDPEDYC) { DetectorUtil.WriteLog("Detect RDPEDYC supported"); } else { DetectorUtil.WriteLog("Detect RDPEDYC unsupported"); } DetectorUtil.WriteLog("Passed", false, LogStyle.StepPassed); }
private void CheckSupportedFeatures() { DetectorUtil.WriteLog("Check specified features support..."); detectInfo.IsSupportAutoReconnect = SupportAutoReconnect(); detectInfo.IsSupportFastPathInput = SupportFastPathInput(); // Notify the UI for detecting feature supported finished DetectorUtil.WriteLog("Passed", false, LogStyle.StepPassed); }
/// <summary> /// Get the list of properties that will be hidden in the configure page. /// </summary> /// <param name="rules">Selected rules.</param> /// <returns>The list of properties which will not be shown in the configure page.</returns> public List <string> GetHiddenProperties(List <CaseSelectRule> rules) { List <string> hiddenPropertiesList = new List <string>(); // Hidden the following properties in RDP_ServerTestSuite.ptfconfig: // 1. TestName // 2. ProtocolName // 3. Version hiddenPropertiesList.AddRange(DetectorUtil.GetPropertiesByFile("RDP_ServerTestSuite.ptfconfig")); return(hiddenPropertiesList); }
private bool PingSUT() { DetectorUtil.WriteLog("Ping Target SUT..."); Ping pingSender = new Ping(); PingOptions options = new PingOptions(); // Use the default TtL value which is 128, // but change the fragmentation behavior. options.DontFragment = true; // Create a buffer of 32 bytes of data to be transmitted. string data = "0123456789ABCDEF0123456789ABCDEF"; byte[] buffer = Encoding.ASCII.GetBytes(data); IPAddress address; if (!IPAddress.TryParse(config.ServerName, out address)) { address = Dns.GetHostEntry(config.ServerName).AddressList.First(); } int timeout = 5000; bool result = false; List <PingReply> replies = new List <PingReply>(); try { for (int i = 0; i < 4; i++) { replies.Add(pingSender.Send(address, timeout, buffer, options)); } } catch (Exception ex) { DetectorUtil.WriteLog(String.Format("PingSUT() threw exception: {0}", ex)); return(false); } foreach (var reply in replies) { result |= (reply.Status == IPStatus.Success); } if (result) { DetectorUtil.WriteLog("Passed", false, LogStyle.StepPassed); return(true); } else { DetectorUtil.WriteLog("Failed", false, LogStyle.StepFailed); DetectorUtil.WriteLog("Target SUT has no response."); return(false); } }
/// <summary> /// Establish a RDP connection to detect RDP feature /// </summary> /// <returns></returns> public bool DetectRDPFeature() { // Establish a RDP connection with RDP client try { DetectorUtil.WriteLog("Establish RDP connection with SUT..."); StartRDPListening(); triggerClientRDPConnect(detectInfo.TriggerMethod); EstablishRDPConnection(); // Set RDP Version SetRdpVersion(); CheckSupportedFeatures(); CheckSupportedProtocols(); } catch (Exception e) { DetectorUtil.WriteLog("Exception occured when establishing RDP connection: " + e.Message); DetectorUtil.WriteLog("" + e.StackTrace); if (e.InnerException != null) { DetectorUtil.WriteLog("**" + e.InnerException.Message); DetectorUtil.WriteLog("**" + e.InnerException.StackTrace); } DetectorUtil.WriteLog("Failed", false, LogStyle.StepFailed); return(false); } finally { // Trigger client to close the RDP connection TriggerClientDisconnectAll(detectInfo.TriggerMethod); if (this.rdpedycServer != null) { this.rdpedycServer.Dispose(); this.rdpedycServer = null; } if (this.rdpbcgrServerStack != null) { this.rdpbcgrServerStack.Dispose(); this.rdpbcgrServerStack = null; } } // Notify the UI for establishing RDP connection successfully. DetectorUtil.WriteLog("Passed", false, LogStyle.StepPassed); return(true); }
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"; } } }
/// <summary> /// Establish a RDP connection to detect RDP feature /// </summary> /// <returns>Return true if detection succeeded.</returns> public bool DetectRDPFeature(Configs config) { try { DetectorUtil.WriteLog("Establish RDP connection with SUT..."); Initialize(config); ConnectRDPServer(); bool status = EstablishRDPConnection( config, requestedProtocol, SVCNames, CompressionType.PACKET_COMPR_TYPE_NONE, false, true, false, false, false, true, true); if (!status) { DetectorUtil.WriteLog("Failed", false, LogStyle.StepFailed); return(false); } DetectorUtil.WriteLog("Passed", false, LogStyle.StepPassed); CheckSupportedFeatures(); CheckSupportedProtocols(); SetRdpVersion(config); } catch (Exception e) { DetectorUtil.WriteLog("Exception occured when establishing RDP connection: " + e.Message); DetectorUtil.WriteLog("" + e.StackTrace); if (e.InnerException != null) { DetectorUtil.WriteLog("**" + e.InnerException.Message); DetectorUtil.WriteLog("**" + e.InnerException.StackTrace); } DetectorUtil.WriteLog("Failed", false, LogStyle.StepFailed); return(false); } // Disconnect ClientInitiatedDisconnect(); Disconnect(); DetectorUtil.WriteLog("Passed", false, LogStyle.StepPassed); return(true); }
private IEnumerable <IPAddress> GetIPAdressOfSut() { try { var result = Dns.GetHostAddresses(DetectionInfo.SUTName).Where(ipAddress => ipAddress.AddressFamily == AddressFamily.InterNetwork); return(result); } catch (Exception ex) { DetectorUtil.WriteLog(String.Format("Cannot get SUT IP addresses: {0}.", ex)); return(new IPAddress[0]); } }
private void CheckSupportedProtocols() { DetectorUtil.WriteLog("Check specified protocols support..."); detectInfo.IsSupportRDPEFS = false; if (mscConnectionInitialPDU.mcsCi.gccPdu.clientNetworkData != null && mscConnectionInitialPDU.mcsCi.gccPdu.clientNetworkData.channelCount > 0) { List <CHANNEL_DEF> channels = mscConnectionInitialPDU.mcsCi.gccPdu.clientNetworkData.channelDefArray; foreach (CHANNEL_DEF channel in channels) { if (channel.name.ToUpper().Contains("RDPDR")) { detectInfo.IsSupportRDPEFS = true; break; } } } // Create Dynamic Virtual Channels to detect protocols supported detectInfo.IsSupportRDPEDISP = (CreateEDYCChannel(RDPDetector.RdpedispChannelName)); if (detectInfo.IsSupportRDPEGFX != null && detectInfo.IsSupportRDPEGFX.Value) { detectInfo.IsSupportRDPEGFX = CreateEDYCChannel(RDPDetector.RdpegfxChannelName); } detectInfo.IsSupportRDPEI = (CreateEDYCChannel(RDPDetector.rdpeiChannelName)); detectInfo.IsSupportRDPEUSB = (CreateEDYCChannel(RDPDetector.RdpeusbChannelName)); detectInfo.IsSupportRDPEVOR = (CreateEDYCChannel(RDPDetector.RdpegtChannelName) && CreateEDYCChannel(RDPDetector.RdpevorControlChannelName) && CreateEDYCChannel(RDPDetector.RdpevorDataChannelName)); if (detectInfo.IsSupportStaticVirtualChannel != null && detectInfo.IsSupportStaticVirtualChannel.Value && ((detectInfo.IsSupportTransportTypeUdpFECR != null && detectInfo.IsSupportTransportTypeUdpFECR.Value) || (detectInfo.IsSupportTransportTypeUdpFECL != null && detectInfo.IsSupportTransportTypeUdpFECL.Value))) { detectInfo.IsSupportRDPEMT = true; detectInfo.IsSupportRDPEUDP = true; } else { detectInfo.IsSupportRDPEMT = false; detectInfo.IsSupportRDPEUDP = false; } // Notify the UI for detecting protocol supported finished DetectorUtil.WriteLog("Passed", false, LogStyle.StepPassed); DetectorUtil.WriteLog("Check specified protocols support finished."); }
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 bool PingSUT() { DetectorUtil.WriteLog("Ping Target SUT..."); Ping pingSender = new Ping(); PingOptions options = new PingOptions(); // Use the default TtL value which is 128, // but change the fragmentation behavior. options.DontFragment = true; // Create a buffer of 32 bytes of data to be transmitted. string data = "0123456789ABCDEF0123456789ABCDEF"; byte[] buffer = Encoding.ASCII.GetBytes(data); int timeout = 5000; bool result = false; List <PingReply> replys = new List <PingReply>(); try { for (int i = 0; i < 4; i++) { replys.Add(pingSender.Send(config.ServerName, timeout, buffer, options)); } } catch { DetectorUtil.WriteLog("Error", false, LogStyle.Error); //return false; throw; } foreach (var reply in replys) { result |= (reply.Status == IPStatus.Success); } if (result) { DetectorUtil.WriteLog("Passed", false, LogStyle.StepPassed); return(true); } else { DetectorUtil.WriteLog("Failed", false, LogStyle.StepFailed); DetectorUtil.WriteLog("Taget SUT don't respond."); return(false); } }
public static bool VerifyCertExist(string filename, string stepname) { string path = FilePath(filename); if (File.Exists(path)) { DetectorUtil.WriteLog(stepname + " success", true, LogStyle.StepPassed); return(true); } else { DetectorUtil.WriteLog(stepname + " failed", false, LogStyle.StepFailed); return(false); } }
public bool ConnectToShare(string serverIp, string clientIp) { try { using (var client = new SMBDClient(DetectionInfo.ConnectionTimeout)) { client.Connect(IPAddress.Parse(serverIp), IPAddress.Parse(clientIp)); client.Smb2Negotiate(DetectionInfo.SupportedSmbDialects); client.Smb2SessionSetup(DetectionInfo.Authentication, DetectionInfo.DomainName, DetectionInfo.SUTName, DetectionInfo.UserName, DetectionInfo.Password); string path = Smb2Utility.GetUncPath(DetectionInfo.SUTName, DetectionInfo.ShareFolder); uint treeId; client.Smb2TreeConnect(path, out treeId); FILEID fileId; client.CreateRandomFile(treeId, out fileId); uint fileLength = client.CalculateSmb2MaxReadWriteSize(); var buffer = Smb2Utility.CreateRandomByteArray((int)fileLength); client.Smb2Write(treeId, fileId, 0, buffer); byte[] output; client.Smb2Read(treeId, fileId, 0, fileLength, out output); bool result = Enumerable.SequenceEqual(buffer, output); if (!result) { DetectorUtil.WriteLog("The content of read and write is inconsistent."); } return(result); } } catch (Exception ex) { DetectorUtil.WriteLog(String.Format("ConnectToShare threw exception: {0}", ex)); return(false); } }
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 TcpTcpConnection(string ipAddr, int port) { try { using (TcpClient c = new TcpClient()) { c.Connect(ipAddr, port); DetectorUtil.WriteLog(string.Format("TCP connection to {0}:{1} successful.", ipAddr, port), false, LogStyle.StepPassed); } } catch (Exception e) { DetectorUtil.WriteLog(string.Format("TCP connection to {0}:{1} failed!", ipAddr, port), false, LogStyle.StepFailed); throw new Exception(string.Format("TCP connection to {0}:{1} failed: {2}", ipAddr, port, e.Message)); } }
public bool RunDetection() { // set config if properties changed config.FullDomainName = properties["Full Qualified Domain Name"]; config.DomainAdminUsername = properties["Domain Administrator Username"]; config.DomainAdminPwd = properties["Domain Administrator Password"]; config.DomainNC = "DC=" + config.FullDomainName.Replace(".", ",DC="); config.PartitionsNC = "CN=Partitions,CN=Configuration,DC=" + config.FullDomainName.Replace(".", ",DC="); config.PDCOperatingSystem = properties["Primary DC Operating System"]; config.PDCComputerName = properties["Primary DC Computer Name"]; config.PDCIP = properties["Primary DC IP Address"]; config.ClientOperatingSystem = properties["Client Computer Operating System"]; config.ClientOSVersion = properties["Client Operating System Version"]; config.ClientComputerName = properties["Client Computer Name"]; config.ClientIP = properties["Client IP Address"]; config.ClientAdminUsername = properties["Client Administrator Username"]; config.ClientAdminPwd = properties["Client Administrator Password"]; config.TriggerDisabled = properties["Enable Offline Capture Testing"]; config.LocalCapFilePath = properties["Capture File Path"]; // run detection and set config if any mis-settings on IP according to the computer name resolve result IsMessageAnalyzerInstalled(); if (bool.Parse(config.TriggerDisabled)) { DetectorUtil.WriteLog("Offline Capture Testing Enabled, Ping Domain Skipped.", false, LogStyle.StepSkipped); DetectorUtil.WriteLog("Offline Capture Testing Enabled, Ping Primary Domain Controller Skipped.", false, LogStyle.StepSkipped); DetectorUtil.WriteLog("Offline Capture Testing Enabled, Tcp Connection Check Skipped.", false, LogStyle.StepSkipped); DetectorUtil.WriteLog("Offline Capture Testing Enabled, Ping Client Computer Skipped.", false, LogStyle.StepSkipped); VerifyCapturePath(config.LocalCapFilePath); } else { Pinghost(config.FullDomainName, "Ping Domain"); config.PDCIP = Pinghost(config.PDCComputerName, "Ping Primary Domain Controller"); TcpTcpConnection(config.PDCIP, 389); config.ClientIP = Pinghost(config.ClientComputerName, "Ping Client Computer"); DetectorUtil.WriteLog(string.Format("Offline Capture Testing Disabled, Verify Capture Path Skipped."), false, LogStyle.StepSkipped); } return(true); }
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") }, }); }
/// <summary> /// Write a log message. /// </summary> /// <param name="level">Log level. Will throw exception when using LogLevel.Error</param> /// <param name="msg">Log message.</param> /// <param name="startNewLine">Start a new line before this message when to UI. True by default.</param> /// <param name="style">The style of the message</param> public void AddLog(LogLevel level, string msg, bool startNewLine = true, LogStyle style = LogStyle.Default) { switch (level) { case LogLevel.Information: case LogLevel.Warning: DetectorUtil.WriteLog(msg, startNewLine, style); break; case LogLevel.Error: AddLog(LogLevel.Information, msg); // PTM will handle the exception and pop up a dialog box to user. throw new Exception(msg); default: break; } }
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); } } }
private void VerifyCapturePath(string path) { try { if (Directory.Exists(path)) { DetectorUtil.WriteLog(string.Format("Verify Offline Capture Path: {0} successful! The path exists.", path), false, LogStyle.StepPassed); } else { DetectorUtil.WriteLog(string.Format("Verify Offline Capture Path: {0} failed! The Path doesn't exist.", path), false, LogStyle.StepFailed); } } catch (Exception e) { DetectorUtil.WriteLog(string.Format("Verify Offline Capture Path: {0} failed!", path), false, LogStyle.StepFailed); throw new Exception(string.Format("Verify Offline Capture Path: {0} failed: {1}", path, e.Message)); } }