diff --git a/lib/filter/init.rb b/lib/filter/init.rb index 4b78a0d0c..6da983632 100644 --- a/lib/filter/init.rb +++ b/lib/filter/init.rb @@ -35,6 +35,18 @@ module BeEF true end + # verify the hostname string is valid + def self.is_valid_hostname?(str) + return false if not BeEF::Filter.is_non_empty_string?(str) + return false if BeEF::Filter.has_non_printable_char?(str) + return false if str.length > 255 + return false if (str =~ /^[a-zA-Z0-9][a-zA-Z0-9\-\.]*[a-zA-Z0-9]$/).nil? + return false if not (str =~ /\.\./).nil? + return false if not (str =~ /\-\-/).nil? + + true + end + end end diff --git a/lib/server/inithandler.rb b/lib/server/inithandler.rb index cfe34a144..1276e372f 100644 --- a/lib/server/inithandler.rb +++ b/lib/server/inithandler.rb @@ -50,6 +50,11 @@ module BeEF raise WEBrick::HTTPStatus::BadRequest, "Invalid page title name" if not Filter.is_valid_pagetitle?(page_title) BD.set(session_id, 'PageTitle', page_title) + # get and store page title + host_name = get_param(request.query, 'HostName') + raise WEBrick::HTTPStatus::BadRequest, "Invalid host name" if not Filter.is_valid_hostname?(host_name) + BD.set(session_id, 'HostName', host_name) + # init details have been returned so set flag and save hooked_browser.has_init = true @guard.synchronize { diff --git a/lib/server/zombiehandler.rb b/lib/server/zombiehandler.rb index 2be31681d..16751fc37 100644 --- a/lib/server/zombiehandler.rb +++ b/lib/server/zombiehandler.rb @@ -48,7 +48,6 @@ module BeEF # create the structure repesenting the hooked browser zombie = BeEF::Models::Zombie.new(:ip => request.peeraddr[3], :session => hook_session_value) - zombie.domain = request.get_referer_domain zombie.firstseen = Time.new.to_i zombie.has_init = false # set to true (in inithandler.rb) when the init values returned zombie.httpheaders = request.header.to_json diff --git a/lib/ui/modules/modules.rb b/lib/ui/modules/modules.rb index 861200cb9..de00f00c8 100644 --- a/lib/ui/modules/modules.rb +++ b/lib/ui/modules/modules.rb @@ -41,10 +41,10 @@ class Modules < BeEF::HttpController 'results' => [] } - # set and add the return values for the page name + # set and add the return values for the page title page_title = BD.get(zombie_session, 'PageTitle') - encoded_page_name = CGI.escapeHTML(page_title) - encoded_page_hash = { 'Page Title' => encoded_page_name } + encoded_page_title = CGI.escapeHTML(page_title) + encoded_page_hash = { 'Page Title' => encoded_page_title } page_name_row = { 'category' => 'Browser Hook Initialisation', @@ -54,6 +54,19 @@ class Modules < BeEF::HttpController summary_grid_hash['results'].push(page_name_row) # add the row + # set and add the return values for the host name + host_name = BD.get(zombie_session, 'HostName') + encoded_host_name = CGI.escapeHTML(host_name) + encoded_host_name_hash = { 'Host Name' => encoded_host_name } + + page_name_row = { + 'category' => 'Browser Hook Initialisation', + 'data' => encoded_host_name_hash, + 'from' => 'Initialisation' + } + + summary_grid_hash['results'].push(page_name_row) # add the row + # set and add the return values for the browser name browser_name = BD.get(zombie_session, 'BrowserName') friendly_browser_name = BeEF::Constants::Browsers.friendly_name(browser_name) diff --git a/lib/ui/zombies/zombies.rb b/lib/ui/zombies/zombies.rb index 4aa0cdfe6..09b0fb5a1 100644 --- a/lib/ui/zombies/zombies.rb +++ b/lib/ui/zombies/zombies.rb @@ -73,11 +73,12 @@ class Zombies < BeEF::HttpController browser_icon = BeEF::Models::BrowserDetails.browser_icon(hooked_browser.session) os_icon = BeEF::Models::BrowserDetails.os_icon(hooked_browser.session) + domain = BeEF::Models::BrowserDetails.get(hooked_browser.session, 'HostName') return { 'session' => hooked_browser.session, 'ip' => hooked_browser.ip, - 'domain' => hooked_browser.domain, + 'domain' => domain, 'browser_icon' => browser_icon, 'os_icon' => os_icon } @@ -89,7 +90,8 @@ class Zombies < BeEF::HttpController hooked_browser_hash = get_simple_hooked_browser_hash(zombie) return hooked_browser_hash.merge( { - 'lastseen' => zombie.lastseen + 'lastseen' => zombie.lastseen, + 'httpheaders' => JSON.parse(zombie.httpheaders) }) end