Sha256: 3c46e28fd71ff20d3e93bfdfbddd28d9ef12bdda3751f8113ae14075e45df11f

Contents?: true

Size: 1.89 KB

Versions: 2

Compression:

Stored size: 1.89 KB

Contents

#!/usr/bin/env ruby
# -*- coding: binary -*-

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

2 entries across 2 versions & 1 rubygems

Version Path
librex-0.0.68 lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/registry_value.rb
librex-0.0.66 lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/registry_value.rb