Default max_read to 1M, solves intermittent issues

git-svn-id: file:///home/svn/framework3/trunk@5876 4d416f70-5f16-0410-b530-b9f4589650da
unstable
HD Moore 2008-11-10 23:03:16 +00:00
parent b11939759e
commit bbb53dd9ea
1 changed files with 32 additions and 35 deletions

View File

@ -132,7 +132,7 @@ require 'rex/proto/smb/exceptions'
def read()
max_read = self.options['pipe_read_max_size'] || nil
max_read = self.options['pipe_read_max_size'] || 1024*1024
min_read = self.options['pipe_read_min_size'] || max_read
raw_response = ''
@ -140,43 +140,40 @@ require 'rex/proto/smb/exceptions'
# Are we reading from a remote pipe over SMB?
if (self.socket.class == Rex::Proto::SMB::SimpleClient::OpenPipe)
begin
if(max_read)
read_limit = nil
while(true)
# Random read offsets will not work on Windows NT 4.0 (thanks Dave!)
read_cnt = (rand(max_read-min_read)+min_read)
if(read_limit)
if(read_cnt + raw_response.length > read_limit)
read_cnt = raw_response.length - read_limit
end
read_limit = nil
while(true)
# Random read offsets will not work on Windows NT 4.0 (thanks Dave!)
read_cnt = (rand(max_read-min_read)+min_read)
if(read_limit)
if(read_cnt + raw_response.length > read_limit)
read_cnt = raw_response.length - read_limit
end
data = self.socket.read( read_cnt, rand(1024)+1)
last if not data.length
raw_response += data
# Keep reading until we have at least the DCERPC header
next if raw_response.length < 10
# We now have to process the raw_response and parse out the DCERPC fragment length
# if we have read enough data. Once we have the length value, we need to make sure
# that we don't read beyond this amount, or it can screw up the SMB state
if (not read_limit)
begin
check = Rex::Proto::DCERPC::Response.new(raw_response)
read_limit = check.frag_len
rescue ::Rex::Proto::DCERPC::Exceptions::InvalidPacket
end
end
break if (read_limit and read_limit == raw_response.length)
end
else
raw_response = self.socket.read()
data = self.socket.read( read_cnt, rand(1024)+1)
last if not data.length
raw_response += data
# Keep reading until we have at least the DCERPC header
next if raw_response.length < 10
# We now have to process the raw_response and parse out the DCERPC fragment length
# if we have read enough data. Once we have the length value, we need to make sure
# that we don't read beyond this amount, or it can screw up the SMB state
if (not read_limit)
begin
check = Rex::Proto::DCERPC::Response.new(raw_response)
read_limit = check.frag_len
rescue ::Rex::Proto::DCERPC::Exceptions::InvalidPacket
end
end
break if (read_limit and read_limit == raw_response.length)
end
rescue Rex::Proto::SMB::Exceptions::NoReply
# I don't care if I didn't get a reply...
rescue Rex::Proto::SMB::Exceptions::ErrorCode => exception