Sha256: 1179270262e5bf1f7c579e92db5eecfd72ae02ab59c1f7e82a521173b4f4c96d

Contents?: true

Size: 1.24 KB

Versions: 9

Compression:

Stored size: 1.24 KB

Contents

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

        def create_theme(name, style_url, opts)
          WPScan::Theme.new(
            name,
            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|//link') 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

9 entries across 9 versions & 1 rubygems

Version Path
wpscan-3.0.8 app/finders/main_theme/css_style.rb
wpscan-3.0.7 app/finders/main_theme/css_style.rb
wpscan-3.0.6 app/finders/main_theme/css_style.rb
wpscan-3.0.5 app/finders/main_theme/css_style.rb
wpscan-3.0.4 app/finders/main_theme/css_style.rb
wpscan-3.0.3 app/finders/main_theme/css_style.rb
wpscan-3.0.2 app/finders/main_theme/css_style.rb
wpscan-3.0.1 app/finders/main_theme/css_style.rb
wpscan-3.0 app/finders/main_theme/css_style.rb