Class: WPScan::DB::DynamicFinders::Wordpress

Inherits:
Base
  • Object
show all
Defined in:
lib/wpscan/db/dynamic_finders/wordpress.rb

Class Method Summary collapse

Methods inherited from Base

db_file, method_missing, respond_to_missing?

Class Method Details

.allowed_classesArray<Symbol>

Returns:

  • (Array<Symbol>)


16
17
18
19
20
# File 'lib/wpscan/db/dynamic_finders/wordpress.rb', line 16

def self.allowed_classes
  @allowed_classes ||= %i[
    Comment Xpath HeaderPattern BodyPattern JavascriptVar QueryParameter WpItemQueryParameter
  ]
end

.create_versions_findersObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/wpscan/db/dynamic_finders/wordpress.rb', line 52

def self.create_versions_finders
  versions_finders_configs.each do |finder_class, config|
    klass = config['class'] || finder_class

    # Instead of raising exceptions, skip unallowed/already defined finders
    # So that, when new DF configs are put in the .yml
    # users with old version of WPScan will still be able to scan blogs
    # when updating the DB but not the tool
    next if version_finder_module.constants.include?(finder_class.to_sym) ||
            !allowed_classes.include?(klass.to_sym)

    version_finder_super_class(klass).create_child_class(version_finder_module, finder_class.to_sym, config)
  end
end

.db_dataHash

Returns:

  • (Hash)


6
7
8
# File 'lib/wpscan/db/dynamic_finders/wordpress.rb', line 6

def self.db_data
  @db_data ||= super['wordpress'] || {}
end

.finder_configs(finder_class, aggressive = false) ⇒ Hash

Parameters:

  • finder_class (Symbol)
  • aggressive (Boolean) (defaults to: false)

Returns:

  • (Hash)


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/wpscan/db/dynamic_finders/wordpress.rb', line 25

def self.finder_configs(finder_class, aggressive = false)
  configs = {}

  return configs unless allowed_classes.include?(finder_class)

  finders = if aggressive
              db_data.reject { |_f, c| c['path'].nil? }
            else
              db_data.select { |_f, c| c['path'].nil? }
            end

  finders.each do |finder_name, config|
    klass = config['class'] || finder_name

    next unless klass.to_sym == finder_class

    configs[finder_name] = config
  end

  configs
end

.version_finder_moduleConstant

Returns:

  • (Constant)


11
12
13
# File 'lib/wpscan/db/dynamic_finders/wordpress.rb', line 11

def self.version_finder_module
  Finders::WpVersion
end

.version_finder_super_class(klass) ⇒ Constant

Parameters:

  • klass (String, Symbol)

Returns:

  • (Constant)


69
70
71
# File 'lib/wpscan/db/dynamic_finders/wordpress.rb', line 69

def self.version_finder_super_class(klass)
  "WPScan::Finders::DynamicFinder::WpVersion::#{klass}".constantize
end

.versions_finders_configsHash

Returns:

  • (Hash)


48
49
50
# File 'lib/wpscan/db/dynamic_finders/wordpress.rb', line 48

def self.versions_finders_configs
  @versions_finders_configs ||= db_data.select { |_finder_name, config| config.key?('version') }
end