15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/msf/core/web_services/servlet/db_export_servlet.rb', line 15
def self.get_db_export
lambda {
warden.authenticate!
begin
opts = params.symbolize_keys
opts[:path] = File.join(Msf::Config.local_directory, "#{File.basename(opts[:path])}-#{SecureRandom.hex}")
output_file = get_db.run_db_export(opts)
encoded_file = Base64.urlsafe_encode64(File.read(File.expand_path(output_file)))
response = {}
response[:db_export_file] = encoded_file
set_json_data_response(response: response)
rescue => e
print_error_and_create_response(error: e, message: 'There was an error exporting the database:', code: 500)
ensure
File.delete(opts[:path])
end
}
end
|