class Rex::Post::Meterpreter::Extensions::Stdapi::Sys::RegistrySubsystem::RemoteRegistryKey

Class wrapper around a remote registry key on the remote side

Attributes

hkey[R]

The open handle to the key on the server.

root_key[R]

The root key name, such as HKEY_LOCAL_MACHINE.

target_host[R]

The remote machine name, such as PDC01

Public Class Methods

close(client, hkey) click to toggle source

Closes the open key. This must be called if the registry key was opened.

# File lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/remote_registry_key.rb, line 106
def self.close(client, hkey)
  if hkey != nil
    return client.sys.registry.close_key(hkey)
  end

  return false
end
finalize(client,hkey) click to toggle source
# File lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/remote_registry_key.rb, line 34
def self.finalize(client,hkey)
  proc { self.close(client,hkey) }
end
new(client, target_host, root_key, hkey) click to toggle source

Initializes an instance of a registry key using the supplied properties and HKEY handle from the server.

# File lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/remote_registry_key.rb, line 25
def initialize(client, target_host, root_key, hkey)
  self.client   = client
  self.root_key = root_key
  self.target_host = target_host
  self.hkey     = hkey

  ObjectSpace.define_finalizer( self, self.class.finalize(self.client, self.hkey) )
end

Public Instance Methods

close() click to toggle source

Instance method for the same

# File lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/remote_registry_key.rb, line 115
def close()
  self.class.close(self.client, self.hkey)
end
create_key(base_key, perm = KEY_READ) click to toggle source

Creates a registry key that is relative to this registry key.

# File lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/remote_registry_key.rb, line 91
def create_key(base_key, perm = KEY_READ)
  return self.client.sys.registry.create_key(self.hkey, base_key, perm)
end
delete_key(base_key, recursive = true) click to toggle source

Deletes a registry key that is relative to this registry key.

# File lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/remote_registry_key.rb, line 98
def delete_key(base_key, recursive = true)
  return self.client.sys.registry.delete_key(self.hkey, base_key, recursive)
end
delete_value(name) click to toggle source

Delete the supplied registry value.

# File lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/remote_registry_key.rb, line 150
def delete_value(name)
  return self.client.sys.registry.delete_value(self.hkey, name)
end
each_key(&block) click to toggle source

Enumerates all of the child keys within this registry key.

# File lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/remote_registry_key.rb, line 47
def each_key(&block)
  return enum_key.each(&block)
end
each_value(&block) click to toggle source

Enumerates all of the child values within this registry key.

# File lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/remote_registry_key.rb, line 54
def each_value(&block)
  return enum_value.each(&block)
end
enum_key() click to toggle source

Retrieves all of the registry keys that are direct descendents of the class’ registry key.

# File lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/remote_registry_key.rb, line 62
def enum_key()
  return self.client.sys.registry.enum_key(self.hkey)
end
enum_value() click to toggle source

Retrieves all of the registry values that exist within the opened registry key.

# File lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/remote_registry_key.rb, line 70
def enum_value()
  return self.client.sys.registry.enum_value(self.hkey)
end
open_key(base_key, perm = KEY_READ) click to toggle source

Opens a registry key that is relative to this registry key.

# File lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/remote_registry_key.rb, line 84
def open_key(base_key, perm = KEY_READ)
  return self.client.sys.registry.open_key(self.hkey, base_key, perm)
end
query_class() click to toggle source

Queries the class of the specified key

# File lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/remote_registry_key.rb, line 143
def query_class
  return self.client.sys.registry.query_class(self.hkey)
end
query_value(name) click to toggle source

Queries the attributes of the supplied registry value relative to the opened registry key.

# File lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/remote_registry_key.rb, line 136
def query_value(name)
  return self.client.sys.registry.query_value(self.hkey, name)
end
set_value(name, type, data) click to toggle source

Sets a value relative to the opened registry key.

# File lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/remote_registry_key.rb, line 128
def set_value(name, type, data)
  return self.client.sys.registry.set_value(self.hkey, name, type, data)
end
to_s() click to toggle source

Returns the path to the key.

# File lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/remote_registry_key.rb, line 163
def to_s
  return "\\\\" + self.target_host + "\\" + self.root_key.to_s + "\\"
end