Sha256: 7486408914d6bd2d519e9cdd46d68a1d93543fe0e3801fbd8695a5aee95af233

Contents?: true

Size: 1.25 KB

Versions: 10

Compression:

Stored size: 1.25 KB

Contents

module WPScan
  module Finders
    module MainTheme
      # From the css style
      class CssStyle < CMSScanner::Finders::Finder
        include Finders::WpItems::URLsInHomepage

        def create_theme(slug, style_url, opts)
          WPScan::Theme.new(
            slug,
            target,
            opts.merge(found_by: found_by, confidence: 70, style_url: style_url)
          )
        end

        def passive(opts = {})
          passive_from_css_href(target.homepage_res, opts) || passive_from_style_code(target.homepage_res, opts)
        end

        def passive_from_css_href(res, opts)
          target.in_scope_urls(res, '//style/@src|//link/@href') do |url|
            next unless Addressable::URI.parse(url).path =~ %r{/themes/([^\/]+)/style.css\z}i

            return create_theme(Regexp.last_match[1], url, opts)
          end
          nil
        end

        def passive_from_style_code(res, opts)
          res.html.css('style').each do |tag|
            code = tag.text.to_s
            next if code.empty?

            next unless code =~ %r{#{item_code_pattern('themes')}\\?/style\.css[^"'\( ]*}i

            return create_theme(Regexp.last_match[1], Regexp.last_match[0].strip, opts)
          end
          nil
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
wpscan-3.4.5 app/finders/main_theme/css_style.rb
wpscan-3.4.4 app/finders/main_theme/css_style.rb
wpscan-3.4.3 app/finders/main_theme/css_style.rb
wpscan-3.4.2 app/finders/main_theme/css_style.rb
wpscan-3.4.1 app/finders/main_theme/css_style.rb
wpscan-3.4.0 app/finders/main_theme/css_style.rb
wpscan-3.3.3 app/finders/main_theme/css_style.rb
wpscan-3.3.2 app/finders/main_theme/css_style.rb
wpscan-3.3.1 app/finders/main_theme/css_style.rb
wpscan-3.3.0 app/finders/main_theme/css_style.rb