From 9ccd8c633ba181b4619b3d6d6c7db90e38c647d1 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 22 Feb 2024 20:55:10 -0500 Subject: [PATCH] Textfields for ARE module input fields. --- .../javascript/ui/panel/AutoRunModuleForm.js | 66 ++++++++++++----- .../media/javascript/ui/panel/common.js | 74 +++++++++++++++++-- 2 files changed, 113 insertions(+), 27 deletions(-) diff --git a/extensions/admin_ui/media/javascript/ui/panel/AutoRunModuleForm.js b/extensions/admin_ui/media/javascript/ui/panel/AutoRunModuleForm.js index 002f0a232..f74bbcc75 100644 --- a/extensions/admin_ui/media/javascript/ui/panel/AutoRunModuleForm.js +++ b/extensions/admin_ui/media/javascript/ui/panel/AutoRunModuleForm.js @@ -10,6 +10,49 @@ AutoRunModuleForm = function(moduleData, deleteFn, moveUp, moveDown, ruleId, ind const moduleTextAreaId = `rule-${ruleId}-module-textarea-${index}`; const chainModeComboId = `rule-${ruleId}-module-combo-${index}`; + const moduleOptionsContainer = new Ext.Panel({ + padding: '5 5 5 5', + border: false, + layout: 'form', + items: [/*{ + xtype: 'combo', + id: chainModeComboId, + fieldLabel: 'Chain Mode', + store: ['moduleA', 'moduleB'], // TODO: Update this to the array of commands. + queryMode: 'local', // Use local data. + triggerAction: 'all', // Show both options instead of just the default. + editable: false, // Disable manual text input. + forceSelection: true, + value: moduleData.name, + },*/ + { + xtype: 'displayfield', + fieldLabel: 'Module Name', + value: moduleData.name, + }, + { + xtype: 'displayfield', + fieldLabel: 'Module Author', + value: moduleData.author ? moduleData.author : 'anonymous', + } + ] + }); + + function loadModule() { + // TODO: Need to query module option types so that not everything is given a textfield. + console.log("Module data:"); + console.log(moduleData); + for (key in moduleData.options) { + const value = moduleData.options[key]; + const inputField = new Ext.form.TextField({ + fieldLabel: key, + value: value ? value : '', + }); + moduleOptionsContainer.add(inputField); + }; + } + loadModule(); + const buttonContainer = new Ext.Container({ layout: { type: 'hbox', @@ -34,30 +77,13 @@ AutoRunModuleForm = function(moduleData, deleteFn, moveUp, moveDown, ruleId, ind ] }); + AutoRunModuleForm.superclass.constructor.call(this, { padding: '10 10 10 10', closable: false, items: [ - /*{ - xtype: 'combo', - id: chainModeComboId, - fieldLabel: 'Chain Mode', - store: ['sequential', 'nested-forward'], - queryMode: 'local', // Use local data. - triggerAction: 'all', // Show both options instead of just the default. - editable: false, // Disable manual text input. - forceSelection: true, - value: moduleData.chain_mode ? moduleData.chain_mode : 'sequential' - },*/ - { - xtype: 'textarea', - id: moduleTextAreaId, - fieldLabel: 'Module Data', - value: moduleData ? JSON.stringify(moduleData) : '{}', - grow: true, - width: '80%' - }, - buttonContainer + moduleOptionsContainer, + buttonContainer ]}); }; diff --git a/extensions/admin_ui/media/javascript/ui/panel/common.js b/extensions/admin_ui/media/javascript/ui/panel/common.js index 750bda90e..dd5e21a90 100644 --- a/extensions/admin_ui/media/javascript/ui/panel/common.js +++ b/extensions/admin_ui/media/javascript/ui/panel/common.js @@ -357,13 +357,13 @@ function genNewExploitPanel(panel, command_module_id, command_module_name, zombi fieldLabel: 'Description', fieldClass: 'command-module-panel-description', value: module.Description - }), - new Ext.form.DisplayField({ - name: 'command_module_id_visible', - fieldLabel: 'Id', - fieldClass: 'command-module-panel-description', - value: command_module_id - }) + }), + new Ext.form.DisplayField({ + name: 'command_module_id_visible', + fieldLabel: 'Id', + fieldClass: 'command-module-panel-description', + value: command_module_id + }) ], buttons:[{ @@ -425,3 +425,63 @@ function genNewExploitPanel(panel, command_module_id, command_module_name, zombi }); } }; + + +function genNewAutoRunModulePanel(panel, module, ruleId) { + if(typeof panel != 'object') { + Ext.beef.msg('Bad!', 'Incorrect panel chosen.'); + return; + } + + panel.removeAll(); + if(module.name == 'some special command module') { + //HERE we will develop specific panels for the command modules that require it. + } else { + var form = new Ext.form.FormPanel({ + id: `form-are-module-${ruleId}`, + border: false, + labelWidth: 75, + defaultType: 'textfield', + title: module.name, + bodyStyle: 'padding: 5px;', + + items: [ + new Ext.form.DisplayField({ + name: 'command_module_description', + fieldLabel: 'Description', + fieldClass: 'command-module-panel-description', + value: module.description + }), + ], + + buttons:[{ + text: "Save Module", + handler: function() {console.log("Saved module...")} + }] + }); + + // create the panel and hide it + /* + var payload_panel = new Ext.Panel({ + id: 'payload-panel', // used with Ext.GetCmp('payload-panel') + bodyStyle: 'padding:10px;', // we can assign styles to the main div + layout : 'form', + bodyBorder: false, + height: 200, + hidden: true, + border: false //we can remove the border of the panel + }); + */ + + Ext.each(module.Data, function(input){ + // Fake a zombie "session" property for the sake of getting it working. + generate_form_input_field(form, input, null, false, {session: module.name})} + ); + + //form.add(payload_panel); + panel.add(form); + panel.doLayout(); + // hide the load mask after rendering of the config panel is done + //panel.configLoadMask.hide(); + } +}; \ No newline at end of file