@@ -57,15 +57,6 @@ def puts(o = '')
|
|||||||
super(o)
|
super(o)
|
||||||
end
|
end
|
||||||
|
|
||||||
class File
|
|
||||||
# @param [ String ] file_path
|
|
||||||
#
|
|
||||||
# @return [ String ] The charset of the file
|
|
||||||
def self.charset(file_path)
|
|
||||||
%x{file --mime #{file_path}}[%r{charset=([^\n]+)\n}, 1]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
module Terminal
|
module Terminal
|
||||||
class Table
|
class Table
|
||||||
def render
|
def render
|
||||||
|
|||||||
@@ -126,22 +126,15 @@ class WpUser < WpItem
|
|||||||
# Load the passwords from the wordlist, which can be a file path or
|
# Load the passwords from the wordlist, which can be a file path or
|
||||||
# an array or passwords
|
# an array or passwords
|
||||||
#
|
#
|
||||||
# File comments are ignored, but will miss passwords if they start with a hash...
|
|
||||||
#
|
|
||||||
# @param [ String, Array<String> ] wordlist
|
# @param [ String, Array<String> ] wordlist
|
||||||
#
|
#
|
||||||
# @return [ Array<String> ]
|
# @return [ Array<String> ]
|
||||||
def self.passwords_from_wordlist(wordlist)
|
def self.passwords_from_wordlist(wordlist)
|
||||||
if wordlist.is_a?(String)
|
if wordlist.is_a?(String)
|
||||||
passwords = []
|
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|
|
File.open(wordlist).each do |line|
|
||||||
passwords << line.strip
|
passwords << line.chop
|
||||||
end
|
end
|
||||||
elsif wordlist.is_a?(Array)
|
elsif wordlist.is_a?(Array)
|
||||||
passwords = wordlist
|
passwords = wordlist
|
||||||
|
|||||||
@@ -3,4 +3,5 @@ pa55w0rd
|
|||||||
#comment
|
#comment
|
||||||
admin
|
admin
|
||||||
root
|
root
|
||||||
|
spaceafterandbefore
|
||||||
kansei<EFBFBD><EFBFBD>
|
kansei<EFBFBD><EFBFBD>
|
||||||
|
|||||||
@@ -3,4 +3,5 @@ pa55w0rd
|
|||||||
#comment
|
#comment
|
||||||
admin
|
admin
|
||||||
root
|
root
|
||||||
|
spaceafterandbefore
|
||||||
kansei£Ô
|
kansei£Ô
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ shared_examples 'WpUser::BruteForcable' do
|
|||||||
before { Browser.instance.max_threads = 1 }
|
before { Browser.instance.max_threads = 1 }
|
||||||
|
|
||||||
describe '::passwords_from_wordlist' do
|
describe '::passwords_from_wordlist' do
|
||||||
let(:expected) { %w{password1 pa55w0rd #comment admin root kansei£Ô} }
|
let(:expected) { %w{password1 pa55w0rd #comment admin root} << ' spaceafterandbefore ' }
|
||||||
let(:exception) { 'Invalid wordlist, expected String or Array' }
|
let(:exception) { 'Invalid wordlist, expected String or Array' }
|
||||||
|
|
||||||
after do
|
after do
|
||||||
@@ -25,7 +25,7 @@ shared_examples 'WpUser::BruteForcable' do
|
|||||||
let(:wordlist) { wordlist_iso }
|
let(:wordlist) { wordlist_iso }
|
||||||
|
|
||||||
it 'returns the expected passwords' do
|
it 'returns the expected passwords' do
|
||||||
@expected = expected
|
@expected = expected << "kansei\xA3\xD4"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ shared_examples 'WpUser::BruteForcable' do
|
|||||||
let(:wordlist) { wordlist_utf8 }
|
let(:wordlist) { wordlist_utf8 }
|
||||||
|
|
||||||
it 'returns the expected passwords' do
|
it 'returns the expected passwords' do
|
||||||
@expected = expected
|
@expected = expected << 'kansei£Ô'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user