avoid stack overflow on too many empty pipe reads in a row

GSoC/Meterpreter_Web_Console
Brent Cook 2018-06-29 17:48:39 -05:00
parent 2856c46199
commit 3b228b0abd
1 changed files with 3 additions and 3 deletions

View File

@ -29,7 +29,7 @@ module Rex::Proto::SMB
client.close(file_id, tree_id)
end
def read_ruby_smb(length, offset)
def read_ruby_smb(length, offset, depth = 0)
if length.nil?
max_size = client.open_files[client.last_file_id].size
fptr = offset
@ -50,8 +50,8 @@ module Rex::Proto::SMB
begin
data = client.read(file_id, offset, length).pack('C*')
rescue RubySMB::Error::UnexpectedStatusCode => e
if e.message == 'STATUS_PIPE_EMPTY'
data = read_ruby_smb(length, offset)
if e.message == 'STATUS_PIPE_EMPTY' && depth < 2
data = read_ruby_smb(length, offset, depth + 1)
else
raise e
end