diff --git a/extensions/requester/api/hook.rb b/extensions/requester/api/hook.rb index c6ef2f38f..a4e497fc0 100644 --- a/extensions/requester/api/hook.rb +++ b/extensions/requester/api/hook.rb @@ -66,6 +66,7 @@ module BeEF allow_cross_domain = http_db_object.allow_cross_domain.to_s req_parts = http_db_object.request.split(/ |\n/) verb = req_parts[0] + proto = http_db_object.proto uri = req_parts[1] headers = {} @@ -102,11 +103,14 @@ module BeEF end end + # set default port if nil if @port.nil? - if uri.match(/^https:/) - @port = 443 + if uri.to_s =~ /^https?/ + # absolute + (uri.match(/^https:/)) ? @port = 443 : @port = 80 else - @port = 80 + # relative + (proto == 'https') ? @port = 443 : @port = 80 end end @@ -117,6 +121,7 @@ module BeEF http_request_object = { 'id' => http_db_object.id, 'method' => verb, + 'proto' => proto, 'host' => @host, 'port' => @port, 'data' => @post_data, @@ -129,6 +134,7 @@ module BeEF http_request_object = { 'id' => http_db_object.id, 'method' => verb, + 'proto' => proto, 'host' => @host, 'port' => @port, 'uri' => uri, diff --git a/extensions/requester/controllers/requester.rb b/extensions/requester/controllers/requester.rb index 44ea44d74..dfbe6f3b0 100644 --- a/extensions/requester/controllers/requester.rb +++ b/extensions/requester/controllers/requester.rb @@ -75,10 +75,16 @@ class Requester < BeEF::Extension::AdminUI::HttpController (self.err_msg 'Invalid HTTP HostPort';return @body = '{success : false}') if not BeEF::Filters.nums_only?(hostport) #check the target hostport end + proto = @params['proto'] || 'http' + if proto !~ /\Ahttps?\z/ + (self.err_msg 'Invalid request protocol';return @body = '{success : false}') + end + # Saves the new HTTP request. http = H.new( :request => raw_request, :method => verb, + :proto => proto, :domain => hostname, :port => hostport, :path => uri, @@ -119,6 +125,7 @@ class Requester < BeEF::Extension::AdminUI::HttpController H.all(:hooked_browser_id => zombie.id).each{|http| history << { 'id' => http.id, + 'proto' => http.proto, 'domain' => http.domain, 'port' => http.port, 'path' => http.path, @@ -162,6 +169,7 @@ class Requester < BeEF::Extension::AdminUI::HttpController 'request' => http_db.request, 'response' => response_data, 'response_headers' => http_db.response_headers, + 'proto' => http_db.proto, 'domain' => http_db.domain, 'port' => http_db.port, 'path' => http_db.path, diff --git a/extensions/requester/models/http.rb b/extensions/requester/models/http.rb index 4c6854c3e..9977b0b59 100644 --- a/extensions/requester/models/http.rb +++ b/extensions/requester/models/http.rb @@ -47,6 +47,9 @@ module Models # The content length for the request. property :content_length, Text, :lazy => false, :default => 0 + # The request protocol/scheme (http/https) + property :proto, Text, :lazy => false + # The domain on which perform the request. property :domain, Text, :lazy => false