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

#clientObject (protected)

:nodoc:



99
100
101
# File 'lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/registry_value.rb', line 99

def client
  @client
end

#dataObject

The arbitrary data stored within the value, if any.



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

def data
  @data
end

#hkeyObject

The remote server key handle.



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

def hkey
  @hkey
end

#nameObject

The name of the registry value.



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

def name
  @name
end

#typeObject

The type of data represented by the registry value.



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

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
80
# 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 "REG_MULTI_SZ" if (type == REG_MULTI_SZ)
  return nil
end