Exemplo n.º 1
0
        public static void Write(FilteringSettings filteringSettings)
        {
            try
            {
                if (InternetBlocker.IsInternetReachable())
                {
                    ServiceAdapter.CustomCommend((int)ServiceAdapter.CustomCommends.stopCatchFiles);

                    string path = Path.Combine(App.GetAppDataFolder(), "CustomBlackList");

                    StreamWriter stream = new StreamWriter(path);

                    IEnumerable <string> urlsBlacklist = new[] { "" };
                    urlsBlacklist = urlsBlacklist.Concat(UrlsBlacklistsByCategories(filteringSettings));
                    urlsBlacklist = urlsBlacklist.Concat(filteringSettings.GetCustomBlackList());
                    urlsBlacklist = urlsBlacklist.Except(filteringSettings.GetCustomExceptionsList());
                    string HostsText = GetSafeSearchHostsText(filteringSettings) + Environment.NewLine + UrlsListToHostsText(urlsBlacklist);

                    stream.Write(HostsText);
                    stream.Close();

                    ServiceAdapter.CustomCommend((int)ServiceAdapter.CustomCommends.updateHostsFile);
                    ServiceAdapter.CustomCommend((int)ServiceAdapter.CustomCommends.startCatchFiles);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "HostsFileAdapter.Write Error");
            }
        }
Exemplo n.º 2
0
 public static void UpdateBlockedList()
 {
     if (InternetBlocker.IsInternetReachable())
     {
         blockedApp = Regex.Split(Tools.GetTextFromUri("http://f4e.mmb.org.il/data/blockedApp"), "\r\n|\r|\n");
     }
 }
Exemplo n.º 3
0
 public static Boolean IsActiveVersion()
 {
     if (InternetBlocker.IsInternetReachable())
     {
         string active_versions = Tools.GetTextFromUri("http://f4e.mmb.org.il/data/active_versions");
         string current_version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
         if (active_versions != null)
         {
             return(active_versions.Contains(current_version));
         }
         else
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 4
0
        public static Boolean CheckForUpdates()
        {
            if (InternetBlocker.IsInternetReachable())
            {
                string last_version    = Tools.GetTextFromUri("http://f4e.mmb.org.il/data/last_version");
                string current_version = Assembly.GetExecutingAssembly().GetName().Version.ToString();

                if (last_version != null)
                {
                    return(!(last_version == current_version));
                }
                else
                {
                    return(false);
                }
            }
            return(false);
        }
Exemplo n.º 5
0
        public static void KeepServiceOn()
        {
            new Thread(() =>
            {
                if (ServiceAdapter.GetServiceStatus("GUIAdapter") == "Running")
                {
                    isServiceIsOn          = true;
                    serviceHasDetected     = true;
                    prevent_close_attempts = 0;
                }
                else
                {
                    if (prevent_close_attempts == 0)
                    {
                        MailsSender.SendUnusualActivityAlert();
                    }
                    prevent_close_attempts++;

                    ServiceAdapter.StartService("GUIAdapter", 10000);

                    if (InternetBlocker.IsInternetReachable())
                    {
                        InternetBlocker.Block(true);
                    }

                    if (ServiceAdapter.GetServiceStatus("GUIAdapter") == "Stopped")
                    {
                        if (serviceHasDetected)
                        {
                            BootController.DoExitWin(BootController.EWX_REBOOT);
                        }
                    }

                    isServiceIsOn = false;
                }
            }).Start();
        }
Exemplo n.º 6
0
        private static void DefenceChecker_Elapsed(object sender, ElapsedEventArgs e)
        {
            KeepServiceOn();
            RunInSafeMode();
            RunInStartUp();
            PreventSystemFilesEdit();
            ProblematicAppsBlocker.Block();
            tick_count++;
            if (isServiceIsOn == true)
            {
                if (runInSafeModeStatus == false || preventSystemFilesEditStatus == false || runInStartUpStatus == false)
                {
                    if (!runInSafeModeStatus)
                    {
                        RunInSafeMode();
                    }

                    if (!preventSystemFilesEditStatus)
                    {
                        PreventSystemFilesEdit();
                    }

                    if (!runInStartUpStatus)
                    {
                        RunInStartUp();
                    }

                    if (tick_count > 1200)
                    {
                        CustomNotifyIcon.ShowNotificationMessage(500, "המערכת זיהתה חריגה", "המערכת זיהתה כי אחת ממערכות ההגנה אינה פעילה. לחץ כאן לפרטים", System.Windows.Forms.ToolTipIcon.Error);
                        tick_count = 0;
                    }
                }
            }
            else
            {
                if (tick_count > 1200)
                {
                    CustomNotifyIcon.ShowNotificationMessage(500, "הסינון אינו יציב", "אחת מהמערכות הקריטיות לפעילות הסינון אינה פעילה, הודעה נשלחה למנהל המערכת.", System.Windows.Forms.ToolTipIcon.Error);
                    tick_count = 0;
                }
            }

            scheduelUpdate++;
            if (scheduelUpdate == 60)
            {
                new Thread(() =>
                {
                    Application.Current.Dispatcher.Invoke((Action) delegate
                    {
                        if (GetBlockSchedulingStatus() == true)
                        {
                            if (SchedulePage.Instance.IsBlockNow())
                            {
                                if (InternetBlocker.IsInternetReachable() == true)
                                {
                                    InternetBlocker.Block(true);
                                }
                            }
                            else
                            {
                                if (InternetBlocker.IsInternetReachable() == false)
                                {
                                    InternetBlocker.Block(false);
                                }
                            }
                        }
                    });
                }).Start();
            }
        }