Land #4922, REG_MULTI_SZ for type2str
commit
fa2fbc387c
|
@ -380,13 +380,20 @@ class Registry
|
|||
# Returns the integer value associated with the supplied registry value
|
||||
# type (like REG_SZ).
|
||||
#
|
||||
# @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms724884(v=vs.85).aspx
|
||||
# @param type [String] A Windows registry type constant name, e.g. 'REG_SZ'
|
||||
# @return [Integer] one of the `REG_*` constants
|
||||
def self.type2str(type)
|
||||
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
|
||||
case type
|
||||
when 'REG_BINARY' then REG_BINARY
|
||||
when 'REG_DWORD' then REG_DWORD
|
||||
when 'REG_EXPAND_SZ' then REG_EXPAND_SZ
|
||||
when 'REG_MULTI_SZ' then REG_MULTI_SZ
|
||||
when 'REG_NONE' then REG_NONE
|
||||
when 'REG_SZ' then REG_SZ
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
require 'rex/post/meterpreter/extensions/stdapi/sys/registry'
|
||||
|
||||
RSpec.describe Rex::Post::Meterpreter::Extensions::Stdapi::Sys::Registry do
|
||||
|
||||
describe '.type2str' do
|
||||
subject { described_class.type2str(type) }
|
||||
|
||||
context "with 'REG_BINARY'" do
|
||||
let(:type) { 'REG_BINARY' }
|
||||
it { should eq(3) }
|
||||
end
|
||||
context "with 'REG_DWORD'" do
|
||||
let(:type) { 'REG_DWORD' }
|
||||
it { should eq(4) }
|
||||
end
|
||||
context "with 'REG_EXPAND_SZ'" do
|
||||
let(:type) { 'REG_EXPAND_SZ' }
|
||||
it { should eq(2) }
|
||||
end
|
||||
context "with 'REG_MULTI_SZ'" do
|
||||
let(:type) { 'REG_MULTI_SZ' }
|
||||
it { should eq(7) }
|
||||
end
|
||||
context "with 'REG_NONE'" do
|
||||
let(:type) { 'REG_NONE' }
|
||||
it { should eq(0) }
|
||||
end
|
||||
context "with 'REG_SZ'" do
|
||||
let(:type) { 'REG_SZ' }
|
||||
it { should eq(1) }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue