Sha256: 519c9f8fc2370306dafbb167dc1e4a70a40eb4a492e33e9ae404647b22549601

Contents?: true

Size: 1.69 KB

Versions: 24

Compression:

Stored size: 1.69 KB

Contents

# frozen_string_literal: true

module CMSScanner
  module Finders
    module InterestingFindings
      # XML RPC finder
      class XMLRPC < Finder
        # @return [ Array<String> ] The potential urls to the XMl RPC file
        def potential_urls
          @potential_urls ||= []
        end

        # @return [ Array<XMLRPC> ]
        def passive(opts = {})
          [passive_headers(opts), passive_body(opts)].compact
        end

        # @return [ XMLRPC ]
        def passive_headers(_opts = {})
          url = target.homepage_res.headers['X-Pingback']

          return unless target.in_scope?(url)

          potential_urls << url

          NS::Model::XMLRPC.new(url, confidence: 30, found_by: 'Headers (Passive Detection)')
        end

        # @return [ XMLRPC ]
        def passive_body(_opts = {})
          target.homepage_res.html.css('link[rel="pingback"]').each do |tag|
            url = tag.attribute('href').to_s

            next unless target.in_scope?(url)

            potential_urls << url

            return NS::Model::XMLRPC.new(url, confidence: 30, found_by: 'Link Tag (Passive Detection)')
          end
          nil
        end

        # @return [ XMLRPC ]
        def aggressive(_opts = {})
          potential_urls << target.url('xmlrpc.php')

          potential_urls.uniq.each do |potential_url|
            next unless target.in_scope?(potential_url)

            res = NS::Browser.post(potential_url, body: Digest::MD5.hexdigest(rand(999_999).to_s[0..5]))

            next unless /<methodResponse>/i.match?(res&.body)

            return NS::Model::XMLRPC.new(potential_url, confidence: 100, found_by: DIRECT_ACCESS)
          end
          nil
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 3 rubygems

Version Path
cms_scanner-0.14.3 app/finders/interesting_findings/xml_rpc.rb
cms_scanner-0.14.2 app/finders/interesting_findings/xml_rpc.rb
cms_scanner-0.13.9 app/finders/interesting_findings/xml_rpc.rb
cms_scanner-0.13.8 app/finders/interesting_findings/xml_rpc.rb
new_cms_scanner-0.13.7 app/finders/interesting_findings/xml_rpc.rb
k8s_cms_scanner-0.1.0 app/finders/interesting_findings/xml_rpc.rb
cms_scanner-0.13.7 app/finders/interesting_findings/xml_rpc.rb
cms_scanner-0.13.6 app/finders/interesting_findings/xml_rpc.rb
cms_scanner-0.13.5 app/finders/interesting_findings/xml_rpc.rb
cms_scanner-0.13.4 app/finders/interesting_findings/xml_rpc.rb
cms_scanner-0.13.3 app/finders/interesting_findings/xml_rpc.rb
cms_scanner-0.13.2 app/finders/interesting_findings/xml_rpc.rb
cms_scanner-0.13.1 app/finders/interesting_findings/xml_rpc.rb
cms_scanner-0.13.0 app/finders/interesting_findings/xml_rpc.rb
cms_scanner-0.12.2 app/finders/interesting_findings/xml_rpc.rb
cms_scanner-0.12.1 app/finders/interesting_findings/xml_rpc.rb
cms_scanner-0.12.0 app/finders/interesting_findings/xml_rpc.rb
cms_scanner-0.11.0 app/finders/interesting_findings/xml_rpc.rb
cms_scanner-0.10.1 app/finders/interesting_findings/xml_rpc.rb
cms_scanner-0.10.0 app/finders/interesting_findings/xml_rpc.rb