Class: Metasploit::Framework::DataService::ManagedRemoteDataService
- Inherits:
-
Object
- Object
- Metasploit::Framework::DataService::ManagedRemoteDataService
- Includes:
- Singleton
- Defined in:
- lib/metasploit/framework/data_service/remote/managed_remote_data_service.rb
Overview
Primarily for testing this instance is used to manage a data service started within a separate process.
Instance Method Summary collapse
-
#remote_data_service ⇒ Object
Returns the client used to interact with the remote data service.
-
#running? ⇒ Boolean
Returns true if the managed data service process is running.
-
#start(opts) ⇒ Object
Starts a remote data service process.
-
#stop ⇒ Object
Stops the remote data service process.
Instance Method Details
#remote_data_service ⇒ Object
Returns the client used to interact with the remote data service
25 26 27 |
# File 'lib/metasploit/framework/data_service/remote/managed_remote_data_service.rb', line 25 def remote_data_service return @remote_host_data_service end |
#running? ⇒ Boolean
Returns true if the managed data service process is running.
18 19 20 |
# File 'lib/metasploit/framework/data_service/remote/managed_remote_data_service.rb', line 18 def running? return @running end |
#start(opts) ⇒ Object
Starts a remote data service process
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/metasploit/framework/data_service/remote/managed_remote_data_service.rb', line 32 def start(opts) @mutex.synchronize do return if @running # started with no signal to prevent ctrl-c from taking out db db_script = File.join( Msf::Config.install_root, opts[:process_name]) wait_t = Open3.pipeline_start(db_script) @pid = wait_t[0].pid puts "Started process with pid #{@pid}" endpoint = "http://#{opts[:host]}:#{opts[:port]}" @remote_host_data_service = Metasploit::Framework::DataService::RemoteHTTPDataService.new(endpoint) count = 0 loop do count = count + 1 if count > 10 raise 'Unable to start remote data service' end sleep(1) if @remote_host_data_service.is_online? break end end @running = true end end |
#stop ⇒ Object
Stops the remote data service process
NOTE: This has potential issues on windows
70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/metasploit/framework/data_service/remote/managed_remote_data_service.rb', line 70 def stop @mutex.synchronize do return unless @running begin Process.kill("TERM", @pid) @running = false rescue Exception => e puts "Unable to kill db process: #{e.}" end end end |