From a6b60d72bd80ed80c195cf9c5ead3e7a520e4583 Mon Sep 17 00:00:00 2001 From: Vichingo455 Date: Mon, 23 Jun 2025 16:03:48 +0200 Subject: [PATCH] Almost done first beta --- .../ApplicationIntegrityOperation.cs | 4 +- patch-seb/Form1.Designer.cs | 23 +- patch-seb/Form1.cs | 27 ++- patch-seb/OfflinePatcher.Designer.cs | 213 +++++++++++++++- patch-seb/OfflinePatcher.cs | 229 +++++++++++++++++- patch-seb/Program.cs | 25 +- patch-seb/Properties/Resources.Designer.cs | 32 +++ patch-seb/Properties/Resources.resx | 6 + patch-seb/Resources/cert.reg | Bin 0 -> 7466 bytes patch-seb/Resources/cert_offline.reg | Bin 0 -> 7472 bytes patch-seb/Variables.cs | 13 + patch-seb/patch-seb.csproj | 3 + 12 files changed, 551 insertions(+), 24 deletions(-) create mode 100644 patch-seb/Resources/cert.reg create mode 100644 patch-seb/Resources/cert_offline.reg create mode 100644 patch-seb/Variables.cs diff --git a/SafeExamBrowser.Runtime/Operations/ApplicationIntegrityOperation.cs b/SafeExamBrowser.Runtime/Operations/ApplicationIntegrityOperation.cs index 93e0fe2..fd75a8b 100644 --- a/SafeExamBrowser.Runtime/Operations/ApplicationIntegrityOperation.cs +++ b/SafeExamBrowser.Runtime/Operations/ApplicationIntegrityOperation.cs @@ -41,12 +41,12 @@ namespace SafeExamBrowser.Runtime.Operations } else { - logger.Info("Application integrity successfully verified."); + logger.Warn("Application integrity is compromised!"); } } else { - logger.Info("Application integrity successfully verified."); + logger.Warn("Failed to verify application integrity!"); } return OperationResult.Success; diff --git a/patch-seb/Form1.Designer.cs b/patch-seb/Form1.Designer.cs index ed309c3..dcecf79 100644 --- a/patch-seb/Form1.Designer.cs +++ b/patch-seb/Form1.Designer.cs @@ -33,6 +33,7 @@ this.textBox1 = new System.Windows.Forms.TextBox(); this.button1 = new System.Windows.Forms.Button(); this.checkBox1 = new System.Windows.Forms.CheckBox(); + this.checkBox2 = new System.Windows.Forms.CheckBox(); this.SuspendLayout(); // // label1 @@ -65,9 +66,9 @@ // this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.button1.Location = new System.Drawing.Point(435, 262); + this.button1.Location = new System.Drawing.Point(389, 262); this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(124, 46); + this.button1.Size = new System.Drawing.Size(170, 46); this.button1.TabIndex = 2; this.button1.Text = "PATCH"; this.button1.UseVisualStyleBackColor = true; @@ -85,11 +86,26 @@ this.checkBox1.Text = "Backup"; this.checkBox1.UseVisualStyleBackColor = true; // + // checkBox2 + // + this.checkBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.checkBox2.AutoSize = true; + this.checkBox2.Checked = true; + this.checkBox2.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBox2.Location = new System.Drawing.Point(128, 274); + this.checkBox2.Name = "checkBox2"; + this.checkBox2.Size = new System.Drawing.Size(151, 25); + this.checkBox2.TabIndex = 4; + this.checkBox2.Text = "Install Certificate"; + this.checkBox2.UseVisualStyleBackColor = true; + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 21F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(571, 330); + this.Controls.Add(this.checkBox2); this.Controls.Add(this.checkBox1); this.Controls.Add(this.button1); this.Controls.Add(this.textBox1); @@ -114,6 +130,7 @@ private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.Button button1; private System.Windows.Forms.CheckBox checkBox1; - } + private System.Windows.Forms.CheckBox checkBox2; + } } diff --git a/patch-seb/Form1.cs b/patch-seb/Form1.cs index 42f7add..0ae751f 100644 --- a/patch-seb/Form1.cs +++ b/patch-seb/Form1.cs @@ -21,7 +21,6 @@ namespace patch_seb public static bool started = false; public static bool alreadyPatched = false; public static string SEBPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + @"\SafeExamBrowser\Application\"; - public static string SupportedSEB = "3.9.0.787"; public static int something = 0; public Form1() @@ -35,8 +34,11 @@ namespace patch_seb private void Form1_Load(object sender, EventArgs e) { - AddLog("Safe Exam Browser Patch v" + Application.ProductVersion + " (Safe Exam Browser v" + SupportedSEB + ")"); - //AddLog("For Safe Exam Browser version " + SupportedSEB); + #if DEBUG + AddLog("Safe Exam Browser Patch (Debug/Beta) v" + Application.ProductVersion + " (Safe Exam Browser v" + Variables.SupportedSEB + ")"); + #else + AddLog("Safe Exam Browser Patch v" + Application.ProductVersion + " (Safe Exam Browser v" + Variables.SupportedSEB + ")"); + #endif AddLog(""); if (Environment.Is64BitOperatingSystem) { @@ -61,12 +63,12 @@ namespace patch_seb { FileVersionInfo SEBVersion = FileVersionInfo.GetVersionInfo(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + @"\SafeExamBrowser\Application\SafeExamBrowser.exe"); FileVersionInfo SEBDLLVersion = FileVersionInfo.GetVersionInfo(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + @"\SafeExamBrowser\Application\SafeExamBrowser.Configuration.dll"); - if (SEBVersion.FileVersion != SupportedSEB) + if (SEBVersion.FileVersion != Variables.SupportedSEB) { AddLog("[ERROR] Found unsupported Safe Exam Browser version."); button1.Enabled = false; } - else if (SEBVersion.ProductVersion == SupportedSEB || SEBDLLVersion.ProductVersion == "1.0.0.0") // Somehow the patched version string differs from the official version string. + else if (SEBVersion.ProductVersion == Variables.SupportedSEB || SEBDLLVersion.ProductVersion == "1.0.0.0") // Somehow the patched version string differs from the official version string. { checkBox1.Checked = false; checkBox1.Enabled = false; @@ -170,6 +172,19 @@ namespace patch_seb File.WriteAllBytes(SEBPath + @"SafeExamBrowser.UserInterface.Desktop.dll", Resources.SafeExamBrowser_UserInterface_Desktop1); File.WriteAllBytes(SEBPath + @"SafeExamBrowser.UserInterface.Mobile.dll", Resources.SafeExamBrowser_UserInterface_Mobile1); } + if (checkBox2.Checked) + { + File.WriteAllText(Path.GetTempPath() + @"\SEB.reg", Resources.cert); + ProcessStartInfo info = new ProcessStartInfo + { + FileName = Environment.GetFolderPath(Environment.SpecialFolder.Windows) + @"\regedit.exe", + Arguments = $@"/s \""{Path.GetTempPath() + @"\SEB.reg"}\""", + CreateNoWindow = true, + WindowStyle = ProcessWindowStyle.Hidden + }; + Process.Start(info).WaitForExit(); + File.Delete(Path.GetTempPath() + @"\SEB.reg"); + } AddLog("PATCHING DONE"); button1.Text = "PATCH DONE"; } @@ -184,7 +199,7 @@ namespace patch_seb if (something == 4) { something = 0; - MessageBox.Show("Safe Exam Browser Patch v" + Application.ProductVersion + "\nFor Safe Exam Browser version " + SupportedSEB + "\nCreated with love by Vichingo455\n\nBecause Freedom is a right, respect it.", "Safe Exam Browser Patch", MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show("Safe Exam Browser Patch v" + Application.ProductVersion + "\nFor Safe Exam Browser version " + Variables.SupportedSEB + "\nCreated with love by Vichingo455\n\nBecause Freedom is a right, respect it.", "Safe Exam Browser Patch", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { diff --git a/patch-seb/OfflinePatcher.Designer.cs b/patch-seb/OfflinePatcher.Designer.cs index 60399ac..e5a619c 100644 --- a/patch-seb/OfflinePatcher.Designer.cs +++ b/patch-seb/OfflinePatcher.Designer.cs @@ -30,6 +30,24 @@ { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(OfflinePatcher)); this.label1 = new System.Windows.Forms.Label(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.partitionComboBox = new System.Windows.Forms.ComboBox(); + this.label2 = new System.Windows.Forms.Label(); + this.button1 = new System.Windows.Forms.Button(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.label3 = new System.Windows.Forms.Label(); + this.selectedinstallation = new System.Windows.Forms.Label(); + this.autodetect = new System.Windows.Forms.RadioButton(); + this.x64 = new System.Windows.Forms.RadioButton(); + this.x86 = new System.Windows.Forms.RadioButton(); + this.checkBox1 = new System.Windows.Forms.CheckBox(); + this.checkBox2 = new System.Windows.Forms.CheckBox(); + this.button2 = new System.Windows.Forms.Button(); + this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.groupBox1.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.groupBox3.SuspendLayout(); this.SuspendLayout(); // // label1 @@ -38,17 +56,180 @@ | System.Windows.Forms.AnchorStyles.Right))); this.label1.AutoSize = true; this.label1.Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label1.Location = new System.Drawing.Point(336, 9); + this.label1.Location = new System.Drawing.Point(215, 9); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(343, 28); + this.label1.Size = new System.Drawing.Size(324, 28); this.label1.TabIndex = 0; - this.label1.Text = "Safe Exam Browser Offline Patcher"; + this.label1.Text = "Safe Exam Browser Offline Patch"; + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.button1); + this.groupBox1.Controls.Add(this.label2); + this.groupBox1.Controls.Add(this.partitionComboBox); + this.groupBox1.Location = new System.Drawing.Point(12, 54); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(716, 100); + this.groupBox1.TabIndex = 1; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Safe Exam Browser installations"; + // + // partitionComboBox + // + this.partitionComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.partitionComboBox.FormattingEnabled = true; + this.partitionComboBox.Location = new System.Drawing.Point(178, 44); + this.partitionComboBox.Name = "partitionComboBox"; + this.partitionComboBox.Size = new System.Drawing.Size(381, 29); + this.partitionComboBox.TabIndex = 0; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(6, 47); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(149, 21); + this.label2.TabIndex = 1; + this.label2.Text = "Installation to patch:"; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(583, 44); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(116, 29); + this.button1.TabIndex = 2; + this.button1.Text = "USE"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.checkBox2); + this.groupBox2.Controls.Add(this.checkBox1); + this.groupBox2.Controls.Add(this.x86); + this.groupBox2.Controls.Add(this.x64); + this.groupBox2.Controls.Add(this.autodetect); + this.groupBox2.Controls.Add(this.selectedinstallation); + this.groupBox2.Controls.Add(this.label3); + this.groupBox2.Enabled = false; + this.groupBox2.Location = new System.Drawing.Point(12, 176); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(716, 222); + this.groupBox2.TabIndex = 2; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Patch settings"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(21, 73); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(233, 21); + this.label3.TabIndex = 0; + this.label3.Text = "Safe Exam Browser Architecture:"; + // + // selectedinstallation + // + this.selectedinstallation.AutoSize = true; + this.selectedinstallation.Location = new System.Drawing.Point(21, 38); + this.selectedinstallation.Name = "selectedinstallation"; + this.selectedinstallation.Size = new System.Drawing.Size(190, 21); + this.selectedinstallation.TabIndex = 1; + this.selectedinstallation.Text = "Selected Installation: none"; + // + // autodetect + // + this.autodetect.AutoSize = true; + this.autodetect.Checked = true; + this.autodetect.Location = new System.Drawing.Point(260, 73); + this.autodetect.Name = "autodetect"; + this.autodetect.Size = new System.Drawing.Size(233, 25); + this.autodetect.TabIndex = 2; + this.autodetect.TabStop = true; + this.autodetect.Text = "Auto-Detect (recommended)"; + this.autodetect.UseVisualStyleBackColor = true; + // + // x64 + // + this.x64.AutoSize = true; + this.x64.Location = new System.Drawing.Point(525, 73); + this.x64.Name = "x64"; + this.x64.Size = new System.Drawing.Size(60, 25); + this.x64.TabIndex = 3; + this.x64.Text = "x64"; + this.x64.UseVisualStyleBackColor = true; + // + // x86 + // + this.x86.AutoSize = true; + this.x86.Location = new System.Drawing.Point(605, 73); + this.x86.Name = "x86"; + this.x86.Size = new System.Drawing.Size(60, 25); + this.x86.TabIndex = 4; + this.x86.Text = "x86"; + this.x86.UseVisualStyleBackColor = true; + // + // checkBox1 + // + this.checkBox1.AutoSize = true; + this.checkBox1.Location = new System.Drawing.Point(25, 110); + this.checkBox1.Name = "checkBox1"; + this.checkBox1.Size = new System.Drawing.Size(86, 25); + this.checkBox1.TabIndex = 5; + this.checkBox1.Text = "Backup"; + this.checkBox1.UseVisualStyleBackColor = true; + // + // checkBox2 + // + this.checkBox2.AutoSize = true; + this.checkBox2.Checked = true; + this.checkBox2.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBox2.Location = new System.Drawing.Point(25, 152); + this.checkBox2.Name = "checkBox2"; + this.checkBox2.Size = new System.Drawing.Size(467, 25); + this.checkBox2.TabIndex = 6; + this.checkBox2.Text = "Install custom certificate on the offline system (recommended)"; + this.checkBox2.UseVisualStyleBackColor = true; + // + // button2 + // + this.button2.Enabled = false; + this.button2.Location = new System.Drawing.Point(220, 679); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(270, 62); + this.button2.TabIndex = 3; + this.button2.Text = "PATCH"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // groupBox3 + // + this.groupBox3.Controls.Add(this.textBox1); + this.groupBox3.Location = new System.Drawing.Point(12, 414); + this.groupBox3.Name = "groupBox3"; + this.groupBox3.Size = new System.Drawing.Size(716, 245); + this.groupBox3.TabIndex = 4; + this.groupBox3.TabStop = false; + this.groupBox3.Text = "Patch logs"; + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(3, 25); + this.textBox1.Multiline = true; + this.textBox1.Name = "textBox1"; + this.textBox1.ReadOnly = true; + this.textBox1.Size = new System.Drawing.Size(707, 204); + this.textBox1.TabIndex = 0; // // OfflinePatcher // this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 21F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1069, 637); + this.ClientSize = new System.Drawing.Size(742, 753); + this.Controls.Add(this.groupBox3); + this.Controls.Add(this.button2); + this.Controls.Add(this.groupBox2); + this.Controls.Add(this.groupBox1); this.Controls.Add(this.label1); this.Font = new System.Drawing.Font("Segoe UI", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; @@ -57,6 +238,13 @@ this.Name = "OfflinePatcher"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Safe Exam Browser Offline Patcher"; + this.Load += new System.EventHandler(this.OfflinePatcher_Load); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); + this.groupBox3.ResumeLayout(false); + this.groupBox3.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -65,5 +253,20 @@ #endregion private System.Windows.Forms.Label label1; - } + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.ComboBox partitionComboBox; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.RadioButton x86; + private System.Windows.Forms.RadioButton x64; + private System.Windows.Forms.RadioButton autodetect; + private System.Windows.Forms.Label selectedinstallation; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.CheckBox checkBox2; + private System.Windows.Forms.CheckBox checkBox1; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.GroupBox groupBox3; + private System.Windows.Forms.TextBox textBox1; + } } \ No newline at end of file diff --git a/patch-seb/OfflinePatcher.cs b/patch-seb/OfflinePatcher.cs index ee281e1..3590baf 100644 --- a/patch-seb/OfflinePatcher.cs +++ b/patch-seb/OfflinePatcher.cs @@ -1,10 +1,14 @@ -using System; +using patch_seb.Properties; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; +using System.Diagnostics; using System.Drawing; +using System.IO; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; @@ -12,9 +16,232 @@ namespace patch_seb { public partial class OfflinePatcher : Form { + public static string installation = ""; + public static bool isBackup; + public static bool started = false; + public static bool alreadyPatched = false; + public static bool is64bits = false; + public static string SEBPath = ""; public OfflinePatcher() { InitializeComponent(); } + public void AddLog(string log) + { + this.textBox1.Text += log + Environment.NewLine; + } + + private void button1_Click(object sender, EventArgs e) + { + installation = partitionComboBox.SelectedItem.ToString(); + selectedinstallation.Text = $"Selected Installation: {installation}"; + AddLog($"[INFO] Selected {installation}"); + groupBox2.Enabled = true; + button2.Enabled = true; + if (File.Exists(installation + @"Windows\SysWOW64\cmd.exe")) + { + AddLog($"[INFO] Detected x64 installation on {installation}."); + is64bits = true; + } + else + { + AddLog($"[INFO] Detected x86 installation on {installation}."); + } + FileVersionInfo SEBVersion = FileVersionInfo.GetVersionInfo(installation + @"Program Files\SafeExamBrowser\Application\SafeExamBrowser.exe"); + FileVersionInfo SEBDLLVersion = FileVersionInfo.GetVersionInfo(installation + @"Program Files\SafeExamBrowser\Application\SafeExamBrowser.Configuration.dll"); + if (SEBVersion.ProductVersion == Variables.SupportedSEB || SEBDLLVersion.ProductVersion == "1.0.0.0") // Somehow the patched version string differs from the official version string. + { + alreadyPatched = true; + isBackup = false; + checkBox1.Enabled = false; + button2.Text = "PATCH AGAIN/UPDATE"; + AddLog($"READY TO UPDATE/PATCH AGAIN {installation}."); + } + else + { + AddLog($"READY TO PATCH {installation}."); + } + started = false; + } + + private void OfflinePatcher_Load(object sender, EventArgs e) + { + #if DEBUG + AddLog("Safe Exam Browser Offline Patch (Debug/Beta) v" + Application.ProductVersion + " (Safe Exam Browser v" + Variables.SupportedSEB + ")"); + #else + AddLog("Safe Exam Browser Offline Patch v" + Application.ProductVersion + " (Safe Exam Browser v" + Variables.SupportedSEB + ")"); + #endif + AddLog(""); + partitionComboBox.Items.Clear(); + AddLog("[INFO] Searching for suitable partitions..."); + DriveInfo[] allDrives = DriveInfo.GetDrives(); + foreach (DriveInfo drive in allDrives) + { + if (drive.IsReady && drive.Name != @"X:\" && File.Exists(drive.Name + @"Program Files\SafeExamBrowser\Application\SafeExamBrowser.exe")) + { + FileVersionInfo SEBVersion = FileVersionInfo.GetVersionInfo(drive.Name + @"Program Files\SafeExamBrowser\Application\SafeExamBrowser.exe"); + FileVersionInfo SEBDLLVersion = FileVersionInfo.GetVersionInfo(drive.Name + @"Program Files\SafeExamBrowser\Application\SafeExamBrowser.Configuration.dll"); + if (SEBVersion.FileVersion != Variables.SupportedSEB) + { + AddLog($"[WARNING] Partition {drive.Name} contains unsupported Safe Exam Browser version, not adding to the list."); + } + else if (SEBVersion.ProductVersion == Variables.SupportedSEB || SEBDLLVersion.ProductVersion == "1.0.0.0") // Somehow the patched version string differs from the official version string. + { + AddLog($"[WARNING] Partition {drive.Name} contains an already patched Safe Exam Browser, adding to the list anyway."); + string label = $"{drive.Name}"; + partitionComboBox.Items.Add(label); + } + else + { + AddLog($"[INFO] Partition {drive.Name} contains a supported Safe Exam Browser version, adding to the list."); + string label = $"{drive.Name}"; + partitionComboBox.Items.Add(label); + } + } + else + { + AddLog($"[WARNING] Partition {drive.Name} doesn't contain an installed Safe Exam Browser version or is not formatted correctly, not adding to the list."); + } + } + + if (partitionComboBox.Items.Count > 0) + { + AddLog($"[INFO] Found {partitionComboBox.Items.Count} partitions suitable for the patch."); + partitionComboBox.SelectedIndex = 0; + } + else + { + AddLog("[ERROR] Found 0 partitions suitable for the patch."); + button1.Enabled = false; + } + } + + private void button2_Click(object sender, EventArgs e) + { + SEBPath = installation + @"Program Files\SafeExamBrowser\Application"; + if (alreadyPatched) + { + var dialog = MessageBox.Show("An already patched Safe Exam Browser has been found. Are you sure to continue?", "Safe Exam Browser Offline Patch", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); + if (dialog == DialogResult.No) + { + return; + } + } + isBackup = checkBox1.Checked; + if (!started) + { + started = true; + Thread thr = new Thread(PatchThread); + thr.Start(); + } + } + private void PatchThread() + { + if (isBackup) + { + try + { + if (File.Exists(SEBPath + @"SafeExamBrowser.exe.backup")) + { + File.Delete(SEBPath + @"SafeExamBrowser.exe.backup"); + } + File.Copy(SEBPath + @"SafeExamBrowser.exe", SEBPath + @"SafeExamBrowser.exe.backup"); + if (File.Exists(SEBPath + @"SafeExamBrowser.Client.exe.backup")) + { + File.Delete(SEBPath + @"SafeExamBrowser.Client.exe.backup"); + } + File.Copy(SEBPath + @"SafeExamBrowser.Client.exe", SEBPath + @"SafeExamBrowser.Client.exe.backup"); + if (File.Exists(SEBPath + @"SafeExamBrowser.Configuration.dll.backup")) + { + File.Delete(SEBPath + @"SafeExamBrowser.Configuration.dll.backup"); + } + File.Copy(SEBPath + @"SafeExamBrowser.Configuration.dll", SEBPath + @"SafeExamBrowser.Configuration.dll.backup"); + if (File.Exists(SEBPath + @"SafeExamBrowser.Monitoring.dll.backup")) + { + File.Delete(SEBPath + @"SafeExamBrowser.Monitoring.dll.backup"); + } + File.Copy(SEBPath + @"SafeExamBrowser.Monitoring.dll", SEBPath + @"SafeExamBrowser.Monitoring.dll.backup"); + if (File.Exists(SEBPath + @"SafeExamBrowser.UserInterface.Desktop.dll.backup")) + { + File.Delete(SEBPath + @"SafeExamBrowser.UserInterface.Desktop.dll.backup"); + } + File.Copy(SEBPath + @"SafeExamBrowser.UserInterface.Desktop.dll", SEBPath + @"SafeExamBrowser.UserInterface.Desktop.dll.backup"); + if (File.Exists(SEBPath + @"SafeExamBrowser.UserInterface.Mobile.dll.backup")) + { + File.Delete(SEBPath + @"SafeExamBrowser.UserInterface.Mobile.dll.backup"); + } + File.Copy(SEBPath + @"SafeExamBrowser.UserInterface.Mobile.dll", SEBPath + @"SafeExamBrowser.UserInterface.Mobile.dll.backup"); + } + catch (Exception ex) + { + AddLog("[ERROR] " + ex.Message); + } + } + try + { + File.Delete(SEBPath + @"SafeExamBrowser.exe"); + File.Delete(SEBPath + @"SafeExamBrowser.Client.exe"); + File.Delete(SEBPath + @"SafeExamBrowser.Configuration.dll"); + File.Delete(SEBPath + @"SafeExamBrowser.Monitoring.dll"); + File.Delete(SEBPath + @"SafeExamBrowser.UserInterface.Desktop.dll"); + File.Delete(SEBPath + @"SafeExamBrowser.UserInterface.Mobile.dll"); + if (is64bits) // 64 bits patch + { + File.WriteAllBytes(SEBPath + @"SafeExamBrowser.exe", Resources.SafeExamBrowser); + File.WriteAllBytes(SEBPath + @"SafeExamBrowser.Client.exe", Resources.SafeExamBrowser_Client); + File.WriteAllBytes(SEBPath + @"SafeExamBrowser.Configuration.dll", Resources.SafeExamBrowser_Configuration); + File.WriteAllBytes(SEBPath + @"SafeExamBrowser.Monitoring.dll", Resources.SafeExamBrowser_Monitoring); + File.WriteAllBytes(SEBPath + @"SafeExamBrowser.UserInterface.Desktop.dll", Resources.SafeExamBrowser_UserInterface_Desktop); + File.WriteAllBytes(SEBPath + @"SafeExamBrowser.UserInterface.Mobile.dll", Resources.SafeExamBrowser_UserInterface_Mobile); + } + else // 32 bits patch + { + File.WriteAllBytes(SEBPath + @"SafeExamBrowser.exe", Resources.SafeExamBrowser1); + File.WriteAllBytes(SEBPath + @"SafeExamBrowser.Client.exe", Resources.SafeExamBrowser_Client1); + File.WriteAllBytes(SEBPath + @"SafeExamBrowser.Configuration.dll", Resources.SafeExamBrowser_Configuration1); + File.WriteAllBytes(SEBPath + @"SafeExamBrowser.Monitoring.dll", Resources.SafeExamBrowser_Monitoring1); + File.WriteAllBytes(SEBPath + @"SafeExamBrowser.UserInterface.Desktop.dll", Resources.SafeExamBrowser_UserInterface_Desktop1); + File.WriteAllBytes(SEBPath + @"SafeExamBrowser.UserInterface.Mobile.dll", Resources.SafeExamBrowser_UserInterface_Mobile1); + } + if (checkBox2.Checked) + { + // Load offline registry + ProcessStartInfo load = new ProcessStartInfo + { + FileName = Environment.GetFolderPath(Environment.SpecialFolder.Windows) + @"System32\reg.exe", + Arguments = $@"load HKLM\OFFSOFTWARE {installation}Windows\System32\config\software", + CreateNoWindow = true, + WindowStyle = ProcessWindowStyle.Hidden + }; + Process.Start(load).WaitForExit(); + // Add certificate to offline registry + File.WriteAllText(Path.GetTempPath() + @"\SEB.reg", Resources.cert_offline); + ProcessStartInfo info = new ProcessStartInfo + { + FileName = Environment.GetFolderPath(Environment.SpecialFolder.Windows) + @"\regedit.exe", + Arguments = $@"/s \""{Path.GetTempPath() + @"\SEB.reg"}\""", + CreateNoWindow = true, + WindowStyle = ProcessWindowStyle.Hidden + }; + Process.Start(info).WaitForExit(); + File.Delete(Path.GetTempPath() + @"\SEB.reg"); + // Unload offline registry + ProcessStartInfo unload = new ProcessStartInfo + { + FileName = Environment.GetFolderPath(Environment.SpecialFolder.Windows) + @"System32\reg.exe", + Arguments = $@"unload HKLM\OFFSOFTWARE", + CreateNoWindow = true, + WindowStyle = ProcessWindowStyle.Hidden + }; + Process.Start(unload).WaitForExit(); + } + AddLog($"PATCHING DONE ON {installation}."); + button2.Text = "PATCH DONE"; + } + catch (Exception ex) + { + AddLog("[ERROR] " + ex.Message); + } + } } } diff --git a/patch-seb/Program.cs b/patch-seb/Program.cs index 170d2d6..c9230de 100644 --- a/patch-seb/Program.cs +++ b/patch-seb/Program.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; @@ -16,21 +17,31 @@ namespace patch_seb { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - if (args.Length == 1) + // Checks + if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.Windows) + @"\System32\wpeinit.exe")) { - if (args[1] == "/offline" || args[1] == "/Offline") + // Running in Windows PE environment, launch the offline patcher + Application.Run(new OfflinePatcher()); + } + else + { + // Check if the user wants the offline patcher + if (args.Length == 1) { - Application.Run(new OfflinePatcher()); + if (args[1] == "/offline" || args[1] == "/Offline") + { + Application.Run(new OfflinePatcher()); + } + else + { + Application.Run(new Form1()); + } } else { Application.Run(new Form1()); } } - else - { - Application.Run(new Form1()); - } } } } diff --git a/patch-seb/Properties/Resources.Designer.cs b/patch-seb/Properties/Resources.Designer.cs index f88acc6..bf771fc 100644 --- a/patch-seb/Properties/Resources.Designer.cs +++ b/patch-seb/Properties/Resources.Designer.cs @@ -60,6 +60,38 @@ namespace patch_seb.Properties { } } + /// + /// Cerca una stringa localizzata simile a Windows Registry Editor Version 5.00 + /// + ///[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SystemCertificates\ROOT\Certificates\05737772423FD69437E6CB3414588365A01BC1CF] + ///"Blob"=hex:5c,00,00,00,01,00,00,00,04,00,00,00,00,08,00,00,19,00,00,00,01,00,\ + /// 00,00,10,00,00,00,89,b3,20,3f,64,c9,40,55,fa,01,d8,bc,c2,46,23,f5,0f,00,00,\ + /// 00,01,00,00,00,14,00,00,00,9b,59,e4,8f,91,2b,32,28,53,7d,fa,59,57,11,4d,24,\ + /// 9e,c3,79,4f,03,00,00,00,01,00,00,00,14,00,00,00,05,73,77,72,42,3f,d6,94,37,\ + /// e6,cb,34,14,58,83,65,a0,1b,c1,c [stringa troncata]";. + /// + internal static string cert { + get { + return ResourceManager.GetString("cert", resourceCulture); + } + } + + /// + /// Cerca una stringa localizzata simile a Windows Registry Editor Version 5.00 + /// + ///[HKEY_LOCAL_MACHINE\OFFSOFTWARE\Microsoft\SystemCertificates\ROOT\Certificates\05737772423FD69437E6CB3414588365A01BC1CF] + ///"Blob"=hex:5c,00,00,00,01,00,00,00,04,00,00,00,00,08,00,00,19,00,00,00,01,00,\ + /// 00,00,10,00,00,00,89,b3,20,3f,64,c9,40,55,fa,01,d8,bc,c2,46,23,f5,0f,00,00,\ + /// 00,01,00,00,00,14,00,00,00,9b,59,e4,8f,91,2b,32,28,53,7d,fa,59,57,11,4d,24,\ + /// 9e,c3,79,4f,03,00,00,00,01,00,00,00,14,00,00,00,05,73,77,72,42,3f,d6,94,37,\ + /// e6,cb,34,14,58,83,65,a0,1b,c [stringa troncata]";. + /// + internal static string cert_offline { + get { + return ResourceManager.GetString("cert_offline", resourceCulture); + } + } + /// /// Cerca una risorsa localizzata di tipo System.Byte[]. /// diff --git a/patch-seb/Properties/Resources.resx b/patch-seb/Properties/Resources.resx index 10489dd..163049a 100644 --- a/patch-seb/Properties/Resources.resx +++ b/patch-seb/Properties/Resources.resx @@ -118,6 +118,12 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + ..\Resources\cert.reg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16 + + + ..\Resources\cert_offline.reg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16 + ..\Resources\x64\SafeExamBrowser.exe;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 diff --git a/patch-seb/Resources/cert.reg b/patch-seb/Resources/cert.reg new file mode 100644 index 0000000000000000000000000000000000000000..3507517eff9c2a7d26436b63e8408e6795c69262 GIT binary patch literal 7466 zcmchcZHpX56ou=v;C~4DJV^JvkKhLr6BLbs7z|=0^z?LVK(mkpG=E;b=RAF>-r3zq z5|w2;y;aq>&V4^s`RmUo<#~BgPUWKfUS5@3`$hb{DW8-kem*WA`S-{2W%)Y3`Jp^3-;{^tZuva^eO4aCzjtHqtMYBk zJ}uwH-2L*nJc;o~9(fQl`;dJR(l5#wJ8IP%BN@tX@wIk-9jivK?Bach*{AXS!}xg| zZ#S=L0_m=-;#WV*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.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace patch_seb +{ + internal class Variables + { + public static string SupportedSEB = "3.9.0.787"; + } +} diff --git a/patch-seb/patch-seb.csproj b/patch-seb/patch-seb.csproj index 4ccd6e3..f13cc71 100644 --- a/patch-seb/patch-seb.csproj +++ b/patch-seb/patch-seb.csproj @@ -68,6 +68,7 @@ + Form1.cs @@ -99,6 +100,8 @@ + +