Skip to content

Commit e29b2ae

Browse files
David MaloneyDavid Maloney
authored andcommitted
add credential rpc calls
1 parent 1e32574 commit e29b2ae

File tree

1 file changed

+45
-2
lines changed

1 file changed

+45
-2
lines changed

lib/msf/core/rpc/v10/rpc_db.rb

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@ def find_workspace(wspace = nil)
1818
self.framework.db.workspace
1919
end
2020

21+
def fix_cred_options(opts)
22+
new_opts = fix_options(opts)
23+
24+
# Convert some of are data back to symbols
25+
if new_opts[:origin_type]
26+
new_opts[:origin_type] = new_opts[:origin_type].to_sym
27+
end
28+
29+
if new_opts[:private_type]
30+
new_opts[:private_type] = new_opts[:private_type].to_sym
31+
end
32+
33+
new_opts
34+
end
35+
2136
def fix_options(opts)
2237
newopts = {}
2338
opts.each do |k,v|
@@ -91,11 +106,39 @@ def init_db_opts_workspace(xopts)
91106

92107
public
93108

94-
def rpc_create_credential(xopts)
95-
create_credential(xopts)
109+
def rpc_create_cracked_credential(xopts)
110+
opts = fix_cred_options(xopts)
111+
create_credential(opts)
96112
end
97113

114+
def rpc_create_credential(xopts)
115+
opts = fix_cred_options(xopts)
116+
core = create_credential(opts)
117+
118+
ret = {
119+
username: core.public.try(:username),
120+
private: core.private.try(:data),
121+
private_type: core.private.try(:type),
122+
realm_value: core.realm.try(:value),
123+
realm_key: core.realm.try(:key)
124+
}
125+
126+
if opts[:last_attempted_at] && opts[:status]
127+
opts[:core] = core
128+
opts[:last_attempted_at] = opts[:last_attempted_at].to_datetime
129+
login = create_credential_login(opts)
130+
131+
ret[:host] = login.service.host.address,
132+
ret[:sname] = login.service.name
133+
ret[:status] = login.status
134+
end
135+
ret
136+
end
98137

138+
def rpc_invalidate_login(xopts)
139+
opts = fix_cred_options(xopts)
140+
invalidate_login(opts)
141+
end
99142

100143
def rpc_hosts(xopts)
101144
::ActiveRecord::Base.connection_pool.with_connection {

0 commit comments

Comments
 (0)