Sha256: f45709ff5b2e3e948350771465857aee6f1d0ae2d7b47d506c82b031efd505bc

Contents?: true

Size: 1.86 KB

Versions: 42

Compression:

Stored size: 1.86 KB

Contents

#!/usr/bin/env ruby

require 'rex/post/meterpreter/extensions/stdapi/constants'
require 'rex/post/meterpreter/extensions/stdapi/sys/registry'

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

###
#
# Class wrapper around a logical registry value on the remote side.
#
###
class RegistryValue

	#
	# Initializes a registry value instance that's associated with the supplied
	# server key handle.
	#
	def initialize(client, hkey, name, type = nil, data = nil)
		self.client = client
		self.hkey   = hkey
		self.name   = name
		self.type   = type
		self.data   = data
	end	

	#
	# Sets the value's data.
	#
	def set(data, type = nil)
		if (type == nil)
			type = self.type
		end
		if (self.client.sys.registry.set_value(self.hkey, self.name,
				type, data))
			self.data = data
			self.type = type

			return true
		end

		return false
	end

	#
	# Queries the value's data.
	#
	def query()
		val =  self.client.sys.registry.query_value(self.hkey, self.name)

		if (val != nil)
			self.data = val.data
			self.type = val.type
		end

		return self.data
	end

	#
	# Deletes the value.
	#
	def delete()
		return self.client.sys.registry.delete_value(self.hkey, self.name)
	end

	def type_to_s
		return "REG_SZ" if (type == REG_SZ)
		return "REG_DWORD" if (type == REG_DWORD)
		return "REG_BINARY" if (type == REG_BINARY)
		return "REG_EXPAND_SZ" if (type == REG_EXPAND_SZ)
		return "REG_NONE" if (type == REG_NONE)
		return nil
	end

	#
	# The remote server key handle.
	#
	attr_reader   :hkey
	#
	# The name of the registry value.
	#
	attr_reader   :name
	#
	# The type of data represented by the registry value.
	#
	attr_reader   :type
	#
	# The arbitrary data stored within the value, if any.
	#
	attr_reader   :data
protected
	attr_accessor :client # :nodoc:
	attr_writer   :hkey, :name, :type, :data # :nodoc:
end

end; end; end; end; end; end; end

Version data entries

42 entries across 42 versions & 1 rubygems

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