Sha256: c241b887843ab881e3dccd89c722b2e80fdf68cf717768f3969398c0d79140c6

Contents?: true

Size: 1.18 KB

Versions: 43

Compression:

Stored size: 1.18 KB

Contents

#!/usr/bin/env ruby

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) # :nodoc:
		request = Packet.create_request('stdapi_sys_power_exitwindows')

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

		response = client.send_request(request)

		return self
	end

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

	#
	# Shuts down the remote machine.
	#
	def Power.shutdown(force = 0, reason = 0)
		flags  = EWX_POWEROFF
		flags |= EWX_FORCEIFHUNG if force == 1
		flags |= EWX_FORCE       if force == 2

		self._exitwindows(flags, reason)
	end

end

end end end end end end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
librex-0.0.65 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
librex-0.0.63 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
librex-0.0.54 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
librex-0.0.53 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
librex-0.0.52 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
librex-0.0.51 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
librex-0.0.50 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
librex-0.0.49 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
librex-0.0.48 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
librex-0.0.47 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
librex-0.0.46 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
librex-0.0.44 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
librex-0.0.43 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
librex-0.0.42 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
librex-0.0.41 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
librex-0.0.40 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
librex-0.0.39 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
librex-0.0.38 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
librex-0.0.37 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb
librex-0.0.36 lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb