Class: Rex::Post::Meterpreter::Extensions::Stdapi::Sys::Power

Inherits:
Object
  • Object
show all
Defined in:
lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb

Overview

This class provides access to the power of the remote machine (reboot, etc).

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.clientObject

Returns the value of attribute client.



24
25
26
# File 'lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb', line 24

def client
  @client
end

Class Method Details

._exitwindows(flags, reason = 0, force = 0) ⇒ Object

Calls ExitWindows on the remote machine with the supplied parameters.



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb', line 30

def Power._exitwindows(flags, reason = 0, force = 0) # :nodoc:
  request = Packet.create_request(COMMAND_ID_STDAPI_SYS_POWER_EXITWINDOWS)

  flags |= EWX_FORCEIFHUNG if force == 1
  flags |= EWX_FORCE       if force == 2

  request.add_tlv(TLV_TYPE_POWER_FLAGS, flags);
  request.add_tlv(TLV_TYPE_POWER_REASON, reason);

  client.send_request(request)
end

.reboot(force = 0, reason = 0) ⇒ Object

Reboots the remote machine.



45
46
47
# File 'lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb', line 45

def Power.reboot(force = 0, reason = 0)
  self._exitwindows(EWX_REBOOT, reason, force)
end

.shutdown(force = 0, reason = 0) ⇒ Object

Shuts down the remote machine.



52
53
54
# File 'lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb', line 52

def Power.shutdown(force = 0, reason = 0)
  self._exitwindows(EWX_POWEROFF, reason, force)
end