From 6c3c67fec00d4f9e02bf8a4911241234f968764a Mon Sep 17 00:00:00 2001 From: HD Moore Date: Mon, 18 Sep 2006 00:29:14 +0000 Subject: [PATCH] More bug fixes... git-svn-id: file:///home/svn/framework3/trunk@3911 4d416f70-5f16-0410-b530-b9f4589650da --- plugins/db_postgres.rb | 2 +- plugins/db_sqlite2.rb | 12 ++++++++---- plugins/db_sqlite3.rb | 10 +++++++--- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/plugins/db_postgres.rb b/plugins/db_postgres.rb index 392c243c70..04b6acfb28 100644 --- a/plugins/db_postgres.rb +++ b/plugins/db_postgres.rb @@ -46,7 +46,7 @@ class Plugin::DBPostgres < Msf::Plugin def cmd_db_disconnect(*args) if (framework.db) framework.db.disconnect() - driver.remove_dispatcher(DatabaseCommandDispatcher) + driver.remove_dispatcher('Database Backend') end end diff --git a/plugins/db_sqlite2.rb b/plugins/db_sqlite2.rb index 73c80c8846..8a2ebec87a 100644 --- a/plugins/db_sqlite2.rb +++ b/plugins/db_sqlite2.rb @@ -45,7 +45,7 @@ class Plugin::DBSQLite2 < Msf::Plugin def cmd_db_disconnect(*args) if (framework.db) framework.db.disconnect() - driver.remove_dispatcher(DatabaseCommandDispatcher) + driver.remove_dispatcher('Database Backend') end end @@ -58,7 +58,11 @@ class Plugin::DBSQLite2 < Msf::Plugin opts['dbfile'] = info[:path] - + if (not File.exists?(opts['dbfile'])) + print_status("The specified database does not exist") + return + end + if (not framework.db.connect(opts)) raise PluginLoadError.new("Failed to connect to the database") end @@ -79,7 +83,7 @@ class Plugin::DBSQLite2 < Msf::Plugin odb = File.join(Msf::Config.install_root, "data", "sql", "sqlite2.db") - File.copy(odb, info[:path]) + FileUtils.copy(odb, info[:path]) if (not framework.db.connect(opts)) raise PluginLoadError.new("Failed to connect to the database") @@ -98,7 +102,7 @@ class Plugin::DBSQLite2 < Msf::Plugin def parse_db_uri(path) res = {} - res[:path] = path || Msf::Config.config_directory('metasploit3.db2') + res[:path] = path || File.join(Msf::Config.config_directory, 'sqlite2.db') res end end diff --git a/plugins/db_sqlite3.rb b/plugins/db_sqlite3.rb index 76c35ba6fc..c9bcd6348d 100644 --- a/plugins/db_sqlite3.rb +++ b/plugins/db_sqlite3.rb @@ -45,7 +45,7 @@ class Plugin::DBSQLite3 < Msf::Plugin def cmd_db_disconnect(*args) if (framework.db) framework.db.disconnect() - driver.remove_dispatcher(DatabaseCommandDispatcher) + driver.remove_dispatcher('Database Backend') end end @@ -58,6 +58,10 @@ class Plugin::DBSQLite3 < Msf::Plugin opts['dbfile'] = info[:path] + if (not File.exists?(opts['dbfile'])) + print_status("The specified database does not exist") + return + end if (not framework.db.connect(opts)) raise PluginLoadError.new("Failed to connect to the database") @@ -79,7 +83,7 @@ class Plugin::DBSQLite3 < Msf::Plugin odb = File.join(Msf::Config.install_root, "data", "sql", "sqlite3.db") - File.copy(odb, info[:path]) + FileUtils.copy(odb, info[:path]) if (not framework.db.connect(opts)) raise PluginLoadError.new("Failed to connect to the database") @@ -98,7 +102,7 @@ class Plugin::DBSQLite3 < Msf::Plugin def parse_db_uri(path) res = {} - res[:path] = path || Msf::Config.config_directory('metasploit3.db3') + res[:path] = path || File.join(Msf::Config.config_directory, 'sqlite3.db') res end end