Add 'proto' property to Requester HTTP model

This commit is contained in:
Brendan Coles
2015-12-14 12:40:34 +00:00
parent e354ab8045
commit 95abdf6781
3 changed files with 20 additions and 3 deletions

View File

@@ -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,

View File

@@ -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,

View File

@@ -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