Module: Watobo::Mixin::Shaper::HttpResponse

Defined in:
lib/watobo/mixins/shapers.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::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

#unchunkObject



414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
# File 'lib/watobo/mixins/shapers.rb', line 414

def unchunk
  if self.transfer_encoding == TE_CHUNKED then
    self.removeHeader("Transfer-Encoding")
    self.addHeader("Content-Length", "0")
    new_r = []
    new_r.concat self.headers
    new_r.push "\r\n"

    bytes_to_read = 20
    body = []
    is_new_chunk = false

    off = 0
    new_body = ''

    body_orig = self.body
    return true if body_orig.nil?
    # puts body_orig.class
    puts body_orig.length
    pattern = '[0-9a-fA-F]{1,6}\r?\n'
    while off >= 0 and off < body_orig.length
      chunk_pos  = body_orig.index(/(#{pattern})/, off)
      len_raw = $1
      unless chunk_pos.nil?
        #len_raw = body_orig.match(/#{pattern}/, chunk_pos)[0]
        # puts "ChunkLen: #{len_raw} (#{len_raw.strip.hex})"
        len = len_raw.strip.hex

        chunk_start = chunk_pos + len_raw.length
        chunk_end = chunk_start + len

        break if len == 0

        #new_body.chomp!
        chunk = "#{body_orig[chunk_start..chunk_end]}"
      new_body += chunk.chomp!

      off = chunk_end
      end
    end
  new_r.push new_body
  self.replace(new_r)
  self.fix_content_length
  # puts "="
  # self.headers.each {|h| puts h}
  # puts "="
  end

end

#unzipObject



464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
# File 'lib/watobo/mixins/shapers.rb', line 464

def unzip

  if self.content_encoding == TE_GZIP or self.transfer_encoding == TE_GZIP
    begin
      if self.has_body?
        gziped = self.pop
        gz = Zlib::GzipReader.new( StringIO.new( gziped ) )
        data = gz.read
        #puts data
        self << data
        self.removeHeader("Transfer-Encoding") if self.transfer_encoding == TE_GZIP
        self.removeHeader("Content-Encoding") if self.content_encoding == TE_GZIP
      self.fix_content_length
      end

    rescue => bang
      puts bang
    end
  end
end