Skip to content

Commit 74c00cf

Browse files
committed
WIP: Enable HTTPS client.
Removed RemoteServiceEndpoint and using URI instead.
1 parent 76143bd commit 74c00cf

File tree

5 files changed

+15
-35
lines changed

5 files changed

+15
-35
lines changed

lib/metasploit/framework/data_service/proxy/core.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def run_remote_db_process(opts)
199199
@pid = wait_t[0].pid
200200
puts "Started process with pid #{@pid}"
201201

202-
endpoint = Metasploit::Framework::DataService::RemoteServiceEndpoint.new('localhost', 8080)
202+
endpoint = URI.parse('http://localhost:8080')
203203
remote_host_data_service = Metasploit::Framework::DataService::RemoteHTTPDataService.new(endpoint)
204204
register_data_service(remote_host_data_service, true)
205205
end

lib/metasploit/framework/data_service/remote/http/core.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ class RemoteHTTPDataService
2020
POST_REQUEST = 'POST'
2121

2222
#
23-
# @param endpoint - A RemoteServiceEndpoint. Cannot be nil
23+
# @param [String] endpoint A valid http or https URL. Cannot be nil
2424
#
2525
def initialize(endpoint)
2626
validate_endpoint(endpoint)
27-
@endpoint = endpoint
27+
@endpoint = URI.parse(endpoint)
2828
build_client_pool(5)
2929
end
3030

@@ -175,7 +175,6 @@ def initialize(response)
175175

176176
def validate_endpoint(endpoint)
177177
raise 'Endpoint cannot be nil' if endpoint.nil?
178-
raise "Endpoint: #{endpoint.class} not of type RemoteServiceEndpoint" unless endpoint.is_a?(RemoteServiceEndpoint)
179178
end
180179

181180
def append_workspace(data_hash)
@@ -224,7 +223,10 @@ def build_client_pool(size)
224223
@client_pool = Queue.new()
225224
(1..size).each {
226225
http = Net::HTTP.new(@endpoint.host, @endpoint.port)
227-
http.use_ssl = true if @endpoint.use_ssl
226+
if @endpoint.is_a?(URI::HTTPS)
227+
http.use_ssl = true
228+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
229+
end
228230
@client_pool << http
229231
}
230232
end

lib/metasploit/framework/data_service/remote/http/remote_service_endpoint.rb

Lines changed: 0 additions & 26 deletions
This file was deleted.

lib/metasploit/framework/data_service/remote/msf_red/msf_red_service.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def load_job_handlers
4242
end
4343

4444
def inject_data_service
45-
remote_service_endpoint = Metasploit::Framework::DataService::RemoteServiceEndpoint.new(CONSOLE_SERVICE_HOST_NAME, CONSOLE_SERVICE_PORT)
46-
remote_data_service = Metasploit::Framework::DataService::RemoteHTTPDataService.new(remote_service_endpoint)
45+
endpoint = URI.parse("http://#{CONSOLE_SERVICE_HOST_NAME}:#{CONSOLE_SERVICE_PORT}")
46+
remote_data_service = Metasploit::Framework::DataService::RemoteHTTPDataService.new(endpoint)
4747
remote_data_service.set_header(SESSION_KEY_VALUE, @session_key)
4848
data_service_manager = Metasploit::Framework::DataService::DataProxy.instance
4949
data_service_manager.register_data_service(remote_data_service)

lib/msf/ui/console/command_dispatcher/db.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,21 @@ def cmd_list_data_services()
100100
end
101101

102102
def cmd_add_data_service(*args)
103+
protocol = "http"
103104
while (arg = args.shift)
104105
case arg
105106
when '-h'
106107
host = args.shift
107108
when '-p'
108109
port = args.shift
110+
when '-s'
111+
protocol = "https"
112+
args.shift
109113
end
110114
end
111115

112-
remote_service_endpoint = Metasploit::Framework::DataService::RemoteServiceEndpoint.new(host, port)
113-
remote_data_service = Metasploit::Framework::DataService::RemoteHTTPDataService.new(remote_service_endpoint)
116+
endpoint = "#{protocol}://#{host}:#{port}"
117+
remote_data_service = Metasploit::Framework::DataService::RemoteHTTPDataService.new(endpoint)
114118
data_service_manager = Metasploit::Framework::DataService::DataProxy.instance
115119
data_service_manager.register_data_service(remote_data_service)
116120
end

0 commit comments

Comments
 (0)