Land #9872, Fix JSONRPC fields in external modules

4.x
Adam Cammack 2018-04-13 15:00:26 -05:00 committed by Metasploit
parent 0bb0e78599
commit 8bacddb18f
No known key found for this signature in database
GPG Key ID: CDFB5FA52007B954
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'
}
})