This commit is contained in:
erwanlr
2013-10-02 15:36:02 +01:00
parent 8adfcf5866
commit f4460f315e
5 changed files with 7 additions and 21 deletions

View File

@@ -126,22 +126,15 @@ class WpUser < WpItem
# Load the passwords from the wordlist, which can be a file path or
# an array or passwords
#
# File comments are ignored, but will miss passwords if they start with a hash...
#
# @param [ String, Array<String> ] wordlist
#
# @return [ Array<String> ]
def self.passwords_from_wordlist(wordlist)
if wordlist.is_a?(String)
passwords = []
charset = File.charset(wordlist).upcase
opt = "r:#{charset}"
# To remove warning when charset = UTF-8
# Ignoring internal encoding UTF-8: it is identical to external encoding utf-8
opt += ':UTF-8' if charset != 'UTF-8'
File.open(wordlist, opt).each do |line|
passwords << line.strip
File.open(wordlist).each do |line|
passwords << line.chop
end
elsif wordlist.is_a?(Array)
passwords = wordlist