From 874bc14278f0ca17a679ea6836bd6304b72f83cb Mon Sep 17 00:00:00 2001 From: antisnatchor Date: Mon, 28 May 2012 13:44:05 +0100 Subject: [PATCH] Close issues #541 and #684. Added 2 command line options to ovveride default port and websocket server port --- beef | 11 ++++++++++- core/main/console/commandline.rb | 11 +++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/beef b/beef index b99cc5672..6302be317 100755 --- a/beef +++ b/beef @@ -59,6 +59,15 @@ if BeEF::Core::Console::CommandLine.parse[:ascii_art] == true BeEF::Core::Console::Banners.print_ascii_art end +# @note Check if port and WebSocket port need to be updated from command line parameters +unless BeEF::Core::Console::CommandLine.parse[:port].empty? + config.set('beef.http.port', BeEF::Core::Console::CommandLine.parse[:port]) +end + +unless BeEF::Core::Console::CommandLine.parse[:ws_port].empty? + config.set('beef.http.websocket.port', BeEF::Core::Console::CommandLine.parse[:ws_port]) +end + # @note Prints BeEF welcome message BeEF::Core::Console::Banners.print_welcome_msg @@ -115,7 +124,7 @@ print_info "RESTful API key: #{BeEF::Core::Crypto::api_token}" #@note Starts the WebSocket server if config.get("beef.http.websocket.enable") BeEF::Core::Websocket::Websocket.instance - print_info "Starting WebSocket server on port [#{config.get("beef.http.websocket.port")}], secure [#{config.get("beef.http.websocket.secure")}], timer [#{config.get("beef.http.websocket.alive_timer")}]" + print_info "Starting WebSocket server on port [#{config.get("beef.http.websocket.port").to_i}], secure [#{config.get("beef.http.websocket.secure")}], timer [#{config.get("beef.http.websocket.alive_timer")}]" end diff --git a/core/main/console/commandline.rb b/core/main/console/commandline.rb index 340e79135..1ad2fa025 100644 --- a/core/main/console/commandline.rb +++ b/core/main/console/commandline.rb @@ -26,6 +26,9 @@ module BeEF @options[:resetdb] = false @options[:ascii_art] = false @options[:ext_config] = "" + @options[:port] = "" + @options[:ws_port] = "" + @already_parsed = false @@ -53,6 +56,14 @@ module BeEF opts.on('-c', '--config FILE', 'Load a different configuration file: if it\'s called custom-config.yaml, git automatically ignores it.') do |f| @options[:ext_config] = f end + + opts.on('-p', '--port PORT', 'Change the default BeEF listening port') do |p| + @options[:port] = p + end + + opts.on('-w', '--wsport WS_PORT', 'Change the default BeEF WebSocket listening port') do |ws_port| + @options[:ws_port] = ws_port + end end optparse.parse!