Created UI class for modules in Auto Run.
This commit is contained in:
@@ -92,6 +92,7 @@ module BeEF
|
||||
ui/panel/WelcomeTab.js
|
||||
ui/panel/AutoRunTab.js
|
||||
ui/panel/AutoRunRuleForm.js
|
||||
ui/panel/AutoRunModuleForm.js
|
||||
ui/panel/ModuleSearching.js
|
||||
]
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* Form that displays fields for a module.
|
||||
*
|
||||
* moduleData: The object definition of this moduleData from the Auto Run Engine.
|
||||
* deleteFn: callback function to delete this moduleData.
|
||||
* moveUp: moves the module up one spot in the Auto Run execution order.
|
||||
* moveDown: moves the module down one spot in the Auto Run exection order.
|
||||
*/
|
||||
AutoRunModuleForm = function(moduleData, deleteFn, moveUp, moveDown) {
|
||||
const moduleNameId = `module-name-${moduleData.id}`;
|
||||
const moduleTextAreaId = `module-name-${moduleData.id}`;
|
||||
const chainModeComboId = `module-combo-${moduleData.id}`;
|
||||
|
||||
AutoRunModuleForm.superclass.constructor.call(this, {
|
||||
padding:'10 10 10 10',
|
||||
items: [{
|
||||
xtype: 'textfield',
|
||||
id: moduleNameId,
|
||||
value: moduleData.name ? moduleData.name : '',
|
||||
fieldLabel: 'Name',
|
||||
},/*{
|
||||
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: 'displayfield',
|
||||
fieldLabel: 'Author',
|
||||
value: moduleData.author ? moduleData.author : 'anonymous',
|
||||
},{
|
||||
xtype: 'textarea',
|
||||
id: moduleTextAreaId,
|
||||
fieldLabel: 'Module Data',
|
||||
value: moduleData ? JSON.stringify(moduleData) : '{}',
|
||||
grow: true,
|
||||
width: '80%'
|
||||
},
|
||||
{
|
||||
xtype: 'button',
|
||||
text: 'Delete',
|
||||
handler: deleteFn,
|
||||
},{
|
||||
xtype: 'button',
|
||||
text: 'Move Forward',
|
||||
handler: moveUp,
|
||||
disabled: moveUp == undefined
|
||||
},{
|
||||
xtype: 'button',
|
||||
text: 'Move Back',
|
||||
handler: moveDown,
|
||||
disabled: moveDown == undefined
|
||||
}
|
||||
],
|
||||
border: false,
|
||||
closable: false
|
||||
});
|
||||
};
|
||||
|
||||
Ext.extend(AutoRunModuleForm, Ext.Container, {});
|
||||
@@ -25,10 +25,23 @@ AutoRunRuleForm = function(rule, deleteFn, updateFn, addFn) {
|
||||
const self = this;
|
||||
const ruleTextFieldId = `rule-name-${rule.id}`;
|
||||
const chainModeComboId = `rule-chain-mode-${rule.id}`;
|
||||
const moduleFieldId = `rule-module-field-${rule.id}`;
|
||||
const modules = JSON.parse(rule['modules']);
|
||||
const moduleForms = [];
|
||||
for (let i = 0; i < modules.length; ++i) {
|
||||
const isFirstModule = i === 0;
|
||||
const isLastModule = i >= modules.length - 1;
|
||||
moduleForms.push(new AutoRunModuleForm(
|
||||
modules[i],
|
||||
function() {console.log("delete this module")},
|
||||
isFirstModule ? undefined : function() {console.log("move up")},
|
||||
isLastModule ? undefined : function() {console.log("move down")},
|
||||
));
|
||||
}
|
||||
console.log(`Number of modules: ${moduleForms.length}`);
|
||||
|
||||
function handleUpdateRule() {
|
||||
// TODO: Check if inputs are valid.
|
||||
// TODO: Get data from modules.
|
||||
const form = self.getForm();
|
||||
const formValues = form.getValues();
|
||||
const updatedRule = {
|
||||
@@ -38,7 +51,6 @@ AutoRunRuleForm = function(rule, deleteFn, updateFn, addFn) {
|
||||
execution_order: JSON.parse(rule['execution_order']),
|
||||
name: formValues[ruleTextFieldId],
|
||||
chain_mode: formValues[chainModeComboId],
|
||||
modules: JSON.parse(formValues[moduleFieldId]),
|
||||
};
|
||||
console.log(updatedRule);
|
||||
updateFn(updatedRule);
|
||||
@@ -72,7 +84,9 @@ AutoRunRuleForm = function(rule, deleteFn, updateFn, addFn) {
|
||||
xtype: 'displayfield',
|
||||
fieldLabel: 'OS version(s)',
|
||||
value: rule.os_version ? rule.os_version : 'All',
|
||||
},{
|
||||
},
|
||||
...moduleForms,
|
||||
{
|
||||
xtype: 'combo',
|
||||
id: chainModeComboId,
|
||||
fieldLabel: 'Chain Mode',
|
||||
@@ -82,12 +96,6 @@ AutoRunRuleForm = function(rule, deleteFn, updateFn, addFn) {
|
||||
editable: false, // Disable manual text input.
|
||||
forceSelection: true,
|
||||
value: rule.chain_mode ? rule.chain_mode : 'sequential'
|
||||
},{
|
||||
xtype: 'textarea',
|
||||
id: moduleFieldId,
|
||||
fieldLabel: 'modules',
|
||||
value: rule.modules ? rule.modules : '[]',
|
||||
grow: true
|
||||
},{
|
||||
xtype: 'displayfield',
|
||||
fieldLabel: 'Execution Order',
|
||||
|
||||
Reference in New Issue
Block a user