Add method to remove network host
This commit is contained in:
@@ -876,7 +876,44 @@ ZombieTab_Network = function(zombie) {
|
|||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}]
|
},{
|
||||||
|
xtype: 'menuseparator'
|
||||||
|
},{
|
||||||
|
text: 'Remove',
|
||||||
|
iconCls: 'zombie-tree-ctxMenu-delete',
|
||||||
|
handler: function() {
|
||||||
|
var host_id = record.get('id');
|
||||||
|
if (!confirm('Are you sure you want to remove network host [id: '+host_id+', ip: '+ ip +'] ?')) {
|
||||||
|
commands_statusbar.update_fail('Cancelled');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
commands_statusbar.update_sending('Removing network host [id: '+ host_id +', ip: '+ ip +'] ...');
|
||||||
|
$jwterm.ajax({
|
||||||
|
contentType: 'application/json',
|
||||||
|
dataType: 'json',
|
||||||
|
type: 'DELETE',
|
||||||
|
url: "/api/network/host/" + host_id + "?token=" + token,
|
||||||
|
async: false,
|
||||||
|
processData: false,
|
||||||
|
success: function(data){
|
||||||
|
try {
|
||||||
|
if (data.success) {
|
||||||
|
commands_statusbar.update_sent('Removed network host successfully');
|
||||||
|
Ext.getCmp('network-host-grid-zombie-'+zombie.session).getStore().reload();
|
||||||
|
} else {
|
||||||
|
commands_statusbar.update_fail('Could not remove network host');
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
commands_statusbar.update_fail('Could not remove network host');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(){
|
||||||
|
commands_statusbar.update_fail('Could not remove host');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
grid.rowCtxMenu.showAt(e.getXY());
|
grid.rowCtxMenu.showAt(e.getXY());
|
||||||
|
|||||||
@@ -68,6 +68,16 @@ module BeEF
|
|||||||
network_host
|
network_host
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Removes a network host from the data store
|
||||||
|
#
|
||||||
|
def self.delete(id)
|
||||||
|
(print_error "Failed to remove network host. Invalid host ID."; return) if id.to_s !~ /\A\d+\z/
|
||||||
|
host = BeEF::Core::Models::NetworkHost.get(id.to_i)
|
||||||
|
(print_error "Failed to remove network host [id: #{id}]. Host does not exist."; return) if host.nil?
|
||||||
|
host.destroy
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -119,6 +119,27 @@ module BeEF
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Removes a specific host given its id
|
||||||
|
delete '/host/:id' do
|
||||||
|
begin
|
||||||
|
id = params[:id]
|
||||||
|
raise InvalidParamError, 'id' if id !~ /\A\d+\z/
|
||||||
|
|
||||||
|
host = @nh.all(:id => id)
|
||||||
|
halt 404 if host.nil?
|
||||||
|
|
||||||
|
result = {}
|
||||||
|
result['success'] = @nh.delete(id)
|
||||||
|
result.to_json
|
||||||
|
rescue InvalidParamError => e
|
||||||
|
print_error e.message
|
||||||
|
halt 400
|
||||||
|
rescue StandardError => e
|
||||||
|
print_error "Internal error while removing network host with id #{id} (#{e.message})"
|
||||||
|
halt 500
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Returns a specific service given its id
|
# Returns a specific service given its id
|
||||||
get '/service/:id' do
|
get '/service/:id' do
|
||||||
begin
|
begin
|
||||||
|
|||||||
Reference in New Issue
Block a user