Conform to JSONRPC 2.0 spec in external modules

Responses to queries had a `response` field instead of the required
`result` field.
GSoC/Meterpreter_Web_Console
Adam Cammack 2018-04-12 16:55:27 -05:00
parent 2a6acfd1d0
commit e65de2b56f
No known key found for this signature in database
GPG Key ID: C9378BA088092D66
3 changed files with 6 additions and 6 deletions

View File

@ -14,9 +14,9 @@ class Msf::Modules::External::Message
m = self.new(j['method'].to_sym)
m.params = j['params']
m
elsif j['response']
elsif j['result']
m = self.new(:reply)
m.params = j['response']
m.params = j['result']
m.id = j['id']
m
end

View File

@ -66,11 +66,11 @@ def report_vuln(ip, name, **opts):
def run(metadata, module_callback):
req = json.loads(os.read(0, 10000).decode("utf-8"))
if req['method'] == 'describe':
rpc_send({'jsonrpc': '2.0', 'id': req['id'], 'response': metadata})
rpc_send({'jsonrpc': '2.0', 'id': req['id'], 'result': metadata})
elif req['method'] == 'run':
args = req['params']
module_callback(args)
rpc_send({'jsonrpc': '2.0', 'id': req['id'], 'response': {
rpc_send({'jsonrpc': '2.0', 'id': req['id'], 'result': {
'message': 'Module completed'
}})

View File

@ -30,12 +30,12 @@ module Metasploit
req = JSON.parse($stdin.readpartial(10000), symbolize_names: true)
if req[:method] == 'describe'
rpc_send({
jsonrpc: '2.0', id: req[:id], response: metadata
jsonrpc: '2.0', id: req[:id], result: metadata
})
elsif req[:method] == 'run'
callback.call req[:params]
rpc_send({
jsonrpc: '2.0', id: req[:id], response: {
jsonrpc: '2.0', id: req[:id], result: {
message: 'Module completed'
}
})