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
41
42
# 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('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);

  response = client.send_request(request)

  return response
end

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

Reboots the remote machine.



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

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.



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

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