Module: Watobo::Mixin::Parser::Web10
- Defined in:
- lib/watobo/mixins/httpparser.rb
Constant Summary
Constants included
from Constants
Constants::AC_GROUP_APACHE, Constants::AC_GROUP_DOMINO, Constants::AC_GROUP_ENUMERATION, Constants::AC_GROUP_FILE_INCLUSION, Constants::AC_GROUP_FLASH, Constants::AC_GROUP_GENERIC, Constants::AC_GROUP_JBOSS, Constants::AC_GROUP_JOOMLA, Constants::AC_GROUP_SAP, Constants::AC_GROUP_SQL, Constants::AC_GROUP_TYPO3, Constants::AC_GROUP_XSS, Constants::AUTH_TYPE_BASIC, Constants::AUTH_TYPE_DIGEST, Constants::AUTH_TYPE_NONE, Constants::AUTH_TYPE_NTLM, Constants::AUTH_TYPE_UNKNOWN, Constants::CHAT_SOURCE_AUTO_SCAN, Constants::CHAT_SOURCE_FUZZER, Constants::CHAT_SOURCE_INTERCEPT, Constants::CHAT_SOURCE_MANUAL, Constants::CHAT_SOURCE_MANUAL_SCAN, Constants::CHAT_SOURCE_PROXY, Constants::CHAT_SOURCE_UNDEF, Constants::DEFAULT_PORT_HTTP, Constants::DEFAULT_PORT_HTTPS, Constants::FINDING_TYPE_HINT, Constants::FINDING_TYPE_INFO, Constants::FINDING_TYPE_UNDEFINED, Constants::FINDING_TYPE_VULN, Constants::FIRST_TIME_FILE, Constants::GUI_REGULAR_FONT_SIZE, Constants::GUI_SMALL_FONT_SIZE, Constants::ICON_PATH, Constants::LOG_DEBUG, Constants::LOG_INFO, Constants::SCAN_CANCELED, Constants::SCAN_FINISHED, Constants::SCAN_PAUSED, Constants::SCAN_STARTED, Constants::TE_CHUNKED, Constants::TE_COMPRESS, Constants::TE_DEFLATE, Constants::TE_GZIP, Constants::TE_IDENTITY, Constants::TE_NONE, Constants::VULN_RATING_CRITICAL, Constants::VULN_RATING_HIGH, Constants::VULN_RATING_INFO, Constants::VULN_RATING_LOW, Constants::VULN_RATING_MEDIUM, Constants::VULN_RATING_UNDEFINED
Instance Method Summary
collapse
Instance Method Details
#__connection_close? ⇒ Boolean
581
582
583
584
585
586
|
# File 'lib/watobo/mixins/httpparser.rb', line 581
def __connection_close?
("Connection") do |h|
return true if h =~ /close/i
end
return false
end
|
#body ⇒ Object
603
604
605
606
607
608
609
610
611
|
# File 'lib/watobo/mixins/httpparser.rb', line 603
def body
begin
return nil if self.nil? or self.length < 3
return self.last if self[-2].strip.empty?
rescue
return nil
end
nil
end
|
#body_encoded ⇒ Object
636
637
638
639
640
641
642
643
644
645
646
647
648
|
# File 'lib/watobo/mixins/httpparser.rb', line 636
def body_encoded
b = self.body
cs = self.charset
return nil if b.nil?
return b.unpack("C*").pack("C*") if cs.nil?
begin
return b.encode(cs, :invalid => :replace, :undef => :replace, :replace => '').unpack("C*").pack("C*")
rescue => bang
puts bang
puts bang.backtrace if $DEBUG
return b.unpack("C*").pack("C*")
end
end
|
#charset ⇒ Object
690
691
692
693
694
695
696
697
698
699
700
|
# File 'lib/watobo/mixins/httpparser.rb', line 690
def charset
cs = nil
self.each do |line|
break if line.strip.empty?
if line =~ /^Content-Type: .*charset=([^;]*)/i then
cs = $1
break
end
end
return cs
end
|
#connection_close? ⇒ Boolean
588
589
590
591
592
593
|
# File 'lib/watobo/mixins/httpparser.rb', line 588
def connection_close?
("Connection") do |h|
return false if h =~ /keep\-alive/i
end
return true
end
|
#content_encoding ⇒ Object
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
|
# File 'lib/watobo/mixins/httpparser.rb', line 486
def content_encoding
te = TE_NONE
self.each do |line|
break if line.strip.empty?
if line =~ /^Content-Encoding: (.*)/i then
dummy = $1.strip
puts "Content-Encoding => #{dummy}"
te = case dummy
when /chunked/i
TE_CHUNKED
when /compress/i
TE_COMPRESS
when /zip/i
TE_GZIP
when /deflate/i
TE_DEFLATE
when /identity/i
TE_IDENTITY
else
TE_NONE
end
break
end
end
return te
end
|
#content_length ⇒ Object
472
473
474
475
476
477
478
479
480
481
482
483
484
|
# File 'lib/watobo/mixins/httpparser.rb', line 472
def content_length
ct = -1
self.each do |line|
break if line.strip.empty?
if line =~ /^Content-Length: (.*)/i then
ct = $1.to_i
break
end
end
return ct
end
|
#content_type(default_ct = 'undefined') ⇒ Object
448
449
450
451
452
453
454
455
456
457
458
|
# File 'lib/watobo/mixins/httpparser.rb', line 448
def content_type(default_ct='undefined')
ct = default_ct
self.each do |line|
break if line.strip.empty?
if line =~ /^Content-Type: ([^;]*);?/i then
ct = $1
break
end
end
return ct.strip
end
|
#content_type_ex(default_ct = 'undefined') ⇒ Object
460
461
462
463
464
465
466
467
468
469
470
|
# File 'lib/watobo/mixins/httpparser.rb', line 460
def content_type_ex(default_ct='undefined')
ct = default_ct
self.each do |line|
break if line.strip.empty?
if line =~ /^Content-Type: (.*)/i then
ct = $1.strip
break
end
end
return ct.strip
end
|
#contentMD5 ⇒ Object
542
543
544
545
546
|
# File 'lib/watobo/mixins/httpparser.rb', line 542
def contentMD5
b = self.body.nil? ? "" : self.body
hash = Digest::MD5.hexdigest(b)
return hash
end
|
#cookies_UNUSED ⇒ Object
731
732
733
734
735
736
737
738
739
740
741
742
743
744
|
# File 'lib/watobo/mixins/httpparser.rb', line 731
def cookies_UNUSED
cookie_list=[]
self..each do |line|
if line =~ /Cookie2?: (.*)/i then
clist = $1.split(";")
clist.each do |c|
cookie_list.push c.strip
end
end
end
return cookie_list
end
|
#data_UNUSED ⇒ Object
746
747
748
749
|
# File 'lib/watobo/mixins/httpparser.rb', line 746
def data_UNUSED
return self.last.strip if self.last =~ /\=.*\&?/i
return ""
end
|
#has_body? ⇒ Boolean
577
578
579
|
# File 'lib/watobo/mixins/httpparser.rb', line 577
def has_body?
self.body.nil? ? false : true
end
|
595
596
597
598
599
600
601
|
# File 'lib/watobo/mixins/httpparser.rb', line 595
def (name)
self.each do |l|
return false if l.strip.empty?
return true if l =~ /^#{name}:/i
end
return false
end
|
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
|
# File 'lib/watobo/mixins/httpparser.rb', line 430
def ()
=[]
self..each do ||
begin
if =~ /^#{}/i then
dummy = .split(/:/)
value=dummy[1]
value.gsub!(/^[ ]*/,"")
.push value
end
rescue => bang
puts bang
puts bang.backtrace if $DEBUG
end
end
return
end
|
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
|
# File 'lib/watobo/mixins/httpparser.rb', line 702
def (filter=nil, &b)
begin
=[]
self.each do |line|
cl = line.unpack("C*").pack("C*")
return if cl.strip.empty?
unless filter.nil?
if cl =~ /#{filter}/
yield line if block_given?
.push line
end
else
yield line if block_given?
.push line
end
end
return
rescue => bang
puts "! no headers available !".upcase
puts bang
puts bang.backtrace
if $DEBUG
puts bang.backtrace
puts self.to_yaml
end
return nil
end
end
|
#is_text? ⇒ Boolean
613
614
615
616
617
618
619
620
621
622
|
# File 'lib/watobo/mixins/httpparser.rb', line 613
def is_text?
ct = self.content_type(nil)
if ct.nil?
return true if self.body_encoded.ascii_only?
return false
else
return true if ct =~ /text/i
return false
end
end
|
624
625
626
627
628
|
# File 'lib/watobo/mixins/httpparser.rb', line 624
def is_wwwform?
ct = self.content_type
return true if ct =~ /form/i
return false
end
|
#is_xml? ⇒ Boolean
630
631
632
633
634
|
# File 'lib/watobo/mixins/httpparser.rb', line 630
def is_xml?
ct = self.content_type
return true if ct =~ /xml/i
return false
end
|
#new_cookies(&b) ⇒ Object
returns array of new cookies Set-Cookie: mycookie=b41dc9e55d6163f78321996b10c940edcec1b4e55a76464c4e9d25e160ac0ec5b769806b; Path=/
660
661
662
663
664
665
666
667
668
|
# File 'lib/watobo/mixins/httpparser.rb', line 660
def new_cookies(&b)
nc = []
("Set-Cookie") do |h|
cookie = Watobo::Cookie.new(h)
yield cookie if block_given?
nc << cookie
end
nc
end
|
#parm_names ⇒ Object
396
397
398
399
400
401
402
403
404
405
406
407
408
|
# File 'lib/watobo/mixins/httpparser.rb', line 396
def parm_names
parm_names=[]
parmlist=[]
parmlist.concat(get_parms)
parmlist.concat(post_parms)
parmlist.each do |p|
p.gsub!(/=.*/,'')
parm_names.push p
end
return parm_names
end
|
#parms ⇒ Object
388
389
390
391
392
393
394
|
# File 'lib/watobo/mixins/httpparser.rb', line 388
def parms
parmlist=[]
parmlist.concat(get_parms)
parmlist.concat(post_parms)
return parmlist
end
|
#post_parm_names(&block) ⇒ Object
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
|
# File 'lib/watobo/mixins/httpparser.rb', line 410
def post_parm_names(&block)
parm_names=[]
parmlist=[]
parmlist.concat(post_parms)
parmlist.each do |p|
if p then
p.gsub!(/=.*/,'')
p.strip!
yield p if block_given?
parm_names << p
end
end
return parm_names
end
|
#post_parm_value(parm_name) ⇒ Object
def get_parm_value(parm_name)
parm_value = ""
self.get_parms.each do |parm|
if parm =~ /^#{Regexp.quote(parm_name)}=/i then
dummy = parm.split(/=/)
if dummy.length > 1 then
# parm_value=dummy[1].gsub(/^[ ]*/,"")
parm_value=dummy[1].strip
end
end
end
return parm_value
end
562
563
564
565
566
567
568
569
570
571
572
573
574
575
|
# File 'lib/watobo/mixins/httpparser.rb', line 562
def post_parm_value(parm_name)
parm_value=""
self.post_parms.each do |parm|
if parm =~ /#{Regexp.quote(parm_name)}/i then
dummy = parm.split(/=/)
if dummy.length > 1 then
parm_value = dummy[1].strip
else
end
end
end
return parm_value
end
|
#post_parms ⇒ Object
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
|
# File 'lib/watobo/mixins/httpparser.rb', line 370
def post_parms
parmlist=[]
return parmlist unless has_body?
begin
if self.last =~ /\=.*\&?/i
parmlist = self.last.split(/\&/)
end
rescue => bang
if $DEBUG
puts bang
puts bang.backtrace
end
end
return parmlist
end
|
#responseCode ⇒ Object
650
651
652
653
654
655
656
|
# File 'lib/watobo/mixins/httpparser.rb', line 650
def responseCode
if self.first =~ /^HTTP\/... (\d+) /
return $1
else
return nil
end
end
|
#status ⇒ Object
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
|
# File 'lib/watobo/mixins/httpparser.rb', line 670
def status
begin
dummy = self.first.unpack("C*").pack("C*")
if dummy =~ /^HTTP\/1\.\d{1,2} (.*)/i then
return $1.chomp
else
return ''
end
rescue => bang
if $DEBUG
puts "! No Status Available !".upcase
puts bang
puts bang.backtrace
end
return nil
end
end
|
#transferEncoding ⇒ Object
Also known as:
transfer_encoding
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
|
# File 'lib/watobo/mixins/httpparser.rb', line 513
def transferEncoding
te = TE_NONE
self.each do |line|
break if line.strip.empty?
if line =~ /^Transfer-Encoding: (.*)/i then
dummy = $1.strip
te = case dummy
when 'chunked'
TE_CHUNKED
when 'compress'
TE_COMPRESS
when 'zip'
TE_GZIP
when 'deflate'
TE_DEFLATE
when 'identity'
TE_IDENTITY
else
TE_NONE
end
break
end
end
return te
end
|