@@ -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' => [ ] ,
@@ -49,34 +48,29 @@ def initialize
49
48
def show_command ( cracker_instance )
50
49
return unless datastore [ 'ShowCommand' ]
51
50
52
- newaction = getaction ( )
53
-
54
- if newaction == 'john'
51
+ if action . name == 'john'
55
52
cmd = cracker_instance . john_crack_command
56
- elsif newaction == 'hashcat'
53
+ elsif action . name == 'hashcat'
57
54
cmd = cracker_instance . hashcat_crack_command
58
55
end
59
56
print_status ( " Cracking Command: #{ cmd . join ( ' ' ) } " )
60
57
end
61
58
62
59
def check_results ( passwords , results , hash_type , method )
63
-
64
- newaction = getaction ( )
65
-
66
60
passwords . each do |password_line |
67
61
password_line . chomp!
68
62
next if password_line . blank?
69
63
70
64
fields = password_line . split ( ':' )
71
65
cred = { 'hash_type' => hash_type , 'method' => method }
72
66
# If we don't have an expected minimum number of fields, this is probably not a hash line
73
- if newaction == 'john'
67
+ if action . name == 'john'
74
68
next unless fields . count >= 3
75
69
76
70
cred [ 'username' ] = fields . shift
77
71
cred [ 'core_id' ] = fields . pop
78
72
cred [ 'password' ] = fields . join ( ':' ) # Anything left must be the password. This accounts for passwords with semi-colons in it
79
- elsif newaction == 'hashcat'
73
+ elsif action . name == 'hashcat'
80
74
next unless fields . count >= 2
81
75
82
76
cred [ 'core_id' ] = fields . shift
@@ -95,9 +89,6 @@ def check_results(passwords, results, hash_type, method)
95
89
end
96
90
97
91
def run
98
-
99
- newaction = getaction ( )
100
-
101
92
tbl = tbl = cracker_results_table
102
93
103
94
hash_types_to_crack = [ ]
@@ -109,7 +100,7 @@ def run
109
100
110
101
# build our job list
111
102
hash_types_to_crack . each do |hash_type |
112
- job = hash_job ( hash_type , newaction )
103
+ job = hash_job ( hash_type , action . name )
113
104
if job . nil?
114
105
print_status ( "No #{ hash_type } found to crack" )
115
106
else
@@ -127,7 +118,7 @@ def run
127
118
# Inner array format: db_id, hash_type, username, password, method_of_crack
128
119
results = [ ]
129
120
130
- cracker = new_password_cracker ( newaction )
121
+ cracker = new_password_cracker ( action . name )
131
122
132
123
# generate our wordlist and close the file handle.
133
124
wordlist = wordlist_file
@@ -151,7 +142,7 @@ def run
151
142
# dupe our original cracker so we can safely change options between each run
152
143
cracker_instance = cracker . dup
153
144
cracker_instance . format = format
154
- if newaction == 'john'
145
+ if action . name == 'john'
155
146
cracker_instance . fork = datastore [ 'FORK' ]
156
147
end
157
148
@@ -162,7 +153,7 @@ def run
162
153
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
163
154
next if job [ 'cred_ids_left_to_crack' ] . 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