From 133465c05e7a93efd5f9dbcdc8715924d784fe98 Mon Sep 17 00:00:00 2001 From: Christian Mehlmauer Date: Thu, 20 Sep 2012 22:53:37 +0200 Subject: [PATCH] they are nicknames rdoc --- doc/Array.html | 2 +- doc/Malwares.html | 7 +- doc/Object.html | 57 ++++++++- doc/WpDetector.html | 2 +- doc/WpTarget.html | 16 +-- doc/WpUsernames.html | 125 +++++++++++++------ doc/created.rid | 16 +-- doc/index.html | 64 +++++----- doc/lib/common_helper_rb.html | 2 +- doc/lib/environment_rb.html | 2 +- doc/lib/wpscan/modules/malwares_rb.html | 2 +- doc/lib/wpscan/modules/wp_usernames_rb.html | 2 +- doc/lib/wpscan/wp_detector_rb.html | 2 +- doc/lib/wpscan/wp_target_rb.html | 2 +- doc/wpscan_rb.html | 2 +- lib/wpscan/modules/wp_usernames.rb | 44 +++---- spec/lib/wpscan/modules/wp_usernames_spec.rb | 8 +- wpscan.rb | 6 +- 18 files changed, 235 insertions(+), 126 deletions(-) diff --git a/doc/Array.html b/doc/Array.html index f67b8512..c8e26238 100644 --- a/doc/Array.html +++ b/doc/Array.html @@ -226,7 +226,7 @@
-# File lib/common_helper.rb, line 57
+# File lib/common_helper.rb, line 82
 def _grep_(regexp)
   matches = []
   self.each do |value|
diff --git a/doc/Malwares.html b/doc/Malwares.html
index d75003bd..be23e15a 100644
--- a/doc/Malwares.html
+++ b/doc/Malwares.html
@@ -209,7 +209,7 @@
           
           
malware_pattern(url) + class="method-args">(url_regex) click to toggle source
@@ -223,8 +223,9 @@
 # File lib/wpscan/modules/malwares.rb, line 56
-def self.malware_pattern(url)
-  %{<(?:script|iframe).* src=(?:"|')(#{url}[^"']*)(?:"|')[^>]*>}
+def self.malware_pattern(url_regex)
+  # no need to escape regex here, because malware.txt contains regex
+  %{<(?:script|iframe).* src=(?:"|')(#{url_regex}[^"']*)(?:"|')[^>]*>}
 end
diff --git a/doc/Object.html b/doc/Object.html index 570500e4..1dca7c67 100644 --- a/doc/Object.html +++ b/doc/Object.html @@ -77,6 +77,8 @@
  • #banner
  • +
  • #get_equal_string_end
  • +
  • #help
  • #require_files_from_directory
  • @@ -368,7 +370,7 @@ +
    + + + +
    + get_equal_string_end(stringarray = [""]) + click to toggle source +
    + + +
    + +

    Gets the string all elements in stringarray ends with

    + + + +
    +
    +# File lib/common_helper.rb, line 55
    +def get_equal_string_end(stringarray = [""])
    +  already_found = ""
    +  looping = true
    +  counter = -1
    +  if stringarray.kind_of? Array and stringarray.length > 1
    +    base = stringarray[0]
    +    while looping
    +      character = base[counter, 1]
    +      stringarray.each do |s|
    +        if s[counter, 1] != character
    +          looping = false
    +          break
    +        end
    +      end
    +      if looping == false or (counter * -1 ) >= base.length
    +        break
    +      end
    +      already_found = "#{character if character}#{already_found}"
    +      counter -= 1
    +    end
    +  end
    +  already_found
    +end
    +
    + +
    + + + + +
    + +
    diff --git a/doc/WpDetector.html b/doc/WpDetector.html index 854015dd..761ed08f 100644 --- a/doc/WpDetector.html +++ b/doc/WpDetector.html @@ -292,7 +292,7 @@ regex2 = %{\\?/} regex3 = %{\\?/([^/\\"']+)\\?(?:/|"|')} # Custom wp-content dir is now used in this regex - names = response.body.scan(/#{regex1}#{wp_content_dir}#{regex2}#{type}#{regex3}/) + names = response.body.scan(/#{regex1}#{Regexp.escape(wp_content_dir)}#{regex2}#{Regexp.escape(type)}#{regex3}/) names.flatten! names.uniq! diff --git a/doc/WpTarget.html b/doc/WpTarget.html index 40bdee3e..082fd8e2 100644 --- a/doc/WpTarget.html +++ b/doc/WpTarget.html @@ -414,7 +414,7 @@
    -# File lib/wpscan/wp_target.rb, line 116
    +# File lib/wpscan/wp_target.rb, line 118
     def debug_log_url
       @uri.merge("#{wp_content_dir()}/debug.log").to_s
     end
    @@ -488,7 +488,7 @@
    -# File lib/wpscan/wp_target.rb, line 110
    +# File lib/wpscan/wp_target.rb, line 112
     def has_debug_log?
       # We only get the first 700 bytes of the file to avoid loading huge file (like 2Go)
       response_body = Browser.instance.get(debug_log_url(), :headers => { "range" => "bytes=0-700"}).body
    @@ -564,7 +564,7 @@
                 
                 
    -# File lib/wpscan/wp_target.rb, line 121
    +# File lib/wpscan/wp_target.rb, line 123
     def registration_enabled?
       # TODO
     end
    @@ -597,7 +597,7 @@
    -# File lib/wpscan/wp_target.rb, line 125
    +# File lib/wpscan/wp_target.rb, line 127
     def registration_url
       # TODO
     end
    @@ -733,11 +733,13 @@ def wp_content_dir unless @wp_content_dir index_body = Browser.instance.get(@uri.to_s).body + # Only use the path because domain can be text or an ip + uri_path = @uri.path - if index_body[%{/wp-content/(?:themes|plugins)/}] + if index_body[/#{Regexp.escape(uri_path)}\/wp-content\/(?:themes|plugins)\//] @wp_content_dir = "wp-content" else - @wp_content_dir = index_body[%{(?:href|src)=(?:"|')#{@uri}/?([^"']+)/(?:themes|plugins)/.*(?:"|')}, 1] + @wp_content_dir = index_body[/(?:href|src)\s*=\s*(?:"|').+#{Regexp.escape(uri_path)}([^"']+)\/(?:themes|plugins)\/.*(?:"|')/, 1] end end @wp_content_dir @@ -771,7 +773,7 @@
    -# File lib/wpscan/wp_target.rb, line 103
    +# File lib/wpscan/wp_target.rb, line 105
     def wp_plugins_dir
       unless @wp_plugins_dir
         @wp_plugins_dir = wp_content_dir() + "/plugins"
    diff --git a/doc/WpUsernames.html b/doc/WpUsernames.html
    index 68421de0..0b42814f 100644
    --- a/doc/WpUsernames.html
    +++ b/doc/WpUsernames.html
    @@ -59,11 +59,13 @@
               
               
  • #author_url
  • -
  • #extract_real_name_from_body
  • +
  • #extract_nickname_from_body
  • -
  • #get_real_name_from_response
  • +
  • #get_nickname_from_response
  • -
  • #get_real_name_from_url
  • +
  • #get_nickname_from_url
  • + +
  • #remove_junk_from_nickname
  • #usernames
  • @@ -224,7 +226,7 @@
    -# File lib/wpscan/modules/wp_usernames.rb, line 82
    +# File lib/wpscan/modules/wp_usernames.rb, line 98
     def author_url(author_id)
       @uri.merge("?author=#{author_id}").to_s
     end
    @@ -238,12 +240,12 @@
    -
    - +
    +
    - extract_real_name_from_bodyextract_nickname_from_body(body) click to toggle source
    @@ -255,28 +257,28 @@ -
    +
    -# File lib/wpscan/modules/wp_usernames.rb, line 78
    -def extract_real_name_from_body(body)
    +# File lib/wpscan/modules/wp_usernames.rb, line 79
    +def extract_nickname_from_body(body)
       body[%{<title>([^<]*)</title>}, 1]
     end
    -
    +
    -
    +
    -
    - +
    +
    - get_real_name_from_responseget_nickname_from_response(resp) click to toggle source
    @@ -288,32 +290,32 @@ -
    +
    -# File lib/wpscan/modules/wp_usernames.rb, line 70
    -def get_real_name_from_response(resp)
    -  real_name = nil
    +# File lib/wpscan/modules/wp_usernames.rb, line 71
    +def get_nickname_from_response(resp)
    +  nickname = nil
       if resp.code == 200
    -    real_name = extract_real_name_from_body(resp.body)
    +    nickname = extract_nickname_from_body(resp.body)
       end
    -  real_name
    +  nickname
     end
    -
    +
    -
    +
    -
    - +
    +
    - get_real_name_from_urlget_nickname_from_url(url) click to toggle source
    @@ -325,25 +327,69 @@ -
    +
    -# File lib/wpscan/modules/wp_usernames.rb, line 61
    -def get_real_name_from_url(url)
    +# File lib/wpscan/modules/wp_usernames.rb, line 62
    +def get_nickname_from_url(url)
       resp = Browser.instance.get(url, { :follow_location => true, :max_redirects => 2 })
    -  real_name = nil
    +  nickname = nil
       if resp.code == 200
    -    real_name = extract_real_name_from_body(resp.body)
    +    nickname = extract_nickname_from_body(resp.body)
       end
    -  real_name
    +  nickname
     end
    -
    +
    -
    +
    + + +
    + + + +
    + remove_junk_from_nickname(usernames) + click to toggle source +
    + + +
    + + + + + +
    +
    +# File lib/wpscan/modules/wp_usernames.rb, line 83
    +def remove_junk_from_nickname(usernames)
    +  nicknames = []
    +  usernames.each do |u|
    +    nickname = u[:nickname]
    +    unless nickname == "empty"
    +      nicknames << nickname
    +    end
    +  end
    +  junk = get_equal_string_end(nicknames)
    +  usernames.each do |u|
    +    u[:nickname] = u[:nickname].sub(/#{Regexp.escape(junk)}$/, "")
    +  end
    +  usernames
    +end
    +
    + +
    + + + + +
    @@ -383,22 +429,23 @@ href="http://seclists.org/fulldisclosure/2011/May/493">seclists.org/fulldisclosu response = browser.get(url) username = nil - real_name = nil + nickname = nil if response.code == 301 # username in location? username = response.headers_hash['location'][%{/author/([^/]+)/}, 1] # Get the real name from the redirect site - real_name = get_real_name_from_url(url) + nickname = get_nickname_from_url(url) elsif response.code == 200 # username in body? username = response.body[%{posts by (.*) feed}, 1] - real_name = get_real_name_from_response(response) + nickname = get_nickname_from_response(response) end - unless username == nil and real_name == nil + unless username == nil and nickname == nil usernames << { :id => author_id, :name => username ? username : "empty", - :real_name => real_name ? real_name : "empty"} + :nickname => nickname ? nickname : "empty"} end end + usernames = remove_junk_from_nickname(usernames) # clean the array, remove nils and possible duplicates usernames.flatten! diff --git a/doc/created.rid b/doc/created.rid index d6dc4763..07371c27 100644 --- a/doc/created.rid +++ b/doc/created.rid @@ -1,16 +1,16 @@ -Wed, 19 Sep 2012 22:43:09 +0200 +Thu, 20 Sep 2012 22:51:52 +0200 ./CREDITS Mon, 17 Sep 2012 20:18:24 +0200 ./lib/browser.rb Sun, 16 Sep 2012 15:18:58 +0200 ./lib/cache_file_store.rb Sat, 15 Sep 2012 08:04:03 +0200 -./lib/common_helper.rb Tue, 18 Sep 2012 20:09:48 +0200 -./lib/environment.rb Sat, 15 Sep 2012 08:04:16 +0200 +./lib/common_helper.rb Thu, 20 Sep 2012 22:01:50 +0200 +./lib/environment.rb Thu, 20 Sep 2012 22:12:57 +0200 ./lib/updater/git_updater.rb Sat, 15 Sep 2012 08:00:23 +0200 ./lib/updater/svn_updater.rb Sat, 15 Sep 2012 08:00:34 +0200 ./lib/updater/updater.rb Sat, 15 Sep 2012 08:00:40 +0200 ./lib/updater/updater_factory.rb Sat, 15 Sep 2012 08:00:46 +0200 ./lib/wpscan/exploit.rb Sat, 15 Sep 2012 08:02:16 +0200 ./lib/wpscan/modules/brute_force.rb Wed, 19 Sep 2012 21:41:41 +0200 -./lib/wpscan/modules/malwares.rb Sat, 15 Sep 2012 08:01:01 +0200 +./lib/wpscan/modules/malwares.rb Thu, 20 Sep 2012 22:23:58 +0200 ./lib/wpscan/modules/web_site.rb Wed, 19 Sep 2012 21:33:46 +0200 ./lib/wpscan/modules/wp_config_backup.rb Sat, 15 Sep 2012 08:01:11 +0200 ./lib/wpscan/modules/wp_full_path_disclosure.rb Sat, 15 Sep 2012 08:01:17 +0200 @@ -19,15 +19,15 @@ Wed, 19 Sep 2012 22:43:09 +0200 ./lib/wpscan/modules/wp_readme.rb Sat, 15 Sep 2012 08:01:52 +0200 ./lib/wpscan/modules/wp_themes.rb Tue, 18 Sep 2012 22:28:05 +0200 ./lib/wpscan/modules/wp_timthumbs.rb Wed, 19 Sep 2012 15:03:22 +0200 -./lib/wpscan/modules/wp_usernames.rb Wed, 19 Sep 2012 22:09:14 +0200 +./lib/wpscan/modules/wp_usernames.rb Thu, 20 Sep 2012 22:51:18 +0200 ./lib/wpscan/msfrpc_client.rb Sat, 15 Sep 2012 08:02:28 +0200 ./lib/wpscan/vulnerable.rb Wed, 19 Sep 2012 22:21:47 +0200 -./lib/wpscan/wp_detector.rb Wed, 19 Sep 2012 22:29:50 +0200 +./lib/wpscan/wp_detector.rb Thu, 20 Sep 2012 22:14:29 +0200 ./lib/wpscan/wp_enumerator.rb Wed, 19 Sep 2012 22:30:45 +0200 ./lib/wpscan/wp_item.rb Wed, 19 Sep 2012 22:21:19 +0200 ./lib/wpscan/wp_options.rb Tue, 18 Sep 2012 22:28:27 +0200 ./lib/wpscan/wp_plugin.rb Wed, 19 Sep 2012 22:20:29 +0200 -./lib/wpscan/wp_target.rb Wed, 19 Sep 2012 17:40:16 +0200 +./lib/wpscan/wp_target.rb Thu, 20 Sep 2012 22:16:44 +0200 ./lib/wpscan/wp_theme.rb Wed, 19 Sep 2012 22:20:40 +0200 ./lib/wpscan/wp_version.rb Wed, 19 Sep 2012 21:33:07 +0200 ./lib/wpscan/wp_vulnerability.rb Sat, 15 Sep 2012 08:03:09 +0200 @@ -37,5 +37,5 @@ Wed, 19 Sep 2012 22:43:09 +0200 ./lib/wpstools/parse_svn.rb Sat, 15 Sep 2012 23:36:25 +0200 ./lib/wpstools/wpstools_helper.rb Sat, 15 Sep 2012 08:03:49 +0200 ./README Thu, 13 Sep 2012 22:54:08 +0200 -./wpscan.rb Wed, 19 Sep 2012 22:06:17 +0200 +./wpscan.rb Thu, 20 Sep 2012 22:49:19 +0200 ./wpstools.rb Sat, 15 Sep 2012 08:06:35 +0200 diff --git a/doc/index.html b/doc/index.html index b06908a3..87a16f7c 100644 --- a/doc/index.html +++ b/doc/index.html @@ -173,20 +173,20 @@
  • ::new — RpcClient
  • -
  • ::new — Updater
  • -
  • ::new — Svn_Parser
  • -
  • ::new — WpTheme
  • - -
  • ::new — WpTarget
  • - -
  • ::new — WpPlugin
  • -
  • ::new — Generate_List
  • +
  • ::new — WpTheme
  • +
  • ::new — Exploit
  • +
  • ::new — WpPlugin
  • + +
  • ::new — WpTarget
  • + +
  • ::new — Updater
  • +
  • ::option_to_instance_variable_setter — WpscanOptions
  • ::passive_detection — WpDetector
  • @@ -259,7 +259,7 @@
  • #extract_name_from_url — WpItem
  • -
  • #extract_real_name_from_body — WpUsernames
  • +
  • #extract_nickname_from_body — WpUsernames
  • #forge_request — Browser
  • @@ -273,18 +273,20 @@
  • #get_entry_file_path — CacheFileStore
  • +
  • #get_equal_string_end — Object
  • +
  • #get_exploit_info — RpcClient
  • +
  • #get_nickname_from_response — WpUsernames
  • + +
  • #get_nickname_from_url — WpUsernames
  • +
  • #get_options — RpcClient
  • #get_payloads — RpcClient
  • #get_popular_items — Generate_List
  • -
  • #get_real_name_from_response — WpUsernames
  • - -
  • #get_real_name_from_url — WpUsernames
  • -
  • #get_url — WpItem
  • #get_url_without_filename — WpItem
  • @@ -315,10 +317,10 @@
  • #has_options? — WpscanOptions
  • -
  • #has_readme? — WpItem
  • -
  • #has_readme? — WpReadme
  • +
  • #has_readme? — WpItem
  • +
  • #has_simple_login_lockdown_protection? — WpLoginProtection
  • #has_timthumbs? — WpTimthumbs
  • @@ -327,10 +329,10 @@
  • #is_installed? — SvnUpdater
  • -
  • #is_installed? — GitUpdater
  • -
  • #is_installed? — Updater
  • +
  • #is_installed? — GitUpdater
  • +
  • #is_online? — WebSite
  • #is_wordpress? — WebSite
  • @@ -349,12 +351,12 @@
  • #load_config — Browser
  • -
  • #local_revision_number — GitUpdater
  • -
  • #local_revision_number — SvnUpdater
  • #local_revision_number — Updater
  • +
  • #local_revision_number — GitUpdater
  • +
  • #login — RpcClient
  • #login_protection_plugin — WpLoginProtection
  • @@ -373,10 +375,10 @@
  • #meterpreter_read — RpcClient
  • -
  • #meterpreter_write — Exploit
  • -
  • #meterpreter_write — RpcClient
  • +
  • #meterpreter_write — Exploit
  • +
  • #parse — Svn_Parser
  • #plugins_from_aggressive_detection — WpPlugins
  • @@ -391,20 +393,22 @@
  • #read_entry — CacheFileStore
  • -
  • #read_shell — Exploit
  • -
  • #read_shell — RpcClient
  • -
  • #readme_url — WpReadme
  • +
  • #read_shell — Exploit
  • #readme_url — WpItem
  • +
  • #readme_url — WpReadme
  • +
  • #redirection — WebSite
  • #registration_enabled? — WpTarget
  • #registration_url — WpTarget
  • +
  • #remove_junk_from_nickname — WpUsernames
  • +
  • #repo_directory_arguments — GitUpdater
  • #require_files_from_directory — Object
  • @@ -413,10 +417,10 @@
  • #session_count — Exploit
  • -
  • #sessions — Exploit
  • -
  • #sessions — RpcClient
  • +
  • #sessions — Exploit
  • +
  • #set_option_from_cli — WpscanOptions
  • #simple_login_lockdown_url — WpLoginProtection
  • @@ -439,11 +443,11 @@
  • #to_s — WpItem
  • -
  • #update — Updater
  • +
  • #update — GitUpdater
  • #update — SvnUpdater
  • -
  • #update — GitUpdater
  • +
  • #update — Updater
  • #url — WpTarget
  • @@ -471,10 +475,10 @@
  • #write_entry — CacheFileStore
  • -
  • #write_shell — Exploit
  • -
  • #write_shell — RpcClient
  • +
  • #write_shell — Exploit
  • +
  • #xmlrpc_url — WebSite
  • diff --git a/doc/lib/common_helper_rb.html b/doc/lib/common_helper_rb.html index 4a301e36..84010c5f 100644 --- a/doc/lib/common_helper_rb.html +++ b/doc/lib/common_helper_rb.html @@ -24,7 +24,7 @@
    Last Modified
    -
    2012-09-18 20:09:48 +0200
    +
    2012-09-20 22:01:50 +0200
    Requires
    diff --git a/doc/lib/environment_rb.html b/doc/lib/environment_rb.html index ebcdbf94..4b713387 100644 --- a/doc/lib/environment_rb.html +++ b/doc/lib/environment_rb.html @@ -24,7 +24,7 @@
    Last Modified
    -
    2012-09-15 08:04:16 +0200
    +
    2012-09-20 22:12:57 +0200
    Requires
    diff --git a/doc/lib/wpscan/modules/malwares_rb.html b/doc/lib/wpscan/modules/malwares_rb.html index 2980e23b..990f764a 100644 --- a/doc/lib/wpscan/modules/malwares_rb.html +++ b/doc/lib/wpscan/modules/malwares_rb.html @@ -24,7 +24,7 @@
    Last Modified
    -
    2012-09-15 08:01:01 +0200
    +
    2012-09-20 22:23:58 +0200
    Requires
    diff --git a/doc/lib/wpscan/modules/wp_usernames_rb.html b/doc/lib/wpscan/modules/wp_usernames_rb.html index 3e5d3cd9..7ef6e513 100644 --- a/doc/lib/wpscan/modules/wp_usernames_rb.html +++ b/doc/lib/wpscan/modules/wp_usernames_rb.html @@ -24,7 +24,7 @@
    Last Modified
    -
    2012-09-19 22:09:14 +0200
    +
    2012-09-20 22:51:18 +0200
    Requires
    diff --git a/doc/lib/wpscan/wp_detector_rb.html b/doc/lib/wpscan/wp_detector_rb.html index cdf9b6eb..a4e21806 100644 --- a/doc/lib/wpscan/wp_detector_rb.html +++ b/doc/lib/wpscan/wp_detector_rb.html @@ -24,7 +24,7 @@
    Last Modified
    -
    2012-09-19 22:29:50 +0200
    +
    2012-09-20 22:14:29 +0200
    Requires
    diff --git a/doc/lib/wpscan/wp_target_rb.html b/doc/lib/wpscan/wp_target_rb.html index ceb525f7..49db64bb 100644 --- a/doc/lib/wpscan/wp_target_rb.html +++ b/doc/lib/wpscan/wp_target_rb.html @@ -24,7 +24,7 @@
    Last Modified
    -
    2012-09-19 17:40:16 +0200
    +
    2012-09-20 22:16:44 +0200
    Requires
    diff --git a/doc/wpscan_rb.html b/doc/wpscan_rb.html index bd4bb22f..b8a7434f 100644 --- a/doc/wpscan_rb.html +++ b/doc/wpscan_rb.html @@ -24,7 +24,7 @@
    Last Modified
    -
    2012-09-19 22:06:17 +0200
    +
    2012-09-20 22:49:19 +0200
    Requires
    diff --git a/lib/wpscan/modules/wp_usernames.rb b/lib/wpscan/modules/wp_usernames.rb index e9178ac4..9ff66110 100644 --- a/lib/wpscan/modules/wp_usernames.rb +++ b/lib/wpscan/modules/wp_usernames.rb @@ -35,23 +35,23 @@ module WpUsernames response = browser.get(url) username = nil - real_name = nil + nickname = nil if response.code == 301 # username in location? username = response.headers_hash['location'][%r{/author/([^/]+)/}i, 1] # Get the real name from the redirect site - real_name = get_real_name_from_url(url) + nickname = get_nickname_from_url(url) elsif response.code == 200 # username in body? username = response.body[%r{posts by (.*) feed}i, 1] - real_name = get_real_name_from_response(response) + nickname = get_nickname_from_response(response) end - unless username == nil and real_name == nil + unless username == nil and nickname == nil usernames << { :id => author_id, :name => username ? username : "empty", - :real_name => real_name ? real_name : "empty"} + :nickname => nickname ? nickname : "empty"} end end - usernames = remove_junk_from_real_name(usernames) + usernames = remove_junk_from_nickname(usernames) # clean the array, remove nils and possible duplicates usernames.flatten! @@ -59,38 +59,38 @@ module WpUsernames usernames.uniq end - def get_real_name_from_url(url) + def get_nickname_from_url(url) resp = Browser.instance.get(url, { :follow_location => true, :max_redirects => 2 }) - real_name = nil + nickname = nil if resp.code == 200 - real_name = extract_real_name_from_body(resp.body) + nickname = extract_nickname_from_body(resp.body) end - real_name + nickname end - def get_real_name_from_response(resp) - real_name = nil + def get_nickname_from_response(resp) + nickname = nil if resp.code == 200 - real_name = extract_real_name_from_body(resp.body) + nickname = extract_nickname_from_body(resp.body) end - real_name + nickname end - def extract_real_name_from_body(body) + def extract_nickname_from_body(body) body[%r{([^<]*)}i, 1] end - def remove_junk_from_real_name(usernames) - real_names = [] + def remove_junk_from_nickname(usernames) + nicknames = [] usernames.each do |u| - real_name = u[:real_name] - unless real_name == "empty" - real_names << real_name + nickname = u[:nickname] + unless nickname == "empty" + nicknames << nickname end end - junk = get_equal_string_end(real_names) + junk = get_equal_string_end(nicknames) usernames.each do |u| - u[:real_name] = u[:real_name].sub(/#{Regexp.escape(junk)}$/, "") + u[:nickname] = u[:nickname].sub(/#{Regexp.escape(junk)}$/, "") end usernames end diff --git a/spec/lib/wpscan/modules/wp_usernames_spec.rb b/spec/lib/wpscan/modules/wp_usernames_spec.rb index 17c9f2f0..193e4f3c 100644 --- a/spec/lib/wpscan/modules/wp_usernames_spec.rb +++ b/spec/lib/wpscan/modules/wp_usernames_spec.rb @@ -52,7 +52,7 @@ shared_examples_for "WpUsernames" do usernames.length.should == 1 usernames[0][:id].should == 3 usernames[0][:name].should == "Youhou" - usernames[0][:real_name].should == "empty" + usernames[0][:nickname].should == "empty" end it "should return an array with 1 username (from in the body response)" do @@ -61,7 +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"}] + usernames.should === [{ :id => 2, :name => "admin", :nickname => "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 @@ -73,8 +73,8 @@ shared_examples_for "WpUsernames" do usernames = @module.usernames(:range => (1..5)) usernames.should_not be_empty - expected = [{:id => 2, :name =>"admin", :real_name => "admin | Wordpress 3.3.2"}, - {:id => 4, :name => "Youhou", :real_name => "empty"}] + expected = [{:id => 2, :name =>"admin", :nickname => "admin | Wordpress 3.3.2"}, + {:id => 4, :name => "Youhou", :nickname => "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 f5864c15..76a534de 100755 --- a/wpscan.rb +++ b/wpscan.rb @@ -324,14 +324,14 @@ begin max_id_length = usernames.sort{|a,b| a[:id] <=> b[:id]}.last[:id].to_s.length max_name_length = usernames.sort{|a,b| a[:name] <=> b[:name]}.last[:name].length - max_real_name_length = usernames.sort{|a,b| a[:real_name] <=> b[:real_name]}.last[:real_name].length + max_nickname_length = usernames.sort{|a,b| a[:nickname] <=> b[:nickname]}.last[:nickname].length space = 1 usernames.each do |u| id_string = "id: #{u[:id].to_s.ljust(max_id_length + space)}" name_string = "name: #{u[:name].ljust(max_name_length + space)}" - real_name_string = "real_name: #{u[:real_name].ljust(max_real_name_length + space)}" - puts " | #{id_string}| #{name_string}| #{real_name_string}" + nickname_string = "nickname: #{u[:nickname].ljust(max_nickname_length + space)}" + puts " | #{id_string}| #{name_string}| #{nickname_string}" end end