diff --git a/lib/wpscan/vulnerable.rb b/lib/wpscan/vulnerable.rb index b4bacfbc..440ee590 100644 --- a/lib/wpscan/vulnerable.rb +++ b/lib/wpscan/vulnerable.rb @@ -30,9 +30,9 @@ class Vulnerable xml.xpath(@vulns_xpath).each do |node| vulnerabilities << WpVulnerability.new( - node.search('title').text, - node.search('reference').text, - node.search('type').text + node.search("title").text, + node.search("reference").text, + node.search("type").text ) end vulnerabilities diff --git a/lib/wpscan/wp_item.rb b/lib/wpscan/wp_item.rb index a685e8e8..9bbeacbe 100644 --- a/lib/wpscan/wp_item.rb +++ b/lib/wpscan/wp_item.rb @@ -28,7 +28,7 @@ class WpItem < Vulnerable @path = options[:path] @name = options[:name] || extract_name_from_url @vulns_xml = options[:vulns_xml] - @vulns_xpath = options[:vulns_xpath] + @vulns_xpath = options[:vulns_xpath].sub(/\$name\$/, @name) raise("url not set") unless @url raise("path not set") unless @path diff --git a/lib/wpscan/wp_plugin.rb b/lib/wpscan/wp_plugin.rb index 3475f731..e94bed61 100644 --- a/lib/wpscan/wp_plugin.rb +++ b/lib/wpscan/wp_plugin.rb @@ -19,7 +19,7 @@ class WpPlugin < WpItem def initialize(options = {}) options[:vulns_xml] = options[:vulns_xml] || DATA_DIR + '/plugin_vulns.xml' - options[:vulns_xpath] = "//plugin[@name='#@name']/vulnerability" + options[:vulns_xpath] = "//plugin[@name='$name$']/vulnerability" options[:vulns_xpath_2] = "//plugin" options[:type] = "plugins" super(options) diff --git a/lib/wpscan/wp_theme.rb b/lib/wpscan/wp_theme.rb index a5c65079..7e7c2d95 100644 --- a/lib/wpscan/wp_theme.rb +++ b/lib/wpscan/wp_theme.rb @@ -24,7 +24,7 @@ class WpTheme < WpItem def initialize(options = {}) options[:vulns_xml] = options[:vulns_xml] || DATA_DIR + '/wp_theme_vulns.xml' - options[:vulns_xpath] = "//theme[@name='#@name']/vulnerability" + options[:vulns_xpath] = "//theme[@name='$name$']/vulnerability" @version = options[:version] @style_url = options[:style_url] super(options) diff --git a/spec/lib/wpscan/wp_item_spec.rb b/spec/lib/wpscan/wp_item_spec.rb index 59b47bdc..0293a3fd 100644 --- a/spec/lib/wpscan/wp_item_spec.rb +++ b/spec/lib/wpscan/wp_item_spec.rb @@ -22,7 +22,9 @@ describe WpPlugin do before :each do @instance = WpItem.new(:url => "http://sub.example.com/path/to/wordpress/", :path => "plugins/test/asdf.php", - :vulns_xml => "XXX.xml" + :vulns_xml => "XXX.xml", + :name => "test", + :vulns_xpath => "XX" ) end @@ -174,7 +176,8 @@ describe WpPlugin do it "should return false" do instance2 = WpItem.new(:url => "http://sub.example.com/path/to/wordpress/", :path => "plugins/newname/asdf.php", - :vulns_xml => "XXX.xml" + :vulns_xml => "XXX.xml", + :vulns_xpath => "XX" ) (@instance==instance2).should == false end @@ -182,7 +185,8 @@ describe WpPlugin do it "should return true" do instance2 = WpItem.new(:url => "http://sub.example.com/path/to/wordpress/", :path => "plugins/test/asdf.php", - :vulns_xml => "XXX.xml" + :vulns_xml => "XXX.xml", + :vulns_xpath => "XX" ) (@instance==instance2).should == true end diff --git a/spec/lib/wpscan/wp_vulnerability_spec.rb b/spec/lib/wpscan/wp_vulnerability_spec.rb index 536dfbe6..7c646f1a 100644 --- a/spec/lib/wpscan/wp_vulnerability_spec.rb +++ b/spec/lib/wpscan/wp_vulnerability_spec.rb @@ -1,9 +1,9 @@ # TODO describe "#vulnerabilities" do - let(:location_url) { 'http://example.localhost/' } - let(:fixtures_dir) { SPEC_FIXTURES_WPSCAN_WP_PLUGIN_DIR + '/vulnerabilities' } - let(:vulns_xml) { fixtures_dir + '/plugin_vulns.xml' } + let(:location_url) { "http://example.localhost/" } + let(:fixtures_dir) { SPEC_FIXTURES_WPSCAN_WP_PLUGIN_DIR + "/vulnerabilities" } + let(:vulns_xml) { fixtures_dir + "/plugin_vulns.xml" } let(:wp_plugin) { WpPlugin.new(:url => location_url, :name => "spec-plugin", :path => "plugins/spec-plugin/", @@ -24,7 +24,7 @@ describe "#vulnerabilities" do vulnerabilities.should_not be_empty vulnerabilities.length.should == 2 vulnerabilities.each { |vulnerability| vulnerability.should be_a WpVulnerability } - vulnerabilities[0].title.should === 'WPScan Spec' - vulnerabilities[1].title.should === 'Spec SQL Injection' + vulnerabilities[0].title.should === "WPScan Spec" + vulnerabilities[1].title.should === "Spec SQL Injection" end end \ No newline at end of file