Parent

WebSite

Attributes

uri[R]

Public Class Methods

new(site_url) click to toggle source
# File lib/wpscan/web_site.rb, line 6
def initialize(site_url)
  self.url = site_url
end
page_hash(url) click to toggle source

Return the MD5 hash of the page given by url

# File lib/wpscan/web_site.rb, line 79
def self.page_hash(url)
  Digest::MD5.hexdigest(Browser.instance.get(url).body)
end

Public Instance Methods

error_404_hash() click to toggle source

Return the MD5 hash of a 404 page

# File lib/wpscan/web_site.rb, line 91
def error_404_hash
  unless @error_404_hash
    non_existant_page = Digest::MD5.hexdigest(rand(999_999_999).to_s) + '.html'
    @error_404_hash   = WebSite.page_hash(@uri.merge(non_existant_page).to_s)
  end
  @error_404_hash
end
has_basic_auth?() click to toggle source
# File lib/wpscan/web_site.rb, line 23
def has_basic_auth?
  Browser.instance.get(@uri.to_s).code == 401
end
has_robots?() click to toggle source

Checks if a robots.txt file exists

# File lib/wpscan/web_site.rb, line 107
def has_robots?
  Browser.instance.get(robots_url).code == 200
end
has_xml_rpc?() click to toggle source
# File lib/wpscan/web_site.rb, line 27
def has_xml_rpc?
  !xml_rpc_url.nil?
end
homepage_hash() click to toggle source
# File lib/wpscan/web_site.rb, line 83
def homepage_hash
  unless @homepage_hash
    @homepage_hash = WebSite.page_hash(@uri.to_s)
  end
  @homepage_hash
end
online?() click to toggle source

Checks if the remote website is up.

# File lib/wpscan/web_site.rb, line 19
def online?
  Browser.instance.get(@uri.to_s).code != 0
end
redirection(url = nil) click to toggle source

See if the remote url returns 30x redirect This method is recursive Return a string with the redirection or nil

# File lib/wpscan/web_site.rb, line 61
def redirection(url = nil)
  redirection = nil
  url ||= @uri.to_s
  response = Browser.instance.get(url)

  if response.code == 301 || response.code == 302
    redirection = response.headers_hash['location']

    # Let's check if there is a redirection in the redirection
    if other_redirection = redirection(redirection)
      redirection = other_redirection
    end
  end

  redirection
end
robots_url() click to toggle source

Gets a robots.txt URL

# File lib/wpscan/web_site.rb, line 112
def robots_url
  robots = @uri.clone
  robots.path = '/robots.txt'
  robots.to_s
end
rss_url() click to toggle source

Will try to find the rss url in the homepage Only the first one found iw returned

# File lib/wpscan/web_site.rb, line 101
def rss_url
  homepage_body = Browser.instance.get(@uri.to_s).body
  homepage_body[%{<link .* type="application/rss\+xml" .* href="([^"]+)" />}, 1]
end
url() click to toggle source
# File lib/wpscan/web_site.rb, line 14
def url
  @uri.to_s
end
url=(url) click to toggle source
# File lib/wpscan/web_site.rb, line 10
def url=(url)
  @uri = URI.parse(add_trailing_slash(add_http_protocol(url)))
end
xml_rpc_url() click to toggle source

See www.hixie.ch/specs/pingback/pingback-1.0#TOC2.3

# File lib/wpscan/web_site.rb, line 32
def xml_rpc_url
  unless @xmlrpc_url
    @xmlrpc_url = xml_rpc_url_from_headers() || xml_rpc_url_from_body()
  end
  @xmlrpc_url
end
xml_rpc_url_from_body() click to toggle source
# File lib/wpscan/web_site.rb, line 52
def xml_rpc_url_from_body
  body = Browser.instance.get(@uri.to_s).body

  body[%{<link rel="pingback" href="([^"]+)" ?\/?>}, 1]
end
xml_rpc_url_from_headers() click to toggle source
# File lib/wpscan/web_site.rb, line 39
def xml_rpc_url_from_headers
  headers    = Browser.instance.get(@uri.to_s).headers_hash
  xmlrpc_url = nil

  unless headers.nil?
    pingback_url = headers['X-Pingback']
    unless pingback_url.nil? || pingback_url.empty?
      xmlrpc_url = pingback_url
    end
  end
  xmlrpc_url
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.