Skip to content

Commit 6c1a3f4

Browse files
committed
Merge pull request rapid7#3555 from jlee-r7/bug/MSP-10817/jtr-typo
Now able to complete without error. MSP-10817 #land
2 parents ffd7d28 + eee72a8 commit 6c1a3f4

File tree

3 files changed

+37
-14
lines changed

3 files changed

+37
-14
lines changed

lib/metasploit/framework/jtr/cracker.rb

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ def crack_command
119119

120120
if config.present?
121121
cmd << ( "--config=" + config )
122+
else
123+
cmd << ( "--config=" + john_config_file )
122124
end
123125

124126
if pot.present?
@@ -162,6 +164,13 @@ def each_cracked_password
162164
end
163165
end
164166

167+
# This method returns the path to a default john.conf file.
168+
#
169+
# @return [String] the path to the default john.conf file
170+
def john_config_file
171+
::File.join( ::Msf::Config.data_directory, "john", "confs", "john.conf" )
172+
end
173+
165174
# This method returns the path to a default john.pot file.
166175
#
167176
# @return [String] the path to the default john.pot file
@@ -189,6 +198,8 @@ def show_command
189198

190199
if config
191200
cmd << "--config=#{config}"
201+
else
202+
cmd << ( "--config=" + john_config_file )
192203
end
193204

194205
cmd << hash_path
@@ -199,11 +210,11 @@ def show_command
199210
# This method tries to identify the correct version of the pre-shipped
200211
# JtR binaries to use based on the platform.
201212
#
202-
# @return [NilClass] if the correct bianry could not be determined
213+
# @return [NilClass] if the correct binary could not be determined
203214
# @return [String] the path to the selected binary
204215
def select_shipped_binary
205216
cpuinfo_base = ::File.join(Msf::Config.data_directory, "cpuinfo")
206-
runpath = nil
217+
run_path = nil
207218
if File.directory?(cpuinfo_base)
208219
data = nil
209220

@@ -215,11 +226,11 @@ def select_shipped_binary
215226
end
216227
case data
217228
when /sse2/
218-
run_path ||= "run.win32.sse2/john.exe"
229+
run_path ||= ::File.join(Msf::Config.data_directory, "john", "run.win32.sse2", "john.exe")
219230
when /mmx/
220-
run_path ||= "run.win32.mmx/john.exe"
231+
run_path ||= ::File.join(Msf::Config.data_directory, "john", "run.win32.mmx", "john.exe")
221232
else
222-
run_path ||= "run.win32.any/john.exe"
233+
run_path ||= ::File.join(Msf::Config.data_directory, "john", "run.win32.any", "john.exe")
223234
end
224235
when /x86_64-linux/
225236
fname = "#{cpuinfo_base}/cpuinfo.ia64.bin"
@@ -229,9 +240,9 @@ def select_shipped_binary
229240
end
230241
case data
231242
when /mmx/
232-
run_path ||= "run.linux.x64.mmx/john"
243+
run_path ||= ::File.join(Msf::Config.data_directory, "john", "run.linux.x64.mmx", "john")
233244
else
234-
run_path ||= "run.linux.x86.any/john"
245+
run_path ||= ::File.join(Msf::Config.data_directory, "john", "run.linux.x86.any", "john")
235246
end
236247
when /i[\d]86-linux/
237248
fname = "#{cpuinfo_base}/cpuinfo.ia32.bin"
@@ -241,15 +252,15 @@ def select_shipped_binary
241252
end
242253
case data
243254
when /sse2/
244-
run_path ||= "run.linux.x86.sse2/john"
255+
run_path ||= ::File.join(Msf::Config.data_directory, "john", "run.linux.x86.sse2", "john")
245256
when /mmx/
246-
run_path ||= "run.linux.x86.mmx/john"
257+
run_path ||= ::File.join(Msf::Config.data_directory, "john", "run.linux.x86.mmx", "john")
247258
else
248-
run_path ||= "run.linux.x86.any/john"
259+
run_path ||= ::File.join(Msf::Config.data_directory, "john", "run.linux.x86.any", "john")
249260
end
250261
end
251262
end
252-
runpath
263+
run_path
253264
end
254265

255266

lib/msf/core/auxiliary/jtr.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ def initialize(info = {})
4141

4242
end
4343

44+
# @param pwd [String] Password recovered from cracking an LM hash
45+
# @param hash [String] NTLM hash for this password
46+
# @return [String] `pwd` converted to the correct case to match the
47+
# given NTLM hash
48+
# @return [nil] if no case matches the NT hash. This can happen when
49+
# `pwd` came from a john run that only cracked half of the LM hash
4450
def john_lm_upper_to_ntlm(pwd, hash)
4551
pwd = pwd.upcase
4652
hash = hash.upcase

modules/auxiliary/analyze/jtr_crack_fast.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def initialize
3030
def run
3131
cracker = new_john_cracker
3232

33-
#generate our wordlist and close the file handle
33+
# generate our wordlist and close the file handle
3434
wordlist = wordlist_file
3535
wordlist.close
3636
print_status "Wordlist file written out to #{wordlist.path}"
@@ -53,10 +53,10 @@ def run
5353
end
5454

5555
if format == 'lm'
56-
print_status "Cracking #{format} hashes in incremental mode (LanMan)..."
56+
print_status "Cracking #{format} hashes in incremental mode (All4)..."
5757
cracker_instance.rules = nil
5858
cracker_instance.wordlist = nil
59-
cracker_instance.incremental = 'LanMan'
59+
cracker_instance.incremental = 'All4'
6060
cracker_instance.crack do |line|
6161
print_status line.chomp
6262
end
@@ -98,6 +98,12 @@ def run
9898
end
9999
end
100100
password = john_lm_upper_to_ntlm(password, nt_hash)
101+
# password can be nil if the hash is broken (i.e., the NT and
102+
# LM sides don't actually match) or if john was only able to
103+
# crack one half of the LM hash. In the latter case, we'll
104+
# have a line like:
105+
# username:???????WORD:...:...:::
106+
next if password.nil?
101107
end
102108

103109
print_good "#{username}:#{password}:#{core_id}"

0 commit comments

Comments
 (0)