コード例 #1
0
        /// <summary>
        /// Run auto detection properly.
        /// </summary>
        /// <returns>Return true if the function succeeded.</returns>
        public bool RunDetection(DetectContext context)
        {
            logWriter.ApplyDetectContext(context);

            try
            {
                if (context.Token.IsCancellationRequested)
                {
                    return(false);
                }

                logWriter.AddLog(DetectLogLevel.Information, "Detect Client HostName...");

                // set config if properties changed
                config.ServerName   = properties[RDPValueDetector.ServerName];
                config.ServerDomain = properties[RDPValueDetector.ServerDomain];
                if (config.ServerDomain != null && config.ServerDomain.Length == 0)
                {
                    config.ServerDomain = config.ServerName;
                }
                config.ServerPort         = properties[RDPValueDetector.ServerPort];
                config.ServerUserName     = properties[RDPValueDetector.ServerUserName];
                config.ServerUserPassword = properties[RDPValueDetector.ServerUserPassword];
                config.ClientName         = Dns.GetHostName();
                logWriter.AddLog(DetectLogLevel.Warning, "Finished", false, LogStyle.StepPassed);

                if (context.Token.IsCancellationRequested)
                {
                    return(false);
                }

                if (!DetectSUTIPAddress())
                {
                    return(false);
                }

                using (var detector = new RDPDetector(detectionInfo, logWriter))
                {
                    if (!detector.DetectRDPFeature(config))
                    {
                        return(false);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                logWriter.AddLog(DetectLogLevel.Warning, "Failed", false, LogStyle.StepFailed);
                logWriter.AddLog(DetectLogLevel.Information, String.Format("RunDetection() threw exception: {0}", ex));
                logWriter.AddLog(DetectLogLevel.Information, ex.StackTrace);
                return(false);
            }
        }
コード例 #2
0
        /// <summary>
        /// Runs property autodetection.
        /// </summary>
        /// <returns>Return true if the function is succeeded.</returns>
        public bool RunDetection(DetectContext context)
        {
            logWriter.ApplyDetectContext(context);
            try
            {
                if (context.Token.IsCancellationRequested)
                {
                    return(false);
                }

                if (!DetectSUTIPAddress())
                {
                    return(false);
                }

                if (context.Token.IsCancellationRequested)
                {
                    return(false);
                }

                using (var detector = new RDPDetector(detectionInfo, logWriter))
                {
                    if (!detector.DetectRDPFeature())
                    {
                        return(false);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                logWriter.AddLog(DetectLogLevel.Warning, "Failed", false, LogStyle.StepFailed);
                logWriter.AddLog(DetectLogLevel.Error, ex.Message);
                return(false);
            }
        }