Class: Rex::Post::Meterpreter::Extensions::Stdapi::Sys::RegistrySubsystem::RegistryValue

Inherits:
Object
  • Object
show all
Defined in:
lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/registry_value.rb

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, hkey, name, type = nil, data = nil) ⇒ RegistryValue

Initializes a registry value instance that’s associated with the supplied server key handle.



25
26
27
28
29
30
31
# File 'lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/registry_value.rb', line 25

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

Instance Attribute Details

#dataObject

The arbitrary data stored within the value, if any.



96
97
98
# File 'lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/registry_value.rb', line 96

def data
  @data
end

#hkeyObject

The remote server key handle.



84
85
86
# File 'lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/registry_value.rb', line 84

def hkey
  @hkey
end

#nameObject

The name of the registry value.



88
89
90
# File 'lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/registry_value.rb', line 88

def name
  @name
end

#typeObject

The type of data represented by the registry value.



92
93
94
# File 'lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/registry_value.rb', line 92

def type
  @type
end

Instance Method Details

#deleteObject

Deletes the value.



68
69
70
# File 'lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/registry_value.rb', line 68

def delete()
  return self.client.sys.registry.delete_value(self.hkey, self.name)
end

#queryObject

Queries the value’s data.



54
55
56
57
58
59
60
61
62
63
# File 'lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/registry_value.rb', line 54

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

#set(data, type = nil) ⇒ Object

Sets the value’s data.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/registry_value.rb', line 36

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

#type_to_sObject



72
73
74
75
76
77
78
79
# File 'lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/registry_value.rb', line 72

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