2011-10-26 22:32:08 +00:00
|
|
|
##
|
2013-10-15 18:50:46 +00:00
|
|
|
# This module requires Metasploit: http//metasploit.com/download
|
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2011-10-26 22:32:08 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
|
|
|
|
require 'msf/core'
|
2014-06-18 19:50:08 +00:00
|
|
|
require 'msf/core/auxiliary/jtr'
|
2011-10-26 22:32:08 +00:00
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
include Msf::Auxiliary::JohnTheRipper
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => 'John the Ripper MS SQL Password Cracker (Fast Mode)',
|
|
|
|
'Description' => %Q{
|
|
|
|
This module uses John the Ripper to identify weak passwords that have been
|
|
|
|
acquired from the mssql_hashdump module. Passwords that have been successfully
|
|
|
|
cracked are then saved as proper credentials
|
|
|
|
},
|
|
|
|
'Author' =>
|
|
|
|
[
|
|
|
|
'theLightCosine',
|
|
|
|
'hdm'
|
|
|
|
],
|
|
|
|
'License' => MSF_LICENSE # JtR itself is GPLv2, but this wrapper is MSF (BSD)
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def run
|
2014-06-18 19:50:08 +00:00
|
|
|
@formats = Set.new
|
|
|
|
cracker = new_john_cracker
|
|
|
|
|
|
|
|
#generate our wordlist and close the file handle
|
|
|
|
wordlist = wordlist_file
|
|
|
|
wordlist.close
|
2014-06-19 18:08:43 +00:00
|
|
|
print_status "Wordlist file written out to #{wordlist.path}"
|
2014-06-18 19:50:08 +00:00
|
|
|
cracker.wordlist = wordlist.path
|
|
|
|
cracker.hash_path = hash_file
|
|
|
|
|
|
|
|
@formats.each do |format|
|
2014-06-19 17:38:01 +00:00
|
|
|
# dupe our original cracker so we can safely change options between each run
|
|
|
|
cracker_instance = cracker.dup
|
|
|
|
cracker_instance.format = format
|
|
|
|
print_status "Cracking #{format} hashes in normal wordlist mode..."
|
|
|
|
cracker_instance.crack do |line|
|
|
|
|
print_status line.chomp
|
|
|
|
end
|
|
|
|
|
|
|
|
print_status "Cracking #{format} hashes in single mode..."
|
|
|
|
cracker_instance.rules = 'single'
|
|
|
|
cracker_instance.crack do |line|
|
|
|
|
print_status line.chomp
|
|
|
|
end
|
|
|
|
|
|
|
|
print_status "Cracking #{format} hashes in incremental mode (All4)..."
|
|
|
|
cracker_instance.rules = nil
|
2014-06-19 18:08:43 +00:00
|
|
|
cracker_instance.wordlist = nil
|
|
|
|
cracker_instance.incremental = 'All4'
|
2014-06-19 17:38:01 +00:00
|
|
|
cracker_instance.crack do |line|
|
|
|
|
print_status line.chomp
|
|
|
|
end
|
|
|
|
|
|
|
|
print_status "Cracking #{format} hashes in incremental mode (Digits5)..."
|
2014-06-19 18:08:43 +00:00
|
|
|
cracker_instance.incremental = 'Digits5'
|
2014-06-19 17:38:01 +00:00
|
|
|
cracker_instance.crack do |line|
|
|
|
|
print_status line.chomp
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
2014-06-19 17:16:49 +00:00
|
|
|
|
|
|
|
print_status "Cracked Passwords this run:"
|
2014-06-19 17:38:01 +00:00
|
|
|
cracker_instance.each_cracked_password do |password_line|
|
2014-06-19 17:16:49 +00:00
|
|
|
next if password_line.blank?
|
2014-06-19 20:07:33 +00:00
|
|
|
# We look for the outpuy line containing username:password:core.id: for our actual password results
|
2014-06-19 17:16:49 +00:00
|
|
|
next unless password_line =~ /\w+:\w+:\d+:/
|
|
|
|
username, password, core_id = password_line.split(':')
|
|
|
|
create_cracked_credential( username: username, password: password, core_id: core_id)
|
2014-06-19 17:38:01 +00:00
|
|
|
print_good password_line.chomp
|
2014-06-19 17:16:49 +00:00
|
|
|
end
|
2014-06-18 19:50:08 +00:00
|
|
|
end
|
2013-08-30 21:28:54 +00:00
|
|
|
|
2014-06-18 19:50:08 +00:00
|
|
|
end
|
2013-08-30 21:28:54 +00:00
|
|
|
|
2014-06-18 19:50:08 +00:00
|
|
|
def hash_file
|
|
|
|
hashlist = Rex::Quickfile.new("hashes_tmp")
|
|
|
|
Metasploit::Credential::NonreplayableHash.joins(:cores).where(metasploit_credential_cores: { workspace_id: myworkspace.id }, jtr_format: ['mssql', 'mssql05']).each do |hash|
|
|
|
|
# Track the formats that we've seen so we do not attempt a format that isn't relevant
|
|
|
|
@formats << hash.jtr_format
|
|
|
|
hash.cores.each do |core|
|
|
|
|
user = core.public.username
|
|
|
|
hash_string = "0x#{hash.data}"
|
|
|
|
id = core.id
|
|
|
|
hashlist.puts "#{user}:#{hash_string}:#{id}:"
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
|
|
|
end
|
2014-06-18 19:50:08 +00:00
|
|
|
hashlist.close
|
|
|
|
print_status "Hashes Written out to #{hashlist.path}"
|
|
|
|
hashlist.path
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
2011-10-26 22:32:08 +00:00
|
|
|
|
2014-06-18 19:50:08 +00:00
|
|
|
|
2011-10-26 23:31:12 +00:00
|
|
|
end
|