/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Bt_Save_Click(object sender, EventArgs e) { // Create and populate temlate object var newTemplateData = new MinaryTemplateData(); newTemplateData.TemplateConfig.Name = this.tb_TemplateName.Text; newTemplateData.TemplateConfig.Description = this.tb_TemplateDescription.Text; newTemplateData.TemplateConfig.Reference = this.tb_TemplateReferenceLink.Text; newTemplateData.TemplateConfig.Author = this.tb_AuthorName.Text; newTemplateData.TemplateConfig.Version = this.tb_Version.Text; // Configure attack settings int tmpNumberSelectedTargetSystems = -1; int.TryParse(this.tb_MaxNoTargetSystems.Text, out tmpNumberSelectedTargetSystems); newTemplateData.AttackConfig.NumberSelectedTargetSystems = tmpNumberSelectedTargetSystems; newTemplateData.AttackConfig.ScanNetwork = this.cb_ArpScan.Checked ? 1 : 0; newTemplateData.AttackConfig.StartAttack = this.cb_StartAttackingTargets.Checked ? 1 : 0; newTemplateData.AttackConfig.IsAdvancedScan = this.rb_GuiAdvanced.Checked ? 1 : 0; newTemplateData.AttackConfig.IsDebuggingOn = this.rb_DebuggingOn.Checked ? 1 : 0; try { this.TemplateParametersAreValid(newTemplateData); } catch (Exception ex) { MessageDialog.Inst.ShowError(string.Empty, ex.Message, this); return; } // Plugin data foreach (TabPage tmpTabPage in this.minaryMain.MinaryTabPageHandler.VisibleTabPages) { Minary.DataTypes.MinaryExtension tmpExtension = this.minaryMain.PluginHandler.TabPagesCatalog[tmpTabPage.Text]; TemplatePluginData tmpPluginData = tmpExtension.PluginObject.OnGetTemplateData(); newTemplateData.Plugins.Add(new Plugin(tmpTabPage.Text, tmpPluginData)); } // Show save file dialog this.sfd_TemplateFile.InitialDirectory = Path.Combine(Directory.GetCurrentDirectory(), Minary.Config.CustomTemplatesDir); this.sfd_TemplateFile.Filter = $"Minary template files|*.{Minary.Config.MinaryFileExtension}"; this.sfd_TemplateFile.Title = $"Export current configuration to a .{Minary.Config.MinaryFileExtension} file"; this.sfd_TemplateFile.AddExtension = true; DialogResult dialogResult = this.sfd_TemplateFile.ShowDialog(); if (dialogResult == DialogResult.Cancel) { return; } else if (string.IsNullOrEmpty(this.sfd_TemplateFile.FileName)) { var message = "You didn't define an output file"; MessageDialog.Inst.ShowWarning(string.Empty, message, this); return; } // Save template to file system try { this.SaveTemplateToFile(newTemplateData); this.minaryMain.TemplateName.Text = newTemplateData.TemplateConfig.Name; } catch (Exception ex) { LogCons.Inst.Write(LogLevel.Error, $"Error occurred while saving template : {ex.Message}"); string message = $"Error occurred while saving template : {ex.Message}"; MessageDialog.Inst.ShowWarning(string.Empty, message, this); } }
public void LoadPluginData(string tabPageName, TemplatePluginData pluginData) { LogCons.Inst.Write(LogLevel.Info, $"Calls interface: LoadPluginData() \"{tabPageName}\""); Minary.DataTypes.MinaryExtension realPluginObj = this.minaryMain.PluginHandler.TabPagesCatalog[tabPageName]; realPluginObj.PluginObject.OnLoadTemplateData(pluginData); }