Skip to content

Commit ffcec52

Browse files
committed
Successfully storing creds remotely
1 parent 5232e99 commit ffcec52

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ module CredentialDataProxy
33
def create_credential(opts)
44
begin
55
data_service = self.get_data_service()
6-
if !data_service.is_a?(Msf::DBManager)
7-
opts[:data] = Base64.urlsafe_encode64(opts[:data]) if opts[:data]
8-
end
96
data_service.create_credential(opts)
107
rescue Exception => e
118
puts "Call to #{data_service.class}#create_credential threw exception: #{e.message}"

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,24 @@ module RemoteSessionDataService
33
SESSION_API_PATH = '/api/1/msf/session'
44

55
def report_session(opts)
6-
if (opts[:session].kind_of? Msf::Session)
7-
opts = convert_msf_session_to_hash(opts[:session])
6+
session = opts[:session]
7+
if (session.kind_of? Msf::Session)
8+
opts = convert_msf_session_to_hash(session)
89
opts[:session_dto] = true
910
elsif (opts[:host])
1011
opts[:host] = opts[:host].address
1112
end
1213

1314
#TODO: Fix
1415
opts[:time_stamp] = Time.now.utc
15-
self.post_data_async(SESSION_API_PATH, opts)
16+
sess_db = json_to_open_struct_object(self.post_data(SESSION_API_PATH, opts))
17+
session.db_record = sess_db
1618
end
1719

20+
# def get_session(opts = {})
21+
# json_to_open_struct_object(self.get_data(SESSION_API_PATH, opts), [])
22+
# end
23+
1824
#######
1925
private
2026
#######

lib/msf/core/db_manager/http/job_processor.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def start_processor_thread()
2222
wrapper.job.call(wrapper.job_args)
2323
rescue Exception => e
2424
puts "Error executing job #{e.message}"
25+
e.backtrace.each { |line| puts "#{line}\n"}
2526
end
2627
end
2728
}

lib/msf/core/db_manager/http/servlet/credential_servlet.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ def self.get_credentials
3535

3636
def self.create_credential
3737
lambda {
38-
job = lambda { |opts| get_db().report_cred(opts) }
38+
job = lambda { |opts|
39+
opts[:origin_type] = opts[:origin_type].to_sym
40+
opts[:private_type] = opts[:private_type].to_sym
41+
get_db().create_credential(opts)
42+
}
3943
exec_report_job(request, &job)
4044
}
4145
end

lib/msf/core/db_manager/session.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ def report_session_dto(session_dto)
156156
# This is a live session, we know the host is vulnerable to something.
157157
infer_vuln_from_session_dto(session_dto, session_db_record, workspace)
158158
end
159+
session_db_record
159160
}
160161
end
161162

0 commit comments

Comments
 (0)