Skip to content

Commit

Permalink
add -y to db_connect, fixes #3046
Browse files Browse the repository at this point in the history
git-svn-id: file:///home/svn/framework3/trunk@10802 4d416f70-5f16-0410-b530-b9f4589650da
  • Loading branch information
jlee-r7 committed Oct 23, 2010
1 parent cdef02c commit c03da4f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/msf/ui/console/command_dispatcher/db.rb
Expand Up @@ -1499,6 +1499,19 @@ def cmd_db_destroy(*args)

def cmd_db_connect(*args)
return if not db_check_driver
if (args[0] == "-y")
if (args[1] and not File.exists? File.expand_path(args[1]))
print_error("File not found")
return
end
file = args[1] || File.join(Msf::Config.get_config_root, "database.yml")
if (File.exists? File.expand_path(file))
db = YAML.load(File.read(file))['production']
cmd_db_driver(db['adapter'])
framework.db.connect(db)
return
end
end
meth = "db_connect_#{framework.db.driver}"
if(self.respond_to?(meth))
self.send(meth, *args)
Expand Down Expand Up @@ -1629,6 +1642,7 @@ def db_parse_db_uri_sqlite3(path)
def db_connect_mysql(*args)
if(args[0] == nil or args[0] == "-h" or args[0] == "--help")
print_status(" Usage: db_connect <user:pass>@<host:port>/<database>")
print_status(" OR: db_connect -y [path/to/database.yml]")
print_status("Examples:")
print_status(" db_connect user@metasploit3")
print_status(" db_connect user:pass@192.168.0.2/metasploit3")
Expand Down Expand Up @@ -1788,6 +1802,7 @@ def db_parse_db_uri_mysql(path)
def db_connect_postgresql(*args)
if(args[0] == nil or args[0] == "-h" or args[0] == "--help")
print_status(" Usage: db_connect <user:pass>@<host:port>/<database>")
print_status(" OR: db_connect -y [path/to/database.yml]")
print_status("Examples:")
print_status(" db_connect user@metasploit3")
print_status(" db_connect user:pass@192.168.0.2/metasploit3")
Expand Down

0 comments on commit c03da4f

Please sign in to comment.