Path: blob/master/extensions/admin_ui/media/javascript/ui/panel/tabs/ZombieTabCommands.js
1155 views
//1// Copyright (c) 2006-2025 Wade Alcorn - [email protected]2// Browser Exploitation Framework (BeEF) - https://beefproject.com3// See the file 'doc/COPYING' for copying permission4//56/*7* The command tab panel. Listing the list of commands sent to the zombie.8* Loaded in /ui/panel/index.html9*/10ZombieTab_Commands = function(zombie) {11var originalRoot;1213var command_module_config = new Ext.Panel({14id: 'zombie-command-module-config-'+zombie.session,15region: 'center',16border: true,17layout: 'fit'18});1920var command_module_grid = new Ext.grid.GridPanel({21store: new Ext.data.JsonStore({22url: '<%= @base_path %>/modules/commandmodule/commands.json',23params: { // insert the nonce with the form24nonce: Ext.get ("nonce").dom.value25},26autoDestroy: false,27autoLoad: false,28root: 'commands',29fields: ['label', 'creationdate', 'id', 'object_id'],30sortInfo: {field: 'id', direction: 'ASC'}31}),3233id: 'command-module-grid-zombie-'+zombie.session,34title: "Module Results History",35sortable: true,36autoWidth: false,37region: 'west',38stripeRows: true,39autoScroll: true,40border: true,41width: 260,42i:0,43minSize: 160,44maxSize: 300,45split: true,4647view: new Ext.grid.GridView({48forceFit: true,49emptyText: "The results from executed command modules will be listed here.",50enableRowBody:true51}),5253columns: [54{header: 'id', width: 35, sortable: true, dataIndex: 'id'},55{header: 'date', width: 100, sortable: true, dataIndex: 'creationdate'},56{header: 'label', sortable: true, dataIndex: 'label', renderer:57function(value, metaData, record, rowIndex, colIndex, store) {58return 'command '+($jEncoder.encoder.encodeForHTML(record.get("id")+1));59}60},61{header: 'object_id', sortable: true, dataIndex: 'object_id', hidden: true, menuDisabled: true}62]63});6465command_module_grid.on('rowclick', function(grid, rowIndex, e) {66var r = grid.getStore().getAt(rowIndex).data;67var command_id = r.object_id || null;6869if(!command_id) return;7071genExistingExploitPanel(command_module_config, command_id, zombie, commands_statusbar);72});7374LoadCommandPanelEvent = function(node,keyclick) {75if(!node.leaf && !keyclick) {76node.toggle();77} else if (!node.leaf && keyclick) {78return;79} else {80command_module_config.configLoadMask = new Ext.LoadMask(Ext.getBody(), {msg:"Please wait, module config is loading..."});81command_module_config.configLoadMask.show();82command_module_grid.i = 0;83command_module_grid.store.baseParams = {command_module_id: node.attributes.id, zombie_session: zombie.session};84command_module_grid.store.reload({ //reload the command module grid85params: { // insert the nonce with the request to reload the grid86nonce: Ext.get ("nonce").dom.value87}88});8990genNewExploitPanel(command_module_config, node.id, node.text, zombie, commands_statusbar);91commands_statusbar.showValid('Ready');92}93};9495var command_module_tree_search = new Ext.form.TextField( {96emptyText: 'Search',97id: 'module-search-' + zombie.session,98style: {99width: '100%'100},101listeners: {102specialkey : function(field,e){103if(e.getKey() == e.ENTER){104if( field.getValue() ){105var root = {106text: "Search results",107children: search_module(originalRoot, field.getValue())108};109command_module_tree.setRootNode(root);110} else111command_module_tree.setRootNode(originalRoot);112113}114}115}116});117118var command_module_tree_search_panel = new Ext.Panel({119id: "zombie-command-modules-search-panel"+zombie.session,120items: [ command_module_tree_search ],121width: 190,122minSize: 190,123maxSize: 500,124region: 'north'125});126127var command_module_tree = new Ext.tree.TreePanel({128id: "zombie-command-modules"+zombie.session,129region: 'center',130width: 190,131minSize: 190,132maxSize: 500,133useArrows: true,134autoScroll: true,135animate: true,136containerScroll: true,137rootVisible: false,138root: {nodeType: 'async'},139loader: new Ext.tree.TreeLoader({140dataUrl: '<%= @base_path %>/modules/select/commandmodules/tree.json',141baseParams: {zombie_session: zombie.session},142listeners:{143beforeload: function(treeloader, node, callback) {144// Show loading mask on body, to prevent the user interacting with the UI145treeloader.treeLoadingMask = new Ext.LoadMask(Ext.getBody(), {msg:"Please wait, command tree is loading..."});146treeloader.treeLoadingMask.show();147return true;148},149load: function(treeloader, node, response) {150// Hide loading mask after tree is fully loaded151treeloader.treeLoadingMask.hide();152originalRoot = command_module_tree.root.childNodes;153return true;154}155}156}),157listeners: {158'click': function(node) {159LoadCommandPanelEvent(node,false);160},161'afterrender' : function() {162},163'selectionchange' : function() {164},165'activate' : function() {166},167'deactivate' : function() {168},169'select' : function() {170},171'keyup' : function() {172},173'render' : function(c) {174c.getEl().on('keyup', function(a) {175LoadCommandPanelEvent(Ext.getCmp('zombie-command-modules'+zombie.session).getSelectionModel().getSelectedNode(),true);176});177}178}179});180181var command_module_tree_container = new Ext.Panel({182id: "zombie-command-modules-container"+zombie.session,183title: "Module Tree",184border: true,185width: 190,186minSize: 190,187maxSize: 500, // if some command module names are even longer, adjust this value188layout: 'border',189region: 'west',190split: true,191items: [ command_module_tree_search_panel,command_module_tree ],192});193194195var commands_statusbar = new Beef_StatusBar(zombie.session);196197ZombieTab_Commands.superclass.constructor.call(this, {198id: 'zombie-'+zombie.session+'-command-module-panel',199title:'Commands',200layout: 'fit',201region: 'center',202items: {203layout: 'border',204border: false,205// enable width resize of the command_module_tree206defaults: {207collapsible: false,208split: true209},210items: [211command_module_tree_container,212new Ext.Panel({213id: 'zombie-command-module-west-'+zombie.session,214region: 'center',215layout: 'border',216border: false,217items: [command_module_grid, command_module_config]218})]219},220221bbar: commands_statusbar222});223224var sb = Ext.getCmp('command-module-bbar-zombie-'+zombie.session);225};226227Ext.extend(ZombieTab_Commands, Ext.Panel, {228listeners: {229close: function(panel) {}230}231});232233234