From 25224ab95c90879fbe86d123f157cb00793a09a6 Mon Sep 17 00:00:00 2001 From: Belim Date: Mon, 21 Sep 2020 18:55:47 +0200 Subject: [PATCH] Add files via upload --- src/Privatezilla/MainWindow.Designer.cs | 31 +-- src/Privatezilla/MainWindow.cs | 59 +++--- src/Privatezilla/MainWindow.resx | 177 +++++++----------- src/Privatezilla/Properties/AssemblyInfo.cs | 4 +- .../Properties/Resources.Designer.cs | 17 +- src/Privatezilla/Properties/Resources.resx | 12 +- 6 files changed, 125 insertions(+), 175 deletions(-) diff --git a/src/Privatezilla/MainWindow.Designer.cs b/src/Privatezilla/MainWindow.Designer.cs index bd1b47d..fe9fbc5 100644 --- a/src/Privatezilla/MainWindow.Designer.cs +++ b/src/Privatezilla/MainWindow.Designer.cs @@ -54,9 +54,8 @@ this.PnlPS = new System.Windows.Forms.Panel(); this.BtnMenuPS = new System.Windows.Forms.Button(); this.TxtPSInfo = new System.Windows.Forms.TextBox(); - this.TxtOutputPS = new System.Windows.Forms.TextBox(); - this.TxtConsolePS = new System.Windows.Forms.TextBox(); this.LblPSHeader = new System.Windows.Forms.Label(); + this.TxtConsolePS = new System.Windows.Forms.TextBox(); this.PSMenu = new System.Windows.Forms.ContextMenuStrip(this.components); this.PSImport = new System.Windows.Forms.ToolStripMenuItem(); this.PSSaveAs = new System.Windows.Forms.ToolStripMenuItem(); @@ -139,10 +138,10 @@ // PnlNav // this.PnlNav.BackColor = System.Drawing.Color.WhiteSmoke; - this.PnlNav.Controls.Add(this.TvwSettings); this.PnlNav.Controls.Add(this.LblPS); this.PnlNav.Controls.Add(this.LblSettings); this.PnlNav.Controls.Add(this.LblMainMenu); + this.PnlNav.Controls.Add(this.TvwSettings); this.PnlNav.Controls.Add(this.LstPS); resources.ApplyResources(this.PnlNav, "PnlNav"); this.PnlNav.Name = "PnlNav"; @@ -274,9 +273,8 @@ this.PnlPS.BackColor = System.Drawing.Color.White; this.PnlPS.Controls.Add(this.BtnMenuPS); this.PnlPS.Controls.Add(this.TxtPSInfo); - this.PnlPS.Controls.Add(this.TxtOutputPS); - this.PnlPS.Controls.Add(this.TxtConsolePS); this.PnlPS.Controls.Add(this.LblPSHeader); + this.PnlPS.Controls.Add(this.TxtConsolePS); this.PnlPS.Name = "PnlPS"; // // BtnMenuPS @@ -300,13 +298,11 @@ this.TxtPSInfo.Name = "TxtPSInfo"; this.TxtPSInfo.ReadOnly = true; // - // TxtOutputPS + // LblPSHeader // - resources.ApplyResources(this.TxtOutputPS, "TxtOutputPS"); - this.TxtOutputPS.BackColor = System.Drawing.Color.White; - this.TxtOutputPS.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.TxtOutputPS.ForeColor = System.Drawing.Color.Black; - this.TxtOutputPS.Name = "TxtOutputPS"; + resources.ApplyResources(this.LblPSHeader, "LblPSHeader"); + this.LblPSHeader.BackColor = System.Drawing.Color.Gainsboro; + this.LblPSHeader.Name = "LblPSHeader"; // // TxtConsolePS // @@ -318,12 +314,6 @@ this.TxtConsolePS.ForeColor = System.Drawing.Color.Black; this.TxtConsolePS.Name = "TxtConsolePS"; // - // LblPSHeader - // - resources.ApplyResources(this.LblPSHeader, "LblPSHeader"); - this.LblPSHeader.BackColor = System.Drawing.Color.Gainsboro; - this.LblPSHeader.Name = "LblPSHeader"; - // // PSMenu // this.PSMenu.BackColor = System.Drawing.Color.WhiteSmoke; @@ -364,11 +354,11 @@ // // PnlSettingsBottom // - this.PnlSettingsBottom.Controls.Add(this.BtnSettingsAnalyze); this.PnlSettingsBottom.Controls.Add(this.BtnSettingsUndo); this.PnlSettingsBottom.Controls.Add(this.BtnSettingsDo); - this.PnlSettingsBottom.Controls.Add(this.ChkCodePS); this.PnlSettingsBottom.Controls.Add(this.BtnDoPS); + this.PnlSettingsBottom.Controls.Add(this.BtnSettingsAnalyze); + this.PnlSettingsBottom.Controls.Add(this.ChkCodePS); resources.ApplyResources(this.PnlSettingsBottom, "PnlSettingsBottom"); this.PnlSettingsBottom.Name = "PnlSettingsBottom"; // @@ -400,8 +390,8 @@ this.BackColor = System.Drawing.Color.White; this.Controls.Add(this.PnlSettingsBottom); this.Controls.Add(this.PnlNav); - this.Controls.Add(this.PnlSettings); this.Controls.Add(this.PnlPS); + this.Controls.Add(this.PnlSettings); this.Name = "MainWindow"; this.ShowIcon = false; this.MainMenu.ResumeLayout(false); @@ -439,7 +429,6 @@ private System.Windows.Forms.Button BtnSettingsAnalyze; private System.Windows.Forms.Panel PnlPS; private System.Windows.Forms.TextBox TxtPSInfo; - private System.Windows.Forms.TextBox TxtOutputPS; private System.Windows.Forms.TextBox TxtConsolePS; private System.Windows.Forms.ContextMenuStrip PSMenu; private System.Windows.Forms.ToolStripMenuItem PSImport; diff --git a/src/Privatezilla/MainWindow.cs b/src/Privatezilla/MainWindow.cs index 7926018..f876706 100644 --- a/src/Privatezilla/MainWindow.cs +++ b/src/Privatezilla/MainWindow.cs @@ -1,19 +1,17 @@ using Privatezilla.ITreeNode; using System; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.Diagnostics; using System.Drawing; -using System.Globalization; // Localization using System.IO; using System.Linq; -using System.Management.Automation; using System.Net; using System.Runtime.CompilerServices; using System.Text; -using System.Threading; // Localization using System.Threading.Tasks; using System.Windows.Forms; +using System.Globalization; +using System.Threading; namespace Privatezilla { @@ -97,7 +95,7 @@ namespace Privatezilla public MainWindow() { // Uncomment lower line and add lang code to run localization test - // Thread.CurrentThread.CurrentUICulture = new CultureInfo("es"); + // Thread.CurrentThread.CurrentUICulture = new CultureInfo("es"); InitializeComponent(); @@ -586,7 +584,7 @@ namespace Privatezilla /// /// Run custom PowerShell scripts /// - private void BtnDoPS_Click(object sender, EventArgs e) + private async void BtnDoPS_Click(object sender, EventArgs e) { if (LstPS.CheckedItems.Count == 0) { @@ -598,24 +596,42 @@ namespace Privatezilla if (LstPS.GetItemChecked(i)) { LstPS.SelectedIndex = i; + string psdir = @"scripts\" + LstPS.SelectedItem.ToString() + ".ps1"; + var ps1File = psdir; + + var equals = new[] { "Silent" }; + var str = TxtPSInfo.Text; + BtnDoPS.Text = Properties.Resources.statusDoPSProcessing; PnlPS.Enabled = false; - //TxtOutputPS.Clear(); - using (PowerShell powerShell = PowerShell.Create()) + // Silent + if (equals.Any(str.Contains)) { - powerShell.AddScript(TxtConsolePS.Text); - powerShell.AddCommand("Out-String"); - Collection PSOutput = powerShell.Invoke(); - StringBuilder stringBuilder = new StringBuilder(); - foreach (PSObject pSObject in PSOutput) - stringBuilder.AppendLine(pSObject.ToString()); + var startInfo = new ProcessStartInfo() + { + FileName = "powershell.exe", + Arguments = $"-executionpolicy bypass -file \"{ps1File}\"", + UseShellExecute = false, + CreateNoWindow = true, + }; - TxtOutputPS.Text = stringBuilder.ToString(); - - BtnDoPS.Text = Properties.Resources.statusDoPSApply; - PnlPS.Enabled = true; + await Task.Run(() => { Process.Start(startInfo).WaitForExit(); }); } + else // Create ConsoleWindow + { + var startInfo = new ProcessStartInfo() + { + FileName = "powershell.exe", + Arguments = $"-executionpolicy bypass -file \"{ps1File}\"", + UseShellExecute = false, + }; + + await Task.Run(() => { Process.Start(startInfo).WaitForExit(); }); + } + + BtnDoPS.Text = Properties.Resources.statusDoPSApply; + PnlPS.Enabled = true; // Done! MessageBox.Show("Script " + "\"" + LstPS.Text + "\" " + Properties.Resources.msgPSSuccess, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); @@ -632,12 +648,10 @@ namespace Privatezilla { ChkCodePS.Text = Properties.Resources.PSBack; TxtConsolePS.Visible = true; - TxtOutputPS.Visible = false; } else { - ChkCodePS.Text = Properties.Resources.PSViewCode; - TxtOutputPS.Visible = true; + ChkCodePS.Text = Properties.Resources.ChkCodePS; TxtConsolePS.Visible = false; } } @@ -677,7 +691,6 @@ namespace Privatezilla /// /// Save PowerShell script files as new preset script files /// - private void PSSaveAs_Click(object sender, EventArgs e) { if (ChkCodePS.Checked == false) @@ -711,7 +724,7 @@ namespace Privatezilla private void PSMarketplace_Click(object sender, EventArgs e) { - Process.Start("http://www.builtbybel.com/marketplace"); + Process.Start("https://github.com/builtbybel/privatezilla/tree/master/scripts"); } private void CommunityPkg_Click(object sender, EventArgs e) diff --git a/src/Privatezilla/MainWindow.resx b/src/Privatezilla/MainWindow.resx index e2cfb51..d4381b3 100644 --- a/src/Privatezilla/MainWindow.resx +++ b/src/Privatezilla/MainWindow.resx @@ -145,7 +145,7 @@ PnlNav - 0 + 3 True @@ -175,7 +175,7 @@ PnlNav - 3 + 2 17, 17 @@ -273,7 +273,7 @@ PnlNav - 1 + 0 True @@ -306,7 +306,7 @@ PnlNav - 2 + 1 Top, Bottom, Left, Right @@ -525,7 +525,7 @@ $this - 4 + 5 Bottom, Right @@ -558,7 +558,7 @@ PnlSettingsBottom - 1 + 0 Bottom, Right @@ -591,7 +591,7 @@ PnlSettingsBottom - 2 + 1 Bottom, Left @@ -624,7 +624,7 @@ PnlSettingsBottom - 0 + 3 Top, Bottom, Left, Right @@ -681,13 +681,13 @@ 110 - Welcome to the Modern Policy Editor, which allows you to apply group policies and custom settings in the form of PowerShell scripts and templates (bundled scripts). + Welcome to the Scripting Editor, which allows you to apply third-party script files and custom settings in form of PowerShell scripts and templates (bundled scripts). Select a script to view it's description. To check the code for vulnerabilities click on "View code". -To obtain new objects (templates, scripts etc.) visit the Marketplace in the upper right menu. Privatezilla uses the Marketplace of the app "SharpApp". Since this app is from the same developer and the scripting is based upon Powershell, they are also compatible with each other. +To obtain new objects (templates, scripts etc.) visit the Marketplace in the upper right menu. @@ -702,43 +702,40 @@ To obtain new objects (templates, scripts etc.) visit the Marketplace in the upp 1 - - Top, Bottom, Left, Right + + Top, Left, Right - - Consolas, 9pt + + Segoe UI Semibold, 12pt, style=Bold - - 242, 48 + + 0, 0 - - True + + 5, 0, 0, 0 - - Both + + 716, 45 - - 474, 722 + + 116 - - 10 + + Apply PowerShell Script - - PS + + MiddleLeft - - False + + LblPSHeader - - TxtOutputPS + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - + PnlPS - + 2 @@ -780,42 +777,6 @@ To obtain new objects (templates, scripts etc.) visit the Marketplace in the upp 3 - - Top, Left, Right - - - Segoe UI Semibold, 12pt, style=Bold - - - 0, 0 - - - 5, 0, 0, 0 - - - 716, 45 - - - 116 - - - Apply PowerShell Script - - - MiddleLeft - - - LblPSHeader - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - PnlPS - - - 4 - 366, 0 @@ -838,7 +799,7 @@ To obtain new objects (templates, scripts etc.) visit the Marketplace in the upp $this - 5 + 4 132, 19 @@ -899,6 +860,42 @@ To obtain new objects (templates, scripts etc.) visit the Marketplace in the upp System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Bottom, Right + + + Flat + + + Segoe UI, 9.75pt + + + 508, 14 + + + 196, 32 + + + 114 + + + Apply selected + + + False + + + BtnDoPS + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + PnlSettingsBottom + + + 2 + Bottom, Left @@ -942,42 +939,6 @@ To obtain new objects (templates, scripts etc.) visit the Marketplace in the upp PnlSettingsBottom - 3 - - - Bottom, Right - - - Flat - - - Segoe UI, 9.75pt - - - 508, 14 - - - 196, 32 - - - 114 - - - Apply selected - - - False - - - BtnDoPS - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - PnlSettingsBottom - - 4 diff --git a/src/Privatezilla/Properties/AssemblyInfo.cs b/src/Privatezilla/Properties/AssemblyInfo.cs index 4bd1076..46814d5 100644 --- a/src/Privatezilla/Properties/AssemblyInfo.cs +++ b/src/Privatezilla/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, // indem Sie "*" wie unten gezeigt eingeben: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.40.2")] -[assembly: AssemblyFileVersion("0.40.2")] +[assembly: AssemblyVersion("0.41.0")] +[assembly: AssemblyFileVersion("0.41.0")] diff --git a/src/Privatezilla/Properties/Resources.Designer.cs b/src/Privatezilla/Properties/Resources.Designer.cs index c87d960..663e6b1 100644 --- a/src/Privatezilla/Properties/Resources.Designer.cs +++ b/src/Privatezilla/Properties/Resources.Designer.cs @@ -106,7 +106,7 @@ namespace Privatezilla.Properties { } /// - /// Sucht eine lokalisierte Zeichenfolge, die View Code ähnelt. + /// Sucht eine lokalisierte Zeichenfolge, die View code ähnelt. /// internal static string ChkCodePS { get { @@ -283,7 +283,7 @@ namespace Privatezilla.Properties { } /// - /// Sucht eine lokalisierte Zeichenfolge, die What does this template/script do?\r\n ähnelt. + /// Sucht eine lokalisierte Zeichenfolge, die What does this script do?\r\n ähnelt. /// internal static string PSInfo { get { @@ -309,15 +309,6 @@ namespace Privatezilla.Properties { } } - /// - /// Sucht eine lokalisierte Zeichenfolge, die View code ähnelt. - /// - internal static string PSViewCode { - get { - return ResourceManager.GetString("PSViewCode", resourceCulture); - } - } - /// /// Sucht eine lokalisierte Zeichenfolge, die You are using an unoffical version of Privatezilla. ähnelt. /// @@ -1480,13 +1471,13 @@ namespace Privatezilla.Properties { } /// - /// Sucht eine lokalisierte Zeichenfolge, die Welcome to the Modern Policy Editor, which allows you to apply group policies and custom settings in the form of PowerShell scripts and templates (bundled scripts). + /// Sucht eine lokalisierte Zeichenfolge, die Welcome to the Scripting Editor, which allows you to apply third-party script files and custom settings in form of PowerShell scripts and templates (bundled scripts). /// ///Select a script to view it's description. /// ///To check the code for vulnerabilities click on "View code". /// - ///To obtain new objects (templates, scripts etc.) visit the Marketplace in the upper right menu. Privatezilla uses the Marketplace of the app "SharpApp". Since this app is from the same developer and the scripting is based upon Powershell [Rest der Zeichenfolge wurde abgeschnitten]"; ähnelt. + ///To obtain new objects (templates, scripts etc.) visit the Marketplace in the upper right menu. ähnelt. /// internal static string TxtPSInfo { get { diff --git a/src/Privatezilla/Properties/Resources.resx b/src/Privatezilla/Properties/Resources.resx index 5ba5644..a95bb45 100644 --- a/src/Privatezilla/Properties/Resources.resx +++ b/src/Privatezilla/Properties/Resources.resx @@ -138,7 +138,7 @@ Main menu - View Code + View code GUI @@ -226,7 +226,7 @@ Add translation credits here! Scripting menu - What does this template/script do?\r\n + What does this script do?\r\n Scripting menu @@ -237,10 +237,6 @@ Add translation credits here! Save current script as new preset script Scripting menu - - View code - GUI - You are using an unoffical version of Privatezilla. @@ -731,13 +727,13 @@ Add translation credits here! Do you really want to revert all selected settings to Windows 10 default state? - Welcome to the Modern Policy Editor, which allows you to apply group policies and custom settings in the form of PowerShell scripts and templates (bundled scripts). + Welcome to the Scripting Editor, which allows you to apply third-party script files and custom settings in form of PowerShell scripts and templates (bundled scripts). Select a script to view it's description. To check the code for vulnerabilities click on "View code". -To obtain new objects (templates, scripts etc.) visit the Marketplace in the upper right menu. Privatezilla uses the Marketplace of the app "SharpApp". Since this app is from the same developer and the scripting is based upon Powershell, they are also compatible with each other. +To obtain new objects (templates, scripts etc.) visit the Marketplace in the upper right menu. GUI \ No newline at end of file