Move option http.web_ui_basepath to extension.admin_ui.base_path

This commit is contained in:
Brendan Coles
2019-02-17 04:54:26 +00:00
parent 6911842e67
commit 9c9119f9cd
8 changed files with 36 additions and 23 deletions

View File

@@ -54,9 +54,6 @@ beef:
#public: "" # public hostname/IP address #public: "" # public hostname/IP address
#public_port: "" # public port (experimental) #public_port: "" # public port (experimental)
# Web Admin user interface URI
web_ui_basepath: "/ui"
# Hook # Hook
hook_file: "/hook.js" hook_file: "/hook.js"
hook_session_name: "BEEFHOOK" hook_session_name: "BEEFHOOK"
@@ -155,6 +152,7 @@ beef:
extension: extension:
admin_ui: admin_ui:
enable: true enable: true
base_path: "/ui"
demos: demos:
enable: true enable: true
events: events:

View File

@@ -80,14 +80,14 @@ module Banners
proto = configuration.get("beef.http.https.enable") == true ? 'https' : 'http' proto = configuration.get("beef.http.https.enable") == true ? 'https' : 'http'
hook_file = configuration.get("beef.http.hook_file") hook_file = configuration.get("beef.http.hook_file")
admin_ui = configuration.get("beef.extension.admin_ui.enable") ? true : false admin_ui = configuration.get("beef.extension.admin_ui.enable") ? true : false
web_ui_basepath = configuration.get("beef.http.web_ui_basepath") admin_ui_path = configuration.get("beef.extension.admin_ui.base_path")
# display the hook URL and Admin UI URL on each interface from the interfaces array # display the hook URL and Admin UI URL on each interface from the interfaces array
self.interfaces.map do |host| self.interfaces.map do |host|
print_info "running on network interface: #{host}" print_info "running on network interface: #{host}"
port = configuration.get("beef.http.port") port = configuration.get("beef.http.port")
data = "Hook URL: #{proto}://#{host}:#{port}#{hook_file}\n" data = "Hook URL: #{proto}://#{host}:#{port}#{hook_file}\n"
data += "UI URL: #{proto}://#{host}:#{port}#{web_ui_basepath}/panel\n" if admin_ui data += "UI URL: #{proto}://#{host}:#{port}#{admin_ui_path}/panel\n" if admin_ui
print_more data print_more data
end end
@@ -97,7 +97,7 @@ module Banners
port = configuration.get("beef.http.public_port") || configuration.get('beef.http.port') port = configuration.get("beef.http.public_port") || configuration.get('beef.http.port')
print_info 'Public:' print_info 'Public:'
data = "Hook URL: #{proto}://#{host}:#{port}#{hook_file}\n" data = "Hook URL: #{proto}://#{host}:#{port}#{hook_file}\n"
data += "UI URL: #{proto}://#{host}:#{port}#{web_ui_basepath}/panel\n" if admin_ui data += "UI URL: #{proto}://#{host}:#{port}#{admin_ui_path}/panel\n" if admin_ui
print_more data print_more data
end end
end end

View File

@@ -130,7 +130,7 @@ module BeEF
# @note Default root page # @note Default root page
get "/" do get "/" do
if config.get("beef.http.web_server_imitation.enable") if config.get("beef.http.web_server_imitation.enable")
bp = config.get "beef.http.web_ui_basepath" bp = config.get "beef.extension.admin_ui.base_path"
type = config.get("beef.http.web_server_imitation.type") type = config.get("beef.http.web_server_imitation.type")
case type case type
when "apache" when "apache"

View File

@@ -152,6 +152,10 @@ module BeEF
print_warning 'Warning: Default SSL cert/key in use.' print_warning 'Warning: Default SSL cert/key in use.'
print_more 'Use the generate-certificate utility to generate a new certificate.' print_more 'Use the generate-certificate utility to generate a new certificate.'
end end
rescue => e
print_error "Failed to prepare HTTP server: #{e.message}"
puts e.backtrace
exit 1
end end
# #

View File

@@ -51,7 +51,7 @@ module API
end end
config = BeEF::Core::Configuration.instance config = BeEF::Core::Configuration.instance
bp = config.get "beef.http.web_ui_basepath" bp = config.get "beef.extension.admin_ui.base_path"
# if more dynamic variables are needed in JavaScript files # if more dynamic variables are needed in JavaScript files
# add them here in the following Hash # add them here in the following Hash
@@ -75,7 +75,7 @@ module API
config = BeEF::Core::Configuration.instance config = BeEF::Core::Configuration.instance
# Web UI base path, like http://beef_domain/<bp>/panel # Web UI base path, like http://beef_domain/<bp>/panel
bp = config.get "beef.http.web_ui_basepath" bp = config.get "beef.extension.admin_ui.base_path"
# registers the http controllers used by BeEF core (authentication, logs, modules and panel) # registers the http controllers used by BeEF core (authentication, logs, modules and panel)
Dir["#{$root_dir}/extensions/admin_ui/controllers/**/*.rb"].each do |http_module| Dir["#{$root_dir}/extensions/admin_ui/controllers/**/*.rb"].each do |http_module|

View File

@@ -24,6 +24,10 @@ module AdminUI
def initialize(data = {}) def initialize(data = {})
@erubis = nil @erubis = nil
@status = 200 if data['status'].nil? @status = 200 if data['status'].nil?
@session = BeEF::Extension::AdminUI::Session.instance
config = BeEF::Core::Configuration.instance
@bp = config.get "beef.extension.admin_ui.base_path"
@headers = {'Content-Type' => 'text/html; charset=UTF-8'} if data['headers'].nil? @headers = {'Content-Type' => 'text/html; charset=UTF-8'} if data['headers'].nil?
@@ -40,11 +44,8 @@ module AdminUI
def run(request, response) def run(request, response)
@request = request @request = request
@params = request.params @params = request.params
@session = BeEF::Extension::AdminUI::Session.instance
config = BeEF::Core::Configuration.instance
# Web UI base path, like http://beef_domain/<bp>/panel # Web UI base path, like http://beef_domain/<bp>/panel
@bp = config.get "beef.http.web_ui_basepath"
auth_url = "#{@bp}/authentication" auth_url = "#{@bp}/authentication"
# test if session is unauth'd and whether the auth functionality is requested # test if session is unauth'd and whether the auth functionality is requested
@@ -77,7 +78,6 @@ module AdminUI
# set content type # set content type
if @headers['Content-Type'].nil? if @headers['Content-Type'].nil?
@headers['Content-Type']='text/html; charset=UTF-8' # default content and charset type for all pages @headers['Content-Type']='text/html; charset=UTF-8' # default content and charset type for all pages
@headers['Content-Type']='application/json; charset=UTF-8' if request.path =~ /\.json$/
end end
rescue => e rescue => e
print_error "Error handling HTTP request: #{e.message}" print_error "Error handling HTTP request: #{e.message}"
@@ -85,22 +85,27 @@ module AdminUI
end end
# Constructs a html script tag (from media/javascript directory) # Constructs a html script tag (from media/javascript directory)
def script_tag(filename) "<script src=\"#{$url}#{@bp}/media/javascript/#{filename}\" type=\"text/javascript\"></script>" end def script_tag(filename)
"<script src=\"#{$url}#{@bp}/media/javascript/#{filename}\" type=\"text/javascript\"></script>"
end
# Constructs a html script tag (from media/javascript-min directory) # Constructs a html script tag (from media/javascript-min directory)
def script_tag_min(filename) "<script src=\"#{$url}#{@bp}/media/javascript-min/#{filename}\" type=\"text/javascript\"></script>" end def script_tag_min(filename)
"<script src=\"#{$url}#{@bp}/media/javascript-min/#{filename}\" type=\"text/javascript\"></script>"
end
# Constructs a html stylesheet tag # Constructs a html stylesheet tag
def stylesheet_tag(filename) "<link rel=\"stylesheet\" href=\"#{$url}#{@bp}/media/css/#{filename}\" type=\"text/css\" />" end def stylesheet_tag(filename)
"<link rel=\"stylesheet\" href=\"#{$url}#{@bp}/media/css/#{filename}\" type=\"text/css\" />"
end
# Constructs a hidden html nonce tag # Constructs a hidden html nonce tag
def nonce_tag def nonce_tag
@session = BeEF::Extension::AdminUI::Session.instance "<input type=\"hidden\" name=\"nonce\" id=\"nonce\" value=\"#{@session.get_nonce}\"/>"
"<input type=\"hidden\" name=\"nonce\" id=\"nonce\" value=\"" + @session.get_nonce + "\"/>"
end end
def base_path def base_path
"#{@bp}" @bp.to_s
end end
private private
@@ -108,10 +113,10 @@ module AdminUI
@eruby @eruby
# Unescapes a URL-encoded string. # Unescapes a URL-encoded string.
def unescape(s); s.tr('+', ' ').gsub(/%([\da-f]{2})/in){[$1].pack('H*')} end def unescape(s)
s.tr('+', ' ').gsub(/%([\da-f]{2})/in){[$1].pack('H*')}
end
end end
end end
end end
end end

View File

@@ -8,8 +8,14 @@ beef:
admin_ui: admin_ui:
name: 'Admin UI' name: 'Admin UI'
enable: false enable: false
# Admin UI base path
base_path: "/ui"
# Favicon
favicon_file_name: "favicon.ico" favicon_file_name: "favicon.ico"
favicon_dir: "/images" favicon_dir: "/images"
login_fail_delay: 1 login_fail_delay: 1
play_sound_on_new_zombie: false play_sound_on_new_zombie: false

View File

@@ -16,7 +16,7 @@
<body> <body>
<div style='font:12px tahoma,arial,helvetica,sans-serif; width: 450px; margin: 0 auto;' > <div style='font:12px tahoma,arial,helvetica,sans-serif; width: 450px; margin: 0 auto;' >
<img src='<%= BeEF::Core::Configuration.instance.get("beef.http.web_ui_basepath") %>/media/images/beef.jpg' /> <img src='beef.jpg' />
<p>You should be hooked into <b>BeEF</b>.</p> <p>You should be hooked into <b>BeEF</b>.</p>
<p>Have fun while your browser is working against you.</p> <p>Have fun while your browser is working against you.</p>