Path: blob/master/app/finders/main_theme/css_style_in_homepage.rb
485 views
# frozen_string_literal: true12module WPScan3module Finders4module MainTheme5# From the CSS style in the homepage6class CssStyleInHomepage < CMSScanner::Finders::Finder7include Finders::WpItems::UrlsInPage # To have the item_code_pattern method available here89def create_theme(slug, style_url, opts)10Model::Theme.new(11slug,12target,13opts.merge(found_by: found_by, confidence: 70, style_url: style_url)14)15end1617def passive(opts = {})18passive_from_css_href(target.homepage_res, opts) || passive_from_style_code(target.homepage_res, opts)19end2021def passive_from_css_href(res, opts)22target.in_scope_uris(res, '//link/@href[contains(., "style.css")]') do |uri|23next unless uri.path =~ %r{/themes/([^/]+)/style.css\z}i2425return create_theme(Regexp.last_match[1], uri.to_s, opts)26end27nil28end2930def passive_from_style_code(res, opts)31res.html.css('style').each do |tag|32code = tag.text.to_s33next if code.empty?3435next unless code =~ %r{#{item_code_pattern('themes')}\\?/style\.css[^"'( ]*}i3637return create_theme(Regexp.last_match[1], Regexp.last_match[0].strip, opts)38end39nil40end41end42end43end44end454647