public static IEnumerable <string> getAsHosts()
        {
            List <string>        hosts           = new List <string>();
            IEnumerable <string> categorizeHosts = new[] { "" };

            hosts.AddRange(getSafeSearchHosts());
            hosts.AddRange(getSafeYoutubeHosts());

            List <string> blacklist = Resources.profile.Default.customBlacklist;

            //turn the urls to loop hosts (blocked)
            foreach (string url in blacklist)
            {
                hosts.Add("0.0.0.0 " + url + " www." + url + " https://" + url + " https://www." + url);
            }

            if (FilteringSystem.IsSocialBlocked())
            {
                categorizeHosts = categorizeHosts.Concat(getSocialHosts());
            }

            if (FilteringSystem.IsAdsBlocked())
            {
                categorizeHosts = categorizeHosts.Concat(getAdsHosts());
            }

            if (FilteringSystem.IsGamblingBlocked())
            {
                categorizeHosts = categorizeHosts.Concat(getGamblingHosts());
            }

            return(hosts.Concat(categorizeHosts));
        }
예제 #2
0
        protected override void OnBeforeUninstall(IDictionary savedState)
        {
            base.OnBeforeInstall(savedState);

            //Prevent uninstalling while the app is on
            if (!IsAllAppClosed("MMB-Filter"))
            {
                MessageBox.Show("לפני הסרת התקנה יש לסגור את המערכת. סגור את המערכת ולאחר מכן נסה שנית.");
                throw new ApplicationException("לא ניתן להסיר את התוכנה בזמן שאחד המופעים שלה פתוח");
            }

            installingProcess = false;

            //ask for password
            Dialogs.EnterPassword enterPassword = new Dialogs.EnterPassword("על מנת להסיר את ההתקנה יש להזין סיסמת מנהל", true);
            DialogResult          dialogResult  = enterPassword.ShowDialog();

            enterPassword.BringToFront();

            if (dialogResult == DialogResult.OK)
            {
                string gettedPass = enterPassword.gettedText;
                if (gettedPass == PasswordEncryption.Decrypt(Installer.GetUninstallingPass()) || FilteringSystem.IsAdminPassword(gettedPass))
                {
                    string localDataPath = Environment.ExpandEnvironmentVariables("%localappdata%") + @"\MMB\";

                    try
                    {
                        //Delete the appData
                        Directory.Delete(localDataPath, true);
                    }
                    catch
                    {}
                    //Set dhcp dns
                    DnsController.setMode(false);

                    //Stop the internt blocker service
                    ServiceAdapter.StopService("GUIAdapter", 10000);

                    //Uninstall the Service
                    string servicePath = Assembly.GetExecutingAssembly().CodeBase;
                    servicePath = servicePath.Replace("MMB-Filter.exe", "MMB-Service.exe");
                    ServiceAdapter.UninstallService(servicePath);

                    //realese the internet blocking
                    InternetBlocker.block(false);

                    MessageBox.Show("הסרת ההתקנה הסתיימה", "לוקחים אחריות", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information, System.Windows.Forms.MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.ServiceNotification);
                }
                else
                {
                    MessageBox.Show("הסיסמה שגויה, התראה נשלחה למנהל המערכת", "לוקחים אחריות", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    throw new ApplicationException("לא ניתן להסיר באמצעות סיסמה שגויה");
                }
            }
        }
예제 #3
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(true);


            //Start by looking for administrator privilege
            if (IsAdmin())
            {
                //If administrator privilege is granted

                //close the current proceess if same process already opened.
                if (Environment.GetCommandLineArgs().Length > 1)
                {
                    if (Environment.GetCommandLineArgs()[0] != "runAgainAsAdmin")
                    {
                        if (System.Diagnostics.Process.GetProcessesByName(System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetEntryAssembly().Location)).Count() > 1)
                        {
                            System.Diagnostics.Process.GetCurrentProcess().Kill();
                        }
                    }
                }

                // setup to custom font.
                SetupFont();

                //add the app to startup applications.
                TaskingSchedule.RunOnStartup("MMB", Application.StartupPath + "\\" + System.AppDomain.CurrentDomain.FriendlyName);

                //run the app service
                ServiceAdapter.StartService("GUIAdapter", 10000);

                //setup global menuForm.
                menuForm = new MenuForm();

                //check if this is the first time the app is opening on this computer.
                if (IsFirstOpening())
                {
                    ActAsFirstOpening();
                }

                //setup the filtering system.
                FilteringSystem.Setup();

                //start new menu form.
                Application.Run(menuForm);
            }
            else //
            {
                //If administrator privilege not granted, run again as administrator
                if (StartAgainAsAdmin())
                {
                    //By opening a new administrator-privileged process, close the current process.
                    Application.ExitThread();
                }
                else
                {
                    //If the second attempt of opening as an administrator permission failed, Block the Internet (by the service) and close the current procees.
                    ServiceAdapter.StartInternetBlocking();
                    MessageBox.Show("אפליקציה זו חייבת לרוץ כמנהל, האינטרנט מושבת.", "שגיאה", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
                    Application.Exit();
                }
            }
        }