Skip to content

Commit 5a899d5

Browse files
committed
Renamed msfdb to avoid omnibus collision, removed inline data service startup code
1 parent 3bc0608 commit 5a899d5

File tree

9 files changed

+17
-54
lines changed

9 files changed

+17
-54
lines changed

lib/metasploit/framework/command/console.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ def driver_options
7979
driver_options['DatabaseEnv'] = options.environment
8080
driver_options['DatabaseMigrationPaths'] = options.database.migrations_paths
8181
driver_options['DatabaseYAML'] = options.database.config
82-
driver_options['DatabaseRemoteProcess'] = options.database.remote_process
8382
driver_options['DeferModuleLoads'] = options.modules.defer_loads
8483
driver_options['DisableBanner'] = options.console.quiet
8584
driver_options['DisableDatabase'] = options.database.disable

lib/metasploit/framework/data_service/proxy/core.rb

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,6 @@ def respond_to?(method_name, include_private=false)
110110
false
111111
end
112112

113-
#
114-
# Attempt to shutdown the local db process if it exists
115-
#
116-
def exit_called
117-
if @pid
118-
ilog 'Shutdown called, attempting to kill db process'
119-
begin
120-
Process.kill('TERM', @pid)
121-
rescue Exception => e
122-
elog "Unable to kill db process: #{e.message}"
123-
end
124-
end
125-
end
126-
127113
def get_data_service
128114
raise 'No registered data_service' unless @current_data_service
129115
return @current_data_service
@@ -139,14 +125,11 @@ def setup(opts)
139125
if !db_manager.nil?
140126
register_data_service(db_manager, true)
141127
@usable = true
142-
elsif opts['DatabaseRemoteProcess']
143-
run_remote_db_process(opts)
144-
@usable = true
145128
else
146129
@error = 'disabled'
147130
end
148131
rescue Exception => e
149-
raise "Unable to initialize a dataservice #{e.message}"
132+
raise "Unable to initialize data service: #{e.message}"
150133
end
151134
end
152135

@@ -166,19 +149,6 @@ def data_service_exist?(data_service)
166149
return false
167150
end
168151

169-
170-
def run_remote_db_process(opts)
171-
# started with no signal to prevent ctrl-c from taking out db
172-
db_script = File.join( Msf::Config.install_root, "msfdb -ns")
173-
wait_t = Open3.pipeline_start(db_script)
174-
@pid = wait_t[0].pid
175-
dlog("Started data service process with pid #{@pid}")
176-
177-
endpoint = URI.parse('http://localhost:8080')
178-
remote_host_data_service = Metasploit::Framework::DataService::RemoteHTTPDataService.new(endpoint)
179-
register_data_service(remote_host_data_service, true)
180-
end
181-
182152
end
183153
end
184154
end

lib/metasploit/framework/data_service/remote/http/core.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ def initialize(endpoint, https_opts = {})
3131
build_client_pool(5)
3232
end
3333

34+
def connection_established?
35+
true
36+
end
37+
38+
def after_establish_connection
39+
40+
end
41+
42+
def error
43+
'none'
44+
end
45+
3446
#
3547
# POST data to the HTTP endpoint and don't wait for the endpoint to process the data before getting a response
3648
#

lib/metasploit/framework/parsed_options/base.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,6 @@ def option_parser
137137
options.database.config = path
138138
end
139139

140-
option_parser.on('-dbrp', 'Run database as a separate local process') do
141-
options.database.remote_process = true
142-
end
143-
144140
option_parser.separator ''
145141
option_parser.separator 'Framework options'
146142

lib/metasploit/framework/parsed_options/remote_db.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ def options
2222
@options
2323
end
2424

25+
#######
2526
private
27+
#######
2628

2729
def option_parser
2830
unless @option_parser

lib/msf/core/db_manager/http/http_db_manager_service.rb

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,6 @@ class HttpDBManagerService
77

88
def start(opts)
99
parsed_options = Metasploit::Framework::ParsedOptions::RemoteDB.new
10-
if (parsed_options.options.database.no_signal)
11-
print_warning 'Trap handling removed'
12-
opts[:signals] = false
13-
@shutdown_on_interupt = false
14-
else
15-
@shutdown_on_interupt = true
16-
end
17-
1810
require_environment!(parsed_options)
1911

2012
if opts[:ssl]
@@ -36,13 +28,6 @@ def start_http_server(opts)
3628

3729
Rack::Handler::Thin.run(SinatraApp, opts) do |server|
3830

39-
# TODO: prevent accidental shutdown from msfconsole eg: ctrl-c
40-
[:INT, :TERM].each { |sig|
41-
trap(sig) {
42-
server.stop if (@shutdown_on_interupt || sig == :TERM)
43-
}
44-
}
45-
4631
if opts[:ssl] && opts[:ssl] = true
4732
print_good "SSL Enabled"
4833
server.ssl = true

lib/msf/core/framework.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def search(match, logger: nil)
272272
private
273273

274274
def get_db
275-
if !options['DatabaseRemoteProcess'] && !options['DisableDatabase']
275+
if !options['DisableDatabase']
276276
db_manager = Msf::DBManager.new(self)
277277
db_manager.init_db(options)
278278
options[:db_manager] = db_manager

lib/msf/ui/console/command_dispatcher/core.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,6 @@ def cmd_exit(*args)
457457
forced = false
458458
forced = true if (args[0] and args[0] =~ /-y/i)
459459

460-
framework.db.exit_called
461460
if(framework.sessions.length > 0 and not forced)
462461
print_status("You have active sessions open, to exit anyway type \"exit -y\"")
463462
return

msfdb renamed to msfdb_ws

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ end
2020
def parse_args(args)
2121
opts = {}
2222
opt = OptionParser.new
23-
banner = "msfdb - A remote database process for Metasploit Framework.\n"
23+
banner = "msfdb_ws - Metasploit data store as a web service.\n"
2424
banner << "Usage: #{$0} [options] <var=val>"
2525
opt.banner = banner
2626
opt.separator('')

0 commit comments

Comments
 (0)