Exemple #1
0
        static int SilentMode()
        {
            int ExitCode = 0;

            Logger.Log(Logging.LogSeverity.Information, "Superfish Removal Check");

            var agents = Utilities.RemovalAgentFactory.GetRemovalAgents().ToList();

            if (agents != null && agents.Any())
            {
                int agentNumber = 1;
                foreach (var agent in agents)
                {
                    Action <string> logAgentInfo = (status) => {
                        Logger.Log(Logging.LogSeverity.Information, "{0}: {1}", status, agent.UtilityName);
                    };
                    Action <string> logAgentError = (status) => {
                        Logger.Log(Logging.LogSeverity.Error, "{0}: {1}", status, agent.UtilityName);
                    };

                    try
                    {
                        logAgentInfo("Working...");

                        Utilities.FixResult removalResult = agent.RemoveItem();
                        if (removalResult.DidFail)
                        {
                            logAgentError("Error, failed while detecting / removing");
                        }
                        else if (removalResult.DidExist)
                        {
                            if (removalResult.WasRemoved)
                            {
                                logAgentInfo("Found and removed");
                            }
                            else
                            {
                                logAgentError("Found BUT NOT removed");
                                // Error code should be the first error that occurs.
                                ExitCode = (0 == ExitCode) ? agentNumber : ExitCode;
                            }
                        }
                        else
                        {
                            logAgentInfo("Not found");
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(ex, "Exception while working on agent # {0}", agentNumber);
                    }
                    agentNumber++;
                } // End foreach agent
            }     // End all agents

            Logger.Log(Logging.LogSeverity.Information, "Superfish Removal Check Complete!");
            Logger.Log(Logging.LogSeverity.Information, "Return code: {0}", ExitCode);

            return(ExitCode);
        }
 private static Utilities.FixResult TryToExecuteRemoval(Utilities.ISuperfishDetector detector)
 {
     Utilities.FixResult result = null;
     try
     {
         result = detector.RemoveItem();
     }
     catch (Exception ex)
     {
         Logging.Logger.Log(ex, "Exception while trying to invoke superfish detetctor ");
     }
     return(result);
 }
Exemple #3
0
 private static Utilities.FixResult TryToExeuteRemoval(Utilities.ISuperfishDetector detector)
 {
     Utilities.FixResult result = null;
     try
     {
         result = detector.RemoveItem();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     return(result);
 }
Exemple #4
0
        //public const string REGISTRY_KEY_PARENTNAME = "ParentDisplayName";
        //public const string REGISTRY_KEY_SYSCOMPONENT = "SystemComponent";
        //public const string REGISTRY_KEY_WININSTALLER = "WindowsInstaller";
        //public const string REGISTRY_KEY_DISPLAYICO = "DisplayIcon";
        //public const string REGISTRY_KEY_DISPLAYVER = "DisplayVersion";

        public FixResult RemoveItem()
        {
            var result = new FixResult(Localizer.Get().DetectorNameApp);

            try
            {
                result.DidExist   = this.DoesExist();
                result.WasRemoved = this.Remove();
            }
            catch (Exception ex)
            {
                result.DidFail = true;
            }
            return(result);
        }
        /// <summary>
        /// Detects if a removal of Superfish needs to be made, then attempts to
        /// perfom a removal using the specified utility.
        /// </summary>
        /// <remarks></remarks>
        /// <param name="superfishDetector">The utility to use</param>
        /// <returns>The result of the removal</returns>
        public static FixResult RemoveItem(this ISuperfishDetector superfishDetector, bool DetectExistenceOnly = false)
        {
            if (superfishDetector == null)
            {
                throw new ArgumentNullException("superfishDetector");
            }

            string name = null;

            try
            {
                name = superfishDetector.UtilityName;
            }
            catch
            {
                //TODO: Log
            }
            finally
            {
                if (name == null)
                {
                    name = "";
                }
            }

            var result = new FixResult(name);

            try
            {
                result.DidExist = superfishDetector.DoesExist();

                //TODO: This functionality should be discussed,
                //Performing a removal if nothing was found strikes me as odd.
                if (DetectExistenceOnly)
                {
                    result.WasRemoved = false;
                }
                else
                {
                    result.WasRemoved = superfishDetector.Remove();
                }
            }
            catch (Exception)
            {
                result.DidFail = true;
            }
            return(result);
        }
        /// <summary>
        /// Detects if a removal of Superfish needs to be made, then attempts to 
        /// perfom a removal using the specified utility.
        /// </summary>
        /// <remarks></remarks>
        /// <param name="superfishDetector">The utility to use</param>
        /// <returns>The result of the removal</returns>
        public static FixResult RemoveItem(this ISuperfishDetector superfishDetector, bool DetectExistenceOnly = false)
        {
            if (superfishDetector == null)
                throw new ArgumentNullException("superfishDetector");

            string name = null;
            try
            {
                name = superfishDetector.UtilityName;
            }
            catch
            {
                //TODO: Log
            }
            finally
            {
                if (name == null)
                {
                    name = "";
                }
            }

            var result = new FixResult(name);
            try
            {
                result.DidExist = superfishDetector.DoesExist();

                //TODO: This functionality should be discussed,
                //Performing a removal if nothing was found strikes me as odd.
                if (DetectExistenceOnly)
                {
                    result.WasRemoved = false;
                }
                else
                {
                    result.WasRemoved = superfishDetector.Remove();
                }
            }
            catch (Exception)
            {
                result.DidFail = true;
            }
            return result;
        }
        /// <summary>
        /// Adds a line item into the results for a particular scan result
        /// </summary>
        /// <param name="result"></param>
        /// <returns></returns>
        private bool AddLabelBasedOnIndividualResult(Utilities.FixResult result)
        {
            bool error = false;

            try
            {
                var    stringTable = Localizer.Get();
                string text        = String.Empty;
                if (result == null || result.DidFail)
                {
                    text = stringTable.Error;
                }
                else
                {
                    if (result.DidExist)
                    {
                        if (result.WasRemoved)
                        {
                            text = stringTable.ResultFoundAndRemoved;
                        }
                        else
                        {
                            text  = stringTable.ResultFoundButNotRemoved;
                            error = true;
                        }
                    }
                    else
                    {
                        text = stringTable.ResultNotFound;
                    }
                }

                string completeText = String.Format("{0} - {1}", text, result.NameOfItem);
                this.ResultsFlowPanel.Controls.Add(GenerateResultLabel(completeText));
            }
            catch (Exception ex)
            {
                Logging.Logger.Log(ex, "Exception while adding result label");
            }
            return(error);
        }
Exemple #8
0
        private bool UpdateLabelBasedOnResult(Utilities.FixResult result)
        {
            bool error = false;

            try
            {
                var    stringTable = Localizer.Get();
                string text        = String.Empty;
                if (result == null || result.DidFail)
                {
                    text = stringTable.Error;
                }
                else
                {
                    if (result.DidExist)
                    {
                        if (result.WasRemoved)
                        {
                            text = stringTable.ResultFoundAndRemoved;
                        }
                        else
                        {
                            text  = stringTable.ResultFoundButNotRemoved;
                            error = true;
                        }
                    }
                    else
                    {
                        text = stringTable.ResultNotFound;
                    }
                }

                string completeText = String.Format("{0} - {1}", text, result.NameOfItem);
                this.ResultsFlowPanel.Controls.Add(GenerageResultLabel(completeText));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(error);
        }
        /// <summary>
        /// Translates a single removal result into an overall result for displaying to the user
        /// </summary>
        /// <param name="fixResult"></param>
        /// <returns></returns>
        private static OverallResult CalculateSingleResult(Utilities.FixResult fixResult)
        {
            OverallResult result = OverallResult.None;

            if (fixResult == null || fixResult.DidFail)
            {
                result = OverallResult.Error;
            }
            else
            {
                if (fixResult.DidExist)
                {
                    result = fixResult.WasRemoved ? OverallResult.ItemsFoundAndRemoved : OverallResult.ItemsFoundButNotRemoved;
                }
                else
                {
                    result = OverallResult.NoItemsFound;
                }
            }
            return(result);
        }
Exemple #10
0
        static int SilentMode()
        {
            int ExitCode = 0;

            Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Removal Check");

            var appChecker = new Utilities.ApplicationUtility();

            Utilities.FixResult appResult = appChecker.RemoveItem();
            if (appResult.DidFail)
            {
                Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Application: ERROR");
            }
            else if (appResult.DidExist)
            {
                if (appResult.WasRemoved)
                {
                    Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Application: Found & Removed");
                }
                else
                {
                    Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Application: Found - ERROR Removing");
                    ExitCode = 1;  //ExitCode = (0 == ExitCode) ? 1 : 0;
                }
            }
            else
            {
                Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Application: Not found");
            }

            var certChecker = new Utilities.CertificateUtility();

            Utilities.FixResult certResult = certChecker.RemoveItem();
            if (certResult.DidFail)
            {
                Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Certificates: ERROR");
            }
            else if (certResult.DidExist)
            {
                if (certResult.WasRemoved)
                {
                    Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Certificates: Found & Removed");
                }
                else
                {
                    Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Certificates: Found - ERROR Removing");
                    ExitCode = (0 == ExitCode) ? 2 : 0;
                }
            }
            else
            {
                Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Certificates: Not found");
            }

            var certChecker2 = new Utilities.MozillaCertificateUtility();

            Utilities.FixResult certResult2 = certChecker2.RemoveItem();
            if (certResult2.DidFail)
            {
                Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Mozilla Certificates: ERROR");
            }
            else if (certResult2.DidExist)
            {
                if (certResult2.WasRemoved)
                {
                    Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Mozilla Certificates: Found & Removed");
                }
                else
                {
                    Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Mozilla Certificates: Found - ERROR Removing");
                    ExitCode = (0 == ExitCode) ? 3 : 0;
                }
            }
            else
            {
                Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Mozilla Certificates: Not found");
            }

            var regChecker = new Utilities.RegistryUtility();

            Utilities.FixResult regResult = regChecker.RemoveItem();
            if (regResult.DidFail)
            {
                Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Registry Entries: ERROR");
            }
            else if (regResult.DidExist)
            {
                if (regResult.WasRemoved)
                {
                    Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Registry Entries: Found & Removed");
                }
                else
                {
                    Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Registry Entries: Found - ERROR Removing");
                    ExitCode = (0 == ExitCode) ? 4 : 0;
                }
            }
            else
            {
                Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Registry Entries: Not found");
            }

            var fileChecker = new Utilities.FilesDetector();

            Utilities.FixResult fileResult = fileChecker.RemoveItem();
            if (fileResult.DidFail)
            {
                Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Files: ERROR");
            }
            else if (fileResult.DidExist)
            {
                if (fileResult.WasRemoved)
                {
                    Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Files: Found & Removed");
                }
                else
                {
                    Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Files: Found - ERROR Removing");
                    ExitCode = (0 == ExitCode) ? 5 : 0;
                }
            }
            else
            {
                Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Files: Not found");
            }
            Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Removal Check Complete");

            return(ExitCode);
        }