Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/tools/dev/hash_cracker_validator.rb
31347 views
1
#!/usr/bin/env ruby
2
3
# This script is used to validate the hash cracking capabilities of metasploit
4
# https://github.com/rapid7/metasploit-framework/pull/17667 shows the complexity
5
# of trying to insert hashes, run the appropriate hash cracking module, and verify the hashes are cracked.
6
# this automates everything and checks the output of the hash cracking modules to ensure they are working as expected
7
# author: h00die
8
9
require 'open3'
10
require 'tempfile'
11
require 'optparse'
12
13
options = { test: 'all', verbose: false }
14
15
OptionParser.new do |opts|
16
opts.banner = <<~BANNER
17
hash_cracker_validator.rb - A Script to verify hash cracking in Metasploit.
18
19
Based on passwords/hashes from https://docs.metasploit.com/docs/using-metasploit/intermediate/hashes-and-password-cracking.html#hashes
20
21
Usage: hash_cracker_validator.rb [options]
22
BANNER
23
opts.on('--verbose', 'Enable verbose output.') do
24
options[:verbose] = true
25
end
26
opts.on('-t', '--test LIST', "Which tests to conduct. Takes a list of numbers (comma-separated), defaults to 'all'",
27
'Test 1: Test database connection',
28
'Test 2: *nix hashes in john wordlist mode',
29
'Test 3: windows hashes in john wordlist mode',
30
'Test 4: sql hashes in john wordlist mode',
31
'Test 5: osx hashes in john wordlist mode',
32
'Test 6: webapp hashes in john wordlist mode',
33
'Test 7: *nix hashes in hashcat wordlist mode',
34
'Test 8: windows hashes in hashcat wordlist mode',
35
'Test 9: sql hashes in hashcat wordlist mode',
36
'Test 10: mobile hashes in hashcat wordlist mode',
37
'Test 11: osx hashes in hashcat wordlist mode',
38
'Test 12: webapp hashes in hashcat wordlist mode',
39
'Test 13: *nix hashes in john pot mode',
40
'Test 14: windows hashes in john pot mode',
41
'Test 15: sql hashes in john pot mode',
42
'Test 16: osx hashes in john pot mode',
43
'Test 17: webapp hashes in john pot mode',
44
'Test 18: *nix hashes in hashcat pot mode',
45
'Test 19: windows hashes in hashcat pot mode',
46
'Test 20: sql hashes in hashcat pot mode',
47
'Test 21: mobile hashes in hashcat pot mode',
48
'Test 22: osx hashes in hashcat pot mode',
49
'Test 23: webapp hashes in hashcat pot mode',
50
'Test 24: all hashes in john apply_pot mode') do |list|
51
options[:test] = begin
52
list.split(',').map(&:strip).map(&:to_i)
53
rescue StandardError
54
'all'
55
end
56
end
57
end.parse!
58
59
# colors and puts templates from msftidy.rb
60
61
class String
62
def red
63
"\e[1;31;40m#{self}\e[0m"
64
end
65
66
def yellow
67
"\e[1;33;40m#{self}\e[0m"
68
end
69
70
def green
71
"\e[1;32;40m#{self}\e[0m"
72
end
73
74
def cyan
75
"\e[1;36;40m#{self}\e[0m"
76
end
77
end
78
79
def cleanup_text(txt)
80
txt
81
end
82
83
#
84
# Display an error message, given some text
85
#
86
def good(txt)
87
puts "[#{'GOOD'.green}] #{cleanup_text(txt)}"
88
end
89
90
#
91
# Display an error message, given some text
92
#
93
def error(txt)
94
puts "[#{'ERROR'.red}] #{cleanup_text(txt)}"
95
end
96
97
#
98
# Display a warning message, given some text
99
#
100
def warning(txt)
101
puts "[#{'WARNING'.yellow}] #{cleanup_text(txt)}"
102
end
103
104
#
105
# Display a info message, given some text
106
#
107
def info(txt)
108
puts "[#{'INFO'.cyan}] #{cleanup_text(txt)}"
109
end
110
111
def nix_hashes_and_regex
112
creds_command = ''
113
creds_expected_output_regex = []
114
creds_command << ' creds add user:des_password hash:rEK1ecacw.7.c jtr:des;'
115
creds_expected_output_regex << /des_password\s+rEK1ecacw\.7\.c\s+Nonreplayable hash\s+des\s+password$/
116
creds_command << ' creds add user:md5_password hash:\$1\$O3JMY.Tw\$AdLnLjQ/5jXF9.MTp3gHv/ jtr:md5;'
117
creds_expected_output_regex << %r{md5_password\s+\$1\$O3JMY\.Tw\$AdLnLjQ/5jXF9\.MTp3gHv/\s+Nonreplayable hash\s+md5\s+password$}
118
creds_command << ' creds add user:bsdi_password hash:_J9..K0AyUubDrfOgO4s jtr:bsdi;'
119
creds_expected_output_regex << /bsdi_password\s+_J9\.\.K0AyUubDrfOgO4s\s+Nonreplayable hash\s+bsdi\s+password$/
120
creds_command << ' creds add user:sha256_password hash:\$5\$MnfsQ4iN\$ZMTppKN16y/tIsUYs/obHlhdP.Os80yXhTurpBMUbA5 jtr:sha256,crypt;'
121
creds_command << ' set SHA256 true;'
122
creds_expected_output_regex << %r{sha256_password\s+\$5\$MnfsQ4iN\$ZMTppKN16y/tIsUYs/obHlhdP\.Os80yXhTurpBMUbA5\s+Nonreplayable hash\s+sha256,crypt\s+password$}
123
creds_command << ' creds add user:sha512_password hash:\$6\$zWwwXKNj\$gLAOoZCjcr8p/.VgV/FkGC3NX7BsXys3KHYePfuIGMNjY83dVxugPYlxVg/evpcVEJLT/rSwZcDMlVVf/bhf.1 jtr:sha512,crypt;'
124
creds_command << ' set SHA512 true;'
125
creds_expected_output_regex << %r{sha512_password\s+\$6\$zWwwXKNj\$gLAOoZCjcr8p/\.VgV/FkGC3NX7BsXys3KHYePfuIGMNjY83dVxugPYlxVg/evpcV \(TRUNCATED\)\s+Nonreplayable hash\s+sha512,crypt\s+password$}
126
creds_command << ' creds add user:blowfish_password hash:\$2a\$05\$bvIG6Nmid91Mu9RcmmWZfO5HJIMCT8riNW0hEp8f6/FuA2/mHZFpe jtr:bf;'
127
creds_command << ' set BLOWFISH true;'
128
creds_expected_output_regex << %r{blowfish_password\s+\$2a\$05\$bvIG6Nmid91Mu9RcmmWZfO5HJIMCT8riNW0hEp8f6/FuA2/mHZFpe\s+Nonreplayable hash\s+bf\s+password$}
129
return creds_command, creds_expected_output_regex
130
end
131
132
def osx_hashes_and_regex
133
creds_command = ''
134
creds_expected_output_regex = []
135
creds_command << ' creds add user:xsha_hashcat hash:1430823483d07626ef8be3fda2ff056d0dfd818dbfe47683 jtr:xsha;'
136
creds_expected_output_regex << /xsha_hashcat\s+1430823483d07626ef8be3fda2ff056d0dfd818dbfe47683\s+Nonreplayable hash\s+xsha\s+hashcat$/
137
creds_command << ' creds add user:pbkdf2_hashcat hash:\$ml\$35460\$93a94bd24b5de64d79a5e49fa372827e739f4d7b6975c752c9a0ff1e5cf72e05\$752351df64dd2ce9dc9c64a72ad91de6581a15c19176266b44d98919dfa81f0f96cbcb20a1ffb400718c20382030f637892f776627d34e021bad4f81b7de8222 jtr:PBKDF2-HMAC-SHA512;'
138
creds_expected_output_regex << /pbkdf2_hashcat\s+\$ml\$35460\$93a94bd24b5de64d79a5e49fa372827e739f4d7b6975c752c9a0ff1e5cf72e05\$7 \(TRUNCATED\)\s+Nonreplayable hash\s+PBKDF2-HMAC-SHA512\s+hashcat$/
139
creds_command << ' creds add user:xsha512_hashcat hash:648742485c9b0acd786a233b2330197223118111b481abfa0ab8b3e8ede5f014fc7c523991c007db6882680b09962d16fd9c45568260531bdb34804a5e31c22b4cfeb32d jtr:xsha512;'
140
creds_expected_output_regex << /xsha512_hashcat\s+648742485c9b0acd786a233b2330197223118111b481abfa0ab8b3e8ede5f014fc7c523991c0 \(TRUNCATED\)\s+Nonreplayable hash\s+xsha512\s+hashcat$/
141
return creds_command, creds_expected_output_regex
142
end
143
144
def webapp_hashes_and_regex
145
creds_command = ''
146
creds_expected_output_regex = []
147
creds_command << ' creds add user:mediawiki_hashcat hash:\$B\$56668501\$0ce106caa70af57fd525aeaf80ef2898 jtr:mediawiki;'
148
creds_expected_output_regex << /mediawiki_hashcat\s+\$B\$56668501\$0ce106caa70af57fd525aeaf80ef2898\s+Nonreplayable hash\s+mediawiki\s+hashcat$/
149
creds_command << ' creds add user:phpass_p_hashcat hash:\$P\$984478476IagS59wHZvyQMArzfx58u. jtr:phpass;'
150
creds_expected_output_regex << /phpass_p_hashcat\s+\$P\$984478476IagS59wHZvyQMArzfx58u\.\s+Nonreplayable hash\s+phpass\s+hashcat$/
151
creds_command << ' creds add user:phpass_h_hashcat hash:\$H\$984478476IagS59wHZvyQMArzfx58u. jtr:phpass;'
152
creds_expected_output_regex << /phpass_h_hashcat\s+\$H\$984478476IagS59wHZvyQMArzfx58u\.\s+Nonreplayable hash\s+phpass\s+hashcat$/
153
creds_command << ' creds add user:atlassian_hashcat hash:{PKCS5S2}NzIyNzM0NzY3NTIwNjI3MdDDis7wPxSbSzfFqDGf7u/L00kSEnupbz36XCL0m7wa jtr:PBKDF2-HMAC-SHA1;'
154
creds_expected_output_regex << %r{atlassian_hashcat\s+\{PKCS5S2\}NzIyNzM0NzY3NTIwNjI3MdDDis7wPxSbSzfFqDGf7u/L00kSEnupbz36XCL0m7wa\s+Nonreplayable\s+hash\s+PBKDF2-HMAC-SHA1\s+hashcat$}
155
return creds_command, creds_expected_output_regex
156
end
157
158
def mobile_hashes_and_regex
159
creds_command = ''
160
creds_expected_output_regex = []
161
creds_command << ' creds add user:samsungsha1 hash:D1B19A90B87FC10C304E657F37162445DAE27D16:a006983800cc3dd1 jtr:android-samsung-sha1;'
162
creds_expected_output_regex << /samsungsha1\s+D1B19A90B87FC10C304E657F37162445DAE27D16:a006983800cc3dd1\s+Nonreplayable hash\s+android-samsung-sha1\s+1234$/
163
creds_command << ' creds add user:androidsha1 hash:9860A48CA459D054F3FEF0F8518CF6872923DAE2:81fcb23bcadd6c5 jtr:android-sha1;'
164
creds_expected_output_regex << /androidsha1\s+9860A48CA459D054F3FEF0F8518CF6872923DAE2:81fcb23bcadd6c5\s+Nonreplayable hash\s+android-sha1\s+1234$/
165
creds_command << ' creds add user:androidmd5 hash:1C0A0FDB673FBA36BEAEB078322C7393:81fcb23bcadd6c5 jtr:android-md5;'
166
creds_expected_output_regex << /androidmd5\s+1C0A0FDB673FBA36BEAEB078322C7393:81fcb23bcadd6c5\s+Nonreplayable hash\s+android-md5\s+1234$/
167
return creds_command, creds_expected_output_regex
168
end
169
170
def windows_hashes_and_regex_john_compat
171
creds_command = ''
172
creds_expected_output_regex = []
173
creds_command << ' creds add user:lm_password ntlm:E52CAC67419A9A224A3B108F3FA6CB6D:8846F7EAEE8FB117AD06BDD830B7586C jtr:lm;'
174
creds_expected_output_regex << /lm_password\s+e52cac67419a9a224a3b108f3fa6cb6d:8846f7eaee8fb117ad06bdd830b7586c\s+NTLM hash\s+nt,lm\s+PASSWORD$/i # hashcat does PASSWORD, john does password
175
creds_command << ' creds add user:nt_password ntlm:AAD3B435B51404EEAAD3B435B51404EE:8846F7EAEE8FB117AD06BDD830B7586C jtr:nt;'
176
creds_expected_output_regex << /nt_password\s+aad3b435b51404eeaad3b435b51404ee:8846f7eaee8fb117ad06bdd830b7586c\s+NTLM hash\s+nt,lm\s+password$/
177
creds_command << ' creds add user:u4-netntlm hash:u4-netntlm::kNS:338d08f8e26de93300000000000000000000000000000000:9526fb8c23a90751cdd619b6cea564742e1e4bf33006ba41:cb8086049ec4736c jtr:netntlm;'
178
creds_expected_output_regex << /u4-netntlm\s+u4-netntlm::kNS:338d08f8e26de93300000000000000000000000000000000:9526fb8c23a \(TRUNCATED\)\s+Nonreplayable hash\s+netntlm\s+hashcat$/
179
creds_command << ' creds add user:admin hash:admin::N46iSNekpT:08ca45b7d7ea58ee:88dcbe4446168966a153a0064958dac6:5c7830315c7830310000000000000b45c67103d07d7b95acd12ffa11230e0000000052920b85f78d013c31cdb3b92f5d765c783030 jtr:netntlmv2;'
180
creds_expected_output_regex << /admin\s+admin::N46iSNekpT:08ca45b7d7ea58ee:88dcbe4446168966a153a0064958dac6:5c783031 \(TRUNCATED\)\s+Nonreplayable hash\s+netntlmv2\s+hashcat$/
181
creds_command << ' creds add user:mscash-test1 hash:M\$test1#64cd29e36a8431a2b111378564a10631 jtr:mscash;'
182
creds_expected_output_regex << /mscash-test1\s+M\$test1\#64cd29e36a8431a2b111378564a10631\s+Nonreplayable hash\s+mscash\s+test1$/
183
creds_command << ' creds add user:mscash2-hashcat hash:\$DCC2\$10240#tom#e4e938d12fe5974dc42a90120bd9c90f jtr:mscash2;'
184
creds_expected_output_regex << /mscash2-hashcat\s+\$DCC2\$10240\#tom\#e4e938d12fe5974dc42a90120bd9c90f\s+Nonreplayable hash\s+mscash2\s+hashcat$/
185
return creds_command, creds_expected_output_regex
186
end
187
188
def windows_hashes_and_regex_hashcat_compat
189
creds_command = ''
190
creds_expected_output_regex = []
191
cred_temp, regex_temp = windows_hashes_and_regex_john_compat
192
creds_command << cred_temp
193
creds_expected_output_regex += regex_temp
194
return creds_command, creds_expected_output_regex
195
end
196
197
def sql_hashes_and_regex_hashcat_compat
198
creds_command = ''
199
creds_expected_output_regex = []
200
creds_command << ' creds add user:mssql05_toto hash:0x01004086CEB6BF932BC4151A1AF1F13CD17301D70816A8886908 jtr:mssql05;'
201
creds_expected_output_regex << /mssql05_toto\s+0x01004086CEB6BF932BC4151A1AF1F13CD17301D70816A8886908\s+Nonreplayable hash\s+mssql05\s+toto$/
202
creds_command << ' creds add user:mssql_foo hash:0x0100A607BA7C54A24D17B565C59F1743776A10250F581D482DA8B6D6261460D3F53B279CC6913CE747006A2E3254 jtr:mssql;'
203
creds_expected_output_regex << /mssql_foo\s+0x0100A607BA7C54A24D17B565C59F1743776A10250F581D482DA8B6D6261460D3F53B279CC6 \(TRUNCATED\)\s+Nonreplayable hash\s+mssql\s+FOO$/
204
creds_command << ' creds add user:mssql12_Password1! hash:0x0200F733058A07892C5CACE899768F89965F6BD1DED7955FE89E1C9A10E27849B0B213B5CE92CC9347ECCB34C3EFADAF2FD99BFFECD8D9150DD6AACB5D409A9D2652A4E0AF16 jtr:mssql12;'
205
creds_expected_output_regex << /mssql12_Password1!\s+0x0200F733058A07892C5CACE899768F89965F6BD1DED7955FE89E1C9A10E27849B0B213B5CE \(TRUNCATED\)\s+Nonreplayable hash\s+mssql12\s+Password1!$/
206
creds_command << ' creds add user:mysql_probe hash:445ff82636a7ba59 jtr:mysql;'
207
creds_expected_output_regex << /mysql_probe\s+445ff82636a7ba59\s+Nonreplayable hash\s+mysql\s+probe$/
208
creds_command << ' creds add user:mysql-sha1_tere hash:*5AD8F88516BD021DD43F171E2C785C69F8E54ADB jtr:mysql-sha1;'
209
creds_expected_output_regex << /mysql-sha1_tere\s+\*5AD8F88516BD021DD43F171E2C785C69F8E54ADB\s+Nonreplayable hash\s+mysql-sha1\s+tere$/
210
# hashcat des,oracle is a no go: https://github.com/rapid7/metasploit-framework/blob/7a7b009161d6b0839653f21296864da3365402a0/lib/metasploit/framework/password_crackers/cracker.rb#L152-L155
211
# creds_command << ' creds add user:simon hash:4F8BC1809CB2AF77 jtr:des,oracle;'
212
# creds_expected_output_regex << %r{simon\s+4F8BC1809CB2AF77\s+Nonreplayable hash\s+des,oracle\s+A$}
213
# creds_command << ' creds add user:SYSTEM hash:9EEDFA0AD26C6D52 jtr:des,oracle;'
214
# creds_expected_output_regex << %r{SYSTEM\s+9EEDFA0AD26C6D52\s+Nonreplayable hash\s+des,oracle\s+THALES$}
215
216
# can't escape ;?
217
# creds_command << ' creds add user:DEMO hash:\'S:8F2D65FB5547B71C8DA3760F10960428CD307B1C6271691FC55C1F56554A;H:DC9894A01797D91D92ECA1DA66242209;T:23D1F8CAC9001F69630ED2DD8DF67DD3BE5C470B5EA97B622F757FE102D8BF14BEDC94A3CC046D10858D885DB656DC0CBF899A79CD8C76B788744844CADE54EEEB4FDEC478FB7C7CBFBBAC57BA3EF22C\' jtr:raw-sha1,oracle;'
218
# creds_expected_output_regex << %r{mscash2-hashcat\s+\$DCC2\$10240\#tom\#e4e938d12fe5974dc42a90120bd9c90f\s+Nonreplayable hash\s+mscash2\s+hashcat$}
219
# creds_command << ' creds add user:oracle11_epsilon hash:"S:8F2D65FB5547B71C8DA3760F10960428CD307B1C6271691FC55C1F56554A\\\\;H:DC9894A01797D91D92ECA1DA66242209\\\\;T:23D1F8CAC9001F69630ED2DD8DF67DD3BE5C470B5EA97B622F757FE102D8BF14BEDC94A3CC046D10858D885DB656DC0CBF899A79CD8C76B788744844CADE54EEEB4FDEC478FB7C7CBFBBAC57BA3EF22C" jtr:raw-sha1,oracle;'
220
# creds_expected_output_regex << %r{mscash2-hashcat\s+\$DCC2\$10240\#tom\#e4e938d12fe5974dc42a90120bd9c90f\s+Nonreplayable hash\s+mscash2\s+hashcat$}
221
# creds_command << ' creds add user:oracle12c_epsilon hash:"H:DC9894A01797D91D92ECA1DA66242209\\\\;T:E3243B98974159CC24FD2C9A8B30BA62E0E83B6CA2FC7C55177C3A7F82602E3BDD17CEB9B9091CF9DAD672B8BE961A9EAC4D344BDBA878EDC5DCB5899F689EBD8DD1BE3F67BFF9813A464382381AB36B" jtr:pbkdf2,oracle12c;'
222
# creds_expected_output_regex << %r{mscash2-hashcat\s+\$DCC2\$10240\#tom\#e4e938d12fe5974dc42a90120bd9c90f\s+Nonreplayable hash\s+mscash2\s+hashcat$}
223
# creds_command << ' creds add user:example postgres:md5be86a79bf2043622d58d5453c47d4860;'
224
# creds_expected_output_regex << %r{example\s+md5be86a79bf2043622d58d5453c47d4860\s+Postgres md5\s+raw-md5,postgres\s+password$}
225
return creds_command, creds_expected_output_regex
226
end
227
228
def sql_hashes_and_regex_john_compat
229
creds_command = ''
230
creds_expected_output_regex = []
231
cred_temp, regex_temp = sql_hashes_and_regex_hashcat_compat
232
creds_command << cred_temp
233
creds_expected_output_regex += regex_temp
234
creds_command << ' creds add user:simon hash:4F8BC1809CB2AF77 jtr:des,oracle;'
235
creds_expected_output_regex << /simon\s+4F8BC1809CB2AF77\s+Nonreplayable hash\s+des,oracle\s+A$/
236
creds_command << ' creds add user:SYSTEM hash:9EEDFA0AD26C6D52 jtr:des,oracle;'
237
creds_expected_output_regex << /SYSTEM\s+9EEDFA0AD26C6D52\s+Nonreplayable hash\s+des,oracle\s+THALES$/
238
creds_command << cred_temp
239
creds_expected_output_regex += regex_temp
240
return creds_command, creds_expected_output_regex
241
end
242
243
warning 'WARNING: All credentials will be deleted as part of this script execution!'
244
245
start_time = Time.now
246
247
def run_msfconsole(command, expected_output_regexes)
248
section_start_time = Time.now
249
stdout, stderr = Open3.capture3("./msfconsole --defer-module-loads -qx \"#{command}\"")
250
251
failing_regex = expected_output_regexes.find { |regex| !stdout.match?(regex) }
252
253
if failing_regex.nil?
254
good ' SUCCESS: All expected outputs found.'
255
good " Section Runtime: #{Time.now - section_start_time} seconds"
256
return true
257
else
258
error " FAILURE: Expected output not found for regex: #{failing_regex.inspect}"
259
error " STDOUT: #{stdout}"
260
error " Section Runtime: #{Time.now - section_start_time} seconds"
261
error " STDERR: #{stderr}"
262
return false
263
end
264
end
265
266
if options[:test] == 'all' || options[:test].include?(1)
267
info '[1/24] Checking Metasploit database connection...'
268
db_status_command = 'db_status; exit'
269
db_expected_output_regex = [/Connected to .+\. Connection type: .+\./]
270
unless run_msfconsole(db_status_command, db_expected_output_regex)
271
puts '-------------------------------'
272
error 'Database connection check failed. Exiting.'
273
exit 1
274
end
275
end
276
277
wordlist = Tempfile.new('wordlist')
278
File.open(wordlist, 'w') { |file| file.write("password\nhashcat\ntest1\ntoto\nfoo\nPassword1!\nprobe\ntere\na\nTHALES\nepsilon\n1234\nTestPass123#\npasswor\nd\n") }
279
info "Wordlist file created at: #{wordlist.path}"
280
281
if options[:test] == 'all' || options[:test].include?(2)
282
info '[2/24] Running *nix hashes in john wordlist mode...'
283
tempfile = Tempfile.new('john_pot')
284
creds_expected_output_regex = []
285
creds_command = 'setg INCREMENTAL false;setg USE_CREDS false; setg USE_DB_INFO false; setg USE_DEFAULT_WORDLIST false; setg USE_HOSTNAMES false; setg USE_ROOT_WORDS false; setg WORDLIST true; setg verbose true;'
286
cred_temp, regex_temp = nix_hashes_and_regex
287
creds_command << cred_temp
288
creds_expected_output_regex += regex_temp
289
creds_command << ' use auxiliary/analyze/crack_linux;'
290
creds_command << " set CUSTOM_WORDLIST #{wordlist.path};"
291
creds_command << " set POT #{tempfile.path};"
292
creds_command << ' run; creds -d; exit;'
293
info "Run Command: #{creds_command}" if options[:verbose]
294
unless run_msfconsole(creds_command, creds_expected_output_regex)
295
tempfile.close!
296
tempfile.unlink
297
puts '-------------------------------'
298
error 'Credential verification failed. Exiting.'
299
exit 1
300
end
301
tempfile.close!
302
tempfile.unlink
303
end
304
305
if options[:test] == 'all' || options[:test].include?(3)
306
info '[3/24] Running windows hashes in john wordlist mode...'
307
tempfile = Tempfile.new('john_pot')
308
creds_expected_output_regex = []
309
creds_command = 'setg INCREMENTAL false;setg USE_CREDS false; setg USE_DB_INFO false; setg USE_DEFAULT_WORDLIST false; setg USE_HOSTNAMES false; setg USE_ROOT_WORDS false; setg WORDLIST true; setg verbose true;'
310
cred_temp, regex_temp = windows_hashes_and_regex_john_compat
311
creds_command << cred_temp
312
creds_expected_output_regex += regex_temp
313
creds_command << ' use auxiliary/analyze/crack_windows;'
314
creds_command << " set CUSTOM_WORDLIST #{wordlist.path};"
315
creds_command << " set POT #{tempfile.path};"
316
creds_command << ' run; creds -d; exit;'
317
info "Run Command: #{creds_command}" if options[:verbose]
318
unless run_msfconsole(creds_command, creds_expected_output_regex)
319
tempfile.close!
320
tempfile.unlink
321
puts '-------------------------------'
322
error 'Credential verification failed. Exiting.'
323
exit 1
324
end
325
tempfile.close!
326
tempfile.unlink
327
end
328
329
if options[:test] == 'all' || options[:test].include?(4)
330
info '[4/24] Running sql hashes in john wordlist mode...'
331
tempfile = Tempfile.new('john_pot')
332
creds_expected_output_regex = []
333
creds_command = 'setg INCREMENTAL false;setg USE_CREDS false; setg USE_DB_INFO false; setg USE_DEFAULT_WORDLIST false; setg USE_HOSTNAMES false; setg USE_ROOT_WORDS false; setg WORDLIST true; setg verbose true;'
334
cred_temp, regex_temp = sql_hashes_and_regex_john_compat
335
creds_command << cred_temp
336
creds_expected_output_regex += regex_temp
337
338
creds_command << ' use auxiliary/analyze/crack_databases;'
339
creds_command << " set CUSTOM_WORDLIST #{wordlist.path};"
340
creds_command << " set POT #{tempfile.path};"
341
creds_command << ' run; creds -d; exit;'
342
info "Run Command: #{creds_command}" if options[:verbose]
343
unless run_msfconsole(creds_command, creds_expected_output_regex)
344
tempfile.close!
345
tempfile.unlink
346
puts '-------------------------------'
347
error 'Credential verification failed. Exiting.'
348
exit 1
349
end
350
tempfile.close!
351
tempfile.unlink
352
end
353
354
if options[:test] == 'all' || options[:test].include?(5)
355
info '[5/24] Running osx hashes in john wordlist mode...'
356
tempfile = Tempfile.new('john_pot')
357
creds_expected_output_regex = []
358
creds_command = 'setg INCREMENTAL false;setg USE_CREDS false; setg USE_DB_INFO false; setg USE_DEFAULT_WORDLIST false; setg USE_HOSTNAMES false; setg USE_ROOT_WORDS false; setg WORDLIST true; setg verbose true;'
359
cred_temp, regex_temp = osx_hashes_and_regex
360
creds_command << cred_temp
361
creds_expected_output_regex += regex_temp
362
creds_command << ' use auxiliary/analyze/crack_osx;'
363
creds_command << " set CUSTOM_WORDLIST #{wordlist.path};"
364
creds_command << " set POT #{tempfile.path};"
365
creds_command << ' run; creds -d; exit;'
366
info "Run Command: #{creds_command}" if options[:verbose]
367
unless run_msfconsole(creds_command, creds_expected_output_regex)
368
tempfile.close!
369
tempfile.unlink
370
puts '-------------------------------'
371
error 'Credential verification failed. Exiting.'
372
exit 1
373
end
374
tempfile.close!
375
tempfile.unlink
376
end
377
378
if options[:test] == 'all' || options[:test].include?(6)
379
info '[6/24] Running webapp hashes in john wordlist mode...'
380
tempfile = Tempfile.new('john_pot')
381
creds_expected_output_regex = []
382
creds_command = 'setg INCREMENTAL false;setg USE_CREDS false; setg USE_DB_INFO false; setg USE_DEFAULT_WORDLIST false; setg USE_HOSTNAMES false; setg USE_ROOT_WORDS false; setg WORDLIST true; setg verbose true;'
383
cred_temp, regex_temp = webapp_hashes_and_regex
384
creds_command << cred_temp
385
creds_expected_output_regex += regex_temp
386
creds_command << ' use auxiliary/analyze/crack_webapps;'
387
creds_command << " set CUSTOM_WORDLIST #{wordlist.path};"
388
creds_command << " set POT #{tempfile.path};"
389
creds_command << ' run; creds -d; exit;'
390
info "Run Command: #{creds_command}" if options[:verbose]
391
unless run_msfconsole(creds_command, creds_expected_output_regex)
392
tempfile.close!
393
tempfile.unlink
394
puts '-------------------------------'
395
error 'Credential verification failed. Exiting.'
396
exit 1
397
end
398
tempfile.close!
399
tempfile.unlink
400
end
401
402
if options[:test] == 'all' || options[:test].include?(7)
403
info '[7/24] Running *nix hashes in hashcat wordlist mode...'
404
tempfile = Tempfile.new('john_pot')
405
creds_expected_output_regex = []
406
creds_command = 'setg INCREMENTAL false;setg USE_CREDS false; setg USE_DB_INFO false; setg USE_DEFAULT_WORDLIST false; setg USE_HOSTNAMES false; setg USE_ROOT_WORDS false; setg WORDLIST true; setg verbose true;'
407
cred_temp, regex_temp = nix_hashes_and_regex
408
creds_command << cred_temp
409
creds_expected_output_regex += regex_temp
410
creds_command << ' use auxiliary/analyze/crack_linux;'
411
creds_command << " set CUSTOM_WORDLIST #{wordlist.path};"
412
creds_command << " set POT #{tempfile.path};"
413
creds_command << ' set action hashcat;'
414
creds_command << ' run; creds -d; exit;'
415
info "Run Command: #{creds_command}" if options[:verbose]
416
unless run_msfconsole(creds_command, creds_expected_output_regex)
417
tempfile.close!
418
tempfile.unlink
419
puts '-------------------------------'
420
error 'Credential verification failed. Exiting.'
421
exit 1
422
end
423
tempfile.close!
424
tempfile.unlink
425
end
426
427
if options[:test] == 'all' || options[:test].include?(8)
428
info '[8/24] Running windows hashes in hashcat wordlist mode...'
429
tempfile = Tempfile.new('john_pot')
430
creds_expected_output_regex = []
431
creds_command = 'setg INCREMENTAL false;setg USE_CREDS false; setg USE_DB_INFO false; setg USE_DEFAULT_WORDLIST false; setg USE_HOSTNAMES false; setg USE_ROOT_WORDS false; setg WORDLIST true; setg verbose true;'
432
cred_temp, regex_temp = windows_hashes_and_regex_hashcat_compat
433
creds_command << cred_temp
434
creds_expected_output_regex += regex_temp
435
creds_command << ' use auxiliary/analyze/crack_windows;'
436
creds_command << " set CUSTOM_WORDLIST #{wordlist.path};"
437
creds_command << " set POT #{tempfile.path};"
438
creds_command << ' set action hashcat;'
439
creds_command << ' run; creds -d; exit;'
440
info "Run Command: #{creds_command}" if options[:verbose]
441
unless run_msfconsole(creds_command, creds_expected_output_regex)
442
tempfile.close!
443
tempfile.unlink
444
puts '-------------------------------'
445
error 'Credential verification failed. Exiting.'
446
exit 1
447
end
448
tempfile.close!
449
tempfile.unlink
450
end
451
452
if options[:test] == 'all' || options[:test].include?(9)
453
info '[9/24] Running sql hashes in hashcat wordlist mode...'
454
tempfile = Tempfile.new('john_pot')
455
creds_expected_output_regex = []
456
creds_command = 'setg INCREMENTAL false;setg USE_CREDS false; setg USE_DB_INFO false; setg USE_DEFAULT_WORDLIST false; setg USE_HOSTNAMES false; setg USE_ROOT_WORDS false; setg WORDLIST true; setg verbose true;'
457
cred_temp, regex_temp = sql_hashes_and_regex_hashcat_compat
458
creds_command << cred_temp
459
creds_expected_output_regex += regex_temp
460
461
creds_command << ' use auxiliary/analyze/crack_databases;'
462
creds_command << " set CUSTOM_WORDLIST #{wordlist.path};"
463
creds_command << " set POT #{tempfile.path};"
464
creds_command << ' set action hashcat;'
465
creds_command << ' run; creds -d; exit;'
466
info "Run Command: #{creds_command}" if options[:verbose]
467
unless run_msfconsole(creds_command, creds_expected_output_regex)
468
tempfile.close!
469
tempfile.unlink
470
puts '-------------------------------'
471
error 'Credential verification failed. Exiting.'
472
exit 1
473
end
474
tempfile.close!
475
tempfile.unlink
476
end
477
478
if options[:test] == 'all' || options[:test].include?(10)
479
info '[10/24] Running mobile hashes in hashcat wordlist mode...'
480
tempfile = Tempfile.new('john_pot')
481
creds_expected_output_regex = []
482
creds_command = 'setg INCREMENTAL false;setg USE_CREDS false; setg USE_DB_INFO false; setg USE_DEFAULT_WORDLIST false; setg USE_HOSTNAMES false; setg USE_ROOT_WORDS false; setg WORDLIST true; setg verbose true;'
483
cred_temp, regex_temp = mobile_hashes_and_regex
484
creds_command << cred_temp
485
creds_expected_output_regex += regex_temp
486
creds_command << ' use auxiliary/analyze/crack_mobile;'
487
creds_command << " set CUSTOM_WORDLIST #{wordlist.path};"
488
creds_command << " set POT #{tempfile.path};"
489
creds_command << ' set action hashcat;'
490
creds_command << ' run; creds -d; exit;'
491
info "Run Command: #{creds_command}" if options[:verbose]
492
unless run_msfconsole(creds_command, creds_expected_output_regex)
493
tempfile.close!
494
tempfile.unlink
495
puts '-------------------------------'
496
error 'Credential verification failed. Exiting.'
497
exit 1
498
end
499
tempfile.close!
500
tempfile.unlink
501
end
502
503
if options[:test] == 'all' || options[:test].include?(11)
504
info '[11/24] Running osx hashes in hashcat wordlist mode...'
505
tempfile = Tempfile.new('john_pot')
506
creds_expected_output_regex = []
507
creds_command = 'setg INCREMENTAL false;setg USE_CREDS false; setg USE_DB_INFO false; setg USE_DEFAULT_WORDLIST false; setg USE_HOSTNAMES false; setg USE_ROOT_WORDS false; setg WORDLIST true; setg verbose true;'
508
cred_temp, regex_temp = osx_hashes_and_regex
509
creds_command << cred_temp
510
creds_expected_output_regex += regex_temp
511
creds_command << ' use auxiliary/analyze/crack_osx;'
512
creds_command << " set CUSTOM_WORDLIST #{wordlist.path};"
513
creds_command << " set POT #{tempfile.path};"
514
creds_command << ' set action hashcat;'
515
creds_command << ' run; creds -d; exit;'
516
info "Run Command: #{creds_command}" if options[:verbose]
517
unless run_msfconsole(creds_command, creds_expected_output_regex)
518
tempfile.close!
519
tempfile.unlink
520
puts '-------------------------------'
521
error 'Credential verification failed. Exiting.'
522
exit 1
523
end
524
tempfile.close!
525
tempfile.unlink
526
end
527
528
if options[:test] == 'all' || options[:test].include?(12)
529
info '[12/24] Running webapp hashes in hashcat wordlist mode...'
530
tempfile = Tempfile.new('john_pot')
531
creds_expected_output_regex = []
532
creds_command = 'setg INCREMENTAL false;setg USE_CREDS false; setg USE_DB_INFO false; setg USE_DEFAULT_WORDLIST false; setg USE_HOSTNAMES false; setg USE_ROOT_WORDS false; setg WORDLIST true; setg verbose true;'
533
cred_temp, regex_temp = webapp_hashes_and_regex
534
creds_command << cred_temp
535
creds_expected_output_regex += regex_temp
536
creds_command << ' use auxiliary/analyze/crack_webapps;'
537
creds_command << " set CUSTOM_WORDLIST #{wordlist.path};"
538
creds_command << " set POT #{tempfile.path};"
539
creds_command << ' set action hashcat;'
540
creds_command << ' run; creds -d; exit;'
541
info "Run Command: #{creds_command}" if options[:verbose]
542
unless run_msfconsole(creds_command, creds_expected_output_regex)
543
tempfile.close!
544
tempfile.unlink
545
puts '-------------------------------'
546
error 'Credential verification failed. Exiting.'
547
exit 1
548
end
549
tempfile.close!
550
tempfile.unlink
551
end
552
553
wordlist.close!
554
wordlist.unlink
555
556
pot_file = Tempfile.new('john_pot')
557
File.open(pot_file, 'w') { |file| file.write("$1$O3JMY.Tw$AdLnLjQ/5jXF9.MTp3gHv/:password\nrEK1ecacw.7.c:password\n_J9..K0AyUubDrfOgO4s:password\n$2a$05$bvIG6Nmid91Mu9RcmmWZfO5HJIMCT8riNW0hEp8f6/FuA2/mHZFpe:password\n$5$MnfsQ4iN$ZMTppKN16y/tIsUYs/obHlhdP.Os80yXhTurpBMUbA5:password\n$6$zWwwXKNj$gLAOoZCjcr8p/.VgV/FkGC3NX7BsXys3KHYePfuIGMNjY83dVxugPYlxVg/evpcVEJLT/rSwZcDMlVVf/bhf.1:password\n$LM$4a3b108f3fa6cb6d:D\n$LM$e52cac67419a9a22:PASSWOR\n$NT$8846f7eaee8fb117ad06bdd830b7586c:password\nM$test1#64cd29e36a8431a2b111378564a10631:test1\n$DCC2$10240#tom#e4e938d12fe5974dc42a90120bd9c90f:hashcat\n$NETNTLM$cb8086049ec4736c338d08f8e26de933$9526fb8c23a90751cdd619b6cea564742e1e4bf33006ba41:hashcat\n$NETNTLMv2$ADMINN46iSNekpT$08ca45b7d7ea58ee$88dcbe4446168966a153a0064958dac6$5c7830315c7830310000000000000b45c67103d07d7b95acd12ffa11230e0000000052920b85f78d013c31cdb3b92f5d765c783030:hashcat\n0x0100A607BA7C54A24D17B565C59F1743776A10250F581D482DA8B6D6261460D3F53B279CC6913CE747006A2E3254:FOO\n0x01004086CEB6BF932BC4151A1AF1F13CD17301D70816A8886908:toto\n0x0200F733058A07892C5CACE899768F89965F6BD1DED7955FE89E1C9A10E27849B0B213B5CE92CC9347ECCB34C3EFADAF2FD99BFFECD8D9150DD6AACB5D409A9D2652A4E0AF16:Password1!\n445ff82636a7ba59:probe\n*5AD8F88516BD021DD43F171E2C785C69F8E54ADB:tere\nO$SIMON#4f8bc1809cb2af77:A\nO$SYSTEM#9eedfa0ad26c6d52:THALES\n9860a48ca459d054f3fef0f8518cf6872923dae2:81fcb23bcadd6c5:1234\nd1b19a90b87fc10c304e657f37162445dae27d16:a006983800cc3dd1:1234\n1c0a0fdb673fba36beaeb078322c7393:81fcb23bcadd6c5:1234\n1430823483D07626EF8BE3FDA2FF056D0DFD818DBFE47683:hashcat\n$LION$648742485c9b0acd786a233b2330197223118111b481abfa0ab8b3e8ede5f014fc7c523991c007db6882680b09962d16fd9c45568260531bdb34804a5e31c22b4cfeb32d:hashcat\n$pbkdf2-hmac-sha512$35460.93a94bd24b5de64d79a5e49fa372827e739f4d7b6975c752c9a0ff1e5cf72e05.752351df64dd2ce9dc9c64a72ad91de6581a15c19176266b44d98919dfa81f0f96cbcb20a1ffb400718c20382030f637892f776627d34e021bad4f81b7de8222:hashcat\n$pbkdf2-hmac-sha1$10000$37323237333437363735323036323731$d0c38acef03f149b4b37c5a8319feeefcbd34912127ba96f3dfa5c22f49bbc1a:hashcat\n$H$984478476IagS59wHZvyQMArzfx58u.:hashcat\n$P$984478476IagS59wHZvyQMArzfx58u.:hashcat\n$B$56668501$0ce106caa70af57fd525aeaf80ef2898:hashcat\ne52cac67419a9a22:PASSWOR\n4a3b108f3fa6cb6d:D\n8846f7eaee8fb117ad06bdd830b7586c:password\n64cd29e36a8431a2b111378564a10631:test1:test1\nu4-netntlm::kNS:338d08f8e26de93300000000000000000000000000000000:9526fb8c23a90751cdd619b6cea564742e1e4bf33006ba41:cb8086049ec4736c:hashcat\nADMIN::N46iSNekpT:08ca45b7d7ea58ee:88dcbe4446168966a153a0064958dac6:5c7830315c7830310000000000000b45c67103d07d7b95acd12ffa11230e0000000052920b85f78d013c31cdb3b92f5d765c783030:hashcat\n5ad8f88516bd021dd43f171e2c785c69f8e54adb:tere\n648742485c9b0acd786a233b2330197223118111b481abfa0ab8b3e8ede5f014fc7c523991c007db6882680b09962d16fd9c45568260531bdb34804a5e31c22b4cfeb32d:hashcat\n$ml$35460$93a94bd24b5de64d79a5e49fa372827e739f4d7b6975c752c9a0ff1e5cf72e05$752351df64dd2ce9dc9c64a72ad91de6581a15c19176266b44d98919dfa81f0f96cbcb20a1ffb400718c20382030f637892f776627d34e021bad4f81b7de8222:hashcat\n{PKCS5S2}NzIyNzM0NzY3NTIwNjI3MdDDis7wPxSbSzfFqDGf7u/L00kSEnupbz36XCL0m7wa:hashcat\n") }
558
info "john.pot file created at: #{pot_file.path}"
559
560
if options[:test] == 'all' || options[:test].include?(13)
561
info '[13/24] Running *nix hashes in john pot mode...'
562
creds_expected_output_regex = []
563
creds_command = 'setg INCREMENTAL false;setg USE_CREDS false; setg USE_DB_INFO false; setg USE_DEFAULT_WORDLIST false; setg USE_HOSTNAMES false; setg USE_ROOT_WORDS false; setg WORDLIST false; setg verbose true;'
564
cred_temp, regex_temp = nix_hashes_and_regex
565
creds_command << cred_temp
566
creds_expected_output_regex += regex_temp
567
creds_command << ' use auxiliary/analyze/crack_linux;'
568
creds_command << " set POT #{pot_file.path};"
569
creds_command << ' run; creds -d; exit;'
570
info "Run Command: #{creds_command}" if options[:verbose]
571
unless run_msfconsole(creds_command, creds_expected_output_regex)
572
puts '-------------------------------'
573
error 'Credential verification failed. Exiting.'
574
pot_file.close!
575
pot_file.unlink
576
exit 1
577
end
578
end
579
580
if options[:test] == 'all' || options[:test].include?(14)
581
info '[14/24] Running windows hashes in john pot mode...'
582
583
creds_expected_output_regex = []
584
creds_command = 'setg INCREMENTAL false;setg USE_CREDS false; setg USE_DB_INFO false; setg USE_DEFAULT_WORDLIST false; setg USE_HOSTNAMES false; setg USE_ROOT_WORDS false; setg WORDLIST false; setg verbose true;'
585
cred_temp, regex_temp = windows_hashes_and_regex_john_compat
586
creds_command << cred_temp
587
creds_expected_output_regex += regex_temp
588
creds_command << ' use auxiliary/analyze/crack_windows;'
589
creds_command << " set POT #{pot_file.path};"
590
creds_command << ' run; creds -d; exit;'
591
info "Run Command: #{creds_command}" if options[:verbose]
592
unless run_msfconsole(creds_command, creds_expected_output_regex)
593
puts '-------------------------------'
594
error 'Credential verification failed. Exiting.'
595
pot_file.close!
596
pot_file.unlink
597
exit 1
598
end
599
end
600
601
if options[:test] == 'all' || options[:test].include?(15)
602
info '[15/24] Running sql hashes in john pot mode...'
603
604
creds_expected_output_regex = []
605
creds_command = 'setg INCREMENTAL false;setg USE_CREDS false; setg USE_DB_INFO false; setg USE_DEFAULT_WORDLIST false; setg USE_HOSTNAMES false; setg USE_ROOT_WORDS false; setg WORDLIST false; setg verbose true;'
606
cred_temp, regex_temp = sql_hashes_and_regex_john_compat
607
creds_command << cred_temp
608
creds_expected_output_regex += regex_temp
609
610
creds_command << ' use auxiliary/analyze/crack_databases;'
611
creds_command << " set CUSTOM_WORDLIST #{wordlist.path};"
612
creds_command << " set POT #{pot_file.path};"
613
creds_command << ' run; creds -d; exit;'
614
info "Run Command: #{creds_command}" if options[:verbose]
615
unless run_msfconsole(creds_command, creds_expected_output_regex)
616
puts '-------------------------------'
617
error 'Credential verification failed. Exiting.'
618
pot_file.close!
619
pot_file.unlink
620
exit 1
621
end
622
end
623
624
if options[:test] == 'all' || options[:test].include?(16)
625
info '[16/24] Running osx hashes in john pot mode...'
626
627
creds_expected_output_regex = []
628
creds_command = 'setg INCREMENTAL false;setg USE_CREDS false; setg USE_DB_INFO false; setg USE_DEFAULT_WORDLIST false; setg USE_HOSTNAMES false; setg USE_ROOT_WORDS false; setg WORDLIST false; setg verbose true;'
629
cred_temp, regex_temp = osx_hashes_and_regex
630
creds_command << cred_temp
631
creds_expected_output_regex += regex_temp
632
creds_command << ' use auxiliary/analyze/crack_osx;'
633
creds_command << " set POT #{pot_file.path};"
634
creds_command << ' run; creds -d; exit;'
635
info "Run Command: #{creds_command}" if options[:verbose]
636
unless run_msfconsole(creds_command, creds_expected_output_regex)
637
puts '-------------------------------'
638
error 'Credential verification failed. Exiting.'
639
pot_file.close!
640
pot_file.unlink
641
exit 1
642
end
643
end
644
645
if options[:test] == 'all' || options[:test].include?(17)
646
info '[17/24] Running webapp hashes in john pot mode...'
647
648
creds_expected_output_regex = []
649
creds_command = 'setg INCREMENTAL false;setg USE_CREDS false; setg USE_DB_INFO false; setg USE_DEFAULT_WORDLIST false; setg USE_HOSTNAMES false; setg USE_ROOT_WORDS false; setg WORDLIST false; setg verbose true;'
650
cred_temp, regex_temp = webapp_hashes_and_regex
651
creds_command << cred_temp
652
creds_expected_output_regex += regex_temp
653
creds_command << ' use auxiliary/analyze/crack_webapps;'
654
creds_command << " set POT #{pot_file.path};"
655
creds_command << ' run; creds -d; exit;'
656
info "Run Command: #{creds_command}" if options[:verbose]
657
unless run_msfconsole(creds_command, creds_expected_output_regex)
658
puts '-------------------------------'
659
error 'Credential verification failed. Exiting.'
660
pot_file.close!
661
pot_file.unlink
662
exit 1
663
end
664
end
665
666
if options[:test] == 'all' || options[:test].include?(18)
667
info '[18/24] Running *nix hashes in hashcat pot mode...'
668
669
creds_expected_output_regex = []
670
creds_command = 'setg INCREMENTAL false;setg USE_CREDS false; setg USE_DB_INFO false; setg USE_DEFAULT_WORDLIST false; setg USE_HOSTNAMES false; setg USE_ROOT_WORDS false; setg WORDLIST false; setg verbose true;'
671
cred_temp, regex_temp = nix_hashes_and_regex
672
creds_command << cred_temp
673
creds_expected_output_regex += regex_temp
674
creds_command << ' use auxiliary/analyze/crack_linux;'
675
creds_command << " set POT #{pot_file.path};"
676
creds_command << ' set action hashcat;'
677
creds_command << ' run; creds -d; exit;'
678
info "Run Command: #{creds_command}" if options[:verbose]
679
unless run_msfconsole(creds_command, creds_expected_output_regex)
680
puts '-------------------------------'
681
error 'Credential verification failed. Exiting.'
682
pot_file.close!
683
pot_file.unlink
684
exit 1
685
end
686
end
687
688
if options[:test] == 'all' || options[:test].include?(19)
689
info '[19/24] Running windows hashes in hashcat pot mode...'
690
691
creds_expected_output_regex = []
692
creds_command = 'setg INCREMENTAL false;setg USE_CREDS false; setg USE_DB_INFO false; setg USE_DEFAULT_WORDLIST false; setg USE_HOSTNAMES false; setg USE_ROOT_WORDS false; setg WORDLIST false; setg verbose true;'
693
cred_temp, regex_temp = windows_hashes_and_regex_hashcat_compat
694
creds_command << cred_temp
695
creds_expected_output_regex += regex_temp
696
creds_command << ' use auxiliary/analyze/crack_windows;'
697
creds_command << " set POT #{pot_file.path};"
698
creds_command << ' set action hashcat;'
699
creds_command << ' run; creds -d; exit;'
700
info "Run Command: #{creds_command}" if options[:verbose]
701
unless run_msfconsole(creds_command, creds_expected_output_regex)
702
puts '-------------------------------'
703
error 'Credential verification failed. Exiting.'
704
pot_file.close!
705
pot_file.unlink
706
exit 1
707
end
708
end
709
710
if options[:test] == 'all' || options[:test].include?(20)
711
info '[20/24] Running sql hashes in hashcat pot mode...'
712
713
creds_expected_output_regex = []
714
creds_command = 'setg INCREMENTAL false;setg USE_CREDS false; setg USE_DB_INFO false; setg USE_DEFAULT_WORDLIST false; setg USE_HOSTNAMES false; setg USE_ROOT_WORDS false; setg WORDLIST false; setg verbose true;'
715
cred_temp, regex_temp = sql_hashes_and_regex_hashcat_compat
716
creds_command << cred_temp
717
creds_expected_output_regex += regex_temp
718
719
creds_command << ' use auxiliary/analyze/crack_databases;'
720
creds_command << " set POT #{pot_file.path};"
721
creds_command << ' set action hashcat;'
722
creds_command << ' run; creds -d; exit;'
723
info "Run Command: #{creds_command}" if options[:verbose]
724
unless run_msfconsole(creds_command, creds_expected_output_regex)
725
puts '-------------------------------'
726
error 'Credential verification failed. Exiting.'
727
pot_file.close!
728
pot_file.unlink
729
exit 1
730
end
731
end
732
733
if options[:test] == 'all' || options[:test].include?(21)
734
info '[21/24] Running mobile hashes in hashcat pot mode...'
735
736
creds_expected_output_regex = []
737
creds_command = 'setg INCREMENTAL false;setg USE_CREDS false; setg USE_DB_INFO false; setg USE_DEFAULT_WORDLIST false; setg USE_HOSTNAMES false; setg USE_ROOT_WORDS false; setg WORDLIST false; setg verbose true;'
738
cred_temp, regex_temp = mobile_hashes_and_regex
739
creds_command << cred_temp
740
creds_expected_output_regex += regex_temp
741
creds_command << ' use auxiliary/analyze/crack_mobile;'
742
creds_command << " set POT #{pot_file.path};"
743
creds_command << ' set action hashcat;'
744
creds_command << ' run; creds -d; exit;'
745
info "Run Command: #{creds_command}" if options[:verbose]
746
unless run_msfconsole(creds_command, creds_expected_output_regex)
747
puts '-------------------------------'
748
error 'Credential verification failed. Exiting.'
749
pot_file.close!
750
pot_file.unlink
751
exit 1
752
end
753
end
754
755
if options[:test] == 'all' || options[:test].include?(22)
756
info '[22/24] Running osx hashes in hashcat pot mode...'
757
758
creds_expected_output_regex = []
759
creds_command = 'setg INCREMENTAL false;setg USE_CREDS false; setg USE_DB_INFO false; setg USE_DEFAULT_WORDLIST false; setg USE_HOSTNAMES false; setg USE_ROOT_WORDS false; setg WORDLIST false; setg verbose true;'
760
cred_temp, regex_temp = osx_hashes_and_regex
761
creds_command << cred_temp
762
creds_expected_output_regex += regex_temp
763
creds_command << ' use auxiliary/analyze/crack_osx;'
764
creds_command << " set POT #{pot_file.path};"
765
creds_command << ' set action hashcat;'
766
creds_command << ' run; creds -d; exit;'
767
info "Run Command: #{creds_command}" if options[:verbose]
768
unless run_msfconsole(creds_command, creds_expected_output_regex)
769
puts '-------------------------------'
770
error 'Credential verification failed. Exiting.'
771
pot_file.close!
772
pot_file.unlink
773
exit 1
774
end
775
end
776
777
if options[:test] == 'all' || options[:test].include?(23)
778
info '[23/24] Running webapp hashes in hashcat pot mode...'
779
780
creds_expected_output_regex = []
781
creds_command = 'setg INCREMENTAL false;setg USE_CREDS false; setg USE_DB_INFO false; setg USE_DEFAULT_WORDLIST false; setg USE_HOSTNAMES false; setg USE_ROOT_WORDS false; setg WORDLIST false; setg verbose true;'
782
cred_temp, regex_temp = webapp_hashes_and_regex
783
creds_command << cred_temp
784
creds_expected_output_regex += regex_temp
785
creds_command << ' use auxiliary/analyze/crack_webapps;'
786
creds_command << " set POT #{pot_file.path};"
787
creds_command << ' set action hashcat;'
788
creds_command << ' run; creds -d; exit;'
789
info "Run Command: #{creds_command}" if options[:verbose]
790
unless run_msfconsole(creds_command, creds_expected_output_regex)
791
puts '-------------------------------'
792
error 'Credential verification failed. Exiting.'
793
pot_file.close!
794
pot_file.unlink
795
exit 1
796
end
797
end
798
799
if options[:test] == 'all' || options[:test].include?(24)
800
info '[24/24] Running all hashes in john apply_pot mode...'
801
802
creds_expected_output_regex = []
803
creds_command = 'setg verbose true;'
804
cred_temp, regex_temp = nix_hashes_and_regex
805
creds_command << cred_temp
806
creds_expected_output_regex += regex_temp
807
cred_temp, regex_temp = windows_hashes_and_regex_john_compat
808
creds_command << cred_temp
809
creds_expected_output_regex += regex_temp
810
cred_temp, regex_temp = sql_hashes_and_regex_john_compat
811
creds_command << cred_temp
812
creds_expected_output_regex += regex_temp
813
cred_temp, regex_temp = osx_hashes_and_regex
814
creds_command << cred_temp
815
creds_expected_output_regex += regex_temp
816
cred_temp, regex_temp = webapp_hashes_and_regex
817
creds_command << cred_temp
818
creds_expected_output_regex += regex_temp
819
creds_command << ' use auxiliary/analyze/apply_pot;'
820
creds_command << " set POT #{pot_file.path};"
821
creds_command << ' run; creds -d; exit;'
822
info "Run Command: #{creds_command}" if options[:verbose]
823
unless run_msfconsole(creds_command, creds_expected_output_regex)
824
puts '-------------------------------'
825
error 'Credential verification failed. Exiting.'
826
pot_file.close!
827
pot_file.unlink
828
exit 1
829
end
830
end
831
832
pot_file.close!
833
pot_file.unlink
834
835
puts '-------------------------------'
836
good 'All checks passed successfully!'
837
info "Script runtime: #{Time.now - start_time} seconds"
838
839