Class: WPScan::Finders::MainTheme::CssStyle

Inherits:
CMSScanner::Finders::Finder
  • Object
show all
Includes:
WpItems::URLsInHomepage
Defined in:
app/finders/main_theme/css_style.rb

Overview

From the css style

Instance Method Summary collapse

Methods included from WpItems::URLsInHomepage

#item_attribute_pattern, #item_code_pattern, #item_url_pattern, #items_from_codes, #items_from_links

Instance Method Details

#create_theme(name, style_url, opts) ⇒ Object



8
9
10
11
12
13
14
# File 'app/finders/main_theme/css_style.rb', line 8

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

#passive(opts = {}) ⇒ Object



16
17
18
# File 'app/finders/main_theme/css_style.rb', line 16

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

#passive_from_css_href(res, opts) ⇒ Object



20
21
22
23
24
25
26
27
# File 'app/finders/main_theme/css_style.rb', line 20

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

#passive_from_style_code(res, opts) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'app/finders/main_theme/css_style.rb', line 29

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