Sha256: a8cf5807d1c389b5d7a1a04e0a88cbaa1fa9fa5266c6e102c566db418adab704

Contents?: true

Size: 1.97 KB

Versions: 15

Compression:

Stored size: 1.97 KB

Contents

# -*- 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

15 entries across 15 versions & 3 rubygems

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