Skip to content

Commit c38cc44

Browse files
authored
Update crack_osx.rb
1 parent 99ac369 commit c38cc44

File tree

1 file changed

+10
-39
lines changed

1 file changed

+10
-39
lines changed

modules/auxiliary/analyze/crack_osx.rb

Lines changed: 10 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ def initialize
2424
'Actions' => [
2525
['john', { 'Description' => 'Use John the Ripper' }],
2626
['hashcat', { 'Description' => 'Use Hashcat' }],
27-
['auto', { 'Description' => 'Use either John the Ripper or Hashcat, if both are present, use Hashcat' }]
2827
],
29-
'DefaultAction' => 'auto',
28+
'DefaultAction' => 'john',
3029
'Notes' => {
3130
'Stability' => [CRASH_SAFE],
3231
'SideEffects' => [],
@@ -48,28 +47,23 @@ def initialize
4847
def show_command(cracker_instance)
4948
return unless datastore['ShowCommand']
5049

51-
newaction = getaction()
52-
53-
if newaction == 'john'
50+
if action.name == 'john'
5451
cmd = cracker_instance.john_crack_command
55-
elsif newaction == 'hashcat'
52+
elsif action.name == 'hashcat'
5653
cmd = cracker_instance.hashcat_crack_command
5754
end
5855
print_status(" Cracking Command: #{cmd.join(' ')}")
5956
end
6057

6158
def check_results(passwords, results, hash_type, method)
62-
63-
newaction = getaction()
64-
6559
passwords.each do |password_line|
6660
password_line.chomp!
6761
next if password_line.blank?
6862

6963
fields = password_line.split(':')
7064
cred = { 'hash_type' => hash_type, 'method' => method }
7165
# If we don't have an expected minimum number of fields, this is probably not a hash line
72-
if newaction == 'john'
66+
if action.name == 'john'
7367
next unless fields.count >= 3
7468

7569
cred['username'] = fields.shift
@@ -78,7 +72,7 @@ def check_results(passwords, results, hash_type, method)
7872
4.times { fields.pop } # Get rid of extra :
7973
end
8074
cred['password'] = fields.join(':') # Anything left must be the password. This accounts for passwords with semi-colons in it
81-
elsif newaction == 'hashcat'
75+
elsif action.name == 'hashcat'
8276
next unless fields.count >= 3
8377

8478
cred['core_id'] = fields.shift
@@ -97,9 +91,6 @@ def check_results(passwords, results, hash_type, method)
9791
end
9892

9993
def run
100-
101-
newaction = getaction()
102-
10394
tbl = tbl = cracker_results_table
10495

10596
# array of hashes in jtr_format in the db, converted to an OR combined regex
@@ -111,7 +102,7 @@ def run
111102

112103
# build our job list
113104
hash_types_to_crack.each do |hash_type|
114-
job = hash_job(hash_type, newaction)
105+
job = hash_job(hash_type, action.name)
115106
if job.nil?
116107
print_status("No #{hash_type} found to crack")
117108
else
@@ -129,7 +120,7 @@ def run
129120
# Inner array format: db_id, hash_type, username, password, method_of_crack
130121
results = []
131122

132-
cracker = new_password_cracker(newaction)
123+
cracker = new_password_cracker(action.name)
133124

134125
# generate our wordlist and close the file handle.
135126
wordlist = wordlist_file
@@ -153,7 +144,7 @@ def run
153144
# dupe our original cracker so we can safely change options between each run
154145
cracker_instance = cracker.dup
155146
cracker_instance.format = format
156-
if newaction == 'john'
147+
if action.name == 'john'
157148
cracker_instance.fork = datastore['FORK']
158149
end
159150

@@ -162,7 +153,7 @@ def run
162153
results = check_results(cracker_instance.each_cracked_password, results, format, 'Already Cracked/POT')
163154
vprint_good(append_results(tbl, results)) unless results.empty?
164155

165-
if newaction == 'john'
156+
if action.name == 'john'
166157
print_status "Cracking #{format} hashes in single mode..."
167158
cracker_instance.mode_single(wordlist.path)
168159
show_command cracker_instance
@@ -203,7 +194,7 @@ def run
203194
print_status "Cracking #{format} hashes in wordlist mode..."
204195
cracker_instance.mode_wordlist(wordlist.path)
205196
# Turn on KoreLogic rules if the user asked for it
206-
if newaction == 'john' && datastore['KORELOGIC']
197+
if action.name == 'john' && datastore['KORELOGIC']
207198
cracker_instance.rules = 'KoreLogicRules'
208199
print_status 'Applying KoreLogic ruleset...'
209200
end
@@ -227,24 +218,4 @@ def run
227218
end
228219
end
229220
end
230-
231-
def getaction
232-
newaction = action.name
233-
if action.name == 'auto'
234-
path = Rex::FileUtils.find_full_path('hashcat') ||
235-
Rex::FileUtils.find_full_path('hashcat.exe')
236-
if path
237-
newaction = 'hashcat'
238-
else
239-
path = Rex::FileUtils.find_full_path('john') ||
240-
Rex::FileUtils.find_full_path('john.exe')
241-
if path
242-
newaction = 'john'
243-
else
244-
raise PasswordCrackerNotFoundError, 'No suitable john/hashcat binary was found on the system'
245-
end
246-
end
247-
end
248-
return newaction
249-
end
250221
end

0 commit comments

Comments
 (0)