From 55fa6422b24e34a8ec18453b7c0853a92515212d Mon Sep 17 00:00:00 2001 From: Christian Mehlmauer Date: Sat, 22 Sep 2012 10:19:37 +0200 Subject: [PATCH] rpsec tests --- data/wp_versions.xml | 2 +- lib/wpscan/wp_version.rb | 4 +- .../wpscan/wp_version/advanced/3.2.1.js | 1 + .../wp_version/advanced/wp_versions.xml | 41 +++++++++++++++++++ spec/lib/wpscan/wp_version_spec.rb | 38 +++++++++++++++++ 5 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 spec/fixtures/wpscan/wp_version/advanced/3.2.1.js create mode 100644 spec/fixtures/wpscan/wp_version/advanced/wp_versions.xml diff --git a/data/wp_versions.xml b/data/wp_versions.xml index 7d9f1993..b58eb9a1 100644 --- a/data/wp_versions.xml +++ b/data/wp_versions.xml @@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . ryandewhurst at gmail - +--> + + + + + + 1 + 3.2.1 + + + + 1 + 3.2 + + + diff --git a/spec/lib/wpscan/wp_version_spec.rb b/spec/lib/wpscan/wp_version_spec.rb index 1d987c16..df872d93 100644 --- a/spec/lib/wpscan/wp_version_spec.rb +++ b/spec/lib/wpscan/wp_version_spec.rb @@ -138,4 +138,42 @@ describe WpVersion do end end + describe "#find_from_advanced_fingerprinting" do + let(:fixtures_dir) { SPEC_FIXTURES_WPSCAN_WP_VERSION_DIR + '/advanced' } + + it "should return 3.2.1" do + stub_request_to_fixture(:url => @target_uri.merge("wp-admin/js/wp-fullscreen.js").to_s, + :status => 200, + :fixture => "#{fixtures_dir}/3.2.1.js") + version = WpVersion.find_from_advanced_fingerprinting(:url => @target_uri, + :wp_content_dir => "wp-content", + :version_xml => "#{fixtures_dir}/wp_versions.xml") + version.should == "3.2.1" + end + end + + describe "#initialize" do + it "should initialize a WpVersion object" do + v = WpVersion.new(1, { :discovery_method => "method", :vulns_xml => "asdf.xml" }) + v.number.should == 1 + v.discovery_method.should == "method" + end + end + + describe "#find" do + let(:fixtures_dir) { SPEC_FIXTURES_WPSCAN_WP_VERSION_DIR + '/advanced' } + + it "should find all versions" do + # All requests get a HTTP 404 + stub_request(:any, /.*/).to_return(:status => 404) + # Wordpress Version 3.2.1 + stub_request_to_fixture(:url => @target_uri.merge("wp-admin/js/wp-fullscreen.js").to_s, + :status => 200, + :fixture => "#{fixtures_dir}/3.2.1.js") + version = WpVersion.find(@target_uri, "wp-content") + version.number.should == "3.2.1" + version.discovery_method.should == "advanced fingerprinting" + end + end + end