Esempio n. 1
0
        public SetupWnd()
        {
            InitializeComponent();

            this.Title = Translate.fmt("wnd_setup", App.Title);

            this.lblStartup.Text      = Translate.fmt("lbl_startup_options");
            this.chkAutoStart.Content = Translate.fmt("chk_autorun");
            this.chkService.Content   = Translate.fmt("chk_instal_svc");
            this.chkNoUAC.Content     = Translate.fmt("chk_no_uac");

            this.lblFirewall.Text    = Translate.fmt("lbl_firewall_options");
            this.chkUseFW.Content    = Translate.fmt("chk_manage_fw");
            this.chkNotifyFW.Content = Translate.fmt("chk_show_notify");

            chkNoUAC.IsChecked    = AdminFunc.IsSkipUac(App.Key);
            chkNotifyFW.IsChecked = App.GetConfigInt("Firewall", "NotifyConnections", 1) != 0;
        }
        public void Refresh()
        {
            bHold = true;

            chkTray.IsChecked      = App.GetConfigInt("Startup", "Tray") != 0;
            chkAutoStart.IsChecked = App.IsAutoStart();
            chkService.IsChecked   = App.svc.IsInstalled();
            chkNoUAC.IsChecked     = AdminFunc.IsSkipUac(App.mName);

            chkUseFW.IsChecked = App.GetConfigInt("Firewall", "Enabled", 0) != 0;

            if (App.client.IsConnected())
            {
                var mode = App.itf.GetFilteringMode();

                radWhitelist.IsChecked = mode == Firewall.FilteringModes.WhiteList;
                radBlacklist.IsChecked = mode == Firewall.FilteringModes.BlackList;
                radDisabled.IsChecked  = mode == Firewall.FilteringModes.NoFiltering;

                var pol = App.itf.GetAuditPol();
                switch (pol)
                {
                case Firewall.Auditing.All: cmbAudit.SelectedItem = lblAuditAll; break;

                case Firewall.Auditing.Blocked: cmbAudit.SelectedItem = lblAuditBlock; break;

                default: cmbAudit.SelectedItem = lblAuditAll; break;
                }
            }
            else
            {
                chkUseFW.IsEnabled = false;

                radWhitelist.IsEnabled = false;
                radBlacklist.IsEnabled = false;
                radDisabled.IsEnabled  = false;
                cmbAudit.IsEnabled     = false;
            }

            chkNotifyFW.IsEnabled = chkUseFW.IsChecked == true;
            chkNotifyFW.IsChecked = App.GetConfigInt("Firewall", "NotifyBlocked", 1) != 0;

            bHold = false;
        }
Esempio n. 3
0
        public void Refresh()
        {
            bHold = true;

            chkTray.IsChecked      = App.GetConfigInt("Startup", "Tray", 1) != 0;
            chkAutoStart.IsChecked = App.IsAutoStart();
            chkService.IsChecked   = Priv10Service.IsInstalled();
            chkNoUAC.IsChecked     = AdminFunc.IsSkipUac(App.Key);

            chkTweakCheck.IsChecked = App.GetConfigInt("TweakGuard", "AutoCheck", 1) != 0;
            chkTweakFix.IsEnabled   = chkTweakCheck.IsChecked == true;
            chkTweakFix.IsChecked   = App.GetConfigInt("TweakGuard", "AutoFix", 0) != 0;

            chkUseFW.IsChecked = App.GetConfigInt("Firewall", "Enabled", 0) != 0;

            if (App.client.IsConnected())
            {
                var mode = App.client.GetFilteringMode();

                radWhitelist.IsChecked = mode == FirewallManager.FilteringModes.WhiteList;
                radBlacklist.IsChecked = mode == FirewallManager.FilteringModes.BlackList;
                radDisabled.IsChecked  = mode == FirewallManager.FilteringModes.NoFiltering;

                var pol = App.client.GetAuditPolicy();
                switch (pol)
                {
                case FirewallMonitor.Auditing.All: cmbAudit.SelectedItem = lblAuditAll; break;

                case FirewallMonitor.Auditing.Blocked: cmbAudit.SelectedItem = lblAuditBlock; break;

                default: cmbAudit.SelectedItem = lblAuditNone; break;
                }

                chkGuardFW.IsEnabled = chkUseFW.IsChecked == true;
                chkGuardFW.IsChecked = App.client.IsFirewallGuard();

                chkEnableDNS.IsChecked = App.GetConfigInt("DnsProxy", "Enabled", 0) != 0;
            }
            else
            {
                chkUseFW.IsEnabled = false;

                radWhitelist.IsEnabled = false;
                radBlacklist.IsEnabled = false;
                radDisabled.IsEnabled  = false;
                cmbAudit.IsEnabled     = false;

                chkGuardFW.IsEnabled = false;

                chkEnableDNS.IsEnabled = false;
            }

            var fix_mode = App.GetConfigInt("Firewall", "GuardMode", 0);

            radFix.IsChecked     = fix_mode == (int)FirewallGuard.Mode.Fix;
            radDisable.IsChecked = fix_mode == (int)FirewallGuard.Mode.Disable;
            radAlert.IsChecked   = fix_mode == (int)FirewallGuard.Mode.Alert;

            radFix.IsEnabled = radDisable.IsEnabled = radAlert.IsEnabled = (chkGuardFW.IsChecked != false && chkGuardFW.IsEnabled);


            chkNotifyFW.IsEnabled = chkUseFW.IsChecked == true;
            chkNotifyFW.IsChecked = App.GetConfigInt("Firewall", "NotifyConnections", 1) != 0;

            chkDnsInspector.IsChecked = App.GetConfigInt("DnsInspector", "Enabled", 0) != 0;

            chkReverseDNS.IsChecked = App.GetConfigInt("DnsInspector", "UseReverseDNS", 0) != 0;

            // DNS
            chkLocalDNS.IsChecked = App.GetConfigInt("DnsProxy", "SetLocal", 0) != 0;
            string UpstreamDNS = App.GetConfig("DNSProxy", "UpstreamDNS", "8.8.8.8");

            if (!WpfFunc.CmbSelect(cmbRootDNS, UpstreamDNS))
            {
                cmbRootDNS.Text = UpstreamDNS;
            }
            CheckDNS();

            //this.btnBackup.IsEnabled = this.btnRestore.IsEnabled = !App.isPortable;

            bHold = false;
        }
Esempio n. 4
0
        static bool ExecuteCommands()
        {
            if (TestArg("-help") || TestArg("/?"))
            {
                string   Message = "Available command line options\r\n";
                string[] Help    =
                {
                    "Available Console Commands:",
                    "========================================",
                    "",
                    "-state\t\t\tShow instalation state",
                    "-uninstall\t\tUninstall Private Win10",
                    "-shutdown\t\tClose Private Win10 instances",
                    "-restart\t\tRestart Win10 and reload settings",
                    "",
                    "-svc_install\t\tInstall priv10 service (invokes -log_install)",
                    "-svc_remove\t\tRemove priv10 service",
                    "",
                    "-log_install\t\tInstall PrivateWin10 Custom Event Log",
                    "-log_remove\t\tRemove PrivateWin10 Custom Event Log",
                    "",
                    "-restore_dns\t\tRestore original DNS Configuration",
                    "",
                    "-console\t\tShow console with debug output",
                    "-help\t\t\tShow this help message"
                };
                if (!HasConsole)
                {
                    MessageBox.Show(Message + string.Join("\r\n", Help));
                }
                else
                {
                    Console.WriteLine(Message);
                    for (int j = 0; j < Help.Length; j++)
                    {
                        Console.WriteLine(" " + Help[j]);
                    }
                }
                return(true);
            }


            bool bDone = false;

            if (TestArg("-uninstall"))
            {
                AppLog.Debug("Uninstalling Private Win10");
                bDone = true;
            }

            if (TestArg("-svc_remove") || (Priv10Service.IsInstalled() && TestArg("-uninstall")))
            {
                AppLog.Debug("Removing Service...");
                Priv10Service.Uninstall();
                bDone = true;
            }

            if (TestArg("-shutdown") || TestArg("-restart") || TestArg("-restore") || TestArg("-uninstall"))
            {
                AppLog.Debug("Closing instances...");
                if (Priv10Service.IsInstalled())
                {
                    Priv10Service.Terminate();
                }

                Thread.Sleep(500);

                foreach (var proc in Process.GetProcessesByName(App.Key))
                {
                    if (proc.Id == ProcFunc.CurID)
                    {
                        continue;
                    }
                    proc.Kill();
                }

                bDone = true;
            }

            if (TestArg("-restore"))
            {
                string zipPath = GetArg("-restore");

                try
                {
                    if (zipPath == null || !File.Exists(zipPath))
                    {
                        throw new Exception("Data backup zip not specifyed or invalid path");
                    }

                    Console.WriteLine("Restoring settings from {0}", zipPath);

                    string extractPath = App.dataPath;

                    // Normalizes the path.
                    extractPath = Path.GetFullPath(extractPath);

                    // Ensures that the last character on the extraction path
                    // is the directory separator char.
                    // Without this, a malicious zip file could try to traverse outside of the expected
                    // extraction path.
                    if (!extractPath.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal))
                    {
                        extractPath += Path.DirectorySeparatorChar;
                    }

                    // create data directory
                    if (!Directory.Exists(dataPath))
                    {
                        Directory.CreateDirectory(dataPath);
                    }

                    // ensure its writable by non administrators
                    FileOps.SetAnyDirSec(dataPath);

                    // Extract the backuped files
                    using (ZipArchive archive = ZipFile.OpenRead(zipPath))
                    {
                        foreach (ZipArchiveEntry entry in archive.Entries)
                        {
                            // Gets the full path to ensure that relative segments are removed.
                            string destinationPath = Path.GetFullPath(Path.Combine(extractPath, entry.FullName));

                            // Ordinal match is safest, case-sensitive volumes can be mounted within volumes that
                            // are case-insensitive.
                            if (!destinationPath.StartsWith(extractPath, StringComparison.Ordinal))
                            {
                                continue;
                            }

                            Console.WriteLine("Restored file {0}", entry.FullName);
                            if (File.Exists(destinationPath))
                            {
                                FileOps.DeleteFile(destinationPath);
                            }
                            else if (!Directory.Exists(Path.GetDirectoryName(destinationPath)))
                            {
                                Directory.CreateDirectory(Path.GetDirectoryName(destinationPath));
                            }

                            entry.ExtractToFile(destinationPath);
                        }
                    }
                }
                catch (Exception err)
                {
                    Console.WriteLine(err.Message);
                    MessageBox.Show(Translate.fmt("msg_restore_error", err.Message), App.Title, MessageBoxButton.OK, MessageBoxImage.Stop);
                }

                bDone = true;
            }

            if (TestArg("-restart") || TestArg("-restore"))
            {
                Thread.Sleep(500);

                AppLog.Debug("Starting instances...");
                if (Priv10Service.IsInstalled())
                {
                    Priv10Service.Startup();
                }

                Thread.Sleep(500);

                ProcessStartInfo startInfo = new ProcessStartInfo(App.exePath);
                startInfo.UseShellExecute = true;
                startInfo.Verb            = "runas";
                Process.Start(startInfo);

                bDone = true;
            }

            if (TestArg("-log_remove") || (Log.UsingEventLog() && TestArg("-uninstall")))
            {
                AppLog.Debug("Removing Event Log...");
                Log.RemoveEventLog(Key);
                bDone = true;
            }

            if (TestArg("-svc_install"))
            {
                AppLog.Debug("Installing Service...");
                Priv10Service.Install(TestArg("-svc_start"));
                bDone = true;
            }

            if (TestArg("-log_install") || TestArg("-svc_install")) // service needs the event log
            {
                AppLog.Debug("Setting up Event Log...");
                Log.SetupEventLog(Key);
                bDone = true;
            }

            if (TestArg("-restore_dns") || (DnsConfigurator.IsAnyLocalDNS() && TestArg("-uninstall")))
            {
                AppLog.Debug("Restoring DNS Config...");
                DnsConfigurator.RestoreDNS();
                bDone = true;
            }

            if (TestArg("-uninstall") && AdminFunc.IsSkipUac(App.Key))
            {
                AppLog.Debug("Removing UAC Bypass...");
                AdminFunc.SkipUacEnable(App.Key, false);
                bDone = true;
            }

            if (TestArg("-uninstall") && App.IsAutoStart())
            {
                AppLog.Debug("Removing Autostart...");
                App.AutoStart(false);
                bDone = true;
            }

            if (bDone)
            {
                AppLog.Debug("done");
            }


            if (TestArg("-state"))
            {
                Console.WriteLine();
                Console.WriteLine("Instalation State:");
                Console.WriteLine("========================="); // 25
                Console.Write("Auto Start:\t");
                Console.WriteLine(App.IsAutoStart());
                Console.Write("UAC Bypass:\t");
                Console.WriteLine(AdminFunc.IsSkipUac(App.Key));
                Console.Write("Service:\t");
                Console.WriteLine(Priv10Service.IsInstalled());
                Console.Write("Event Log:\t");
                Console.WriteLine(Log.UsingEventLog());
                Console.Write("Local DNS:\t");
                Console.WriteLine(DnsConfigurator.IsAnyLocalDNS());
                Console.WriteLine();
                bDone = true;
            }

            if (TestArg("-wait"))
            {
                Console.WriteLine();
                for (int i = 10; i >= 0; i--)
                {
                    Console.Write("\r{0}%   ", i);
                    Thread.Sleep(1000);
                }
            }

            return(bDone);
        }
Esempio n. 5
0
        static bool ExecuteCommands()
        {
            if (TestArg("-help") || TestArg("/?"))
            {
                string   Message = "Available command line options\r\n";
                string[] Help    =
                {
                    "Available Console Commands:",
                    "========================================",
                    "",
                    "-state\t\t\tShow instalation state",
                    "-uninstall\t\tUninstall PrivateWinTen",
                    "",
                    "-svc_install\t\tInstall priv10 service (invokes -log_install)",
                    "-svc_remove\t\tRemove priv10 service",
                    "",
                    "-log_install\t\tInstall PrivateWin10 Custom Event Log",
                    "-log_remove\t\tRemove PrivateWin10 Custom Event Log",
                    "",
                    "-console\t\tShow console with debug output",
                    "-help\t\t\tShow this help message"
                };
                if (!HasConsole)
                {
                    MessageBox.Show(Message + string.Join("\r\n", Help));
                }
                else
                {
                    Console.WriteLine(Message);
                    for (int j = 0; j < Help.Length; j++)
                    {
                        Console.WriteLine(" " + Help[j]);
                    }
                }
                return(true);
            }


            bool bDone = false;

            if (TestArg("-svc_install"))
            {
                AppLog.Debug("Installing Service...");
                svc.Install(TestArg("-svc_start"));
                bDone = true;
            }

            if (TestArg("-log_install") || TestArg("-svc_install")) // service needs the event log
            {
                AppLog.Debug("Setting up Event Log...");
                Log.SetupEventLog(mAppName);
                bDone = true;
            }

            if (TestArg("-uninstall"))
            {
                AppLog.Debug("Uninstalling PrivateWinTen");
                bDone = true;
            }

            if (TestArg("-svc_remove") || (svc.IsInstalled() && TestArg("-uninstall")))
            {
                AppLog.Debug("Removing Service...");
                svc.Uninstall();
                bDone = true;
            }

            if (TestArg("-log_remove") || (Log.UsingEventLog() && TestArg("-uninstall")))
            {
                AppLog.Debug("Removing Event Log...");
                Log.RemoveEventLog(mAppName);
                bDone = true;
            }

            if (TestArg("-uninstall") && AdminFunc.IsSkipUac(mName))
            {
                AppLog.Debug("Removing UAC Bypass...");
                AdminFunc.SkipUacEnable(mName, false);
                bDone = true;
            }

            if (TestArg("-uninstall") && App.IsAutoStart())
            {
                AppLog.Debug("Removing Autostart...");
                App.AutoStart(false);
                bDone = true;
            }

            if (bDone)
            {
                AppLog.Debug("done");
            }


            if (TestArg("-state"))
            {
                Console.WriteLine();
                Console.WriteLine("Instalation State:");
                Console.WriteLine("========================="); // 25
                Console.Write("Auto Start:\t");
                Console.WriteLine(App.IsAutoStart());
                Console.Write("UAC Bypass:\t");
                Console.WriteLine(AdminFunc.IsSkipUac(mName));
                Console.Write("Event Log:\t");
                Console.WriteLine(Log.UsingEventLog());
                Console.Write("Service:\t");
                Console.WriteLine(svc.IsInstalled());
                Console.WriteLine();
            }

            if (TestArg("-wait"))
            {
                Console.WriteLine();
                for (int i = 10; i >= 0; i--)
                {
                    Console.Write("\r{0}%   ", i);
                    Thread.Sleep(1000);
                }
            }

            return(bDone);
        }
Esempio n. 6
0
        public void Refresh()
        {
            bHold = true;

            chkTray.IsChecked      = App.GetConfigInt("Startup", "Tray") != 0;
            chkAutoStart.IsChecked = App.IsAutoStart();
            chkService.IsChecked   = App.svc.IsInstalled();
            chkNoUAC.IsChecked     = AdminFunc.IsSkipUac(App.mName);

            chkTweakCheck.IsChecked = App.GetConfigInt("TweakGuard", "AutoCheck", 1) != 0;
            chkTweakFix.IsEnabled   = chkTweakCheck.IsChecked == true;
            chkTweakFix.IsChecked   = App.GetConfigInt("TweakGuard", "AutoFix", 0) != 0;

            chkUseFW.IsChecked = App.GetConfigInt("Firewall", "Enabled", 0) != 0;

            if (App.client.IsConnected())
            {
                var mode = App.client.GetFilteringMode();

                radWhitelist.IsChecked = mode == FirewallManager.FilteringModes.WhiteList;
                radBlacklist.IsChecked = mode == FirewallManager.FilteringModes.BlackList;
                radDisabled.IsChecked  = mode == FirewallManager.FilteringModes.NoFiltering;

                var pol = App.client.GetAuditPolicy();
                switch (pol)
                {
                case FirewallMonitor.Auditing.All: cmbAudit.SelectedItem = lblAuditAll; break;

                case FirewallMonitor.Auditing.Blocked: cmbAudit.SelectedItem = lblAuditBlock; break;

                default: cmbAudit.SelectedItem = lblAuditNone; break;
                }

                chkGuardFW.IsChecked = App.client.IsFirewallGuard();
            }
            else
            {
                chkUseFW.IsEnabled = false;

                radWhitelist.IsEnabled = false;
                radBlacklist.IsEnabled = false;
                radDisabled.IsEnabled  = false;
                cmbAudit.IsEnabled     = false;

                chkGuardFW.IsEnabled = false;
            }

            var fix_mode = App.GetConfigInt("Firewall", "GuardMode", 0);

            radFix.IsChecked     = fix_mode == (int)FirewallGuard.Mode.Fix;
            radDisable.IsChecked = fix_mode == (int)FirewallGuard.Mode.Disable;
            radAlert.IsChecked   = fix_mode == (int)FirewallGuard.Mode.Alert;

            radFix.IsEnabled = radDisable.IsEnabled = radAlert.IsEnabled = chkGuardFW.IsChecked != false;


            chkNotifyFW.IsEnabled = chkUseFW.IsChecked == true;
            chkNotifyFW.IsChecked = App.GetConfigInt("Firewall", "NotifyBlocked", 1) != 0;

            bHold = false;
        }