Class: Rex::Post::Meterpreter::Ui::Console::CommandDispatcher::Extapi::Service
- Inherits:
-
Object
- Object
- Rex::Post::Meterpreter::Ui::Console::CommandDispatcher::Extapi::Service
- Defined in:
- lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/service.rb
Overview
Extended API window management user interface.
Constant Summary collapse
- Klass =
Console::CommandDispatcher::Extapi::Service
- @@service_enum_opts =
Options for the service_enum command.
Rex::Parser::Arguments.new( "-h" => [ false, "Help banner" ] )
- @@service_query_opts =
Options for the service_query command.
Rex::Parser::Arguments.new( "-h" => [ false, "Help banner" ] )
- @@service_control_opts =
Options for the service_control command.
Rex::Parser::Arguments.new( "-h" => [ false, "Help banner" ] )
Instance Attribute Summary
Attributes included from Ui::Text::DispatcherShell::CommandDispatcher
Instance Method Summary collapse
-
#cmd_service_control(*args) ⇒ Object
Query a single service for more detail.
-
#cmd_service_enum(*args) ⇒ Object
Query a single service for more detail.
-
#cmd_service_query(*args) ⇒ Object
Query a single service for more detail.
-
#commands ⇒ Object
List of supported commands.
-
#initialize(shell) ⇒ Service
constructor
Initialize the instance.
-
#name ⇒ Object
Name for this dispatcher.
Methods included from Rex::Post::Meterpreter::Ui::Console::CommandDispatcher
check_hash, #client, #log_error, #msf_loaded?, set_hash
Methods included from Ui::Text::DispatcherShell::CommandDispatcher
#cmd_help, #cmd_help_help, #cmd_help_tabs, #deprecated_cmd, #deprecated_commands, #deprecated_help, #help_to_s, #print, #print_error, #print_good, #print_line, #print_status, #print_warning, #tab_complete_filenames, #update_prompt
Constructor Details
#initialize(shell) ⇒ Service
Initialize the instance
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/service.rb', line 41 def initialize(shell) super @status_map = { 1 => "Stopped", 2 => "Starting", 3 => "Stopping", 4 => "Running", 5 => "Continuing", 6 => "Pausing", 7 => "Paused" } @start_type_map = { 0 => "Boot", 1 => "System", 2 => "Automatic", 3 => "Manual", 4 => "Disabled" } end |
Instance Method Details
#cmd_service_control(*args) ⇒ Object
Query a single service for more detail.
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/service.rb', line 169 def cmd_service_control(*args) args.unshift("-h") if args.length != 2 @@service_control_opts.parse(args) do |opt, idx, val| case opt when "-h" print( "\nUsage: service_control [-h] <servicename> <op>\n" + " <servicename> : The name of the service to control.\n" + " <op> : The operation to perform on the service.\n" + " Valid ops: start pause resume stop restart.\n\n") return true end end service_name = args[0] op = args[1] client.extapi.service.control(service_name, op) print_good("Operation #{op} succeeded.") end |
#cmd_service_enum(*args) ⇒ Object
Query a single service for more detail.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/service.rb', line 73 def cmd_service_enum(*args) @@service_enum_opts.parse(args) do |opt, idx, val| case opt when "-h" print( "\nUsage: service_enum [-h]\n\n" + "Enumerate services installed on the target.\n\n" + "Enumeration returns the Process ID, Status, and name of each installed\n" + "service that was enumerated. The 'Int' value indicates if the service is\n" + "able to interact with the desktop.\n\n") return true end end services = client.extapi.service.enumerate table = Rex::Ui::Text::Table.new( 'Header' => 'Service List', 'Indent' => 0, 'SortIndex' => 3, 'Columns' => [ 'PID', 'Status', 'Int', 'Name (Display Name)' ] ) services.each do |s| table << [ s[:pid], @status_map[s[:status]], s[:interactive] ? "Y" : "N", "#{s[:name].downcase} (#{s[:display]})" ] end print_line print_line(table.to_s) print_line print_line("Total services: #{services.length}") print_line return true end |
#cmd_service_query(*args) ⇒ Object
Query a single service for more detail.
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/service.rb', line 126 def cmd_service_query(*args) args.unshift("-h") if args.length != 1 @@service_query_opts.parse(args) do |opt, idx, val| case opt when "-h" print( "\nUsage: service_query [-h] <servicename>\n" + " <servicename>: The name of the service to query.\n\n" + "Gets details information about a particular Windows service, including\n" + "binary path, DACL, load order group, start type and more.\n\n") return true end end service_name = args.shift detail = client.extapi.service.query(service_name) print_line print_line("Name : #{service_name}") print_line("Display : #{detail[:display]}") print_line("Account : #{detail[:startname]}") print_line("Status : #{@status_map[detail[:status]]}") print_line("Start Type : #{@start_type_map[detail[:starttype]]}") print_line("Path : #{detail[:path]}") print_line("L.O. Group : #{detail[:logroup]}") print_line("Interactive : #{detail[:interactive] ? "Yes" : "No"}") print_line("DACL : #{detail[:dacl]}") print_line end |
#commands ⇒ Object
List of supported commands.
23 24 25 26 27 28 29 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/service.rb', line 23 def commands { "service_enum" => "Enumerate all registered Windows services", "service_query" => "Query more detail about a specific Windows service", "service_control" => "Control a single service (start/pause/resume/stop/restart)" } end |
#name ⇒ Object
Name for this dispatcher
34 35 36 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/service.rb', line 34 def name "Extapi: Service Management" end |