Merge pull request #1064 from bmantra/master

delete old zombies via REST api and UI closes #762
This commit is contained in:
bmantra
2014-10-27 20:29:04 +01:00
2 changed files with 56 additions and 2 deletions

View File

@@ -43,6 +43,42 @@ module BeEF
output.to_json
end
get '/:session/delete' do
hb = BeEF::Core::Models::HookedBrowser.first(:session => params[:session])
error 401 unless hb != nil
details = BeEF::Core::Models::BrowserDetails.all(:session_id => hb.session)
details.destroy
logs = BeEF::Core::Models::Log.all(:hooked_browser_id => hb.id)
logs.destroy
commands = BeEF::Core::Models::Command.all(:hooked_browser_id => hb.id)
commands.destroy
results = BeEF::Core::Models::Result.all(:hooked_browser_id => hb.id)
results.destroy
begin
requester = BeEF::Core::Models::Http.all(:hooked_browser_id => hb.id)
requester.destroy
rescue Exception => e
#the requester module may not be enabled
end
begin
xssraysscans = BeEF::Core::Models::Xssraysscan.all(:hooked_browser_id => hb.id)
xssraysscans.destroy
xssraysdetails = BeEF::Core::Models::Xssraysdetail.all(:hooked_browser_id => hb.id)
xssraysdetails.destroy
rescue Exception => e
#the xssraysscan module may not be enabled
end
hb.destroy
end
#
# @note this is basically the same call as /api/hooks, but returns different data structured in arrays rather than objects.
# Useful if you need to query the API via jQuery.dataTable < 1.10 which is currently used in PhishingFrenzy

View File

@@ -76,12 +76,16 @@ Ext.extend(zombiesTreeList, Ext.tree.TreePanel, {
id: 'xssrays_hooked_domain',
text: 'Launch XssRays on Hooked Domain',
iconCls: 'zombie-tree-ctxMenu-xssrays'
},{
id: 'delete_zombie',
text: 'Delete Zombie',
}
],
listeners: {
itemclick: function(item, object) {
var hb_id = this.contextNode.id.split('zombie-online-')[1];
var hb_id_off = this.contextNode.id.split('zombie-offline-')[1];
switch (item.id) {
case 'use_as_proxy':
Ext.Ajax.request({
@@ -97,6 +101,20 @@ Ext.extend(zombiesTreeList, Ext.tree.TreePanel, {
params: 'hb_id=' + escape(hb_id)
});
break;
case 'delete_zombie':
var token = beefwui.get_rest_token();
var hid = '';
if (typeof hb_id_off === 'undefined'){
hid=hb_id;
}else{
hid=hb_id_off;
}
var url = "/api/hooks/" + escape(hid) + "/delete?token=" + token;
Ext.Ajax.request({
url: url,
method: 'GET'
});
break;
}
}
}
@@ -106,7 +124,7 @@ Ext.extend(zombiesTreeList, Ext.tree.TreePanel, {
//creates a new hooked browser tab when a hooked browser is clicked
click: function(node, e) {
if(!node.leaf) return;
mainPanel.remove(mainPanel.getComponent('current-browser'));
if(!mainPanel.getComponent('current-browser')) {
mainPanel.add(new ZombieTab(node.attributes));
@@ -126,7 +144,7 @@ Ext.extend(zombiesTreeList, Ext.tree.TreePanel, {
},
//update the set of rules when a checkbox is clicked
checkchange: function(node, checked) {
}
},