Skip to content

Commit 424e4fb

Browse files
authored
Update crack_databases.rb
1 parent 87d7dec commit 424e4fb

File tree

1 file changed

+11
-41
lines changed

1 file changed

+11
-41
lines changed

modules/auxiliary/analyze/crack_databases.rb

Lines changed: 11 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ def initialize
3434
'Actions' => [
3535
['john', { 'Description' => 'Use John the Ripper' }],
3636
['hashcat', { 'Description' => 'Use Hashcat' }],
37-
['auto', { 'Description' => 'Use either John the Ripper or Hashcat, if both are present, use Hashcat' }]
3837
],
39-
'DefaultAction' => 'auto',
38+
'DefaultAction' => 'john',
4039
'Notes' => {
4140
'Stability' => [CRASH_SAFE],
4241
'SideEffects' => [],
@@ -59,34 +58,29 @@ def initialize
5958
def show_command(cracker_instance)
6059
return unless datastore['ShowCommand']
6160

62-
newaction = getaction()
63-
64-
if newaction == 'john'
61+
if action.name == 'john'
6562
cmd = cracker_instance.john_crack_command
66-
elsif newaction == 'hashcat'
63+
elsif action.name == 'hashcat'
6764
cmd = cracker_instance.hashcat_crack_command
6865
end
6966
print_status(" Cracking Command: #{cmd.join(' ')}")
7067
end
7168

7269
def check_results(passwords, results, hash_type, method)
73-
74-
newaction = getaction()
75-
7670
passwords.each do |password_line|
7771
password_line.chomp!
7872
next if password_line.blank?
7973

8074
fields = password_line.split(':')
8175
cred = { 'hash_type' => hash_type, 'method' => method }
8276

83-
if newaction == 'john'
77+
if action.name == 'john'
8478
next unless fields.count >= 3
8579

8680
cred['username'] = fields.shift
8781
cred['core_id'] = fields.pop
8882
cred['password'] = fields.join(':') # Anything left must be the password. This accounts for passwords with semi-colons in it
89-
elsif newaction == 'hashcat'
83+
elsif action.name == 'hashcat'
9084
next unless fields.count >= 2
9185

9286
cred['core_id'] = fields.shift
@@ -115,9 +109,6 @@ def check_results(passwords, results, hash_type, method)
115109
end
116110

117111
def run
118-
119-
newaction = getaction()
120-
121112
tbl = tbl = cracker_results_table
122113

123114
# array of hashes in jtr_format in the db, converted to an OR combined regex
@@ -137,7 +128,7 @@ def run
137128

138129
# hashcat requires a format we dont have all the data for
139130
# in the current dumper, so this is disabled in module and lib
140-
if newaction == 'john'
131+
if action.name == 'john'
141132
hash_types_to_crack << 'oracle'
142133
hash_types_to_crack << 'dynamic_1506'
143134
end
@@ -152,7 +143,7 @@ def run
152143

153144
# build our job list
154145
hash_types_to_crack.each do |hash_type|
155-
job = hash_job(hash_type, newaction)
146+
job = hash_job(hash_type, action.name)
156147
if job.nil?
157148
print_status("No #{hash_type} found to crack")
158149
else
@@ -170,7 +161,7 @@ def run
170161
# Inner array format: db_id, hash_type, username, password, method_of_crack
171162
results = []
172163

173-
cracker = new_password_cracker(newaction)
164+
cracker = new_password_cracker(action.name)
174165

175166
# generate our wordlist and close the file handle.
176167
wordlist = wordlist_file
@@ -196,7 +187,7 @@ def run
196187
cracker_instance = cracker.dup
197188
cracker_instance.format = format
198189

199-
if newaction == 'john'
190+
if action.name == 'john'
200191
cracker_instance.fork = datastore['FORK']
201192
end
202193

@@ -207,7 +198,7 @@ def run
207198
job['cred_ids_left_to_crack'] = job['cred_ids_left_to_crack'] - results.map { |i| i[0].to_i } # remove cracked hashes from the hash list
208199
next if job['cred_ids_left_to_crack'].empty?
209200

210-
if newaction == 'john'
201+
if action.name == 'john'
211202
print_status "Cracking #{format} hashes in single mode..."
212203
cracker_instance.mode_single(wordlist.path)
213204
show_command cracker_instance
@@ -248,7 +239,7 @@ def run
248239
print_status "Cracking #{format} hashes in wordlist mode..."
249240
cracker_instance.mode_wordlist(wordlist.path)
250241
# Turn on KoreLogic rules if the user asked for it
251-
if newaction == 'john' && datastore['KORELOGIC']
242+
if action.name == 'john' && datastore['KORELOGIC']
252243
cracker_instance.rules = 'KoreLogicRules'
253244
print_status 'Applying KoreLogic ruleset...'
254245
end
@@ -272,25 +263,4 @@ def run
272263
end
273264
end
274265
end
275-
276-
def getaction
277-
newaction = action.name
278-
if action.name == 'auto'
279-
path = Rex::FileUtils.find_full_path('hashcat') ||
280-
Rex::FileUtils.find_full_path('hashcat.exe')
281-
if path
282-
newaction = 'hashcat'
283-
else
284-
path = Rex::FileUtils.find_full_path('john') ||
285-
Rex::FileUtils.find_full_path('john.exe')
286-
if path
287-
newaction = 'john'
288-
else
289-
raise PasswordCrackerNotFoundError, 'No suitable john/hashcat binary was found on the system'
290-
end
291-
end
292-
end
293-
return newaction
294-
end
295-
296266
end

0 commit comments

Comments
 (0)