Sha256: d03cb25adb19354356df41e3b6069d9a649e4c8cd34aec7ed065774f6773b9aa

Contents?: true

Size: 1.24 KB

Versions: 15

Compression:

Stored size: 1.24 KB

Contents

# -*- coding: binary -*-

require 'rex/post/process'
require 'rex/post/meterpreter/packet'
require 'rex/post/meterpreter/client'
require 'rex/post/meterpreter/extensions/stdapi/constants'
require 'rex/post/meterpreter/extensions/stdapi/stdapi'

module Rex
module Post
module Meterpreter
module Extensions
module Stdapi
module Sys

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

  class <<self
    attr_accessor :client
  end

  #
  # Calls ExitWindows on the remote machine with the supplied parameters.
  #
  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

  #
  # Reboots the remote machine.
  #
  def Power.reboot(force = 0, reason = 0)
    self._exitwindows(EWX_REBOOT, reason, force)
  end

  #
  # Shuts down the remote machine.
  #
  def Power.shutdown(force = 0, reason = 0)
    self._exitwindows(EWX_POWEROFF, reason, force)
  end

end

end end end end end end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
rex-2.0.13 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
rex-2.0.12 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
rex-2.0.11 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
rex-2.0.10 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
rex-2.0.9 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
rex-2.0.8 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
rex-2.0.7 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
rex-2.0.5 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
rex-2.0.4 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
dstruct-0.0.1 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
rex-2.0.3 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
librex-0.0.999 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
rex-2.0.2 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
librex-0.0.71 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
librex-0.0.70 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb