Sha256: 6352b5b51f9863a0dc5c5cc13d39b1de988448735245dfd6762569c1bc56aa96

Contents?: true

Size: 1.58 KB

Versions: 16

Compression:

Stored size: 1.58 KB

Contents

# frozen_string_literal: true

module WPScan
  module Finders
    module Users
      # Author Posts
      class AuthorPosts < CMSScanner::Finders::Finder
        # @param [ Hash ] opts
        #
        # @return [ Array<User> ]
        def passive(opts = {})
          found_by_msg = 'Author Posts - %s (Passive Detection)'

          usernames(opts).reduce([]) do |a, e|
            a << Model::User.new(
              e[0],
              found_by: format(found_by_msg, e[1]),
              confidence: e[2]
            )
          end
        end

        # @param [ Hash ] opts
        #
        # @return [ Array<Array>> ]
        def usernames(_opts = {})
          found = potential_usernames(target.homepage_res)

          return found unless found.empty?

          target.homepage_res.html.css('header.entry-header a').each do |post_url_node|
            url = post_url_node['href']

            next if url.nil? || url.empty?

            found += potential_usernames(Browser.get(url))
          end

          found.compact.uniq
        end

        # @param [ Typhoeus::Response ] res
        #
        # @return [ Array<Array> ]
        def potential_usernames(res)
          usernames = []

          target.in_scope_uris(res, '//a/@href') do |uri, node|
            if uri.path =~ %r{/author/([^/\b]+)/?\z}i
              usernames << [Regexp.last_match[1], 'Author Pattern', 100]
            elsif /author=[0-9]+/.match?(uri.query)
              usernames << [node.text.to_s.strip, 'Display Name', 30]
            end
          end

          usernames.uniq
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
wpscan-3.7.8 app/finders/users/author_posts.rb
wpscan-3.7.7 app/finders/users/author_posts.rb
wpscan-3.7.6 app/finders/users/author_posts.rb
wpscan-3.7.5 app/finders/users/author_posts.rb
wpscan-3.7.4 app/finders/users/author_posts.rb
wpscan-3.7.3 app/finders/users/author_posts.rb
wpscan-3.7.2 app/finders/users/author_posts.rb
wpscan-3.7.1 app/finders/users/author_posts.rb
wpscan-3.7.0 app/finders/users/author_posts.rb
wpscan-3.6.3 app/finders/users/author_posts.rb
wpscan-3.6.2 app/finders/users/author_posts.rb
wpscan-3.6.1 app/finders/users/author_posts.rb
wpscan-3.6.0 app/finders/users/author_posts.rb
wpscan-3.5.5 app/finders/users/author_posts.rb
wpscan-3.5.4 app/finders/users/author_posts.rb
wpscan-3.5.3 app/finders/users/author_posts.rb