Changeset 5467

Show
Ignore:
Timestamp:
04/04/08 16:15:55 (6 months ago)
Author:
hdm
Message:

Handle DCERPC reads over SMB pipes in a more efficient fashion. Rename the sadmind exploit, since Solaris is redundant

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • framework3/trunk/lib/rex/proto/dcerpc/client.rb

    r5466 r5467  
    142142                        begin 
    143143                                if(max_read) 
     144                                         
     145                                        read_limit = nil 
     146                                         
    144147                                        while(true) 
    145148                                                # Random read offsets will not work on Windows NT 4.0 (thanks Dave!) 
    146                                                 data = self.socket.read( (rand(max_read-min_read)+min_read), rand(1024)+1) 
     149                                                 
     150                                                read_cnt = (rand(max_read-min_read)+min_read) 
     151                                                if(read_limit) 
     152                                                        if(read_cnt + raw_response.length > read_limit) 
     153                                                                read_cnt = raw_response.length - read_limit 
     154                                                        end 
     155                                                end 
     156                                                 
     157                                                data = self.socket.read( read_cnt, rand(1024)+1) 
    147158                                                last if not data.length 
    148159                                                raw_response += data 
     160                                                 
     161                                                # Keep reading until we have at least the DCERPC header 
     162                                                next if raw_response.length < 10 
     163                                                 
     164                                                # We now have to process the raw_response and parse out the DCERPC fragment length 
     165                                                # if we have read enough data. Once we have the length value, we need to make sure 
     166                                                # that we don't read beyond this amount, or it can screw up the SMB state 
     167                                                begin  
     168                                                        check = Rex::Proto::DCERPC::Response.new(raw_response) 
     169                                                        read_limit = check.frag_len 
     170                                                rescue ::Rex::Proto::DCERPC::Exceptions::InvalidPacket 
     171                                                end 
     172                                                 
     173                                                break if (read_limit and read_limit == raw_response.length) 
    149174                                        end 
    150175                                else 
     
    161186                else  
    162187                        if (self.socket.type? == 'tcp') 
    163                                 if (max_read) 
     188                                if (false and max_read) 
    164189                                        while (true) 
    165190                                                data = self.socket.get_once((rand(max_read-min_read)+min_read), self.options['read_timeout']) 
     
    187212                max_write = self.options['pipe_write_max_size'] || data.length 
    188213                min_write = self.options['pipe_write_min_size'] || max_write 
     214                 
     215                if(min_write > max_write) 
     216                        max_write = min_write 
     217                end 
     218                 
    189219                idx = 0 
    190220 
  • framework3/trunk/lib/rex/proto/dcerpc/response.rb

    r3626 r5467  
    2727                 
    2828                if (! data or data.length < 10) 
    29                         raise Rex::Proto::DCERPC::Exceptions::InvalidPacket, 'Packet header must be at least 10 bytes long
     29                        raise Rex::Proto::DCERPC::Exceptions::InvalidPacket, 'DCERPC response packet is incomplete
    3030                end 
    3131                 
     
    4848                uuid = Rex::Proto::DCERPC::UUID 
    4949                data = self.raw 
    50                          
     50                 
     51                 
     52                if(not data) 
     53                        raise Rex::Proto::DCERPC::Exceptions::InvalidPacket, 'DCERPC response packet is incomplete' 
     54                end 
     55                 
    5156                # BIND_ACK == 12, ALTER_CONTEXT_RESP == 15 
    5257                if (self.type == 12 or self.type == 15)