From c0a05a411904b3ae5a7a6254070b24b11186e2cb Mon Sep 17 00:00:00 2001 From: erwanlr Date: Thu, 20 Dec 2012 17:46:06 +0100 Subject: [PATCH] Ref #52 RSS url detection --- lib/wpscan/modules/web_site.rb | 9 +++- .../web_site/rss_url/wordpress-3.5.htm | 42 +++++++++++++++++++ spec/lib/wpscan/modules/web_site_spec.rb | 12 ++++++ 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100755 spec/fixtures/wpscan/modules/web_site/rss_url/wordpress-3.5.htm diff --git a/lib/wpscan/modules/web_site.rb b/lib/wpscan/modules/web_site.rb index 0093f8f4..3ca711a6 100644 --- a/lib/wpscan/modules/web_site.rb +++ b/lib/wpscan/modules/web_site.rb @@ -93,7 +93,7 @@ module WebSite def homepage_hash unless @homepage_hash - @homepage_hash = WebSite.page_hash(self.url) + @homepage_hash = WebSite.page_hash(@uri.to_s) end @homepage_hash end @@ -106,4 +106,11 @@ module WebSite end @error_404_hash end + + # Will try to find the rss url in the homepage + # Only the first one found iw returned + def rss_url + homepage_body = Browser.instance.get(@uri.to_s).body + homepage_body[%r{}, 1] + end end diff --git a/spec/fixtures/wpscan/modules/web_site/rss_url/wordpress-3.5.htm b/spec/fixtures/wpscan/modules/web_site/rss_url/wordpress-3.5.htm new file mode 100755 index 00000000..aa68154c --- /dev/null +++ b/spec/fixtures/wpscan/modules/web_site/rss_url/wordpress-3.5.htm @@ -0,0 +1,42 @@ + + + + + + + + + +Wordpress 3.5 | Just another WordPress site + + + + + + + + + + + + + + + + + + + + + diff --git a/spec/lib/wpscan/modules/web_site_spec.rb b/spec/lib/wpscan/modules/web_site_spec.rb index f057a992..d056f334 100644 --- a/spec/lib/wpscan/modules/web_site_spec.rb +++ b/spec/lib/wpscan/modules/web_site_spec.rb @@ -148,4 +148,16 @@ shared_examples_for "WebSite" do web_site.error_404_hash.should === Digest::MD5.hexdigest("404 page !") end end + + describe "#rss_url" do + it "should return nil if the url is not found" do + stub_request(:get, web_site.url).to_return(:body => "No RSS link in this body !") + web_site.rss_url.should be_nil + end + + it "should return 'http://lamp-wp/wordpress-3.5/?feed=rss2'" do + stub_request_to_fixture(:url => web_site.url, :fixture => fixtures_dir + "/rss_url/wordpress-3.5.htm") + web_site.rss_url.should === "http://lamp-wp/wordpress-3.5/?feed=rss2" + end + end end