diff --git a/FormConfiguration.Designer.cs b/FormConfiguration.Designer.cs index a649618..fff3f7a 100644 --- a/FormConfiguration.Designer.cs +++ b/FormConfiguration.Designer.cs @@ -1,4 +1,4 @@ -namespace SSH_Test +namespace FHT { partial class FormConfiguration { @@ -41,14 +41,17 @@ this.label5 = new System.Windows.Forms.Label(); this.textBoxTftpIP = new System.Windows.Forms.TextBox(); this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.groupBox5 = new System.Windows.Forms.GroupBox(); + this.buttonProfilePath = new System.Windows.Forms.Button(); this.groupBox4 = new System.Windows.Forms.GroupBox(); this.buttonTasklistDec = new System.Windows.Forms.Button(); this.buttonTasklistEnc = new System.Windows.Forms.Button(); this.buttonEncryptTaskList = new System.Windows.Forms.Button(); - this.openFileDialogTasklist = new System.Windows.Forms.OpenFileDialog(); + this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); + this.groupBox5.SuspendLayout(); this.groupBox4.SuspendLayout(); this.SuspendLayout(); // @@ -154,6 +157,7 @@ // // groupBox3 // + this.groupBox3.Controls.Add(this.groupBox5); this.groupBox3.Controls.Add(this.groupBox4); this.groupBox3.Controls.Add(this.buttonEncryptTaskList); this.groupBox3.Location = new System.Drawing.Point(307, 12); @@ -161,7 +165,27 @@ this.groupBox3.Size = new System.Drawing.Size(240, 177); this.groupBox3.TabIndex = 6; this.groupBox3.TabStop = false; - this.groupBox3.Text = "Encryption"; + this.groupBox3.Text = "Profile && Encryption"; + // + // groupBox5 + // + this.groupBox5.Controls.Add(this.buttonProfilePath); + this.groupBox5.Location = new System.Drawing.Point(8, 87); + this.groupBox5.Name = "groupBox5"; + this.groupBox5.Size = new System.Drawing.Size(200, 54); + this.groupBox5.TabIndex = 10; + this.groupBox5.TabStop = false; + this.groupBox5.Text = "Profile Path"; + // + // buttonProfilePath + // + this.buttonProfilePath.Location = new System.Drawing.Point(15, 18); + this.buttonProfilePath.Name = "buttonProfilePath"; + this.buttonProfilePath.Size = new System.Drawing.Size(163, 29); + this.buttonProfilePath.TabIndex = 9; + this.buttonProfilePath.Text = "profile.json"; + this.buttonProfilePath.UseVisualStyleBackColor = true; + this.buttonProfilePath.Click += new System.EventHandler(this.buttonProfilePath_Click); // // groupBox4 // @@ -203,12 +227,12 @@ this.buttonEncryptTaskList.Text = "Encrypt"; this.buttonEncryptTaskList.UseVisualStyleBackColor = true; // - // openFileDialogTasklist + // openFileDialog // - this.openFileDialogTasklist.DefaultExt = "json"; - this.openFileDialogTasklist.FileName = "tasklisk.json"; - this.openFileDialogTasklist.Filter = "json file|*.json|Powershell scrips|*.ps1"; - this.openFileDialogTasklist.Title = "Task list file"; + this.openFileDialog.DefaultExt = "json"; + this.openFileDialog.FileName = "*.json"; + this.openFileDialog.Filter = "json file|*.json|Powershell scrips|*.ps1"; + this.openFileDialog.Title = "File Path"; // // FormConfiguration // @@ -228,6 +252,7 @@ this.groupBox2.ResumeLayout(false); this.groupBox2.PerformLayout(); this.groupBox3.ResumeLayout(false); + this.groupBox5.ResumeLayout(false); this.groupBox4.ResumeLayout(false); this.ResumeLayout(false); @@ -251,6 +276,8 @@ private System.Windows.Forms.GroupBox groupBox4; private System.Windows.Forms.Button buttonTasklistDec; private System.Windows.Forms.Button buttonTasklistEnc; - private System.Windows.Forms.OpenFileDialog openFileDialogTasklist; + private System.Windows.Forms.OpenFileDialog openFileDialog; + private System.Windows.Forms.Button buttonProfilePath; + private System.Windows.Forms.GroupBox groupBox5; } } \ No newline at end of file diff --git a/FormConfiguration.cs b/FormConfiguration.cs index 8d4c64a..d59d772 100644 --- a/FormConfiguration.cs +++ b/FormConfiguration.cs @@ -12,7 +12,7 @@ using System.Windows.Forms; using System.IO; using System.Security.Cryptography; -namespace SSH_Test +namespace FHT { public partial class FormConfiguration : Form { @@ -29,15 +29,17 @@ namespace SSH_Test public static ILog log; public FormConfiguration(string tftp_IP, string sftpIP, string sftp_Username, string sftp_Password, bool bencryption - , Aes aaes, ILog Log) + , Aes aaes, string sprofilepath, ILog Log) { InitializeComponent(); this.textBoxTftpIP.Text = Tftp_IP = tftp_IP; this.textBoxSftpIP.Text = Sftp_IP = sftpIP; this.textBoxSftpUsername.Text = Sftp_Username = sftp_Username; this.textBoxSftpPassword.Text = Sftp_Password = sftp_Password; + buttonProfilePath.Text = sProfilePath = sprofilepath; aes = aaes; log = Log; + this.Update(); } @@ -66,10 +68,10 @@ namespace SSH_Test private void buttonTasklistEnc_Click(object sender, EventArgs e) { Utilities utilities = new Utilities(log); - if (openFileDialogTasklist.ShowDialog() == DialogResult.OK) + if (openFileDialog.ShowDialog() == DialogResult.OK) { - string Jsonfilename = openFileDialogTasklist.FileName; - string buttonTasklistPath = openFileDialogTasklist.SafeFileName; + string Jsonfilename = openFileDialog.FileName; + string buttonTasklistPath = openFileDialog.SafeFileName; if (File.Exists(Jsonfilename)) { try @@ -99,10 +101,10 @@ namespace SSH_Test private void buttonTasklistDec_Click(object sender, EventArgs e) { Utilities utilities = new Utilities(log); - if (openFileDialogTasklist.ShowDialog() == DialogResult.OK) + if (openFileDialog.ShowDialog() == DialogResult.OK) { - string JsonFileName = openFileDialogTasklist.FileName; - string buttonTasklistPath = openFileDialogTasklist.SafeFileName; + string JsonFileName = openFileDialog.FileName; + string buttonTasklistPath = openFileDialog.SafeFileName; if (File.Exists(JsonFileName)) { try @@ -126,5 +128,14 @@ namespace SSH_Test } } } + + private void buttonProfilePath_Click(object sender, EventArgs e) + { + if (openFileDialog.ShowDialog() == DialogResult.OK) + { + sProfilePath = openFileDialog.FileName; + buttonProfilePath.Text = openFileDialog.SafeFileName; + } + } } } diff --git a/FormConfiguration.resx b/FormConfiguration.resx index e895283..0c2e2c1 100644 --- a/FormConfiguration.resx +++ b/FormConfiguration.resx @@ -117,7 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 diff --git a/TastList.cs b/TastList.cs index fd9080c..586dbfe 100644 --- a/TastList.cs +++ b/TastList.cs @@ -27,14 +27,14 @@ using System.Windows.Forms; using System.Xml; using static System.Windows.Forms.VisualStyles.VisualStyleElement; -namespace SSH_Test +namespace FHT { public partial class TastList : Form { // set to false to enable Encrypt , Decrypt Buttons - public const bool IsAdminDisabled = true; + public const bool IsAdminDisabled = false; public List Tasks = new List(); @@ -133,8 +133,12 @@ namespace SSH_Test dataGridViewTask.AllowDrop = true; dataGridViewTask.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText; dataGridViewTask.RowTemplate.ContextMenuStrip = contextMenuStripRow; - //Load Profile list from "profile.json" - Profiles = utilities.LoadProfile("profile.json", aes); + + //ask for AES key + buttonAESString_Click(null, null); + + //Load Profile list from "Profilefilename" + Profiles = utilities.LoadProfile(Profilefilename, aes); // Configure Profile list to dropdown menu // AES button will update the dropdown menu when AES key is inputed. @@ -316,10 +320,12 @@ namespace SSH_Test row.Cells[1].Value = task.sTaskDescription; row.Cells[2].Value = task.sTaskDevice; row.Cells[4].Value = task.bTaskSelect; - var comboBoxColumn = (DataGridViewComboBoxColumn)dataGridViewTask.Columns[7]; + // var comboBoxColumn = (DataGridViewComboBoxColumn)dataGridViewTask.Columns[7]; // test if task.sprofile name mach any in Profiles, if true, assign that name if (Profiles.Any(pr => pr.ProfileName == task.sProfile)) row.Cells[7].Value = task.sProfile; + else + row.Cells[7].Value = null; dataGridViewTask.Rows.Add(row); } catch (Exception ex) @@ -335,18 +341,49 @@ namespace SSH_Test { FormConfiguration formConfiguration = new FormConfiguration(conInfo.sTftpIP, conInfo.sSftpIP, conInfo.sSftpUsername, conInfo.sSftpPassword, - bEncryption, aes, log); + bEncryption, aes, Profilefilename,log); // Disable Encrypt, Decrypt buttons if(IsAdminDisabled) { formConfiguration.AdminDisable(); } formConfiguration.ShowDialog(); + //reload profile and task list + Profilefilename = formConfiguration.sProfilePath; + //try reloading Profilefilename + Profiles.Clear(); + Profiles = utilities.LoadProfile(Profilefilename, aes); + // Configure Profile list to dropdown menu + try + { + foreach (Profile p in Profiles) + { + log.Info(string.Format("Profile: {0}", p.ProfileName)); + } + + var comboBoxColumn = (DataGridViewComboBoxColumn)dataGridViewTask.Columns[7]; + comboBoxColumn.DataSource = Profiles; // Set the data source of the ComboBox column + comboBoxColumn.DisplayMember = "profileName"; // Displayed property name + comboBoxColumn.ValueMember = "profileName"; //The property name of the value + } + catch (Exception ex) + { + log.Error(ex.Message); + } + + + + //reload tasklist + + buttonLoad_Click(null, null); + conInfo.sTftpIP = formConfiguration.Tftp_IP; conInfo.sSftpIP = formConfiguration.Sftp_IP; conInfo.sSftpUsername = formConfiguration.Sftp_Username; conInfo.sSftpPassword = formConfiguration.Sftp_Password; + dataGridViewTask.Refresh(); + } private void dataGridViewTask_CellClick(object sender, DataGridViewCellEventArgs e) @@ -752,10 +789,10 @@ namespace SSH_Test try { aes.Key = Convert.FromBase64String(formParameter.dParameters["AES string"]); - - //try reloading profile.json + + //try reloading Profilefilename Profiles.Clear(); - Profiles = utilities.LoadProfile("profile.json", aes); + Profiles = utilities.LoadProfile(Profilefilename, aes); // Configure Profile list to dropdown menu try { @@ -782,6 +819,9 @@ namespace SSH_Test } } + + //reload tasklist + buttonLoad_Click(null, null); } } diff --git a/bin/Debug/FHT.exe b/bin/Debug/FHT.exe new file mode 100644 index 0000000..b300920 Binary files /dev/null and b/bin/Debug/FHT.exe differ diff --git a/bin/Debug/FHT.pdb b/bin/Debug/FHT.pdb new file mode 100644 index 0000000..5b84b55 Binary files /dev/null and b/bin/Debug/FHT.pdb differ diff --git a/bin/Debug/profile - laptop.json b/bin/Debug/profile - laptop.json new file mode 100644 index 0000000..2250e9b Binary files /dev/null and b/bin/Debug/profile - laptop.json differ diff --git a/bin/Debug/profile.json b/bin/Debug/profile.json index 0d634c0..6f6e232 100644 Binary files a/bin/Debug/profile.json and b/bin/Debug/profile.json differ diff --git a/profile.json b/profile.json index 3be3e8a..6db9b58 100644 --- a/profile.json +++ b/profile.json @@ -417,7 +417,10 @@ "ProfileCommands": [ "racadm set iDRAC.Users.{Index}.Username {Username}", "racadm set iDRAC.Users.{Index}.Password {Password}", - "racadm get iDRAC.Users.{Index}.Username" + "racadm get iDRAC.Users.{Index}.Username", + "racadm set iDRAC.Users.{Index}.Enable 1", + "racadm set iDRAC.Users.{Index}.IpmiLanPriv 4" + ], "ProfileParameters": [ "{Index}", "{Username}", "{Password}" ] }, @@ -433,7 +436,11 @@ "racadm set iDRAC.Users.4.Password {Password 4}", "racadm get iDRAC.Users.2.Username", "racadm get iDRAC.Users.3.Username", - "racadm get iDRAC.Users.4.Username" + "racadm get iDRAC.Users.4.Username", + "racadm set iDRAC.Users.3.Enable 1", + "racadm set iDRAC.Users.3.IpmiLanPriv 4", + "racadm set iDRAC.Users.4.Enable 1", + "racadm set iDRAC.Users.4.IpmiLanPriv 4" ], "ProfileParameters": [ "{Password 2 root}",