Skip to content

Commit f96f61d

Browse files
author
Brent Cook
committed
enhance module info to be on par with pro RPC interface
1 parent 24d9bec commit f96f61d

File tree

1 file changed

+34
-11
lines changed

1 file changed

+34
-11
lines changed

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

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,23 +101,24 @@ def rpc_info(mtype, mname)
101101
m = _find_module(mtype,mname)
102102
res = {}
103103

104+
res['type'] = m.type
104105
res['name'] = m.name
105-
res['description'] = m.description
106+
res['fullname'] = m.fullname
107+
res['rank'] = m.rank.to_i
108+
res['description'] = Rex::Text.compress(m.description)
106109
res['license'] = m.license
107110
res['filepath'] = m.file_path
108-
res['rank'] = m.rank.to_i
111+
res['arch'] = m.arch.map { |x| x.to_s }
112+
res['platform'] = m.platform.platforms.map { |x| x.to_s }
113+
res['authors'] = m.author.map { |a| a.to_s }
114+
res['privileged'] = m.privileged?
109115

110116
res['references'] = []
111117
m.references.each do |r|
112118
res['references'] << [r.ctx_id, r.ctx_val]
113119
end
114120

115-
res['authors'] = []
116-
m.each_author do |a|
117-
res['authors'] << a.to_s
118-
end
119-
120-
if(m.type == "exploit")
121+
if m.type == 'exploit'
121122
res['targets'] = {}
122123
m.targets.each_index do |i|
123124
res['targets'][i] = m.targets[i].name
@@ -126,18 +127,40 @@ def rpc_info(mtype, mname)
126127
if (m.default_target)
127128
res['default_target'] = m.default_target
128129
end
130+
131+
# Some modules are a combination, which means they are actually aggressive
132+
res['stance'] = m.stance.to_s.index('aggressive') ? 'aggressive' : 'passive'
129133
end
130134

131-
if(m.type == "auxiliary")
135+
if m.type == 'auxiliary' || m.type == 'post'
132136
res['actions'] = {}
133137
m.actions.each_index do |i|
134138
res['actions'][i] = m.actions[i].name
135139
end
136140

137-
if (m.default_action)
141+
if m.default_action
138142
res['default_action'] = m.default_action
139143
end
144+
145+
if m.type == 'auxiliary'
146+
res['stance'] = m.passive? ? 'passive' : 'aggressive'
147+
end
148+
end
149+
150+
opts = {}
151+
m.options.each_key do |k|
152+
o = m.options[k]
153+
opts[k] = {
154+
'type' => o.type,
155+
'required' => o.required,
156+
'advanced' => o.advanced,
157+
'desc' => o.desc
158+
}
159+
160+
opts[k]['default'] = o.default unless o.default.nil?
161+
opts[k]['enums'] = o.enums if o.enums.length > 1
140162
end
163+
res['options'] = opts
141164

142165
res
143166
end
@@ -386,7 +409,7 @@ def rpc_encode(data, encoder, options)
386409

387410
# How to warn?
388411
#if exeopts[:fellback]
389-
# $stderr.puts(OutError + "Warning: Falling back to default template: #{exeopts[:fellback]}")
412+
# $stderr.puts(OutError + "Warning: Falling back to default template: #{exeopts[:fellback]}")
390413
#end
391414

392415
{ "encoded" => output.to_s }

0 commit comments

Comments
 (0)