Fix "localhost" bug for connect calls as well

git-svn-id: file:///home/svn/framework3/trunk@4182 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
HD Moore 2006-12-10 08:27:51 +00:00
parent 40242aca92
commit d39d662c95
1 changed files with 7 additions and 1 deletions

View File

@ -62,7 +62,13 @@ class Plugin::DBMySQL < Msf::Plugin
opts['database'] = info[:name]
opts['host'] = info[:host] if (info[:host])
opts['port'] = info[:port] if (info[:port])
# This is an ugly hack for a broken MySQL adapter:
# http://dev.rubyonrails.org/ticket/3338
if (opts['host'].strip.downcase == 'localhost')
opts['host'] = Socket.gethostbyname("localhost")[3].unpack("C*").join(".")
end
if (not framework.db.connect(opts))
raise PluginLoadError.new("Failed to connect to the database")
end