diff --git a/lib/common/hacks.rb b/lib/common/hacks.rb index 85d7fb14..47d9c608 100644 --- a/lib/common/hacks.rb +++ b/lib/common/hacks.rb @@ -57,15 +57,6 @@ def puts(o = '') super(o) 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 class Table def render diff --git a/lib/common/models/wp_user/brute_forcable.rb b/lib/common/models/wp_user/brute_forcable.rb index 2f79e469..ad896815 100644 --- a/lib/common/models/wp_user/brute_forcable.rb +++ b/lib/common/models/wp_user/brute_forcable.rb @@ -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 ] wordlist # # @return [ Array ] 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 diff --git a/spec/samples/common/models/wp_user/brute_forcable/wordlist-iso-8859-1.txt b/spec/samples/common/models/wp_user/brute_forcable/wordlist-iso-8859-1.txt index fdae0605..cb4d8f8b 100644 --- a/spec/samples/common/models/wp_user/brute_forcable/wordlist-iso-8859-1.txt +++ b/spec/samples/common/models/wp_user/brute_forcable/wordlist-iso-8859-1.txt @@ -3,4 +3,5 @@ pa55w0rd #comment admin root + spaceafterandbefore kansei£Ô diff --git a/spec/samples/common/models/wp_user/brute_forcable/wordlist-utf-8.txt b/spec/samples/common/models/wp_user/brute_forcable/wordlist-utf-8.txt index 2c164467..98040370 100644 --- a/spec/samples/common/models/wp_user/brute_forcable/wordlist-utf-8.txt +++ b/spec/samples/common/models/wp_user/brute_forcable/wordlist-utf-8.txt @@ -3,4 +3,5 @@ pa55w0rd #comment admin root + spaceafterandbefore kansei£Ô diff --git a/spec/shared_examples/wp_user/brute_forcable.rb b/spec/shared_examples/wp_user/brute_forcable.rb index 7749fc7f..0c41dc52 100644 --- a/spec/shared_examples/wp_user/brute_forcable.rb +++ b/spec/shared_examples/wp_user/brute_forcable.rb @@ -9,7 +9,7 @@ shared_examples 'WpUser::BruteForcable' do before { Browser.instance.max_threads = 1 } 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' } after do @@ -25,7 +25,7 @@ shared_examples 'WpUser::BruteForcable' do let(:wordlist) { wordlist_iso } it 'returns the expected passwords' do - @expected = expected + @expected = expected << "kansei\xA3\xD4" end end @@ -33,7 +33,7 @@ shared_examples 'WpUser::BruteForcable' do let(:wordlist) { wordlist_utf8 } it 'returns the expected passwords' do - @expected = expected + @expected = expected << 'kansei£Ô' end end end