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

all_df_data, df_file, method_missing, respond_to_missing?

Class Method Details

.allowed_classesArray<Symbol>

Returns:

  • (Array<Symbol>)


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

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

.create_versions_findersObject



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

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

.df_dataHash

Returns:

  • (Hash)


8
9
10
# File 'lib/wpscan/db/dynamic_finders/wordpress.rb', line 8

def self.df_data
  @df_data ||= all_df_data['wordpress'] || {}
end

.finder_configs(finder_class, aggressive: false) ⇒ Hash

Parameters:

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

Returns:

  • (Hash)


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

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

  return configs unless allowed_classes.include?(finder_class)

  finders = if aggressive
              df_data.reject { |_f, c| c['path'].nil? }
            else
              df_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)


13
14
15
# File 'lib/wpscan/db/dynamic_finders/wordpress.rb', line 13

def self.version_finder_module
  Finders::WpVersion
end

.version_finder_super_class(klass) ⇒ Constant

Parameters:

  • klass (String, Symbol)

Returns:

  • (Constant)


71
72
73
# File 'lib/wpscan/db/dynamic_finders/wordpress.rb', line 71

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

.versions_finders_configsHash

Returns:

  • (Hash)


50
51
52
# File 'lib/wpscan/db/dynamic_finders/wordpress.rb', line 50

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