Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/extensions/admin_ui/media/javascript/ui/panel/tabs/ZombieTabCommands.js
1155 views
1
//
2
// Copyright (c) 2006-2025 Wade Alcorn - [email protected]
3
// Browser Exploitation Framework (BeEF) - https://beefproject.com
4
// See the file 'doc/COPYING' for copying permission
5
//
6
7
/*
8
* The command tab panel. Listing the list of commands sent to the zombie.
9
* Loaded in /ui/panel/index.html
10
*/
11
ZombieTab_Commands = function(zombie) {
12
var originalRoot;
13
14
var command_module_config = new Ext.Panel({
15
id: 'zombie-command-module-config-'+zombie.session,
16
region: 'center',
17
border: true,
18
layout: 'fit'
19
});
20
21
var command_module_grid = new Ext.grid.GridPanel({
22
store: new Ext.data.JsonStore({
23
url: '<%= @base_path %>/modules/commandmodule/commands.json',
24
params: { // insert the nonce with the form
25
nonce: Ext.get ("nonce").dom.value
26
},
27
autoDestroy: false,
28
autoLoad: false,
29
root: 'commands',
30
fields: ['label', 'creationdate', 'id', 'object_id'],
31
sortInfo: {field: 'id', direction: 'ASC'}
32
}),
33
34
id: 'command-module-grid-zombie-'+zombie.session,
35
title: "Module Results History",
36
sortable: true,
37
autoWidth: false,
38
region: 'west',
39
stripeRows: true,
40
autoScroll: true,
41
border: true,
42
width: 260,
43
i:0,
44
minSize: 160,
45
maxSize: 300,
46
split: true,
47
48
view: new Ext.grid.GridView({
49
forceFit: true,
50
emptyText: "The results from executed command modules will be listed here.",
51
enableRowBody:true
52
}),
53
54
columns: [
55
{header: 'id', width: 35, sortable: true, dataIndex: 'id'},
56
{header: 'date', width: 100, sortable: true, dataIndex: 'creationdate'},
57
{header: 'label', sortable: true, dataIndex: 'label', renderer:
58
function(value, metaData, record, rowIndex, colIndex, store) {
59
return 'command '+($jEncoder.encoder.encodeForHTML(record.get("id")+1));
60
}
61
},
62
{header: 'object_id', sortable: true, dataIndex: 'object_id', hidden: true, menuDisabled: true}
63
]
64
});
65
66
command_module_grid.on('rowclick', function(grid, rowIndex, e) {
67
var r = grid.getStore().getAt(rowIndex).data;
68
var command_id = r.object_id || null;
69
70
if(!command_id) return;
71
72
genExistingExploitPanel(command_module_config, command_id, zombie, commands_statusbar);
73
});
74
75
LoadCommandPanelEvent = function(node,keyclick) {
76
if(!node.leaf && !keyclick) {
77
node.toggle();
78
} else if (!node.leaf && keyclick) {
79
return;
80
} else {
81
command_module_config.configLoadMask = new Ext.LoadMask(Ext.getBody(), {msg:"Please wait, module config is loading..."});
82
command_module_config.configLoadMask.show();
83
command_module_grid.i = 0;
84
command_module_grid.store.baseParams = {command_module_id: node.attributes.id, zombie_session: zombie.session};
85
command_module_grid.store.reload({ //reload the command module grid
86
params: { // insert the nonce with the request to reload the grid
87
nonce: Ext.get ("nonce").dom.value
88
}
89
});
90
91
genNewExploitPanel(command_module_config, node.id, node.text, zombie, commands_statusbar);
92
commands_statusbar.showValid('Ready');
93
}
94
};
95
96
var command_module_tree_search = new Ext.form.TextField( {
97
emptyText: 'Search',
98
id: 'module-search-' + zombie.session,
99
style: {
100
width: '100%'
101
},
102
listeners: {
103
specialkey : function(field,e){
104
if(e.getKey() == e.ENTER){
105
if( field.getValue() ){
106
var root = {
107
text: "Search results",
108
children: search_module(originalRoot, field.getValue())
109
};
110
command_module_tree.setRootNode(root);
111
} else
112
command_module_tree.setRootNode(originalRoot);
113
114
}
115
}
116
}
117
});
118
119
var command_module_tree_search_panel = new Ext.Panel({
120
id: "zombie-command-modules-search-panel"+zombie.session,
121
items: [ command_module_tree_search ],
122
width: 190,
123
minSize: 190,
124
maxSize: 500,
125
region: 'north'
126
});
127
128
var command_module_tree = new Ext.tree.TreePanel({
129
id: "zombie-command-modules"+zombie.session,
130
region: 'center',
131
width: 190,
132
minSize: 190,
133
maxSize: 500,
134
useArrows: true,
135
autoScroll: true,
136
animate: true,
137
containerScroll: true,
138
rootVisible: false,
139
root: {nodeType: 'async'},
140
loader: new Ext.tree.TreeLoader({
141
dataUrl: '<%= @base_path %>/modules/select/commandmodules/tree.json',
142
baseParams: {zombie_session: zombie.session},
143
listeners:{
144
beforeload: function(treeloader, node, callback) {
145
// Show loading mask on body, to prevent the user interacting with the UI
146
treeloader.treeLoadingMask = new Ext.LoadMask(Ext.getBody(), {msg:"Please wait, command tree is loading..."});
147
treeloader.treeLoadingMask.show();
148
return true;
149
},
150
load: function(treeloader, node, response) {
151
// Hide loading mask after tree is fully loaded
152
treeloader.treeLoadingMask.hide();
153
originalRoot = command_module_tree.root.childNodes;
154
return true;
155
}
156
}
157
}),
158
listeners: {
159
'click': function(node) {
160
LoadCommandPanelEvent(node,false);
161
},
162
'afterrender' : function() {
163
},
164
'selectionchange' : function() {
165
},
166
'activate' : function() {
167
},
168
'deactivate' : function() {
169
},
170
'select' : function() {
171
},
172
'keyup' : function() {
173
},
174
'render' : function(c) {
175
c.getEl().on('keyup', function(a) {
176
LoadCommandPanelEvent(Ext.getCmp('zombie-command-modules'+zombie.session).getSelectionModel().getSelectedNode(),true);
177
});
178
}
179
}
180
});
181
182
var command_module_tree_container = new Ext.Panel({
183
id: "zombie-command-modules-container"+zombie.session,
184
title: "Module Tree",
185
border: true,
186
width: 190,
187
minSize: 190,
188
maxSize: 500, // if some command module names are even longer, adjust this value
189
layout: 'border',
190
region: 'west',
191
split: true,
192
items: [ command_module_tree_search_panel,command_module_tree ],
193
});
194
195
196
var commands_statusbar = new Beef_StatusBar(zombie.session);
197
198
ZombieTab_Commands.superclass.constructor.call(this, {
199
id: 'zombie-'+zombie.session+'-command-module-panel',
200
title:'Commands',
201
layout: 'fit',
202
region: 'center',
203
items: {
204
layout: 'border',
205
border: false,
206
// enable width resize of the command_module_tree
207
defaults: {
208
collapsible: false,
209
split: true
210
},
211
items: [
212
command_module_tree_container,
213
new Ext.Panel({
214
id: 'zombie-command-module-west-'+zombie.session,
215
region: 'center',
216
layout: 'border',
217
border: false,
218
items: [command_module_grid, command_module_config]
219
})]
220
},
221
222
bbar: commands_statusbar
223
});
224
225
var sb = Ext.getCmp('command-module-bbar-zombie-'+zombie.session);
226
};
227
228
Ext.extend(ZombieTab_Commands, Ext.Panel, {
229
listeners: {
230
close: function(panel) {}
231
}
232
});
233
234