Sha256: 7da810f327e95cd233350983e93e80a5bcd6da5387c6f1cdc6848897f6140c94

Contents?: true

Size: 1.98 KB

Versions: 14

Compression:

Stored size: 1.98 KB

Contents

# frozen_string_literal: true

module WPScan
  module Finders
    module DynamicFinder
      # To be used as a base when creating a dynamic finder
      class Finder < CMSScanner::Finders::Finder
        # @param [ Array ] args
        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

        # Needed to have inheritance of the @child_class_constants
        # If inheritance is not needed, then the #child_class_constant can be used in the classe definition, ie
        #   child_class_constant :FILES, PATTERN: /aaa/i
        # @return [ Hash ]
        def self.child_class_constants
          @child_class_constants ||= { PATH: nil }
        end

        # @param [ Constant ] mod
        # @param [ Constant ] klass
        # @param [ Hash ] config
        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

        # This method has to be overriden in child classes
        #
        # @param [ Typhoeus::Response ] response
        # @param [ Hash ] opts
        # @return [ Mixed ]
        def find(_response, _opts = {})
          raise NoMethodError
        end

        # @param [ Hash ] opts
        def passive(opts = {})
          return if self.class::PATH

          find(target.homepage_res, opts)
        end

        # @param [ Hash ] opts
        def aggressive(opts = {})
          return unless self.class::PATH

          find(Browser.get(target.url(self.class::PATH)), opts)
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
wpscan-3.7.3 lib/wpscan/finders/dynamic_finder/finder.rb
wpscan-3.7.2 lib/wpscan/finders/dynamic_finder/finder.rb
wpscan-3.7.1 lib/wpscan/finders/dynamic_finder/finder.rb
wpscan-3.7.0 lib/wpscan/finders/dynamic_finder/finder.rb
wpscan-3.6.3 lib/wpscan/finders/dynamic_finder/finder.rb
wpscan-3.6.2 lib/wpscan/finders/dynamic_finder/finder.rb
wpscan-3.6.1 lib/wpscan/finders/dynamic_finder/finder.rb
wpscan-3.6.0 lib/wpscan/finders/dynamic_finder/finder.rb
wpscan-3.5.5 lib/wpscan/finders/dynamic_finder/finder.rb
wpscan-3.5.4 lib/wpscan/finders/dynamic_finder/finder.rb
wpscan-3.5.3 lib/wpscan/finders/dynamic_finder/finder.rb
wpscan-3.5.2 lib/wpscan/finders/dynamic_finder/finder.rb
wpscan-3.5.1 lib/wpscan/finders/dynamic_finder/finder.rb
wpscan-3.5.0 lib/wpscan/finders/dynamic_finder/finder.rb