Path: blob/master/lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
19721 views
# -*- coding: binary -*-12require 'rex/post/process'3require 'rex/post/meterpreter/packet'4require 'rex/post/meterpreter/client'5require 'rex/post/meterpreter/extensions/stdapi/constants'6require 'rex/post/meterpreter/extensions/stdapi/stdapi'78module Rex9module Post10module Meterpreter11module Extensions12module Stdapi13module Sys1415###16#17# This class provides access to the power of the remote machine (reboot, etc).18#19###20class Power2122class <<self23attr_accessor :client24end2526#27# Calls ExitWindows on the remote machine with the supplied parameters.28#29def Power._exitwindows(flags, reason = 0, force = 0) # :nodoc:30request = Packet.create_request(COMMAND_ID_STDAPI_SYS_POWER_EXITWINDOWS)3132flags |= EWX_FORCEIFHUNG if force == 133flags |= EWX_FORCE if force == 23435request.add_tlv(TLV_TYPE_POWER_FLAGS, flags);36request.add_tlv(TLV_TYPE_POWER_REASON, reason);3738client.send_request(request)39end4041#42# Reboots the remote machine.43#44def Power.reboot(force = 0, reason = 0)45self._exitwindows(EWX_REBOOT, reason, force)46end4748#49# Shuts down the remote machine.50#51def Power.shutdown(force = 0, reason = 0)52self._exitwindows(EWX_POWEROFF, reason, force)53end5455end5657end end end end end end585960