@@ -24,9 +24,8 @@ def initialize
24
24
'Actions' => [
25
25
[ 'john' , { 'Description' => 'Use John the Ripper' } ] ,
26
26
[ 'hashcat' , { 'Description' => 'Use Hashcat' } ] ,
27
- [ 'auto' , { 'Description' => 'Use either John the Ripper or Hashcat, if both are present, use Hashcat' } ]
28
27
] ,
29
- 'DefaultAction' => 'auto ' ,
28
+ 'DefaultAction' => 'john ' ,
30
29
'Notes' => {
31
30
'Stability' => [ CRASH_SAFE ] ,
32
31
'SideEffects' => [ ] ,
@@ -48,28 +47,23 @@ def initialize
48
47
def show_command ( cracker_instance )
49
48
return unless datastore [ 'ShowCommand' ]
50
49
51
- newaction = getaction ( )
52
-
53
- if newaction == 'john'
50
+ if action . name == 'john'
54
51
cmd = cracker_instance . john_crack_command
55
- elsif newaction == 'hashcat'
52
+ elsif action . name == 'hashcat'
56
53
cmd = cracker_instance . hashcat_crack_command
57
54
end
58
55
print_status ( " Cracking Command: #{ cmd . join ( ' ' ) } " )
59
56
end
60
57
61
58
def check_results ( passwords , results , hash_type , method )
62
-
63
- newaction = getaction ( )
64
-
65
59
passwords . each do |password_line |
66
60
password_line . chomp!
67
61
next if password_line . blank?
68
62
69
63
fields = password_line . split ( ':' )
70
64
cred = { 'hash_type' => hash_type , 'method' => method }
71
65
# 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'
73
67
next unless fields . count >= 3
74
68
75
69
cred [ 'username' ] = fields . shift
@@ -78,7 +72,7 @@ def check_results(passwords, results, hash_type, method)
78
72
4 . times { fields . pop } # Get rid of extra :
79
73
end
80
74
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'
82
76
next unless fields . count >= 3
83
77
84
78
cred [ 'core_id' ] = fields . shift
@@ -97,9 +91,6 @@ def check_results(passwords, results, hash_type, method)
97
91
end
98
92
99
93
def run
100
-
101
- newaction = getaction ( )
102
-
103
94
tbl = tbl = cracker_results_table
104
95
105
96
# array of hashes in jtr_format in the db, converted to an OR combined regex
@@ -111,7 +102,7 @@ def run
111
102
112
103
# build our job list
113
104
hash_types_to_crack . each do |hash_type |
114
- job = hash_job ( hash_type , newaction )
105
+ job = hash_job ( hash_type , action . name )
115
106
if job . nil?
116
107
print_status ( "No #{ hash_type } found to crack" )
117
108
else
@@ -129,7 +120,7 @@ def run
129
120
# Inner array format: db_id, hash_type, username, password, method_of_crack
130
121
results = [ ]
131
122
132
- cracker = new_password_cracker ( newaction )
123
+ cracker = new_password_cracker ( action . name )
133
124
134
125
# generate our wordlist and close the file handle.
135
126
wordlist = wordlist_file
@@ -153,7 +144,7 @@ def run
153
144
# dupe our original cracker so we can safely change options between each run
154
145
cracker_instance = cracker . dup
155
146
cracker_instance . format = format
156
- if newaction == 'john'
147
+ if action . name == 'john'
157
148
cracker_instance . fork = datastore [ 'FORK' ]
158
149
end
159
150
@@ -162,7 +153,7 @@ def run
162
153
results = check_results ( cracker_instance . each_cracked_password , results , format , 'Already Cracked/POT' )
163
154
vprint_good ( append_results ( tbl , results ) ) unless results . empty?
164
155
165
- if newaction == 'john'
156
+ if action . name == 'john'
166
157
print_status "Cracking #{ format } hashes in single mode..."
167
158
cracker_instance . mode_single ( wordlist . path )
168
159
show_command cracker_instance
@@ -203,7 +194,7 @@ def run
203
194
print_status "Cracking #{ format } hashes in wordlist mode..."
204
195
cracker_instance . mode_wordlist ( wordlist . path )
205
196
# Turn on KoreLogic rules if the user asked for it
206
- if newaction == 'john' && datastore [ 'KORELOGIC' ]
197
+ if action . name == 'john' && datastore [ 'KORELOGIC' ]
207
198
cracker_instance . rules = 'KoreLogicRules'
208
199
print_status 'Applying KoreLogic ruleset...'
209
200
end
@@ -227,24 +218,4 @@ def run
227
218
end
228
219
end
229
220
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
250
221
end
0 commit comments