From 1ce620a62632f5e73ad8deb37c30adc3cdb570d4 Mon Sep 17 00:00:00 2001 From: antisnatchor Date: Wed, 2 Jan 2013 20:07:49 +0100 Subject: [PATCH] Created a new beef_common.js files with common functions for the Web UI. Registered as beefwui in the main window object. --- .../admin_ui/controllers/panel/index.html | 6 ++- .../media/javascript/ui/common/beef_common.js | 44 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 extensions/admin_ui/media/javascript/ui/common/beef_common.js diff --git a/extensions/admin_ui/controllers/panel/index.html b/extensions/admin_ui/controllers/panel/index.html index a104a41e8..dbc9a42ef 100644 --- a/extensions/admin_ui/controllers/panel/index.html +++ b/extensions/admin_ui/controllers/panel/index.html @@ -13,12 +13,16 @@ <%= script_tag 'ext-base.js' %> <%= script_tag 'ext-all.js' %> <%= script_tag 'ext-beef.js' %> + <%= script_tag 'esapi/jquery-1.6.4.min.js' %> <%= script_tag 'esapi/Class.create.js' %> <%= script_tag 'esapi/jquery-encoder-0.1.0.js' %> - + + + <%= script_tag 'ui/common/beef_common.js' %> + <%= script_tag 'ux/TabCloseMenu.js' %> <%= script_tag 'ux/StatusBar.js' %> <%= script_tag 'ux/PagingStore.js' %> diff --git a/extensions/admin_ui/media/javascript/ui/common/beef_common.js b/extensions/admin_ui/media/javascript/ui/common/beef_common.js new file mode 100644 index 000000000..1687dc33f --- /dev/null +++ b/extensions/admin_ui/media/javascript/ui/common/beef_common.js @@ -0,0 +1,44 @@ +// +// Copyright (c) 2006-2013 Wade Alcorn - wade@bindshell.net +// Browser Exploitation Framework (BeEF) - http://beefproject.com +// See the file 'doc/COPYING' for copying permission +// + +/*! + * BeEF Web UI commons + */ + +if(typeof beefwui === 'undefined' && typeof window.beefwui === 'undefined') { + + var BeefWUI = { + + rest_token: "", + + /** + * Retrieve the token needed to call the RESTful API. + * This is obviously a post-auth call. + */ + get_rest_token: function() { + if(this.rest_token.length == 0){ + var url = "/ui/modules/getRestfulApiToken.json"; + jQuery.ajax({ + contentType: 'application/json', + dataType: 'json', + type: 'GET', + url: url, + async: false, + processData: false, + success: function(data){ + beefwui.rest_token = data.token; + }, + error: function(){ + beefwui.rest_token = ""; + } + }); + } + return this.rest_token; + } + }; + + window.beefwui = BeefWUI; +}