diff --git a/lib/metasploit/framework/jtr/wordlist.rb b/lib/metasploit/framework/jtr/wordlist.rb index 747859bb5b..5b779b4000 100644 --- a/lib/metasploit/framework/jtr/wordlist.rb +++ b/lib/metasploit/framework/jtr/wordlist.rb @@ -369,12 +369,13 @@ module Metasploit # This method takes all the options provided and streams the generated wordlist out # to a {Rex::Quickfile} and returns the {Rex::Quickfile}. # + # @param max_len [Integer] max length of a word in the wordlist, 0 default for ignored value # @return [Rex::Quickfile] The {Rex::Quickfile} object that the wordlist has been written to - def to_file + def to_file(max_len) valid! wordlist_file = Rex::Quickfile.new("jtrtmp") each_word do |word| - wordlist_file.puts word + wordlist_file.puts max_len == 0 ? word : word[0..max_len] end wordlist_file end diff --git a/lib/msf/core/auxiliary/jtr.rb b/lib/msf/core/auxiliary/jtr.rb index 6140d35998..aa54e8acdd 100644 --- a/lib/msf/core/auxiliary/jtr.rb +++ b/lib/msf/core/auxiliary/jtr.rb @@ -79,9 +79,10 @@ module Auxiliary::JohnTheRipper # This method instantiates a {Metasploit::Framework::JtR::Wordlist}, writes the data # out to a file and returns the {Rex::Quickfile} object. # + # @param max_len [Integer] max length of a word in the wordlist, 0 default for ignored value # @return [nilClass] if there is no active framework db connection # @return [Rex::Quickfile] if it successfully wrote the wordlist to a file - def wordlist_file + def wordlist_file(max_len = 0) return nil unless framework.db.active wordlist = Metasploit::Framework::JtR::Wordlist.new( custom_wordlist: datastore['CUSTOM_WORDLIST'], @@ -93,7 +94,7 @@ module Auxiliary::JohnTheRipper use_common_root: datastore['USE_ROOT_WORDS'], workspace: myworkspace ) - wordlist.to_file + wordlist.to_file(max_len) end end