class WPScan::Finders::DynamicFinder::Finder
To be used as a base when creating a dynamic finder
Public Class Methods
child_class_constant(*args)
click to toggle source
@param [ Array ] args
# File lib/wpscan/finders/dynamic_finder/finder.rb, line 9 def self.child_class_constant(*args) args.each do |arg| if arg.is_a?(Hash) child_class_constants.merge!(arg) else child_class_constants[arg] = nil end end end
child_class_constants()
click to toggle source
Needed to have inheritance of the @child_class_constants If inheritance is not needed, then the child_class_constant can be used in the class definition, ie
child_class_constant :FILES, PATTERN: /aaa/i
@return [ Hash ]
# File lib/wpscan/finders/dynamic_finder/finder.rb, line 23 def self.child_class_constants @child_class_constants ||= { PATH: nil } end
create_child_class(mod, klass, config)
click to toggle source
@param [ Constant ] mod @param [ Constant ] klass @param [ Hash ] config
# File lib/wpscan/finders/dynamic_finder/finder.rb, line 30 def self.create_child_class(mod, klass, config) # Can't use the #child_class_constants directly in the Class.new(self) do; end below class_constants = child_class_constants mod.const_set( klass, Class.new(self) do class_constants.each do |key, value| const_set(key, config[key.downcase.to_s] || value) end end ) end
Public Instance Methods
aggressive(opts = {})
click to toggle source
@param [ Hash ] opts @return [ Mixed ] See find
# File lib/wpscan/finders/dynamic_finder/finder.rb, line 68 def aggressive(opts = {}) return unless self.class::PATH find(Browser.get(target.url(self.class::PATH)), opts) end
find(_response, _opts = {})
click to toggle source
This method has to be overriden in child classes
@param [ Typhoeus::Response
] response @param [ Hash ] opts @return [ Mixed: nil, Object
, Array ]
# File lib/wpscan/finders/dynamic_finder/finder.rb, line 48 def find(_response, _opts = {}) raise NoMethodError end
passive(opts = {})
click to toggle source
@param [ Hash ] opts @return [ Mixed ] See find
# File lib/wpscan/finders/dynamic_finder/finder.rb, line 54 def passive(opts = {}) return if self.class::PATH homepage_result = find(target.homepage_res, opts) unless homepage_result.nil? || (homepage_result.is_a?(Array) && homepage_result&.empty?) return homepage_result end find(target.error_404_res, opts) end