Files

WpUsernames

Public Instance Methods

author_url(author_id) click to toggle source
# File lib/wpscan/modules/wp_usernames.rb, line 49
def author_url(author_id)
  @uri.merge("?author=#{author_id}").to_s
end
usernames(options = {}) click to toggle source

Enumerate wordpress usernames by using Veronica Valeros’s technique: seclists.org/fulldisclosure/2011/May/493

Available options :

:range - default : 1..10

returns an array of usernames (can be empty)

# File lib/wpscan/modules/wp_usernames.rb, line 28
def usernames(options = {})
  range       = options[:range] || (1..10)
  browser     = Browser.instance
  usernames   = []

  range.each do |author_id|
    response = browser.get(author_url(author_id))

    if response.code == 301 # username in location?
      usernames << response.headers_hash['location'][%{/author/([^/]+)/}, 1]
    elsif response.code == 200 # username in body?
      usernames << response.body[%{posts by (.*) feed}, 1]
    end
  end

  # clean the array, remove nils and possible duplicates
  usernames.flatten!
  usernames.compact!
  usernames.uniq
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.