watobo 0.9.14 → 0.9.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/CHANGELOG.md +29 -0
  2. data/config/interceptor.yml +1 -0
  3. data/lib/watobo/core/active_check.rb +1 -2
  4. data/lib/watobo/core/client_cert_store.rb +47 -0
  5. data/lib/watobo/core/scanner3.rb +124 -88
  6. data/lib/watobo/core/session.rb +52 -47
  7. data/lib/watobo/core.rb +1 -11
  8. data/lib/watobo/gui/chatviewer_frame.rb +5 -3
  9. data/lib/watobo/gui/checkboxtree.rb +59 -14
  10. data/lib/watobo/gui/checks_policy_frame.rb +1 -5
  11. data/lib/watobo/gui/client_cert_dialog.rb +260 -96
  12. data/lib/watobo/gui/conversation_table.rb +7 -1
  13. data/lib/watobo/gui/conversation_table_ctrl2.rb +14 -5
  14. data/lib/watobo/gui/edit_comment.rb +1 -1
  15. data/lib/watobo/gui/main_window.rb +40 -5
  16. data/lib/watobo/gui/manual_request_editor.rb +10 -8
  17. data/lib/watobo/gui/quick_scan_dialog.rb +8 -6
  18. data/lib/watobo/gui/scanner_settings_dialog.rb +1 -0
  19. data/lib/watobo/gui/text_viewer.rb +5 -3
  20. data/lib/watobo/http/cookies/cookies.rb +3 -1
  21. data/lib/watobo/http_socket/agent.rb +1 -1
  22. data/lib/watobo/http_socket/client_socket.rb +409 -98
  23. data/lib/watobo/http_socket/connection.rb +1 -1
  24. data/lib/watobo/http_socket/http_socket.rb +47 -39
  25. data/lib/watobo/interceptor/proxy.rb +41 -212
  26. data/lib/watobo/mixins/httpparser.rb +17 -16
  27. data/lib/watobo/mixins/shapers.rb +3 -7
  28. data/lib/watobo.rb +2 -1
  29. data/modules/active/domino/domino_db.rb +5 -7
  30. data/modules/active/struts2/default_handler_ognl.rb +128 -0
  31. data/modules/active/struts2/include_params_ognl.rb +127 -0
  32. data/modules/passive/ajax.rb +5 -3
  33. data/modules/passive/detect_infrastructure.rb +2 -3
  34. data/modules/passive/dirindexing.rb +8 -6
  35. data/modules/passive/disclosure_emails.rb +13 -14
  36. data/modules/passive/disclosure_ipaddr.rb +13 -13
  37. data/modules/passive/hotspots.rb +6 -4
  38. data/modules/passive/in_script_parameter.rb +25 -19
  39. data/modules/passive/redirectionz.rb +1 -1
  40. data/modules/passive/sap-headers.rb +78 -0
  41. data/modules/passive/xss_dom.rb +5 -3
  42. data/plugins/catalog/catalog.rb +7 -2
  43. data/plugins/crawler/gui/auth_frame.rb +20 -5
  44. data/plugins/crawler/gui/crawler_gui.rb +56 -9
  45. data/plugins/crawler/lib/engine.rb +12 -14
  46. data/plugins/filefinder/dbs/sap.db +157 -0
  47. metadata +23 -2
@@ -19,34 +19,33 @@
19
19
  # along with WATOBO; if not, write to the Free Software
20
20
  # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
21
  # .
22
- # @private
22
+ # @private
23
23
  module Watobo#:nodoc: all
24
24
  module HTTPSocket
25
-
26
25
  def self.close(socket)
27
- def close
28
- begin
29
- #if socket.class.to_s =~ /SSLSocket/
30
- if socket.respond_to? :sysclose
31
- #socket.io.shutdown(2)
32
- socket.sysclose
33
- elsif @socket.respond_to? :shutdown
34
- puts "SHUTDOWN"
26
+ # def close
27
+ begin
28
+ #if socket.class.to_s =~ /SSLSocket/
29
+ if socket.respond_to? :sysclose
30
+ #socket.io.shutdown(2)
31
+ socket.sysclose
32
+ elsif socket.respond_to? :shutdown
33
+ #puts "SHUTDOWN"
35
34
  socket.shutdown(Socket::SHUT_RDWR)
36
- end
37
- # finally close it
38
- if socket.respond_to? :close
39
- socket.close
40
- end
41
- return true
42
- rescue => bang
43
- puts bang
44
- puts bang.backtrace if $DEBUG
45
35
  end
46
- false
36
+ # finally close it
37
+ if socket.respond_to? :close
38
+ socket.close
39
+ end
40
+ return true
41
+ rescue => bang
42
+ puts bang
43
+ puts bang.backtrace if $DEBUG
47
44
  end
45
+ false
46
+ # end
48
47
  end
49
-
48
+
50
49
  def self.siteAlive?(chat)
51
50
  #puts chat.class
52
51
  site = nil
@@ -126,7 +125,7 @@ module Watobo#:nodoc: all
126
125
 
127
126
  return false
128
127
  end
129
-
128
+
130
129
  def self.get_ssl_cert_cn( host, port)
131
130
  cn = ""
132
131
  begin
@@ -158,7 +157,6 @@ module Watobo#:nodoc: all
158
157
  cn
159
158
  end
160
159
 
161
-
162
160
  def self.get_peer_subject(socket)
163
161
  begin
164
162
  ctx = OpenSSL::SSL::SSLContext.new()
@@ -192,24 +190,32 @@ module Watobo#:nodoc: all
192
190
  bytes_read += buf.length
193
191
  # end
194
192
  rescue EOFError
195
- return
193
+ if $DEBUG
194
+ puts "#{buf.class} - #{buf}"
195
+ end
196
+ # unless buf.nil?
197
+ # yield buf if block_given?
198
+ # end
199
+ #buf = nil
200
+ break
201
+ #return
196
202
  rescue Timeout::Error
197
203
  puts "!!! Timeout: read_body (max_bytes=#{max_bytes})"
198
204
  #puts "* last data seen on socket:"
199
205
  # puts buf
200
206
  puts $!.backtrace if $DEBUG
201
- return
207
+ break
202
208
  rescue => bang
203
209
  print "E!"
204
210
  puts bang.backtrace if $DEBUG
205
- return
211
+ break
206
212
  end
207
- # puts bytes_read.to_s
213
+ break if buf.nil?
208
214
  yield buf if block_given?
209
- return if max_bytes >= 0 and bytes_read >= max_bytes
215
+ break if max_bytes >= 0 and bytes_read >= max_bytes
210
216
  bytes_to_read -= bytes_read if max_bytes >= 0 && bytes_to_read >= bytes_read
211
217
  end
212
- # end
218
+ return
213
219
  end
214
220
 
215
221
  def self.readChunkedBody(socket)
@@ -279,8 +285,8 @@ module Watobo#:nodoc: all
279
285
  #return
280
286
  raise
281
287
  rescue => bang
282
- # puts "!!! READING HEADER:"
283
- # puts buf
288
+ # puts "!!! READING HEADER:"
289
+ # puts buf
284
290
  puts bang
285
291
  puts bang.backtrace
286
292
  raise
@@ -292,14 +298,14 @@ module Watobo#:nodoc: all
292
298
  return if buf.strip.empty?
293
299
  end
294
300
  end
295
-
301
+
296
302
  def self.read_client_header(socket)
297
303
  buf = ''
298
304
 
299
305
  while true
300
306
  begin
301
- #Timeout::timeout(1.5) do
302
- buf = socket.gets
307
+ #Timeout::timeout(1.5) do
308
+ buf = socket.gets
303
309
  #end
304
310
  rescue EOFError => e
305
311
  puts "EOFError: #{e}"
@@ -308,9 +314,9 @@ module Watobo#:nodoc: all
308
314
  return true
309
315
  rescue Errno::ECONNRESET => e
310
316
  puts "ECONNRESET: #{e}"
311
- #puts "!!! CONNECTION RESET: reading header"
312
- #buf = nil
313
- #return
317
+ #puts "!!! CONNECTION RESET: reading header"
318
+ #buf = nil
319
+ #return
314
320
  #raise
315
321
  return false
316
322
  rescue Errno::ECONNABORTED => e
@@ -321,14 +327,16 @@ module Watobo#:nodoc: all
321
327
  puts "TIMEOUT: #{e}"
322
328
  return false
323
329
  rescue => bang
324
- # puts "!!! READING HEADER:"
325
- # puts buf
330
+ # puts "!!! READING HEADER:"
331
+ # puts buf
326
332
  puts bang
327
333
  puts bang.backtrace
328
334
  raise
329
335
  end
330
336
 
331
337
  return false if buf.nil?
338
+
339
+ # puts buf
332
340
 
333
341
  yield buf if block_given?
334
342
  return if buf.strip.empty?
@@ -132,11 +132,17 @@ module Watobo#:nodoc: all
132
132
  @t_server = Thread.new(@intercept_srv) { |server|
133
133
  while (new_session = server.accept)
134
134
  # new_session.sync = true
135
- Thread.new(new_session) { |session|
135
+ new_sender = Watobo::Session.new(@target)
136
+ Thread.new(new_sender, new_session) { |sender, session|
136
137
 
137
138
  c_sock = Watobo::HTTPSocket::ClientSocket.connect(session)
139
+
140
+ #puts "ClientSocket: #{c_sock}"
138
141
  Thread.exit if c_sock.nil?
142
+
143
+ #
139
144
  # loop for reusing client connections
145
+
140
146
  max_loop = 0
141
147
  loop do
142
148
  flags = []
@@ -144,6 +150,8 @@ module Watobo#:nodoc: all
144
150
 
145
151
  # puts "#{c_sock} - read request"
146
152
  request = c_sock.request
153
+ #puts ">>>"
154
+ # puts request
147
155
  if request.nil? or request.empty? then
148
156
  print "c/"
149
157
  c_sock.close
@@ -167,10 +175,6 @@ module Watobo#:nodoc: all
167
175
  # check if preview is requested
168
176
  if request.host =='watobo.localhost' or request.first =~ /WATOBOPreview/ then
169
177
  if request.first =~ /WATOBOPreview=([0-9a-zA-Z]*)/ then
170
-
171
- puts "* preview requested ..."
172
- # puts request.url
173
-
174
178
  hashid = $1
175
179
  response = @preview[hashid]
176
180
 
@@ -197,43 +201,35 @@ module Watobo#:nodoc: all
197
201
  request_intercepted = true
198
202
 
199
203
  if @target.respond_to? :addRequest
200
- # puts "*INTERCEPT REQUEST"
201
- # puts @target
202
- #notify(:modify_request, request, Thread.current)
203
204
  Watobo.print_debug "send request to target"
204
205
  @target.addRequest(request, Thread.current)
205
- # puts "* stopping thread: #{Thread.current} ..."
206
206
  Thread.stop
207
- # puts "* released thread: #{Thread.current}"
208
207
  else
209
208
  p "! no target for editing request"
210
209
  end
211
210
  @awaiting_requests -= 1
212
211
  end
213
212
  end
214
- # req, resp = @sender.sendRequest(request, :update_sids => false, :update_session => false, :update_contentlength => true)
215
-
216
- #p "getHTTPHeader"
217
- #s_sock, req, resp = @sender.getHTTPHeader(request, :update_sids => true, :update_session => false, :update_contentlength => true)
218
- begin
219
-
220
- s_sock, req, resp = @sender.sendHTTPRequest(request, :update_sids => true, :update_session => false, :update_contentlength => true, :www_auth => @www_auth, :client_certificates => @client_certificates)
221
-
213
+
214
+ begin
215
+ s_sock, req, resp = sender.sendHTTPRequest(request, :update_sids => true,
216
+ :update_session => false,
217
+ :update_contentlength => true,
218
+ :www_auth => @www_auth
219
+ # :client_certificates => @client_certificates
220
+ )
222
221
  if s_sock.nil? then
223
222
  puts "s_sock is nil! bye, bye, ..."
224
223
  puts request if $DEBUG
225
224
  c_sock.write resp.join unless resp.nil?
226
225
  c_sock.close
227
- #Thread.kill Thread.current
228
- Thread.exit
229
- #next
226
+ Thread.exit
230
227
  end
231
228
 
232
229
  rescue => bang
233
230
  puts bang
234
231
  puts bang.backtrace if $DEBUG
235
232
  c_sock.close
236
- #Thread.kill Thread.current
237
233
  Thread.exit
238
234
  end
239
235
 
@@ -250,10 +246,10 @@ module Watobo#:nodoc: all
250
246
  # puts "* got response status: #{resp.status}"
251
247
  missing_credentials = false
252
248
  rs = resp.status
253
- auth_type = AUTH_TYPE_NONE
249
+ auth_type = AUTH_TYPE_NONE
254
250
  if rs =~ /^(401|407)/ then
251
+
255
252
  missing_credentials = true
256
-
257
253
 
258
254
  resp.each do |rl|
259
255
  if rl =~ /^(Proxy|WWW)-Authenticate: Basic/i
@@ -277,20 +273,22 @@ module Watobo#:nodoc: all
277
273
  resp.unshift "HTTP/1.1 200 OK\r\n"
278
274
  end
279
275
  end
280
- else
276
+ #else
281
277
 
282
- resp.push "WATOBO: Unknown authorization type.<br><br>\r\n" + resp.join("<br>\r\n")
283
- resp.shift
284
- resp.unshift "HTTP/1.1 200 OK\r\n"
285
- resp.fix_content_length
278
+ #resp.push "WATOBO: Unknown authorization type.<br><br>\r\n" + resp.join("<br>\r\n")
279
+ #resp.shift
280
+ #resp.unshift "HTTP/1.1 200 OK\r\n"
281
+ #resp.fix_content_length
286
282
 
287
283
  end
288
284
  end
285
+
289
286
  unless auth_type == AUTH_TYPE_UNKNOWN or req.method =~ /^head/i
290
287
  # don't try to read body if request method is HEAD
291
- @sender.readHTTPBody(s_sock, resp, req, :update_sids => true)
288
+ sender.readHTTPBody(s_sock, resp, req, :update_sids => true)
292
289
  Watobo::HTTPSocket.close s_sock
293
290
  end
291
+
294
292
  rescue => bang
295
293
  puts "!!! could not send request !!!"
296
294
  puts bang
@@ -329,7 +327,7 @@ module Watobo#:nodoc: all
329
327
  if missing_credentials
330
328
  resp.set_header("Connection", "close")
331
329
  elsif request.connection_close? or resp.content_length < 0 or max_loop > 4
332
- resp.set_header("Proxy-Connection","close")
330
+ # resp.set_header("Proxy-Connection","close")
333
331
  resp.set_header("Connection","close")
334
332
  else
335
333
  resp.set_header("Connection","keep-alive")
@@ -338,13 +336,10 @@ module Watobo#:nodoc: all
338
336
 
339
337
  resp_data = resp.join
340
338
  c_sock.write resp_data
341
- c_sock.flush
342
- # puts "= RESPONSE ="
343
- # puts resp_data
339
+
344
340
  # puts "---"
345
- # puts resp_data.unpack("H*")[0]
346
- # puts "==="
347
- # puts
341
+ # puts resp_data.unpack("H*")[0]
342
+ # puts "==="
348
343
 
349
344
  rescue Errno::ECONNRESET
350
345
  print "x"
@@ -366,7 +361,8 @@ module Watobo#:nodoc: all
366
361
 
367
362
  Watobo::Chats.add chat
368
363
 
369
-
364
+ # TODO: place check into ClientSocket, because headers must be checked and changed too
365
+ # e.g. if c_sock.open?
370
366
  if missing_credentials or request.connection_close? or resp.content_length < 0 or max_loop > 4
371
367
  c_sock.close
372
368
  Thread.exit
@@ -391,12 +387,6 @@ module Watobo#:nodoc: all
391
387
 
392
388
  puts
393
389
  puts "=== Initialize Interceptor/Proxy ==="
394
- # @project = project
395
- # @settings = settings
396
- # @port = @settings[:intercept_port]
397
- # puts settings.to_yaml
398
-
399
- # @proxy_mode = Watobo::Interceptor.proxy_mode
400
390
 
401
391
  #Watobo::Interceptor.proxy_mode = INTERCEPT_NONE
402
392
 
@@ -450,19 +440,19 @@ module Watobo#:nodoc: all
450
440
  @fake_certs = {}
451
441
  @client_certificates = {}
452
442
  @target = nil
453
- @sender = Watobo::Session.new(@target)
443
+ # @sender = Watobo::Session.new(@target)
454
444
 
455
445
  @bind_addr = Watobo::Conf::Interceptor.bind_addr
456
- puts "> Server: #{@bind_addr}"
446
+ # puts "> Server: #{@bind_addr}"
457
447
  @port = Watobo::Conf::Interceptor.port
458
- puts "> Port: #{@port}"
448
+ # puts "> Port: #{@port}"
459
449
  @proxy_mode = Watobo::Conf::Interceptor.proxy_mode
460
450
 
461
451
  pt = Watobo::Conf::Interceptor.pass_through
462
452
  @contentLength = pt[:content_length]
463
- puts "> PT-ContentLength: #{@contentLength}"
453
+ # puts "> PT-ContentLength: #{@contentLength}"
464
454
  @contentTypes = pt[:content_types]
465
- puts "> PT-ContentTypes: #{@contentTypes}"
455
+ # puts "> PT-ContentTypes: #{@contentTypes}"
466
456
  end
467
457
 
468
458
  #
@@ -529,7 +519,7 @@ module Watobo#:nodoc: all
529
519
  match_parms = true
530
520
  parms_filter = @request_filter_settings[:parms_filter]
531
521
  if parms_filter != ''
532
- puts "!PARMS FILTER: #{parms_filter}"
522
+ # puts "!PARMS FILTER: #{parms_filter}"
533
523
  match_parms = false
534
524
  puts request.parms
535
525
  match_parms = request.parms.find {|x| x =~ /#{parms_filter}/ }
@@ -666,168 +656,7 @@ module Watobo#:nodoc: all
666
656
  ( @proxy_mode & Watobo::Interceptor::MODE_TRANSPARENT ) > 0
667
657
  end
668
658
 
669
- def read_request(socket)
670
- request = []
671
- # read http header lines
672
- session = socket
673
-
674
- ra = socket.remote_address
675
- cport = ra.ip_port
676
- caddr = ra.ip_address
677
-
678
- if transparent?
679
-
680
- ci = @connections.info({ 'host' => caddr, 'port' => cport } )
681
- unless ci['target'].empty? or ci['cn'].empty?
682
- puts "SSL-REQUEST FROM #{caddr}:#{cport}"
683
-
684
- ctx = Watobo::CertStore.acquire_ssl_ctx ci['target'], ci['cn']
685
-
686
- begin
687
- ssl_socket = OpenSSL::SSL::SSLSocket.new(socket, ctx)
688
- ssl_socket.setsockopt( Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, 1)
689
- # ssl_socket.sync_close = true
690
- ssl_socket.sync = true
691
- # puts ssl_socket.methods.sort
692
- session = ssl_socket.accept
693
- rescue OpenSSL::SSL::SSLError => e
694
- puts ">> SSLError"
695
- puts e
696
- return nil, session
697
- rescue => bang
698
- puts bang
699
- puts bang.backtrace
700
- return nil, session
701
- end
702
- else
703
- puts ci['host']
704
- puts ci['cn']
705
- end
706
- end
707
-
708
- Watobo::HTTPSocket.read_header(session) do |line|
709
- # puts line
710
- request.push line
711
- end
712
-
713
- if transparent?
714
- #puts "> get hostname ..."
715
- thn = nil
716
- request.each do |l|
717
- if l =~ /^Host: (.*)/
718
- thn = $1.strip
719
- # puts ">> #{thn}"
720
- end
721
- end
722
- # puts session.class
723
- # puts "* fix request line ..."
724
- # puts request.first
725
- # puts ">>"
726
- if session.is_a? OpenSSL::SSL::SSLSocket
727
- request.first.gsub!(/(^[^[:space:]]{1,}) (.*) (HTTP.*)/i,"\\1 https://#{thn}\\2 \\3")
728
- else
729
- request.first.gsub!(/(^[^[:space:]]{1,}) (.*) (HTTP.*)/i,"\\1 http://#{thn}\\2 \\3")
730
- end
731
- #puts request.first
732
- end
733
-
734
- if request.first =~ /^CONNECT (.*):(\d{1,5}) HTTP\/1\./ then
735
- target = $1
736
- tport = $2
737
- # puts request.first
738
- # print "\n* CONNECT: #{method} #{target} on port #{tport}\n"
739
-
740
- socket.print "HTTP/1.0 200 Connection established\r\n" +
741
- "Proxy-connection: Keep-alive\r\n" +
742
- "Proxy-agent: WATOBO-Proxy/1.1\r\n" +
743
- "\r\n"
744
- bscount = 0 # bad handshake counter
745
- # puts "* wait for ssl handshake ..."
746
- begin
747
- dst = "#{target}:#{tport}"
748
- unless @fake_certs.has_key? dst
749
- puts "NEW CERTIFICATE FOR >> #{dst} <<"
750
- cn = Watobo::HTTPSocket.get_ssl_cert_cn(target, tport)
751
- puts "CN=#{cn}"
752
-
753
- cert = {
754
- :hostname => cn,
755
- :type => 'server',
756
- :user => 'watobo',
757
- :email => 'root@localhost',
758
- }
759
- cert_file, key_file = Watobo::CA.create_cert cert
760
- @fake_certs[dst] = {
761
- :cert => OpenSSL::X509::Certificate.new(File.read(cert_file)),
762
- :key => OpenSSL::PKey::RSA.new(File.read(key_file))
763
- }
764
- end
765
- ctx = OpenSSL::SSL::SSLContext.new()
766
-
767
- #ctx.cert = @cert
768
- ctx.cert = @fake_certs[dst][:cert]
769
- # @ctx.key = OpenSSL::PKey::DSA.new(File.read(key_file))
770
- #ctx.key = @key
771
- ctx.key = @fake_certs[dst][:key]
772
- ctx.tmp_dh_callback = proc { |*args|
773
- @dh_key
774
- }
775
-
776
- ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE
777
- ctx.timeout = 10
778
-
779
- ssl_socket = OpenSSL::SSL::SSLSocket.new(socket, ctx)
780
- ssl_socket.setsockopt( Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, 1)
781
- # ssl_socket.sync_close = true
782
- ssl_socket.sync = true
783
- # puts ssl_socket.methods.sort
784
-
785
- ssl_session = ssl_socket.accept
786
- rescue => bang
787
- puts bang
788
- puts bang.backtrace if $DEBUG
789
- #puts ssl_session
790
- #if not ssl_session then bscount += 1;end
791
- #if bscount > 10 then
792
- # puts "!!! Error: SSL-Handshake with Client/Browser"
793
- # puts bang
794
- return nil, socket
795
- #end
796
- #retry
797
- end
798
- session = ssl_session
799
- # puts "* ssl ok!"
800
- # now read ssl request header
801
- request = []
802
- Watobo::HTTPSocket.read_header(session) do |line|
803
- request.push line
804
- end
805
-
806
- return nil, session if not request.first
807
-
808
- request.first.gsub!(/(^[^[:space:]]{1,})( )(\/.*)/, "\\1 https://#{target}:#{tport}\\3")
809
- end
810
- #puts request
811
- # request.extend Watobo::Mixin::Parser::Url
812
- # request.extend Watobo::Mixin::Parser::Web10
813
- # request.extend Watobo::Mixin::Shaper::Web10
814
- #Watobo::Request.create request
815
- request = Watobo::Request.new(request)
816
-
817
- clen = request.content_length
818
- if clen > 0 then
819
- body = ""
820
- Watobo::HTTPSocket.read_body(session) do |data|
821
- body += data
822
- break if body.length == clen
823
- end
824
- request.push body
825
- end
826
-
827
- return request, session
828
- end
829
-
830
- def isPassThrough?(request, response, s_sock, c_sock)
659
+ def isPassThrough?(request, response, s_sock, c_sock)
831
660
  begin
832
661
  # return false if true
833
662
  reason = nil
@@ -53,7 +53,7 @@ module Watobo#:nodoc: all
53
53
  def file
54
54
  #@file ||= nil
55
55
  #return @file unless @file.nil?
56
- if self.first =~ /^[^[:space:]]{1,} https?:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}[^\?]*\/(.*) HTTP.*/
56
+ if self.first =~ /^[^[:space:]]{1,} [a-zA-Z]+:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}[^\?]*\/(.*) HTTP.*/
57
57
  tmp = $1
58
58
  end_of_file_index = tmp.index(/\?/)
59
59
 
@@ -73,7 +73,7 @@ module Watobo#:nodoc: all
73
73
  def file_ext
74
74
  #@file_ext ||= nil
75
75
  #return @file_ext unless @file_ext.nil?
76
- if self.first =~ /^[^[:space:]]{1,} https?:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}[^\?]*\/(.*) HTTP.*/
76
+ if self.first =~ /^[^[:space:]]{1,} [a-zA-Z]+:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}[^\?]*\/(.*) HTTP.*/
77
77
  @file_ext = $1
78
78
  else
79
79
  @file_ext = ''
@@ -98,7 +98,7 @@ module Watobo#:nodoc: all
98
98
  end
99
99
 
100
100
  def method
101
- if self.first =~ /(^[^[:space:]]{1,}) http/i then
101
+ if self.first =~ /(^[^[:space:]]{1,}) [a-zA-Z]+:\/\//i then
102
102
  return $1
103
103
  else
104
104
  return nil
@@ -128,7 +128,7 @@ module Watobo#:nodoc: all
128
128
  # http://www.mysite.com:80/my/path/show.php?p=aaa&debug=true
129
129
  # path = "my/path/show.php"
130
130
  def path
131
- if self.first =~ /^[^[:space:]]{1,} https?:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}\/([^\?]*).* HTTP/i then
131
+ if self.first =~ /^[^[:space:]]{1,} [a-zA-Z]+:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}\/([^\?]*).* HTTP/i then
132
132
  return $1
133
133
  else
134
134
  return ""
@@ -137,7 +137,7 @@ module Watobo#:nodoc: all
137
137
 
138
138
  # path_ext = "my/path/show.php?p=aaa&debug=true"
139
139
  def path_ext
140
- if self.first =~ /^[^[:space:]]{1,} https?:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}\/(.*) HTTP\//i then
140
+ if self.first =~ /^[^[:space:]]{1,} [a-zA-Z]+:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}\/(.*) HTTP\//i then
141
141
  return $1
142
142
  else
143
143
  return ""
@@ -145,7 +145,7 @@ module Watobo#:nodoc: all
145
145
  end
146
146
 
147
147
  def dir
148
- if self.first =~ /^[^[:space:]]{1,} https?:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}\/([^\?]*)\/.* HTTP/i then
148
+ if self.first =~ /^[^[:space:]]{1,} [a-zA-Z]+:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}\/([^\?]*)\/.* HTTP/i then
149
149
  return $1
150
150
  else
151
151
  return ""
@@ -176,7 +176,7 @@ module Watobo#:nodoc: all
176
176
  cl = self.first.gsub(/\?+/,"?")
177
177
  cl.gsub!(/ HTTP.*/, '')
178
178
  dummy = cl.split('?').first
179
- if dummy =~ /^[^[:space:]]{1,} (https?:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}).*\/(.*)/i then
179
+ if dummy =~ /^[^[:space:]]{1,} ([a-zA-Z]+:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}).*\/(.*)/i then
180
180
  return $2
181
181
  else
182
182
  return ""
@@ -199,12 +199,11 @@ module Watobo#:nodoc: all
199
199
  end
200
200
 
201
201
  def proto
202
- # @proto ||= nil
203
- # return @proto unless @proto.nil?
204
- @proto = "http" if self.first =~ /^[^[:space:]]{1,} http:\/\//i
205
- # puts dummy
206
- @proto = "https" if self.first =~ /^[^[:space:]]{1,} https:\/\//i
207
- @proto
202
+ proto = "unknown"
203
+ if self.first =~ /^[^[:space:]]{1,} ([a-zA-Z]+):\/\//i
204
+ proto = $1
205
+ end
206
+ proto
208
207
  end
209
208
 
210
209
  def is_ssl?
@@ -223,7 +222,7 @@ module Watobo#:nodoc: all
223
222
  def url_string
224
223
  url = ''
225
224
  #return @url unless @url.nil?
226
- if self.first =~ /^[^[:space:]]{1,} (https?:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}.*) HTTP\//i then
225
+ if self.first =~ /^[^[:space:]]{1,} ([a-zA-Z]+:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}.*) HTTP\//i then
227
226
  url = $1
228
227
  end
229
228
  url
@@ -232,7 +231,7 @@ module Watobo#:nodoc: all
232
231
  def site
233
232
  #@site ||= nil
234
233
  #return @site unless @site.nil?
235
- if self.first =~ /^[^[:space:]]{1,} (https?):\/\/([\-0-9a-zA-Z.]*)([:0-9]{0,6})/i then
234
+ if self.first =~ /^[^[:space:]]{1,} ([a-zA-Z]+):\/\/([\-0-9a-zA-Z.]*)([:0-9]{0,6})/i then
236
235
  host = $2
237
236
  port_extension = $3
238
237
  proto = $1
@@ -251,7 +250,8 @@ module Watobo#:nodoc: all
251
250
  def host
252
251
  #@host ||= nil
253
252
  #return @host unless @host.nil?
254
- if self.first =~ /^[^[:space:]]{1,} https?:\/\/([\-0-9a-zA-Z.]*)[:0-9]{0,6}/i then
253
+ #if self.first =~ /^[^[:space:]]{1,} https?:\/\/([\-0-9a-zA-Z.]*)[:0-9]{0,6}/i then
254
+ if self.first =~ /^[^[:space:]]{1,} [a-zA-Z]+:\/\/([\-0-9a-zA-Z.]*)[:0-9]{0,6}/i then
255
255
  @host = $1
256
256
  else
257
257
  @host = ''
@@ -607,6 +607,7 @@ def content_encoding
607
607
  rescue
608
608
  return nil
609
609
  end
610
+ nil
610
611
  end
611
612
 
612
613
  def body_is_text?