From a62b77cc1d6df34bfb6df689f81cda848386671a Mon Sep 17 00:00:00 2001 From: bcoles Date: Mon, 7 May 2012 18:26:27 +0930 Subject: [PATCH] Updated introduction of public port settings These settings are experimental --- config.yaml | 2 +- core/main/console/banners.rb | 1 + core/main/handlers/modules/beefjs.rb | 12 +++++++----- modules/debug/test_network_request/module.rb | 2 +- modules/phonegap/phonegap_persistence/module.rb | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/config.yaml b/config.yaml index 30b5e3a40..d14c27e09 100644 --- a/config.yaml +++ b/config.yaml @@ -32,7 +32,7 @@ beef: port: "3000" # if running behind a nat set the public ip address here #public: "" - #public_port: "" + #public_port: "" # port setting is experimental dns: "localhost" panel_path: "/ui/panel" hook_file: "/hook.js" diff --git a/core/main/console/banners.rb b/core/main/console/banners.rb index 40d52b825..3621d20e9 100644 --- a/core/main/console/banners.rb +++ b/core/main/console/banners.rb @@ -92,6 +92,7 @@ module Banners self.interfaces.map do |host| # display the important URLs on each interface from the interfaces array print_success "running on network interface: #{host}" + beef_host = configuration.get("beef.http.public_port") || configuration.get("beef.http.port") data = "Hook URL: http://#{host}:#{configuration.get("beef.http.port")}#{configuration.get("beef.http.hook_file")}\n" data += "UI URL: http://#{host}:#{configuration.get("beef.http.port")}#{configuration.get("beef.http.panel_path")}\n" diff --git a/core/main/handlers/modules/beefjs.rb b/core/main/handlers/modules/beefjs.rb index 0d9572a99..f5078bf98 100644 --- a/core/main/handlers/modules/beefjs.rb +++ b/core/main/handlers/modules/beefjs.rb @@ -49,11 +49,13 @@ module Modules end # @note if http_port <> public_port in config ini, use the public_port - if hook_session_config['beef_port'] != hook_session_config['beef_public_port'] - hook_session_config['beef_port'] = hook_session_config['beef_public_port'] - hook_session_config['beef_url'].sub!(/#{hook_session_config['beef_port']}/, hook_session_config['beef_public_port']) - if hook_session_config['beef_public_port'] == '443' - hook_session_config['beef_url'].sub!(/http:/, 'https:') + unless hook_session_config['beef_public_port'].nil? + if hook_session_config['beef_port'] != hook_session_config['beef_public_port'] + hook_session_config['beef_port'] = hook_session_config['beef_public_port'] + hook_session_config['beef_url'].sub!(/#{hook_session_config['beef_port']}/, hook_session_config['beef_public_port']) + if hook_session_config['beef_public_port'] == '443' + hook_session_config['beef_url'].sub!(/http:/, 'https:') + end end end diff --git a/modules/debug/test_network_request/module.rb b/modules/debug/test_network_request/module.rb index e649dbdaa..e4de490dd 100644 --- a/modules/debug/test_network_request/module.rb +++ b/modules/debug/test_network_request/module.rb @@ -24,7 +24,7 @@ class Test_network_request < BeEF::Core::Command def self.options @configuration = BeEF::Core::Configuration.instance beef_host = @configuration.get("beef.http.public") || @configuration.get("beef.http.host") - beef_port = @configuration.get("beef.http.port") + beef_port = @configuration.get("beef.http.public_port") || @configuration.get("beef.http.port") return [ {'name' => 'scheme', 'ui_label'=>'Scheme', 'type' => 'text', 'width' => '400px', 'value' => 'http' }, diff --git a/modules/phonegap/phonegap_persistence/module.rb b/modules/phonegap/phonegap_persistence/module.rb index 909014fe2..30face23d 100644 --- a/modules/phonegap/phonegap_persistence/module.rb +++ b/modules/phonegap/phonegap_persistence/module.rb @@ -22,7 +22,7 @@ class Phonegap_persistence < BeEF::Core::Command @configuration = BeEF::Core::Configuration.instance beef_host = @configuration.get("beef.http.public") || @configuration.get("beef.http.host") - beef_port = @configuration.get("beef.http.port") + beef_port = @configuration.get("beef.http.public_port") || @configuration.get("beef.http.port") return [{ 'name' => 'hook_url',