From 05b3a31b4f8824b55bd8016ff8554bf9bd52e075 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Wed, 3 Jun 2020 11:17:23 +0100 Subject: [PATCH] Updated to work with 3.1.3 --- Constants.cs | 2 +- Control4.Jailbreak.csproj | 9 - DirectorManager.cs | 21 +- UI/Composer.Designer.cs | 248 +++++++++------------ UI/Composer.cs | 135 ++--------- UI/Composer.resx | 4 +- UI/Director.cs | 8 +- UI/DirectorPatch.Designer.cs | 421 ++++++++++++++++++++++++++++++----- UI/DirectorPatch.cs | 143 +++++++----- UI/DirectorPatch.resx | 16 +- UI/LogWindow.cs | 6 + UI/MainWindow.Designer.cs | 372 ++++++++++++++----------------- UI/MainWindow.cs | 42 +--- UI/Restore.Designer.cs | 137 ------------ UI/Restore.cs | 146 ------------ UI/Restore.resx | 120 ---------- 16 files changed, 805 insertions(+), 1025 deletions(-) delete mode 100644 UI/Restore.Designer.cs delete mode 100644 UI/Restore.cs delete mode 100644 UI/Restore.resx diff --git a/Constants.cs b/Constants.cs index 03e3fb0..9aba8f5 100644 --- a/Constants.cs +++ b/Constants.cs @@ -44,6 +44,6 @@ public static class Constants /// /// What version of Director/Composer we're aiming at /// - public const string TargetDirectorVersion = @"3.1.0"; + public const string TargetDirectorVersion = @"3.1.3"; } } diff --git a/Control4.Jailbreak.csproj b/Control4.Jailbreak.csproj index d16e1d2..bb8e33f 100644 --- a/Control4.Jailbreak.csproj +++ b/Control4.Jailbreak.csproj @@ -96,12 +96,6 @@ True Resources.resx - - UserControl - - - Restore.cs - UserControl @@ -147,9 +141,6 @@ - - Restore.cs - DirectorPatch.cs diff --git a/DirectorManager.cs b/DirectorManager.cs index 635b55a..e8d9dd0 100644 --- a/DirectorManager.cs +++ b/DirectorManager.cs @@ -26,7 +26,7 @@ public DirectorManager( IPAddress address ) { this.address = address; - SshConnectionInfo = new ConnectionInfo( address.ToString(), "root", new PasswordAuthenticationMethod( "root", "t0talc0ntr0l4!" ) ); + SshConnectionInfo = new ConnectionInfo( address.ToString(), "jailbreak", new PasswordAuthenticationMethod( "jailbreak", "jailbreak" ) ); SshConnectionInfo.RetryAttempts = 1; SshConnectionInfo.Timeout = TimeSpan.FromSeconds( 2 ); } @@ -36,15 +36,20 @@ public DirectorManager( IPAddress address ) public async Task TryInitialize() { - Soap = new SoapClient( address ); - var getItems = await Soap.Call( "GetItems", "filter", "1" ); - var getVersionInfo = await Soap.Call( "GetVersionInfo" ); - var getCommonName = await Soap.Call( "GetCommonName" ); + // + // Since 3.1.1 Soap doesn't work, we probably need a certificate or something + // - SystemName = getItems.SystemItems.All.Single( x => x.Type == 1 ).Name; - CommonName = getCommonName.CommonName; - Version = getVersionInfo.Versions.All.Single( x => x.Name == "Director" ).VersionNumber; + //Soap = new SoapClient( address ); + + //var getItems = await Soap.Call( "GetItems", "filter", "1" ); + //var getVersionInfo = await Soap.Call( "GetVersionInfo" ); + //var getCommonName = await Soap.Call( "GetCommonName" ); + + //SystemName = getItems.SystemItems.All.FirstOrDefault( x => x.Type == 1 ).Name; + //CommonName = getCommonName.CommonName; + //Version = getVersionInfo.Versions.All.Single( x => x.Name == "Director" ).VersionNumber; Trace.WriteLine( $"Version is {Version}" ); diff --git a/UI/Composer.Designer.cs b/UI/Composer.Designer.cs index f664a55..487a56e 100644 --- a/UI/Composer.Designer.cs +++ b/UI/Composer.Designer.cs @@ -28,144 +28,118 @@ protected override void Dispose( bool disposing ) /// private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Composer)); - this.label4 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label5 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.linkFolder = new System.Windows.Forms.LinkLabel(); - this.linkOpenPatched = new System.Windows.Forms.LinkLabel(); - this.button3 = new System.Windows.Forms.Button(); - this.button1 = new System.Windows.Forms.Button(); - this.button2 = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label4.ForeColor = System.Drawing.SystemColors.Highlight; - this.label4.Location = new System.Drawing.Point(13, 193); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(189, 18); - this.label4.TabIndex = 3; - this.label4.Text = "Patching Composer Pro"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label2.ForeColor = System.Drawing.SystemColors.Highlight; - this.label2.Location = new System.Drawing.Point(13, 18); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(178, 18); - this.label2.TabIndex = 7; - this.label2.Text = "Getting Composer Pro"; - // - // label5 - // - this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Composer)); + this.label4 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.button3 = new System.Windows.Forms.Button(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("Microsoft YaHei", 20.25F, System.Drawing.FontStyle.Bold); + this.label4.ForeColor = System.Drawing.SystemColors.Highlight; + this.label4.Location = new System.Drawing.Point(13, 314); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(253, 36); + this.label4.TabIndex = 3; + this.label4.Text = "Composer Config"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("Microsoft YaHei", 20.25F, System.Drawing.FontStyle.Bold); + this.label2.ForeColor = System.Drawing.SystemColors.Highlight; + this.label2.Location = new System.Drawing.Point(13, 52); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(265, 36); + this.label2.TabIndex = 7; + this.label2.Text = "Get Composer Pro"; + // + // label5 + // + this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.label5.Location = new System.Drawing.Point(13, 48); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(390, 57); - this.label5.TabIndex = 8; - this.label5.Text = "The Composer version should match the version of your system. The latest is 3.1.\r" + - "\n\r\nIt doesn\'t feel right linking to Composer Pro downloads but they\'re quite eas" + - "y to find if you know the filename. "; - // - // label3 - // - this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + this.label5.Location = new System.Drawing.Point(19, 97); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(463, 57); + this.label5.TabIndex = 8; + this.label5.Text = "The Composer version should match the version of your system.\r\n\r\nIt doesn\'t feel " + + "right linking to Composer Pro downloads but they\'re quite easy to find if you kn" + + "ow the filename. "; + // + // label3 + // + this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.label3.Location = new System.Drawing.Point(13, 222); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(405, 54); - this.label3.TabIndex = 4; - this.label3.Text = resources.GetString("label3.Text"); - // - // linkFolder - // - this.linkFolder.AutoSize = true; - this.linkFolder.Location = new System.Drawing.Point(13, 337); - this.linkFolder.Name = "linkFolder"; - this.linkFolder.Size = new System.Drawing.Size(115, 13); - this.linkFolder.TabIndex = 11; - this.linkFolder.TabStop = true; - this.linkFolder.Text = "Open Composer Folder"; - this.linkFolder.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.OpenComposerFolder); - // - // linkOpenPatched - // - this.linkOpenPatched.AutoSize = true; - this.linkOpenPatched.Location = new System.Drawing.Point(303, 337); - this.linkOpenPatched.Name = "linkOpenPatched"; - this.linkOpenPatched.Size = new System.Drawing.Size(126, 13); - this.linkOpenPatched.TabIndex = 12; - this.linkOpenPatched.TabStop = true; - this.linkOpenPatched.Text = "Open Patched Composer"; - this.linkOpenPatched.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.StartModdedComposer); - // - // button3 - // - this.button3.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.button3.Image = global:: Garry.Control4.Jailbreak.Properties.Resources.reddit; - this.button3.Location = new System.Drawing.Point(181, 127); - this.button3.Name = "button3"; - this.button3.Size = new System.Drawing.Size(93, 37); - this.button3.TabIndex = 10; - this.button3.Text = " r/c4diy"; - this.button3.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - this.button3.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; - this.button3.UseVisualStyleBackColor = true; - this.button3.Click += new System.EventHandler(this.OpenControl4Reddit); - // - // button1 - // - this.button1.Image = global:: Garry.Control4.Jailbreak.Properties.Resources.loupe; - this.button1.Location = new System.Drawing.Point(280, 127); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(123, 37); - this.button1.TabIndex = 9; - this.button1.Text = " Search Google"; - this.button1.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - this.button1.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.SearchGoogleForComposer); - // - // button2 - // - this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.button2.AutoSize = true; - this.button2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.button2.Image = global:: Garry.Control4.Jailbreak.Properties.Resources.patch; - this.button2.Location = new System.Drawing.Point(250, 289); - this.button2.Name = "button2"; - this.button2.Padding = new System.Windows.Forms.Padding(8); - this.button2.Size = new System.Drawing.Size(153, 39); - this.button2.TabIndex = 5; - this.button2.Text = " Patch Composer.exe"; - this.button2.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; - this.button2.UseVisualStyleBackColor = true; - this.button2.Click += new System.EventHandler(this.PatchComposer); - // - // Composer - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.linkOpenPatched); - this.Controls.Add(this.linkFolder); - this.Controls.Add(this.button3); - this.Controls.Add(this.button1); - this.Controls.Add(this.label5); - this.Controls.Add(this.label2); - this.Controls.Add(this.label3); - this.Controls.Add(this.button2); - this.Controls.Add(this.label4); - this.Name = "Composer"; - this.Size = new System.Drawing.Size(436, 361); - this.ResumeLayout(false); - this.PerformLayout(); + this.label3.Location = new System.Drawing.Point(19, 365); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(463, 78); + this.label3.TabIndex = 4; + this.label3.Text = resources.GetString("label3.Text"); + // + // button3 + // + this.button3.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.button3.Image = global::Garry.Control4.Jailbreak.Properties.Resources.reddit; + this.button3.Location = new System.Drawing.Point(264, 172); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(93, 37); + this.button3.TabIndex = 10; + this.button3.Text = " r/c4diy"; + this.button3.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.button3.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; + this.button3.UseVisualStyleBackColor = true; + this.button3.Click += new System.EventHandler(this.OpenControl4Reddit); + // + // button1 + // + this.button1.Image = global::Garry.Control4.Jailbreak.Properties.Resources.loupe; + this.button1.Location = new System.Drawing.Point(363, 172); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(123, 37); + this.button1.TabIndex = 9; + this.button1.Text = " Search Google"; + this.button1.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.button1.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.SearchGoogleForComposer); + // + // button2 + // + this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.button2.AutoSize = true; + this.button2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.button2.Image = global::Garry.Control4.Jailbreak.Properties.Resources.patch; + this.button2.Location = new System.Drawing.Point(353, 458); + this.button2.Name = "button2"; + this.button2.Padding = new System.Windows.Forms.Padding(8); + this.button2.Size = new System.Drawing.Size(129, 39); + this.button2.TabIndex = 5; + this.button2.Text = "Patch Config File"; + this.button2.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.PatchComposer); + // + // Composer + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.button3); + this.Controls.Add(this.button1); + this.Controls.Add(this.label5); + this.Controls.Add(this.label2); + this.Controls.Add(this.label3); + this.Controls.Add(this.button2); + this.Controls.Add(this.label4); + this.Name = "Composer"; + this.Size = new System.Drawing.Size(500, 547); + this.ResumeLayout(false); + this.PerformLayout(); } @@ -177,7 +151,5 @@ private void InitializeComponent() private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button3; private System.Windows.Forms.Label label3; - private System.Windows.Forms.LinkLabel linkFolder; - private System.Windows.Forms.LinkLabel linkOpenPatched; } } diff --git a/UI/Composer.cs b/UI/Composer.cs index 460fb4d..66f25af 100644 --- a/UI/Composer.cs +++ b/UI/Composer.cs @@ -26,23 +26,20 @@ public Composer( MainWindow MainWindow ) InitializeComponent(); } - void UpdateLinks() - { - var moddedExists = System.IO.File.Exists( "C:\\Program Files (x86)\\Control4\\Composer\\Pro\\ComposerPro.modded.exe" ); - linkOpenPatched.Enabled = moddedExists; - } - private void PatchComposer( object sender, EventArgs eventargs ) { + var oldLine = ""; + var newLine = ""; + var log = new LogWindow( MainWindow ); - log.WriteTrace( "Asking for ComposerPro.exe location\n" ); + log.WriteTrace( "Asking for ComposerPro.exe.config location\n" ); OpenFileDialog open = new OpenFileDialog(); - open.Filter = "Executable Files|*.exe"; - open.Title = "Find Original ComposerPro.exe"; + open.Filter = "Config Files|*.config"; + open.Title = "Find Original ComposerPro.exe.config"; open.InitialDirectory = "C:\\Program Files (x86)\\Control4\\Composer\\Pro"; - open.FileName = "ComposerPro.exe"; + open.FileName = "ComposerPro.exe.config"; if ( open.ShowDialog() != DialogResult.OK ) { @@ -59,124 +56,32 @@ private void PatchComposer( object sender, EventArgs eventargs ) log.WriteNormal( "Opening " ); log.WriteHighlight( $"{open.FileName}\n" ); - using ( var val = AssemblyDefinition.ReadAssembly( open.FileName ) ) - { - log.WriteTrace( $"Finding \"Control4.ComposerPro.MainForm\"\n" ); - - var mainForm = val.MainModule.Types.SingleOrDefault( x => x.FullName == "Control4.ComposerPro.MainForm" ); - if ( mainForm == null ) - { - log.WriteError( "Oops - couldn't find the class Control4.ComposerPro.MainForm\n" ); - return; - } - - log.WriteNormal( $"Found " ); - log.WriteHighlight( $"{mainForm}\n" ); - - log.WriteTrace( $"Finding \"ShowStartupOnFirstRun\"\n" ); - - var showStartupOnFirstRun = mainForm.Methods.SingleOrDefault( x => x.Name == "ShowStartupOnFirstRun" ); - if ( showStartupOnFirstRun == null ) - { - log.WriteError( "Oops - couldn't find the method ShowStartupOnFirstRun (Maybe already patched?)\n" ); - return; - } - - log.WriteNormal( $"Found " ); - log.WriteHighlight( $"{showStartupOnFirstRun}\n" ); - - log.WriteNormal( $"Removing.." ); - mainForm.Methods.Remove( showStartupOnFirstRun ); - log.WriteSuccess( $" ..Done!\n" ); - - // TODO - Skip update check - // TODO - Add info in window title - // TODO - Fix dealeraccount.xml not found exception - - try - { - var outFile = System.IO.Path.ChangeExtension( open.FileName, NewExtension ); - - // - // We might be re-patching for some reason, so delete the old one - // - if ( System.IO.File.Exists( outFile ) ) - { - System.IO.File.Delete( outFile ); - } - - log.WriteNormal( $"Saving to " ); - log.WriteHighlight( $"{outFile}\n\n" ); - - // Save the file - val.Write( outFile ); + var contents = System.IO.File.ReadAllText( open.FileName ); - // We need to copy the config and manifest too, or we'll be missing a bunch of settings - log.WriteNormal( $"Copying " ); - log.WriteHighlight( $"ComposerPro.exe.manifest" ); - log.WriteNormal( $" to " ); - log.WriteHighlight( $"ComposerPro{NewExtension}.manifest\n" ); - - System.IO.File.Copy( $"{open.FileName}.manifest", $"{outFile}.manifest", true ); - - log.WriteNormal( $"Copying " ); - log.WriteHighlight( $"ComposerPro.exe.config" ); - log.WriteNormal( $" to " ); - log.WriteHighlight( $"ComposerPro{NewExtension}.config\n" ); - - System.IO.File.Copy( $"{open.FileName}.config", $"{outFile}.config", true ); - - // Create desktop shortcut - { - log.WriteNormal( $"\nCreating Desktop Shortcut.. " ); - - var shortcutPath = $"{Environment.GetFolderPath( Environment.SpecialFolder.DesktopDirectory )}\\Composer Pro (Patched).url"; - - if ( System.IO.File.Exists( shortcutPath ) ) - System.IO.File.Delete( shortcutPath ); - - using ( StreamWriter writer = new StreamWriter( shortcutPath ) ) - { - var app = outFile.Replace( '\\', '/' ); - - writer.WriteLine( "[InternetShortcut]" ); - writer.WriteLine( $"URL=file:///{app.Replace( " ", "%20" )}" ); - writer.WriteLine( "IconIndex=0" ); - writer.WriteLine( "IconFile=" + app ); - writer.Flush(); - } + if ( !contents.Contains( oldLine ) ) + { + log.WriteHighlight( "Couldn't find the line - probably already patched??" ); + return; + } - log.WriteSuccess( $"done!\n" ); - } + log.WriteHighlight( $"Writing Backup..\n" ); + System.IO.File.WriteAllText( open.FileName + $".backup-{DateTime.Now.ToString( "yyyy-dd-M--HH-mm-ss" )}", contents ); + log.WriteHighlight( $"Writing New File..\n" ); + contents = contents.Replace( oldLine, newLine ); - log.WriteSuccess( $"\nAll done - you can close this window!\n" ); - } - catch ( UnauthorizedAccessException e ) - { - log.WriteError( $"Exception - {e.Message}\n" ); - } - } + System.IO.File.WriteAllText( open.FileName, contents ); + log.WriteHighlight( $"Done!\n" ); } private void SearchGoogleForComposer( object sender, EventArgs e ) { - System.Diagnostics.Process.Start( $"https://www.google.com/search?q=ComposerPro-3.1.0.566729-res.exe" ); + System.Diagnostics.Process.Start( $"https://www.google.com/search?q=ComposerPro-3.1.3.574885-res.exe" ); } private void OpenControl4Reddit( object sender, EventArgs e ) { System.Diagnostics.Process.Start( $"https://www.reddit.com/r/C4diy/" ); } - - private void OpenComposerFolder( object sender, LinkLabelLinkClickedEventArgs e ) - { - System.Diagnostics.Process.Start( $"C:\\Program Files (x86)\\Control4\\Composer" ); - } - - private void StartModdedComposer( object sender, LinkLabelLinkClickedEventArgs e ) - { - System.Diagnostics.Process.Start( $"C:\\Program Files (x86)\\Control4\\Composer\\Pro\\ComposerPro.modded.exe" ); - } } } diff --git a/UI/Composer.resx b/UI/Composer.resx index ccfd6c3..ce75641 100644 --- a/UI/Composer.resx +++ b/UI/Composer.resx @@ -118,8 +118,8 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - This technically isn't needed, but it'll stop composer checking registration status with Control4 on startup, so it'll start up a bit faster. + We need to stop Composer asking Control4 if you're a dealer. To do this we change the ComposerPro_LicensingService_Licensing setting in ComposerPro.exe.config. -We won't overwrite, the new version is saved as ComposerPro.modded.exe +You can do this yourself, or we can do it for you by pressing the button. We'll back up the old config file for you. \ No newline at end of file diff --git a/UI/Director.cs b/UI/Director.cs index 9d0fef9..d3af69c 100644 --- a/UI/Director.cs +++ b/UI/Director.cs @@ -11,6 +11,9 @@ namespace Garry.Control4.Jailbreak { + /// + /// This isn't really used now + /// public partial class Director : UserControl { MainWindow MainWindow; @@ -94,6 +97,9 @@ async Task Connect( Utility.Sddp.DeviceResponse connection ) { try { + + MainWindow.DirectorPatch.Address.Text = connection.EndPoint.Address.ToString(); + MainWindow.SetStatusRight( $"Connecting to {connection.EndPoint.Address}.." ); var director = new DirectorManager( connection.EndPoint.Address ); @@ -127,9 +133,7 @@ internal void DirectorDisconnected() private void UpdateDirectorInfo() { - MainWindow.Backup.Enabled = true; MainWindow.DirectorPatch.Enabled = true; - MainWindow.Restore.Enabled = true; directorInfo.Text = $"System Name: {MainWindow.ConnectedDirector.SystemName}\n"; directorInfo.Text += $"Common Name: {MainWindow.ConnectedDirector.CommonName}\n"; diff --git a/UI/DirectorPatch.Designer.cs b/UI/DirectorPatch.Designer.cs index d9775cb..ed46e21 100644 --- a/UI/DirectorPatch.Designer.cs +++ b/UI/DirectorPatch.Designer.cs @@ -28,63 +28,380 @@ protected override void Dispose( bool disposing ) /// private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DirectorPatch)); - this.label2 = new System.Windows.Forms.Label(); - this.label5 = new System.Windows.Forms.Label(); - this.button1 = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label2.ForeColor = System.Drawing.SystemColors.Highlight; - this.label2.Location = new System.Drawing.Point(13, 18); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(142, 18); - this.label2.TabIndex = 7; - this.label2.Text = "Jailbreak Director"; - // - // label5 - // - this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DirectorPatch)); + this.label5 = new System.Windows.Forms.Label(); + this.button1 = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.button2 = new System.Windows.Forms.Button(); + this.label3 = new System.Windows.Forms.Label(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.label4 = new System.Windows.Forms.Label(); + this.button3 = new System.Windows.Forms.Button(); + this.label6 = new System.Windows.Forms.Label(); + this.label7 = new System.Windows.Forms.Label(); + this.button4 = new System.Windows.Forms.Button(); + this.button5 = new System.Windows.Forms.Button(); + this.label8 = new System.Windows.Forms.Label(); + this.label9 = new System.Windows.Forms.Label(); + this.Password = new System.Windows.Forms.TextBox(); + this.Username = new System.Windows.Forms.TextBox(); + this.Address = new System.Windows.Forms.TextBox(); + this.label10 = new System.Windows.Forms.Label(); + this.label11 = new System.Windows.Forms.Label(); + this.label12 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label13 = new System.Windows.Forms.Label(); + this.label14 = new System.Windows.Forms.Label(); + this.label15 = new System.Windows.Forms.Label(); + this.label16 = new System.Windows.Forms.Label(); + this.textBox2 = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // label5 + // + this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.label5.Location = new System.Drawing.Point(13, 48); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(390, 212); - this.label5.TabIndex = 8; - this.label5.Text = resources.GetString("label5.Text"); - // - // button1 - // - this.button1.Image = global:: Garry.Control4.Jailbreak.Properties.Resources.cup_cake; - this.button1.Location = new System.Drawing.Point(256, 300); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(147, 34); - this.button1.TabIndex = 9; - this.button1.Text = " Jailbreak Director"; - this.button1.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - this.button1.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.JailbreakDirector); - // - // DirectorPatch - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.button1); - this.Controls.Add(this.label5); - this.Controls.Add(this.label2); - this.Name = "DirectorPatch"; - this.Size = new System.Drawing.Size(436, 361); - this.ResumeLayout(false); - this.PerformLayout(); + this.label5.Location = new System.Drawing.Point(17, 495); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(468, 109); + this.label5.TabIndex = 8; + this.label5.Text = resources.GetString("label5.Text"); + // + // button1 + // + this.button1.Image = global::Garry.Control4.Jailbreak.Properties.Resources.cup_cake; + this.button1.Location = new System.Drawing.Point(269, 136); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(105, 34); + this.button1.TabIndex = 9; + this.button1.Text = "Generate"; + this.button1.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.button1.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.GenerateCertificates); + // + // label1 + // + this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.label1.Location = new System.Drawing.Point(17, 72); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(469, 61); + this.label1.TabIndex = 10; + this.label1.Text = "Lets make some certificates so Composer Pro thinks we\'re a dealer. \r\n\r\nLater on w" + + "e\'ll add this certificate to our Director so we can connect to it using Composer" + + " too."; + // + // button2 + // + this.button2.Image = global::Garry.Control4.Jailbreak.Properties.Resources.folder; + this.button2.Location = new System.Drawing.Point(380, 136); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(105, 34); + this.button2.TabIndex = 11; + this.button2.Text = "View Files"; + this.button2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.button2.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.ViewCertificates); + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("Microsoft YaHei", 20.25F, System.Drawing.FontStyle.Bold); + this.label3.ForeColor = System.Drawing.SystemColors.Highlight; + this.label3.Location = new System.Drawing.Point(14, 438); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(172, 36); + this.label3.TabIndex = 12; + this.label3.Text = "Create User"; + // + // textBox1 + // + this.textBox1.BackColor = System.Drawing.SystemColors.ControlLightLight; + this.textBox1.Font = new System.Drawing.Font("Consolas", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.textBox1.Location = new System.Drawing.Point(20, 598); + this.textBox1.Name = "textBox1"; + this.textBox1.ReadOnly = true; + this.textBox1.Size = new System.Drawing.Size(466, 22); + this.textBox1.TabIndex = 13; + this.textBox1.Text = "adduser -G root jailbreak"; + // + // label4 + // + this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.label4.Location = new System.Drawing.Point(17, 632); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(468, 54); + this.label4.TabIndex = 14; + this.label4.Text = "This creates a new root user called \"jailbreak\". It will ask you for a password. " + + "Set the password as jailbreak. It will complain about it being the same as the u" + + "sername, but it\'ll accept it."; + // + // button3 + // + this.button3.Image = global::Garry.Control4.Jailbreak.Properties.Resources.database; + this.button3.Location = new System.Drawing.Point(269, 700); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(216, 34); + this.button3.TabIndex = 15; + this.button3.Text = "Open System Manager"; + this.button3.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.button3.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; + this.button3.UseVisualStyleBackColor = true; + this.button3.Click += new System.EventHandler(this.OpenSystemManager); + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Font = new System.Drawing.Font("Microsoft YaHei", 20.25F, System.Drawing.FontStyle.Bold); + this.label6.ForeColor = System.Drawing.SystemColors.Highlight; + this.label6.Location = new System.Drawing.Point(15, 801); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(273, 36); + this.label6.TabIndex = 16; + this.label6.Text = "Director Certificate"; + // + // label7 + // + this.label7.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.label7.Location = new System.Drawing.Point(19, 859); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(466, 30); + this.label7.TabIndex = 17; + this.label7.Text = "If you created a user we\'ll be able to patch the director with the new certificat" + + "e.\r\n"; + // + // button4 + // + this.button4.Image = global::Garry.Control4.Jailbreak.Properties.Resources.cup_cake; + this.button4.Location = new System.Drawing.Point(300, 964); + this.button4.Name = "button4"; + this.button4.Size = new System.Drawing.Size(185, 34); + this.button4.TabIndex = 18; + this.button4.Text = "Patch Director Certificates"; + this.button4.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.button4.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; + this.button4.UseVisualStyleBackColor = true; + this.button4.Click += new System.EventHandler(this.PatchDirectorCertificates); + // + // button5 + // + this.button5.Image = global::Garry.Control4.Jailbreak.Properties.Resources.cup_cake; + this.button5.Location = new System.Drawing.Point(332, 365); + this.button5.Name = "button5"; + this.button5.Size = new System.Drawing.Size(154, 34); + this.button5.TabIndex = 21; + this.button5.Text = "Copy Composer Certs"; + this.button5.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.button5.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; + this.button5.UseVisualStyleBackColor = true; + this.button5.Click += new System.EventHandler(this.CopyComposerCerts); + // + // label8 + // + this.label8.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.label8.Location = new System.Drawing.Point(20, 282); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(468, 70); + this.label8.TabIndex = 20; + this.label8.Text = resources.GetString("label8.Text"); + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Font = new System.Drawing.Font("Microsoft YaHei", 20.25F, System.Drawing.FontStyle.Bold); + this.label9.ForeColor = System.Drawing.SystemColors.Highlight; + this.label9.Location = new System.Drawing.Point(17, 223); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(315, 36); + this.label9.TabIndex = 19; + this.label9.Text = "Composer Certificates"; + // + // Password + // + this.Password.Location = new System.Drawing.Point(352, 938); + this.Password.Name = "Password"; + this.Password.Size = new System.Drawing.Size(133, 20); + this.Password.TabIndex = 22; + this.Password.Text = "jailbreak"; + // + // Username + // + this.Username.Location = new System.Drawing.Point(213, 938); + this.Username.Name = "Username"; + this.Username.Size = new System.Drawing.Size(133, 20); + this.Username.TabIndex = 23; + this.Username.Text = "jailbreak"; + // + // Address + // + this.Address.Location = new System.Drawing.Point(19, 938); + this.Address.Name = "Address"; + this.Address.Size = new System.Drawing.Size(188, 20); + this.Address.TabIndex = 24; + this.Address.Text = "127.0.0.1"; + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Location = new System.Drawing.Point(20, 922); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(45, 13); + this.label10.TabIndex = 25; + this.label10.Text = "Address"; + // + // label11 + // + this.label11.AutoSize = true; + this.label11.Location = new System.Drawing.Point(210, 922); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(55, 13); + this.label11.TabIndex = 26; + this.label11.Text = "Username"; + // + // label12 + // + this.label12.AutoSize = true; + this.label12.Location = new System.Drawing.Point(349, 922); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(53, 13); + this.label12.TabIndex = 27; + this.label12.Text = "Password"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("Microsoft YaHei", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label2.ForeColor = System.Drawing.SystemColors.Highlight; + this.label2.Location = new System.Drawing.Point(13, 18); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(252, 36); + this.label2.TabIndex = 7; + this.label2.Text = "Make Certificates"; + // + // label13 + // + this.label13.AutoSize = true; + this.label13.Font = new System.Drawing.Font("Microsoft YaHei", 20.25F, System.Drawing.FontStyle.Bold); + this.label13.ForeColor = System.Drawing.SystemColors.Highlight; + this.label13.Location = new System.Drawing.Point(20, 1066); + this.label13.Name = "label13"; + this.label13.Size = new System.Drawing.Size(230, 36); + this.label13.TabIndex = 28; + this.label13.Text = "Restart Director"; + // + // label14 + // + this.label14.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.label14.Location = new System.Drawing.Point(19, 1122); + this.label14.Name = "label14"; + this.label14.Size = new System.Drawing.Size(466, 33); + this.label14.TabIndex = 29; + this.label14.Text = "You need to restart your director for the new certifcates to kick in. You can do " + + "this by right clicking in System Manager and going to Reboot.."; + // + // label15 + // + this.label15.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.label15.Location = new System.Drawing.Point(19, 1289); + this.label15.Name = "label15"; + this.label15.Size = new System.Drawing.Size(463, 33); + this.label15.TabIndex = 31; + this.label15.Text = "It\'s probably a good idea to create the jailbreak user. \r\n\r\nIt\'s probably no less" + + " secure than when the default password for everythign was t0talc0ntr0l4!, but to" + + " be safe, here\'s how:"; + // + // label16 + // + this.label16.AutoSize = true; + this.label16.Font = new System.Drawing.Font("Microsoft YaHei", 20.25F, System.Drawing.FontStyle.Bold); + this.label16.ForeColor = System.Drawing.SystemColors.Highlight; + this.label16.Location = new System.Drawing.Point(17, 1233); + this.label16.Name = "label16"; + this.label16.Size = new System.Drawing.Size(172, 36); + this.label16.TabIndex = 30; + this.label16.Text = "Delete User"; + // + // textBox2 + // + this.textBox2.BackColor = System.Drawing.SystemColors.ControlLightLight; + this.textBox2.Font = new System.Drawing.Font("Consolas", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.textBox2.Location = new System.Drawing.Point(19, 1325); + this.textBox2.Name = "textBox2"; + this.textBox2.ReadOnly = true; + this.textBox2.Size = new System.Drawing.Size(467, 22); + this.textBox2.TabIndex = 32; + this.textBox2.Text = "deluser jailbreak"; + // + // DirectorPatch + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.textBox2); + this.Controls.Add(this.label15); + this.Controls.Add(this.label16); + this.Controls.Add(this.label14); + this.Controls.Add(this.label13); + this.Controls.Add(this.label12); + this.Controls.Add(this.label11); + this.Controls.Add(this.label10); + this.Controls.Add(this.Address); + this.Controls.Add(this.Username); + this.Controls.Add(this.Password); + this.Controls.Add(this.button5); + this.Controls.Add(this.label8); + this.Controls.Add(this.label9); + this.Controls.Add(this.button4); + this.Controls.Add(this.label7); + this.Controls.Add(this.label6); + this.Controls.Add(this.button3); + this.Controls.Add(this.label4); + this.Controls.Add(this.textBox1); + this.Controls.Add(this.label3); + this.Controls.Add(this.button2); + this.Controls.Add(this.label1); + this.Controls.Add(this.button1); + this.Controls.Add(this.label5); + this.Controls.Add(this.label2); + this.Name = "DirectorPatch"; + this.Size = new System.Drawing.Size(500, 1394); + this.ResumeLayout(false); + this.PerformLayout(); } #endregion - private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label5; private System.Windows.Forms.Button button1; - } + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Button button3; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.Button button4; + private System.Windows.Forms.Button button5; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.TextBox Password; + private System.Windows.Forms.TextBox Username; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.Label label11; + private System.Windows.Forms.Label label12; + private System.Windows.Forms.Label label2; + public System.Windows.Forms.TextBox Address; + private System.Windows.Forms.Label label13; + private System.Windows.Forms.Label label14; + private System.Windows.Forms.Label label15; + private System.Windows.Forms.Label label16; + private System.Windows.Forms.TextBox textBox2; + } } diff --git a/UI/DirectorPatch.cs b/UI/DirectorPatch.cs index fa222c0..9815b29 100644 --- a/UI/DirectorPatch.cs +++ b/UI/DirectorPatch.cs @@ -10,6 +10,8 @@ using System.IO; using Mono.Cecil; using System.Diagnostics; +using Renci.SshNet; +using System.Linq.Expressions; namespace Garry.Control4.Jailbreak { @@ -24,42 +26,6 @@ public DirectorPatch( MainWindow MainWindow ) InitializeComponent(); } - private void JailbreakDirector( object sender, EventArgs e ) - { - var log = new LogWindow( MainWindow ); - - log.WriteNormal( "Generating Certificates\n" ); - if ( !GenerateCertificates( log ) ) - { - return; - } - log.WriteSuccess( "Certificate Generation Successful" ); - log.WriteNormal( "\n\n" ); - - log.WriteNormal( "Copying To Composer\n" ); - if ( !PatchComposer( log ) ) - { - return; - } - log.WriteNormal( "\n\n" ); - - log.WriteNormal( "Copying To Director\n" ); - if ( !PatchDirector( log ) ) - { - return; - } - log.WriteNormal( "\n\n" ); - - log.WriteNormal( "Restarting Director\n" ); - if ( !RestartDirector( log ) ) - { - return; - } - log.WriteNormal( "\n\n" ); - - log.WriteSuccess( "100% All Done!" ); - } - bool GenerateCertificates( LogWindow log ) { // @@ -143,10 +109,30 @@ bool PatchComposer( LogWindow log ) bool PatchDirector( LogWindow log ) { - using ( var ssh = MainWindow.ConnectedDirector.ScpClient ) + if ( MainWindow.ConnectedDirector == null ) + { + log.WriteNormal( $"Skipping director patch because we're not connected" ); + return false; + } + + var SshConnectionInfo = new ConnectionInfo( Address.Text.ToString(), Username.Text, new PasswordAuthenticationMethod( Username.Text, Password.Text ) ); + SshConnectionInfo.RetryAttempts = 1; + SshConnectionInfo.Timeout = TimeSpan.FromSeconds( 2 ); + + using ( var ssh = new ScpClient( SshConnectionInfo ) ) { log.WriteNormal( $"Connecting to director via SCP.. " ); - ssh.Connect(); + + try + { + ssh.Connect(); + } + catch ( System.Exception e ) + { + log.WriteError( e ); + return false; + } + log.WriteSuccess( $" .. connected!\n" ); // Get the existing certificate @@ -178,6 +164,7 @@ bool PatchDirector( LogWindow log ) if ( certificate.Contains( localCert ) ) { log.WriteError( $"The certificate on the director already contains our public key!\n" ); + return false; } else { @@ -190,7 +177,7 @@ bool PatchDirector( LogWindow log ) // // This serves no purpose but it doesn't hurt to have it hanging around // - log.WriteNormal( $" Writing to Certs/clientca-prod.pem\n" ); + log.WriteNormal( $" Downloading to Certs/clientca-prod.pem\n" ); System.IO.File.WriteAllText( "Certs/clientca-prod.pem", certificate ); @@ -218,16 +205,6 @@ bool PatchDirector( LogWindow log ) return true; } - bool RestartDirector( LogWindow log ) - { - log.WriteNormal( $"Rebooting..\n" ); - - MainWindow.ConnectedDirector.Reboot( log ); - MainWindow.DirectorDisconnected(); - - return true; - } - private void CopyFile( LogWindow log, string a, string b ) { log.WriteNormal( $"Copying " ); @@ -275,5 +252,71 @@ int RunProcessPrintOutput( LogWindow log, string exe, string arguments ) return process.ExitCode; } - } + + private void GenerateCertificates( object sender, EventArgs e ) + { + var log = new LogWindow( MainWindow ); + + log.WriteNormal( "Generating Certificates\n" ); + if ( !GenerateCertificates( log ) ) + { + return; + } + log.WriteSuccess( "Certificate Generation Successful" ); + log.WriteNormal( "\n\n" ); + } + + private void ViewCertificates( object sender, EventArgs e ) + { + var folder = System.IO.Path.GetFullPath( "Certs" ); + + if ( !System.IO.Directory.Exists( folder ) ) + { + var log = new LogWindow( MainWindow ); + log.WriteError( $"{folder}doesn't exist - did you generate certificates yet?\n" ); + return; + } + + Process.Start( "explorer.exe", folder ); + } + + private void CopyComposerCerts( object sender, EventArgs e ) + { + var log = new LogWindow( MainWindow ); + + log.WriteNormal( "Copying To Composer\n" ); + if ( !PatchComposer( log ) ) + { + return; + } + log.WriteNormal( "\n\n" ); + } + + private void OpenSystemManager( object sender, EventArgs e ) + { + Process.Start( @"C:\Program Files (x86)\Control4\Composer\Pro\Sysman.exe" ); + } + + private void PatchDirectorCertificates( object sender, EventArgs e ) + { + var log = new LogWindow( MainWindow ); + + try + { + + log.WriteNormal( "Copying To Director\n" ); + if ( !PatchDirector( log ) ) + { + return; + } + log.WriteNormal( "\n\n" ); + } + catch ( System.Exception ex ) + { + log.WriteError( ex ); + } + } + + + } } diff --git a/UI/DirectorPatch.resx b/UI/DirectorPatch.resx index 87ab025..9c03863 100644 --- a/UI/DirectorPatch.resx +++ b/UI/DirectorPatch.resx @@ -118,14 +118,16 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - In this step we do three things: + It's time for you to do some work. We need a user so we can add the new certificate to the director. So here's what we need you to do. -1. Generate a new certificate for you to use on your director (or use the last generated one) - -2. Apply the certificate to your Composer settings folder on this computer. - -3. Apply the certificate to your Director by copying a file to it and restarting. +1. Open System Manager +2. Right Click on your director in the list (usually starts with EA5) +3. Go to Terminal +4. Run these commands (in the terminal you can right click to paste) + + + We can copy the new certificates to the composer user settings folder. -Since all we're doing is adding a new certificate it should still be possible for dealers to connect without you having to do anything. +This will mean Composer will think you're a dealer. It will also mean that System Manager will let you use Terminal to connect to your director. \ No newline at end of file diff --git a/UI/LogWindow.cs b/UI/LogWindow.cs index 8f4e59b..90a2dc9 100644 --- a/UI/LogWindow.cs +++ b/UI/LogWindow.cs @@ -47,6 +47,12 @@ internal void WriteWarning( string v ) Write( v ); } + internal void WriteError( System.Exception v ) + { + WriteError( $"\n{v.Message}\n" ); + WriteNormal( $"{v.StackTrace}\n" ); + } + internal void WriteError( string v ) { textBox.SelectionColor = Color.Red; diff --git a/UI/MainWindow.Designer.cs b/UI/MainWindow.Designer.cs index bb37283..31fe5af 100644 --- a/UI/MainWindow.Designer.cs +++ b/UI/MainWindow.Designer.cs @@ -28,229 +28,199 @@ protected override void Dispose( bool disposing ) /// private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainWindow)); - this.MainTabControl = new System.Windows.Forms.TabControl(); - this.tabController = new System.Windows.Forms.TabPage(); - this.tabPage2 = new System.Windows.Forms.TabPage(); - this.menuStrip1 = new System.Windows.Forms.MenuStrip(); - this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.quitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.foldersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.composerFolderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.composerSettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.rc4diyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.splitContainer3 = new System.Windows.Forms.SplitContainer(); - this.StatusTextLeft = new System.Windows.Forms.Label(); - this.StatusTextRight = new System.Windows.Forms.Label(); - this.MainTabControl.SuspendLayout(); - this.menuStrip1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).BeginInit(); - this.splitContainer3.Panel1.SuspendLayout(); - this.splitContainer3.Panel2.SuspendLayout(); - this.splitContainer3.SuspendLayout(); - this.SuspendLayout(); - // - // MainTabControl - // - this.MainTabControl.Controls.Add(this.tabController); - this.MainTabControl.Controls.Add(this.tabPage2); - this.MainTabControl.Dock = System.Windows.Forms.DockStyle.Fill; - this.MainTabControl.HotTrack = true; - this.MainTabControl.Location = new System.Drawing.Point(5, 5); - this.MainTabControl.Margin = new System.Windows.Forms.Padding(6); - this.MainTabControl.Name = "MainTabControl"; - this.MainTabControl.SelectedIndex = 0; - this.MainTabControl.Size = new System.Drawing.Size(474, 406); - this.MainTabControl.TabIndex = 0; - // - // tabController - // - this.tabController.Location = new System.Drawing.Point(4, 22); - this.tabController.Margin = new System.Windows.Forms.Padding(6); - this.tabController.Name = "tabController"; - this.tabController.Padding = new System.Windows.Forms.Padding(6); - this.tabController.Size = new System.Drawing.Size(466, 380); - this.tabController.TabIndex = 0; - this.tabController.Text = "Controller"; - this.tabController.UseVisualStyleBackColor = true; - // - // tabPage2 - // - this.tabPage2.Location = new System.Drawing.Point(4, 22); - this.tabPage2.Name = "tabPage2"; - this.tabPage2.Padding = new System.Windows.Forms.Padding(3); - this.tabPage2.Size = new System.Drawing.Size(466, 377); - this.tabPage2.TabIndex = 1; - this.tabPage2.Text = "Jailbreak"; - this.tabPage2.UseVisualStyleBackColor = true; - // - // menuStrip1 - // - this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainWindow)); + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.quitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.foldersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.composerFolderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.composerSettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.rc4diyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.splitContainer3 = new System.Windows.Forms.SplitContainer(); + this.StatusTextLeft = new System.Windows.Forms.Label(); + this.StatusTextRight = new System.Windows.Forms.Label(); + this.FlowPanel = new System.Windows.Forms.FlowLayoutPanel(); + this.menuStrip1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).BeginInit(); + this.splitContainer3.Panel2.SuspendLayout(); + this.splitContainer3.SuspendLayout(); + this.SuspendLayout(); + // + // menuStrip1 + // + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.fileToolStripMenuItem, this.foldersToolStripMenuItem, this.helpToolStripMenuItem}); - this.menuStrip1.Location = new System.Drawing.Point(0, 0); - this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(484, 24); - this.menuStrip1.TabIndex = 1; - this.menuStrip1.Text = "menuStrip1"; - // - // fileToolStripMenuItem - // - this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Size = new System.Drawing.Size(534, 24); + this.menuStrip1.TabIndex = 1; + this.menuStrip1.Text = "menuStrip1"; + // + // fileToolStripMenuItem + // + this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.quitToolStripMenuItem}); - this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; - this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20); - this.fileToolStripMenuItem.Text = "File"; - // - // quitToolStripMenuItem - // - this.quitToolStripMenuItem.Name = "quitToolStripMenuItem"; - this.quitToolStripMenuItem.Size = new System.Drawing.Size(97, 22); - this.quitToolStripMenuItem.Text = "Quit"; - this.quitToolStripMenuItem.Click += new System.EventHandler(this.FileAndQuit); - // - // foldersToolStripMenuItem - // - this.foldersToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; + this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20); + this.fileToolStripMenuItem.Text = "File"; + // + // quitToolStripMenuItem + // + this.quitToolStripMenuItem.Name = "quitToolStripMenuItem"; + this.quitToolStripMenuItem.Size = new System.Drawing.Size(97, 22); + this.quitToolStripMenuItem.Text = "Quit"; + this.quitToolStripMenuItem.Click += new System.EventHandler(this.FileAndQuit); + // + // foldersToolStripMenuItem + // + this.foldersToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.composerFolderToolStripMenuItem, this.composerSettingsToolStripMenuItem}); - this.foldersToolStripMenuItem.Name = "foldersToolStripMenuItem"; - this.foldersToolStripMenuItem.Size = new System.Drawing.Size(57, 20); - this.foldersToolStripMenuItem.Text = "Folders"; - // - // composerFolderToolStripMenuItem - // - this.composerFolderToolStripMenuItem.Name = "composerFolderToolStripMenuItem"; - this.composerFolderToolStripMenuItem.Size = new System.Drawing.Size(174, 22); - this.composerFolderToolStripMenuItem.Text = "Composer Folder"; - this.composerFolderToolStripMenuItem.Click += new System.EventHandler(this.OpenComposerFolder); - // - // composerSettingsToolStripMenuItem - // - this.composerSettingsToolStripMenuItem.Name = "composerSettingsToolStripMenuItem"; - this.composerSettingsToolStripMenuItem.Size = new System.Drawing.Size(174, 22); - this.composerSettingsToolStripMenuItem.Text = "Composer Settings"; - this.composerSettingsToolStripMenuItem.Click += new System.EventHandler(this.OpenComposerSettingsFolder); - // - // helpToolStripMenuItem - // - this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.foldersToolStripMenuItem.Name = "foldersToolStripMenuItem"; + this.foldersToolStripMenuItem.Size = new System.Drawing.Size(57, 20); + this.foldersToolStripMenuItem.Text = "Folders"; + // + // composerFolderToolStripMenuItem + // + this.composerFolderToolStripMenuItem.Name = "composerFolderToolStripMenuItem"; + this.composerFolderToolStripMenuItem.Size = new System.Drawing.Size(174, 22); + this.composerFolderToolStripMenuItem.Text = "Composer Folder"; + this.composerFolderToolStripMenuItem.Click += new System.EventHandler(this.OpenComposerFolder); + // + // composerSettingsToolStripMenuItem + // + this.composerSettingsToolStripMenuItem.Name = "composerSettingsToolStripMenuItem"; + this.composerSettingsToolStripMenuItem.Size = new System.Drawing.Size(174, 22); + this.composerSettingsToolStripMenuItem.Text = "Composer Settings"; + this.composerSettingsToolStripMenuItem.Click += new System.EventHandler(this.OpenComposerSettingsFolder); + // + // helpToolStripMenuItem + // + this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.aboutToolStripMenuItem, this.rc4diyToolStripMenuItem}); - this.helpToolStripMenuItem.Name = "helpToolStripMenuItem"; - this.helpToolStripMenuItem.Size = new System.Drawing.Size(44, 20); - this.helpToolStripMenuItem.Text = "Help"; - // - // aboutToolStripMenuItem - // - this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem"; - this.aboutToolStripMenuItem.Size = new System.Drawing.Size(183, 22); - this.aboutToolStripMenuItem.Text = "View On GitHub"; - this.aboutToolStripMenuItem.Click += new System.EventHandler(this.ViewOnGithub); - // - // rc4diyToolStripMenuItem - // - this.rc4diyToolStripMenuItem.Name = "rc4diyToolStripMenuItem"; - this.rc4diyToolStripMenuItem.Size = new System.Drawing.Size(183, 22); - this.rc4diyToolStripMenuItem.Text = "Visit C4diy on Reddit"; - this.rc4diyToolStripMenuItem.Click += new System.EventHandler(this.VisitC4Diy); - // - // splitContainer3 - // - this.splitContainer3.Dock = System.Windows.Forms.DockStyle.Fill; - this.splitContainer3.FixedPanel = System.Windows.Forms.FixedPanel.Panel2; - this.splitContainer3.IsSplitterFixed = true; - this.splitContainer3.Location = new System.Drawing.Point(0, 24); - this.splitContainer3.Name = "splitContainer3"; - this.splitContainer3.Orientation = System.Windows.Forms.Orientation.Horizontal; - // - // splitContainer3.Panel1 - // - this.splitContainer3.Panel1.Controls.Add(this.MainTabControl); - this.splitContainer3.Panel1.Margin = new System.Windows.Forms.Padding(5); - this.splitContainer3.Panel1.Padding = new System.Windows.Forms.Padding(5, 5, 5, 0); - // - // splitContainer3.Panel2 - // - this.splitContainer3.Panel2.Controls.Add(this.StatusTextLeft); - this.splitContainer3.Panel2.Controls.Add(this.StatusTextRight); - this.splitContainer3.Panel2.Padding = new System.Windows.Forms.Padding(4); - this.splitContainer3.Panel2MinSize = 20; - this.splitContainer3.Size = new System.Drawing.Size(484, 437); - this.splitContainer3.SplitterDistance = 411; - this.splitContainer3.SplitterWidth = 1; - this.splitContainer3.TabIndex = 2; - // - // StatusTextLeft - // - this.StatusTextLeft.AutoSize = true; - this.StatusTextLeft.BackColor = System.Drawing.Color.Transparent; - this.StatusTextLeft.Dock = System.Windows.Forms.DockStyle.Left; - this.StatusTextLeft.Location = new System.Drawing.Point(4, 4); - this.StatusTextLeft.Name = "StatusTextLeft"; - this.StatusTextLeft.Size = new System.Drawing.Size(0, 13); - this.StatusTextLeft.TabIndex = 0; - this.StatusTextLeft.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // - // StatusTextRight - // - this.StatusTextRight.AutoSize = true; - this.StatusTextRight.BackColor = System.Drawing.Color.Transparent; - this.StatusTextRight.Dock = System.Windows.Forms.DockStyle.Right; - this.StatusTextRight.Location = new System.Drawing.Point(480, 4); - this.StatusTextRight.Name = "StatusTextRight"; - this.StatusTextRight.Size = new System.Drawing.Size(0, 13); - this.StatusTextRight.TabIndex = 1; - this.StatusTextRight.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // MainWindow - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(484, 461); - this.Controls.Add(this.splitContainer3); - this.Controls.Add(this.menuStrip1); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MainMenuStrip = this.menuStrip1; - this.MaximumSize = new System.Drawing.Size(500, 500); - this.MinimumSize = new System.Drawing.Size(500, 500); - this.Name = "MainWindow"; - this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; - this.Text = "Garry\'s Control4 Jailbreak"; - this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.OnFormClosed); - this.MainTabControl.ResumeLayout(false); - this.menuStrip1.ResumeLayout(false); - this.menuStrip1.PerformLayout(); - this.splitContainer3.Panel1.ResumeLayout(false); - this.splitContainer3.Panel2.ResumeLayout(false); - this.splitContainer3.Panel2.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).EndInit(); - this.splitContainer3.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); + this.helpToolStripMenuItem.Name = "helpToolStripMenuItem"; + this.helpToolStripMenuItem.Size = new System.Drawing.Size(44, 20); + this.helpToolStripMenuItem.Text = "Help"; + // + // aboutToolStripMenuItem + // + this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem"; + this.aboutToolStripMenuItem.Size = new System.Drawing.Size(183, 22); + this.aboutToolStripMenuItem.Text = "View On GitHub"; + this.aboutToolStripMenuItem.Click += new System.EventHandler(this.ViewOnGithub); + // + // rc4diyToolStripMenuItem + // + this.rc4diyToolStripMenuItem.Name = "rc4diyToolStripMenuItem"; + this.rc4diyToolStripMenuItem.Size = new System.Drawing.Size(183, 22); + this.rc4diyToolStripMenuItem.Text = "Visit C4diy on Reddit"; + this.rc4diyToolStripMenuItem.Click += new System.EventHandler(this.VisitC4Diy); + // + // splitContainer3 + // + this.splitContainer3.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer3.FixedPanel = System.Windows.Forms.FixedPanel.Panel2; + this.splitContainer3.IsSplitterFixed = true; + this.splitContainer3.Location = new System.Drawing.Point(0, 24); + this.splitContainer3.Name = "splitContainer3"; + this.splitContainer3.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainer3.Panel1 + // + this.splitContainer3.Panel1.Margin = new System.Windows.Forms.Padding(5); + this.splitContainer3.Panel1.Padding = new System.Windows.Forms.Padding(5, 5, 5, 0); + // + // splitContainer3.Panel2 + // + this.splitContainer3.Panel2.Controls.Add(this.StatusTextLeft); + this.splitContainer3.Panel2.Controls.Add(this.StatusTextRight); + this.splitContainer3.Panel2.Padding = new System.Windows.Forms.Padding(4); + this.splitContainer3.Panel2MinSize = 20; + this.splitContainer3.Size = new System.Drawing.Size(534, 537); + this.splitContainer3.SplitterDistance = 511; + this.splitContainer3.SplitterWidth = 1; + this.splitContainer3.TabIndex = 2; + // + // StatusTextLeft + // + this.StatusTextLeft.AutoSize = true; + this.StatusTextLeft.BackColor = System.Drawing.Color.Transparent; + this.StatusTextLeft.Dock = System.Windows.Forms.DockStyle.Left; + this.StatusTextLeft.Location = new System.Drawing.Point(4, 4); + this.StatusTextLeft.Name = "StatusTextLeft"; + this.StatusTextLeft.Size = new System.Drawing.Size(0, 13); + this.StatusTextLeft.TabIndex = 0; + this.StatusTextLeft.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // StatusTextRight + // + this.StatusTextRight.AutoSize = true; + this.StatusTextRight.BackColor = System.Drawing.Color.Transparent; + this.StatusTextRight.Dock = System.Windows.Forms.DockStyle.Right; + this.StatusTextRight.Location = new System.Drawing.Point(530, 4); + this.StatusTextRight.Name = "StatusTextRight"; + this.StatusTextRight.Size = new System.Drawing.Size(0, 13); + this.StatusTextRight.TabIndex = 1; + this.StatusTextRight.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // FlowPanel + // + this.FlowPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.FlowPanel.AutoScroll = true; + this.FlowPanel.BackColor = System.Drawing.SystemColors.Window; + this.FlowPanel.Location = new System.Drawing.Point(0, 24); + this.FlowPanel.Name = "FlowPanel"; + this.FlowPanel.Size = new System.Drawing.Size(534, 513); + this.FlowPanel.TabIndex = 3; + // + // MainWindow + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(534, 561); + this.Controls.Add(this.FlowPanel); + this.Controls.Add(this.splitContainer3); + this.Controls.Add(this.menuStrip1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MainMenuStrip = this.menuStrip1; + this.MaximumSize = new System.Drawing.Size(550, 600); + this.MinimumSize = new System.Drawing.Size(550, 600); + this.Name = "MainWindow"; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.Text = "Garry\'s Control4 Jailbreak"; + this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.OnFormClosed); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + this.splitContainer3.Panel2.ResumeLayout(false); + this.splitContainer3.Panel2.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).EndInit(); + this.splitContainer3.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); } #endregion - private System.Windows.Forms.TabControl MainTabControl; - private System.Windows.Forms.TabPage tabController; private System.Windows.Forms.MenuStrip menuStrip1; private System.Windows.Forms.SplitContainer splitContainer3; private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem quitToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem; - private System.Windows.Forms.TabPage tabPage2; private System.Windows.Forms.Label StatusTextLeft; private System.Windows.Forms.Label StatusTextRight; private System.Windows.Forms.ToolStripMenuItem foldersToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem composerFolderToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem composerSettingsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem rc4diyToolStripMenuItem; - } + private System.Windows.Forms.FlowLayoutPanel FlowPanel; + } } \ No newline at end of file diff --git a/UI/MainWindow.cs b/UI/MainWindow.cs index 227a30f..19feec3 100644 --- a/UI/MainWindow.cs +++ b/UI/MainWindow.cs @@ -13,11 +13,8 @@ namespace Garry.Control4.Jailbreak public partial class MainWindow : Form { public Director Director { get; set; } - public Backup Backup { get; set; } public Composer Composer { get; set; } public DirectorPatch DirectorPatch { get; set; } - public Restore Restore { get; set; } - public DirectorManager ConnectedDirector { get; set; } public MainWindow() @@ -26,30 +23,16 @@ public MainWindow() this.Text += $" - v{Constants.Version} - For C4 v{Constants.TargetDirectorVersion}"; - MainTabControl.TabPages.Clear(); - Director = new Director( this ); - Director.Parent = AddTab( "Director" ); - Director.Dock = DockStyle.Fill; - - Backup = new Backup( this ); - Backup.Parent = AddTab( "Backup" ); - Backup.Dock = DockStyle.Fill; + Director.Parent = FlowPanel; + Director.Hide(); Composer = new Composer( this ); - Composer.Parent = AddTab( "Composer" ); - Composer.Dock = DockStyle.Fill; + Composer.Parent = FlowPanel; DirectorPatch = new DirectorPatch( this ); - DirectorPatch.Parent = AddTab( "Director Patch" ); - DirectorPatch.Dock = DockStyle.Fill; - - Restore = new Restore( this ); - Restore.Parent = AddTab( "Restore" ); - Restore.Dock = DockStyle.Fill; - - MainTabControl.SelectedTab = MainTabControl.TabPages[0]; - + DirectorPatch.Parent = FlowPanel; + CenterToScreen(); Load += OnLoaded; @@ -62,17 +45,6 @@ private async void OnLoaded( object sender, EventArgs e ) await Director.RefreshList(); } - private Control AddTab( string v ) - { - MainTabControl.TabPages.Add( v ); - - var tabPage = MainTabControl.TabPages[MainTabControl.TabPages.Count - 1]; - tabPage.UseVisualStyleBackColor = true; - tabPage.Padding = new Padding( 10 ); - - return tabPage; - } - private void OnFormClosed( object sender, FormClosedEventArgs e ) { Application.Exit(); @@ -96,11 +68,7 @@ private void OpenComposerSettingsFolder( object sender, EventArgs e ) internal void DirectorDisconnected() { ConnectedDirector = null; - Director.DirectorDisconnected(); - Backup.Enabled = false; - DirectorPatch.Enabled = false; - Restore.Enabled = false; } private void ViewOnGithub( object sender, EventArgs e ) diff --git a/UI/Restore.Designer.cs b/UI/Restore.Designer.cs deleted file mode 100644 index 26be378..0000000 --- a/UI/Restore.Designer.cs +++ /dev/null @@ -1,137 +0,0 @@ -namespace Garry.Control4.Jailbreak -{ - partial class Restore - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose( bool disposing ) - { - if ( disposing && (components != null) ) - { - components.Dispose(); - } - base.Dispose( disposing ); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.label2 = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); - this.backupList = new System.Windows.Forms.ListBox(); - this.label3 = new System.Windows.Forms.Label(); - this.restoreUsingFile = new System.Windows.Forms.Button(); - this.restoreFromDirector = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // label2 - // - this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.label2.Location = new System.Drawing.Point(24, 53); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(390, 44); - this.label2.TabIndex = 2; - this.label2.Text = "This will restore your director back to the original certificate and reboot it. T" + - "here\'s no real reason to do this but it\'s here for your peace of mind."; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label1.ForeColor = System.Drawing.SystemColors.Highlight; - this.label1.Location = new System.Drawing.Point(24, 26); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(68, 18); - this.label1.TabIndex = 1; - this.label1.Text = "Restore"; - // - // backupList - // - this.backupList.FormattingEnabled = true; - this.backupList.Location = new System.Drawing.Point(27, 165); - this.backupList.Name = "backupList"; - this.backupList.Size = new System.Drawing.Size(387, 134); - this.backupList.TabIndex = 3; - this.backupList.SelectedIndexChanged += new System.EventHandler(this.SelectedIndexChanged); - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label3.Location = new System.Drawing.Point(24, 149); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(125, 13); - this.label3.TabIndex = 5; - this.label3.Text = "Backups On Director"; - // - // restoreUsingFile - // - this.restoreUsingFile.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.restoreUsingFile.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.restoreUsingFile.Image = global:: Garry.Control4.Jailbreak.Properties.Resources.folder; - this.restoreUsingFile.Location = new System.Drawing.Point(238, 89); - this.restoreUsingFile.Name = "restoreUsingFile"; - this.restoreUsingFile.Padding = new System.Windows.Forms.Padding(2); - this.restoreUsingFile.Size = new System.Drawing.Size(176, 29); - this.restoreUsingFile.TabIndex = 4; - this.restoreUsingFile.Text = " Restore Using File..."; - this.restoreUsingFile.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - this.restoreUsingFile.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; - this.restoreUsingFile.UseVisualStyleBackColor = true; - this.restoreUsingFile.Click += new System.EventHandler(this.RestoreFromFile); - // - // restoreFromDirector - // - this.restoreFromDirector.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.restoreFromDirector.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.restoreFromDirector.Image = global:: Garry.Control4.Jailbreak.Properties.Resources.database; - this.restoreFromDirector.Location = new System.Drawing.Point(238, 305); - this.restoreFromDirector.Name = "restoreFromDirector"; - this.restoreFromDirector.Padding = new System.Windows.Forms.Padding(2); - this.restoreFromDirector.Size = new System.Drawing.Size(176, 29); - this.restoreFromDirector.TabIndex = 0; - this.restoreFromDirector.Text = "Restore Backup"; - this.restoreFromDirector.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - this.restoreFromDirector.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; - this.restoreFromDirector.UseVisualStyleBackColor = true; - this.restoreFromDirector.Click += new System.EventHandler(this.RestoreFromBackup); - // - // Restore - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.label3); - this.Controls.Add(this.restoreUsingFile); - this.Controls.Add(this.backupList); - this.Controls.Add(this.label2); - this.Controls.Add(this.label1); - this.Controls.Add(this.restoreFromDirector); - this.Name = "Restore"; - this.Size = new System.Drawing.Size(436, 355); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Button restoreFromDirector; - private System.Windows.Forms.ListBox backupList; - private System.Windows.Forms.Button restoreUsingFile; - private System.Windows.Forms.Label label3; - } -} diff --git a/UI/Restore.cs b/UI/Restore.cs deleted file mode 100644 index eb06168..0000000 --- a/UI/Restore.cs +++ /dev/null @@ -1,146 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using System.IO; -using Mono.Cecil; -using System.Diagnostics; - -namespace Garry.Control4.Jailbreak -{ - public partial class Restore : UserControl - { - MainWindow MainWindow; - - public Restore( MainWindow MainWindow ) - { - this.MainWindow = MainWindow; - - InitializeComponent(); - } - - protected override void OnVisibleChanged( EventArgs e ) - { - base.OnVisibleChanged( e ); - - if ( this.Visible ) - { - UpdateBackupList(); - } - } - - void UpdateBackupList() - { - if ( MainWindow.ConnectedDirector == null ) - return; - - backupList.Items.Clear(); - restoreFromDirector.Enabled = false; - - using ( var ssh = MainWindow.ConnectedDirector.SshClient ) - { - ssh.Connect(); - - var cmd = ssh.RunCommand( "ls /etc/openvpn/clientca-prod.*.backup" ); - - foreach ( var line in cmd.Result.Split( new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries ) ) - { - backupList.Items.Add( System.IO.Path.GetFileName( line ) ); - } - } - } - - private void RestoreFromFile( object sender, EventArgs e ) - { - var open = new OpenFileDialog(); - open.Filter = "Certificate File|*.pem"; - open.Title = "Find clientca-prod.pem"; - open.FileName = "clientca-prod-downloadedbackup.pem"; - - if ( open.ShowDialog() != DialogResult.OK ) - return; - - var file = System.IO.File.ReadAllText( open.FileName ); - - var log = new LogWindow( MainWindow ); - RestoreCert( log, file ); - } - - private void SelectedIndexChanged( object sender, EventArgs e ) - { - restoreFromDirector.Enabled = backupList.SelectedIndex >= 0; - } - - private void RestoreFromBackup( object sender, EventArgs e ) - { - var log = new LogWindow( MainWindow ); - - var selectedItem = "/etc/openvpn/" + backupList.SelectedItem.ToString(); - - using ( var ssh = MainWindow.ConnectedDirector.ScpClient ) - { - log.WriteNormal( $"Connecting to director via SCP.. " ); - ssh.Connect(); - log.WriteSuccess( $" .. connected!\n" ); - - // Get the existing certificate - using ( var stream = new MemoryStream() ) - { - log.WriteNormal( $"Downloading {selectedItem}\n" ); - ssh.Download( selectedItem, stream ); - log.WriteSuccess( $"Done - got {stream.Length} bytes\n\n" ); - - stream.Position = 0; - - using ( StreamReader reader = new StreamReader( stream ) ) - { - stream.Position = 0; - var certificate = reader.ReadToEnd(); - - RestoreCert( log, certificate ); - } - } - } - } - - private void RestoreCert( LogWindow log, string certificate ) - { - if ( !certificate.Contains( "BEGIN CERTIFICATE" ) ) - { - log.WriteError( "This file doesn't seem to be valid?" ); - return; - } - - using ( var ssh = MainWindow.ConnectedDirector.ScpClient ) - { - log.WriteNormal( $"Connecting to director via SCP.. " ); - ssh.Connect(); - log.WriteSuccess( $" .. connected!\n" ); - - // Get the existing certificate - using ( var stream = new MemoryStream() ) - { - using ( StreamWriter writer = new StreamWriter( stream ) ) - { - writer.Write( certificate ); - writer.Flush(); - - stream.Position = 0; - - log.WriteNormal( $"Uploading /etc/openvpn/clientca-prod.pem\n" ); - ssh.Upload( stream, "/etc/openvpn/clientca-prod.pem" ); - log.WriteSuccess( $"Done!\n" ); - } - } - } - - MainWindow.ConnectedDirector.Reboot( log ); - MainWindow.DirectorDisconnected(); - } - } -} diff --git a/UI/Restore.resx b/UI/Restore.resx deleted file mode 100644 index 1af7de1..0000000 --- a/UI/Restore.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file