diff --git a/lib/wpscan/modules/wp_usernames.rb b/lib/wpscan/modules/wp_usernames.rb index 821eebc0..110d5126 100644 --- a/lib/wpscan/modules/wp_usernames.rb +++ b/lib/wpscan/modules/wp_usernames.rb @@ -45,13 +45,10 @@ module WpUsernames real_name = get_real_name_from_response(response) end - if username == nil and real_name != nil - username = real_name - real_name = nil - end - - unless username == nil - usernames << "id: #{author_id}, name: #{username}#{', real name: ' + real_name if real_name}" + unless username == nil and real_name == nil + usernames << { :id => author_id, + :name => username ? username : "empty", + :real_name => real_name ? real_name : "empty"} end end diff --git a/spec/lib/wpscan/modules/wp_usernames_spec.rb b/spec/lib/wpscan/modules/wp_usernames_spec.rb index 89f4e586..17c9f2f0 100644 --- a/spec/lib/wpscan/modules/wp_usernames_spec.rb +++ b/spec/lib/wpscan/modules/wp_usernames_spec.rb @@ -50,7 +50,9 @@ shared_examples_for "WpUsernames" do usernames = @module.usernames usernames.should_not be_empty usernames.length.should == 1 - usernames[0].should == "id: 3, name: Youhou" + usernames[0][:id].should == 3 + usernames[0][:name].should == "Youhou" + usernames[0][:real_name].should == "empty" end it "should return an array with 1 username (from in the body response)" do @@ -59,16 +61,7 @@ shared_examples_for "WpUsernames" do usernames = @module.usernames(:range => (1..2)) usernames.should_not be_empty - usernames.should === ["id: 2, name: admin, real name: admin | Wordpress 3.3.2"] - end - - it "should return an array with 1 username (testing duplicates)" do - (2..3).each do |id| - stub_request(:get, @module.author_url(id)). - to_return(:status => 200, :body => File.new(@fixtures_dir + '/admin.htm')) - end - - @module.usernames(:range => (1..3)).should === ["admin"] + usernames.should === [{ :id => 2, :name => "admin", :real_name => "admin | Wordpress 3.3.2"}] end it "should return an array with 2 usernames (one is a duplicate and should not be present twice)" do @@ -80,7 +73,9 @@ shared_examples_for "WpUsernames" do usernames = @module.usernames(:range => (1..5)) usernames.should_not be_empty - usernames.sort.should === ["admin", "Youhou"].sort + expected = [{:id => 2, :name =>"admin", :real_name => "admin | Wordpress 3.3.2"}, + {:id => 4, :name => "Youhou", :real_name => "empty"}] + usernames.sort_by { |u| u[:name]}.should === expected.sort_by { |u| u[:name]} end end diff --git a/wpscan.rb b/wpscan.rb index b864ab83..e7bd74d7 100755 --- a/wpscan.rb +++ b/wpscan.rb @@ -322,7 +322,9 @@ begin puts "We found the following #{usernames.length.to_s} username/s :" puts - usernames.each {|username| puts " #{username}"} + usernames.each do |u| + puts " id: #{u[:id]}, name: #{u[:name]}#{', real name: ' + u[:real_name] if u[:real_name]}" + end end else