Skip to content

Commit 86f943e

Browse files
author
Brent Cook
committed
Land rapid7#4959 - @hmoore-r7 - disable unicode filter by default on !windows
2 parents 040ef1e + 24ce011 commit 86f943e

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

lib/msf/base/sessions/meterpreter_options.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def initialize(info = {})
1515
OptString.new('InitialAutoRunScript', [false, "An initial script to run on session creation (before AutoRunScript)", '']),
1616
OptString.new('AutoRunScript', [false, "A script to run automatically on session creation.", '']),
1717
OptBool.new('AutoSystemInfo', [true, "Automatically capture system information on initialization.", true]),
18-
OptBool.new('EnableUnicodeEncoding', [true, "Automatically encode UTF-8 strings as hexadecimal", true]),
18+
OptBool.new('EnableUnicodeEncoding', [true, "Automatically encode UTF-8 strings as hexadecimal", Rex::Compat.is_windows]),
1919
OptPath.new('HandlerSSLCert', [false, "Path to a SSL certificate in unified PEM format, ignored for HTTP transports"])
2020
], self.class)
2121
end

lib/rex/post/meterpreter/extensions/stdapi/fs/dir.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def Dir.entries(name = getwd)
6161
response = client.send_request(request)
6262

6363
response.each(TLV_TYPE_FILE_NAME) { |file_name|
64-
files << file_name.value
64+
files << client.unicode_filter_encode(file_name.value)
6565
}
6666

6767
return files
@@ -97,8 +97,8 @@ def Dir.entries_with_info(name = getwd)
9797

9898
files <<
9999
{
100-
'FileName' => file_name.value,
101-
'FilePath' => fpath[idx].value,
100+
'FileName' => client.unicode_filter_encode(file_name.value),
101+
'FilePath' => client.unicode_filter_encode(fpath[idx].value),
102102
'FileShortName' => fsname[idx] ? fsname[idx].value : nil,
103103
'StatBuf' => st,
104104
}
@@ -147,7 +147,7 @@ def Dir.pwd
147147

148148
response = client.send_request(request)
149149

150-
return response.get_tlv(TLV_TYPE_DIRECTORY_PATH).value
150+
return client.unicode_filter_encode(response.get_tlv(TLV_TYPE_DIRECTORY_PATH).value)
151151
end
152152

153153
#
@@ -197,8 +197,8 @@ def Dir.unlink(path)
197197
def Dir.download(dst, src, recursive = false, force = true, &stat)
198198

199199
self.entries(src).each { |src_sub|
200-
dst_item = dst + ::File::SEPARATOR + src_sub
201-
src_item = src + client.fs.file.separator + src_sub
200+
dst_item = dst + ::File::SEPARATOR + client.unicode_filter_encode(src_sub)
201+
src_item = src + client.fs.file.separator + client.unicode_filter_encode(src_sub)
202202

203203
if (src_sub == '.' or src_sub == '..')
204204
next
@@ -242,8 +242,8 @@ def Dir.download(dst, src, recursive = false, force = true, &stat)
242242
#
243243
def Dir.upload(dst, src, recursive = false, &stat)
244244
::Dir.entries(src).each { |src_sub|
245-
dst_item = dst + client.fs.file.separator + src_sub
246-
src_item = src + ::File::SEPARATOR + src_sub
245+
dst_item = dst + client.fs.file.separator + client.unicode_filter_encode(src_sub)
246+
src_item = src + ::File::SEPARATOR + client.unicode_filter_encode(src_sub)
247247

248248
if (src_sub == '.' or src_sub == '..')
249249
next

lib/rex/post/meterpreter/extensions/stdapi/fs/file.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ def File.search( root=nil, glob="*.*", recurse=true, timeout=-1 )
9191
if( response.result == 0 )
9292
response.each( TLV_TYPE_SEARCH_RESULTS ) do | results |
9393
files << {
94-
'path' => results.get_tlv_value( TLV_TYPE_FILE_PATH ).chomp( '\\' ),
95-
'name' => results.get_tlv_value( TLV_TYPE_FILE_NAME ),
96-
'size' => results.get_tlv_value( TLV_TYPE_FILE_SIZE )
94+
'path' => client.unicode_filter_encode(results.get_tlv_value(TLV_TYPE_FILE_PATH).chomp( '\\' )),
95+
'name' => client.unicode_filter_encode(results.get_tlv_value(TLV_TYPE_FILE_NAME)),
96+
'size' => results.get_tlv_value(TLV_TYPE_FILE_SIZE)
9797
}
9898
end
9999
end
@@ -138,7 +138,7 @@ def File.expand_path(path)
138138

139139
response = client.send_request(request)
140140

141-
return response.get_tlv_value(TLV_TYPE_FILE_PATH)
141+
return client.unicode_filter_encode(response.get_tlv_value(TLV_TYPE_FILE_PATH))
142142
end
143143

144144

0 commit comments

Comments
 (0)