diff --git a/Gemfile b/Gemfile index 618ef7ca6..3a505922b 100644 --- a/Gemfile +++ b/Gemfile @@ -17,6 +17,7 @@ gem "sinatra", "1.4.2" gem "rack", "1.5.2" gem "em-websocket", "~> 0.3.6" gem "jsmin", "~> 1.0.1" +gem "uglifier", "~> 2.2.1" gem "ansi" gem "term-ansicolor", :require => "term/ansicolor" gem "dm-core" diff --git a/config.yaml b/config.yaml index 490ebe0de..42055a5e2 100644 --- a/config.yaml +++ b/config.yaml @@ -30,7 +30,7 @@ beef: # DNS dns_host: "localhost" dns_port: 53 - panel_path: "/ui/panel" + web_ui_basepath: "/ui" hook_file: "/hook.js" hook_session_name: "BEEFHOOK" session_cookie_name: "BEEFSESSION" diff --git a/core/main/client/browser.js b/core/main/client/browser.js index 05409d10c..b783619a5 100644 --- a/core/main/client/browser.js +++ b/core/main/client/browser.js @@ -1325,11 +1325,11 @@ beef.browser = { */ javaEnabled:function () { //Use of deployJava defined in deployJava.js (Oracle java deployment toolkit) - versionJRE = deployJava.getJREs(); + // versionJRE = deployJava.getJREs(); - if(versionJRE != '') - return true; - else + // if(versionJRE != '') + // return true; + // else return false; }, diff --git a/core/main/console/banners.rb b/core/main/console/banners.rb index 71aea366e..c4e1a620f 100644 --- a/core/main/console/banners.rb +++ b/core/main/console/banners.rb @@ -86,7 +86,7 @@ module Banners print_success "running on network interface: #{host}" beef_host = configuration.get("beef.http.public_port") || configuration.get("beef.http.port") data = "Hook URL: #{prototxt}://#{host}:#{configuration.get("beef.http.port")}#{configuration.get("beef.http.hook_file")}\n" - data += "UI URL: #{prototxt}://#{host}:#{configuration.get("beef.http.port")}#{configuration.get("beef.http.panel_path")}\n" + data += "UI URL: #{prototxt}://#{host}:#{configuration.get("beef.http.port")}#{configuration.get("beef.http.web_ui_basepath")}/panel\n" print_more data end diff --git a/core/main/router/router.rb b/core/main/router/router.rb index c6ca5c6e5..e2502b4da 100644 --- a/core/main/router/router.rb +++ b/core/main/router/router.rb @@ -114,6 +114,7 @@ module BeEF # @note Default root page get "/" do if config.get("beef.http.web_server_imitation.enable") + bp = config.get "beef.http.web_ui_basepath" type = config.get("beef.http.web_server_imitation.type") case type when "apache" @@ -209,7 +210,7 @@ module BeEF "
You may now add content to the directory /var/www/html/. Note that until you do so, people visiting your website will see this page and not your content. To prevent this page from ever being used, follow the instructions in the file /etc/httpd/conf.d/welcome.conf.
" + "You are free to use the images below on Apache and CentOS Linux powered HTTP servers. Thanks for using Apache and CentOS!
" + - "" + + "" + "" + "" + "" + @@ -234,7 +235,7 @@ module BeEF "| " +
- " | " +
"" + "Under Construction" +
diff --git a/extensions/admin_ui/api/handler.rb b/extensions/admin_ui/api/handler.rb
index 12358426f..446a46845 100644
--- a/extensions/admin_ui/api/handler.rb
+++ b/extensions/admin_ui/api/handler.rb
@@ -12,40 +12,90 @@ module API
# We use this module to register all the http handler for the Administrator UI
#
module Handler
-
+ require 'uglifier'
+
BeEF::API::Registrar.instance.register(BeEF::Extension::AdminUI::API::Handler, BeEF::API::Server, 'mount_handler')
-
+
+ def self.evaluate_and_minify(content, params, name)
+ erubis = Erubis::FastEruby.new(content)
+ evaluated = erubis.evaluate(params)
+ minified = Uglifier.compile(evaluated)
+ write_to = File.new("#{File.dirname(__FILE__)}/../media/javascript-min/#{name}.js", "w+")
+ File.open(write_to, 'w') { |file| file.write(minified) }
+
+ File.path write_to
+ end
+
+ def self.build_javascript_ui(beef_server)
+ auth_js_file = File.read(File.dirname(__FILE__)+'/../media/javascript/ui/authentication.js') + "\n\n"
+ js_files = ""
+
+ #NOTE: order counts! make sure you know what you're doing if you add files
+ esapi = %w(esapi/Class.create.js esapi/jquery-1.6.4.min.js esapi/jquery-encoder-0.1.0.js)
+ ux = %w(ui/common/beef_common.js ux/PagingStore.js ux/StatusBar.js ux/TabCloseMenu.js)
+ panel = %w(ui/panel/common.js ui/panel/DistributedEngine.js ui/panel/PanelStatusBar.js ui/panel/tabs/ZombieTabDetails.js ui/panel/tabs/ZombieTabLogs.js ui/panel/tabs/ZombieTabCommands.js ui/panel/tabs/ZombieTabRider.js ui/panel/tabs/ZombieTabXssRays.js wterm/wterm.jquery.js ui/panel/tabs/ZombieTabIpec.js ui/panel/tabs/ZombieTabAutorun.js ui/panel/PanelViewer.js ui/panel/DataGrid.js ui/panel/MainPanel.js ui/panel/ZombieTab.js ui/panel/ZombieTabs.js ui/panel/zombiesTreeList.js ui/panel/ZombiesMgr.js ui/panel/Logout.js ui/panel/WelcomeTab.js)
+
+ global_js = esapi + ux + panel
+
+ global_js.each do |file|
+ js_files << File.read(File.dirname(__FILE__)+'/../media/javascript/'+file) + "\n\n"
+ end
+
+ config = BeEF::Core::Configuration.instance
+ bp = config.get "beef.http.web_ui_basepath"
+
+ # if more dynamic variables are needed in JavaScript files
+ # add them here in the following Hash
+ params = {
+ 'base_path' => bp
+ }
+
+ # process all JavaScript files, evaluating them with Erubis
+ web_ui_all = self.evaluate_and_minify(js_files, params, 'web_ui_all')
+ web_ui_auth = self.evaluate_and_minify(auth_js_file, params, 'web_ui_auth')
+
+ beef_server.mount("#{bp}/web_ui_all.js", Rack::File.new(web_ui_all))
+ beef_server.mount("#{bp}/web_ui_auth.js", Rack::File.new(web_ui_auth))
+
+ end
+
#
# This function gets called automatically by the server.
#
def self.mount_handler(beef_server)
- # retrieve the configuration class instance
- configuration = BeEF::Core::Configuration.instance
-
+ config = BeEF::Core::Configuration.instance
+
+ # Web UI base path, like http://beef_domain/ |