diff --git a/lib/msf/core/db.rb b/lib/msf/core/db.rb index bd6d0e4d81..6f31db8d87 100644 --- a/lib/msf/core/db.rb +++ b/lib/msf/core/db.rb @@ -1426,8 +1426,16 @@ class DBManager service = opts.delete(:service) || report_service(:host => host, :port => port, :proto => proto, :name => sname, :workspace => wspace) # Non-US-ASCII usernames are tripping up the database at the moment, this is a temporary fix until we update the tables - ( token[0] = token[0].gsub(/[\x00-\x1f\x7f-\xff]/){|m| "\\x%.2x" % m.unpack("C")[0] } ) if token[0] - ( token[1] = token[1].gsub(/[\x00-\x1f\x7f-\xff]/){|m| "\\x%.2x" % m.unpack("C")[0] } ) if token[1] + if (token[0]) + # convert the token to US-ASCII from UTF-8 to prevent an error + token[0] = token[0].unpack("C*").pack("C*") + token[0] = token[0].gsub(/[\x00-\x1f\x7f-\xff]/){|m| "\\x%.2x" % m.unpack("C")[0] } + end + + if (token[1]) + token[1] = token[1].unpack("C*").pack("C*") + token[1] = token[1].gsub(/[\x00-\x1f\x7f-\xff]/){|m| "\\x%.2x" % m.unpack("C")[0] } + end ret = {}