Sha256: 580c811a5cd9fcb651dded16ac4180ad177e4fe7343d2086804c52a708ee5e66

Contents?: true

Size: 1.33 KB

Versions: 7

Compression:

Stored size: 1.33 KB

Contents

=begin
    Copyright 2010-2014 Tasos Laskos <tasos.laskos@arachni-scanner.com>

    This file is part of the Arachni Framework project and is subject to
    redistribution and commercial restrictions. Please see the Arachni Framework
    web site for more information on licensing and terms of use.
=end

#
# Extracts meta refresh URLs.
#
# @author Tasos "Zapotek" Laskos <tasos.laskos@arachni-scanner.com>
#
# @version 0.1.2
#
class Arachni::Parser::Extractors::MetaRefresh < Arachni::Parser::Extractors::Base

    #
    # Returns an array of paths as plain strings
    #
    # @param    [Nokogiri]  doc  Nokogiri document
    #
    # @return   [Array<String>]  paths
    #
    def run( doc )
        doc.search( "//meta[
                translate(
                    @http-equiv,
                        'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
                        'abcdefghijklmnopqrstuvwxyz'
                    ) = 'refresh'
            ]" ).map do |url|
            begin
                _, url = url['content'].split( ';', 2 )
                next if !url
                unquote( url.split( '=', 2 ).last )
            rescue
                next
            end
        end
    end

    def unquote( str )
        [ '\'', '"' ].each do |q|
            return str[1...-1] if str.start_with?( q ) && str.end_with?( q )
        end
        str
    end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
arachni-1.0.6 components/path_extractors/meta_refresh.rb
arachni-1.0.5 components/path_extractors/meta_refresh.rb
arachni-1.0.4 components/path_extractors/meta_refresh.rb
arachni-1.0.3 components/path_extractors/meta_refresh.rb
arachni-1.0.2 components/path_extractors/meta_refresh.rb
arachni-1.0.1 components/path_extractors/meta_refresh.rb
arachni-1.0 components/path_extractors/meta_refresh.rb