connect to an existing database with db_create
git-svn-id: file:///home/svn/framework3/trunk@5253 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
b143ea1951
commit
3df1e64b39
|
@ -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
|
||||
|
||||
#
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue