Closed sachinly closed 3 years ago
Looks like there's a serialisation error with message pack:
# metasploit-framework/gems/msgpack-1.3.3/lib/msgpack/core_ext.rb:4 MessagePack::CoreExt#to_msgpack:
1: module MessagePack
2: module CoreExt
3: def to_msgpack(packer_or_io = nil)
4: if packer_or_io
5: if packer_or_io.is_a?(MessagePack::Packer)
6: to_msgpack_with_packer packer_or_io
7: else
8: MessagePack.pack(self, packer_or_io)
9: end
10: else
=> 11: MessagePack.pack(self)
12: end
13: end
14: end
15: end
The rpc service is throwing the following error behind the scenes:
> MessagePack.pack(self)
NoMethodError: undefined method `to_msgpack' for /.*/:Regexp
from /Users/adfoster/.rvm/gems/ruby-2.6.6@metasploit-framework/gems/msgpack-1.3.3/lib/msgpack.rb:46:in `write'
I believe it's the module option that the saltstack module uses, which contains a regex object:
"MINIONS"=> {
"type"=>"regexp",
"required"=>true,
"advanced"=>false,
"desc"=>"PCRE regex of minions to target",
"default"=> /.*/
}
Interestingly JSON.pretty_generate(self)
serializes regex as:
"MINIONS": {
"type": "regexp",
"required": true,
"advanced": false,
"desc": "PCRE regex of minions to target",
"default": "(?-mix:.*)"
}
The client doesn't get given the error either. When the service fails, the process
function raises a NoMethodError
- and the current exception handler only catches Msf::RPC::Exception
. Therefore the client gets sent back nil
as a response:
88: def on_request_uri(cli, req)
89: res = Rex::Proto::Http::Response.new()
90: res["Content-Type"] = "binary/message-pack"
91:
92: begin
93: require 'pry'; binding.pry
=> 94: res.body = process(req).to_msgpack
95: rescue Msf::RPC::Exception => e
96: require 'pry'; binding.pry
97: elog('RPC Exception', error: e)
98: res.body = process_exception(e).to_msgpack
99: res.code = e.code
100: end
101: cli.send_response(res)
102: end
[1] pry(#<Msf::RPC::Service>)> process(req).to_msgpack
NoMethodError: undefined method `to_msgpack' for /.*/:Regexp
from /Users/adfoster/.rvm/gems/ruby-2.6.6@metasploit-framework/gems/msgpack-1.3.3/lib/msgpack.rb:46:in `write'
Fixed in #15686
Steps to reproduce
How'd you do it?
msfrpc client get module info, i have some errors.