Convert ANSI data to UTF-8 char by char because MS might

put an invalid character in the WORKGROUP name during SMB
handshake
bug/bundler_fix
Brendan 2016-10-19 17:42:26 -05:00
parent 1644a1e20b
commit b5a41c3011
1 changed files with 17 additions and 1 deletions

View File

@ -108,7 +108,23 @@ class MetasploitModule < Msf::Auxiliary
end
if simple.client.default_domain
desc << " (domain:#{simple.client.default_domain})"
if simple.client.default_domain.encoding.name == "UTF-8"
desc << " (domain:#{simple.client.default_domain})"
else
# Workgroup names are in ANSI, but may contain invalid characters
# Go through each char and convert/check
temp_workgroup = simple.client.default_domain.dup
desc << " (workgroup:"
temp_workgroup.each_char do |i|
begin
desc << i.encode("UTF-8")
rescue Encoding::UndefinedConversionError => e
desc << '?'
print_error("Found incompatible (non-ANSI) character in Workgroup name. Replaced with '?'")
end
end
desc << " )"
end
conf[:SMBDomain] = simple.client.default_domain
match_conf['host.domain'] = conf[:SMBDomain]
end