Skip to content

Commit 1eb3c32

Browse files
author
Tod Beardsley
committed
Land rapid7#2175, force string encoding for RPC
Metasploit takes great pains to ensure that all strings are encoded as plain old US-ASCII. This PR enforces this conversion over RPC as well. [FixRM rapid7#7888]
2 parents e50ef20 + 7937fbc commit 1eb3c32

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Service
2323

2424
attr_accessor :service, :srvhost, :srvport, :uri, :options
2525
attr_accessor :handlers, :default_handler, :tokens, :users, :framework
26-
attr_accessor :dispatcher_timeout, :token_timeout, :debug
26+
attr_accessor :dispatcher_timeout, :token_timeout, :debug, :str_encoding
2727

2828
def initialize(framework, options={})
2929
self.framework = framework
@@ -36,6 +36,7 @@ def initialize(framework, options={})
3636
:port => 3790
3737
}.merge(options)
3838

39+
self.str_encoding = ''.encoding.name
3940
self.srvhost = self.options[:host]
4041
self.srvport = self.options[:port]
4142
self.uri = self.options[:uri]
@@ -121,6 +122,8 @@ def process(req)
121122
raise ArgumentError, "Invalid Message Format"
122123
end
123124

125+
msg.map { |a| a.respond_to?(:force_encoding) ? a.force_encoding(self.str_encoding) : a }
126+
124127
group, funct = msg.shift.split(".", 2)
125128

126129
if not self.handlers[group]

0 commit comments

Comments
 (0)