connect to an existing database with db_create

git-svn-id: file:///home/svn/framework3/trunk@5253 4d416f70-5f16-0410-b530-b9f4589650da
unstable
HD Moore 2007-12-31 09:18:41 +00:00
parent b143ea1951
commit 3df1e64b39
2 changed files with 26 additions and 26 deletions

View File

@ -83,31 +83,31 @@ class Plugin::DBSQLite2 < Msf::Plugin
opts['dbfile'] = info[:path]
sql = File.join(Msf::Config.install_root, "data", "sql", "sqlite.sql")
if (File.exists?(opts['dbfile']))
print_status("The specified database already exists, use db_connect or delete this file")
print_status("File: #{opts['dbfile']}")
return
end
print_status("The specified database already exists, connecting")
else
print_status("Creating a new database instance...")
print_status("Creating a new database instance...")
db = SQLite::Database.new(opts['dbfile'])
File.read(sql).split(";").each do |line|
begin
db.execute(line.strip)
rescue ::SQLite::Exceptions::SQLException, ::NoMethodError
db = SQLite::Database.new(opts['dbfile'])
File.read(sql).split(";").each do |line|
begin
db.execute(line.strip)
rescue ::SQLite::Exceptions::SQLException, ::NoMethodError
end
end
db.close
end
db.close
if (not framework.db.connect(opts))
raise PluginLoadError.new("Failed to connect to the database")
end
driver.append_dispatcher(DatabaseCommandDispatcher)
print_status("Successfully connected to the database")
print_status("File: #{opts['dbfile']}")
end
#

View File

@ -90,29 +90,29 @@ class Plugin::DBSQLite3 < Msf::Plugin
sql = File.join(Msf::Config.install_root, "data", "sql", "sqlite.sql")
if (File.exists?(opts['dbfile']))
print_status("The specified database already exists, use db_connect or delete this file")
print_status("File: #{opts['dbfile']}")
return
end
print_status("The specified database already exists, connecting")
else
print_status("Creating a new database instance...")
print_status("Creating a new database instance...")
db = SQLite3::Database.new(opts['dbfile'])
File.read(sql).split(";").each do |line|
begin
db.execute(line.strip)
rescue ::SQLite3::SQLException, ::SQLite3::MisuseException
db = SQLite3::Database.new(opts['dbfile'])
File.read(sql).split(";").each do |line|
begin
db.execute(line.strip)
rescue ::SQLite3::SQLException, ::SQLite3::MisuseException
end
end
db.close
end
db.close
if (not framework.db.connect(opts))
raise PluginLoadError.new("Failed to connect to the database")
end
driver.append_dispatcher(DatabaseCommandDispatcher)
print_status("Successfully created the database")
print_status("Successfully connected to the database")
print_status("File: #{opts['dbfile']}")
end