File tree Expand file tree Collapse file tree 2 files changed +47
-6
lines changed
lib/rex/post/meterpreter/extensions/stdapi/sys
spec/lib/rex/post/meterpreter/extensions/stdapi/sys Expand file tree Collapse file tree 2 files changed +47
-6
lines changed Original file line number Diff line number Diff line change @@ -380,13 +380,20 @@ def self.key2str(key)
380
380
# Returns the integer value associated with the supplied registry value
381
381
# type (like REG_SZ).
382
382
#
383
+ # @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms724884(v=vs.85).aspx
384
+ # @param type [String] A Windows registry type constant name, e.g. 'REG_SZ'
385
+ # @return [Integer] one of the `REG_*` constants
383
386
def self . type2str ( type )
384
- return REG_SZ if ( type == 'REG_SZ' )
385
- return REG_DWORD if ( type == 'REG_DWORD' )
386
- return REG_BINARY if ( type == 'REG_BINARY' )
387
- return REG_EXPAND_SZ if ( type == 'REG_EXPAND_SZ' )
388
- return REG_NONE if ( type == 'REG_NONE' )
389
- return nil
387
+ case type
388
+ when 'REG_BINARY' then REG_BINARY
389
+ when 'REG_DWORD' then REG_DWORD
390
+ when 'REG_EXPAND_SZ' then REG_EXPAND_SZ
391
+ when 'REG_MULTI_SZ' then REG_MULTI_SZ
392
+ when 'REG_NONE' then REG_NONE
393
+ when 'REG_SZ' then REG_SZ
394
+ else
395
+ nil
396
+ end
390
397
end
391
398
392
399
#
Original file line number Diff line number Diff line change
1
+ require 'rex/post/meterpreter/extensions/stdapi/sys/registry'
2
+
3
+ RSpec . describe Rex ::Post ::Meterpreter ::Extensions ::Stdapi ::Sys ::Registry do
4
+
5
+ describe '.type2str' do
6
+ subject { described_class . type2str ( type ) }
7
+
8
+ context "with 'REG_BINARY'" do
9
+ let ( :type ) { 'REG_BINARY' }
10
+ it { should eq ( 3 ) }
11
+ end
12
+ context "with 'REG_DWORD'" do
13
+ let ( :type ) { 'REG_DWORD' }
14
+ it { should eq ( 4 ) }
15
+ end
16
+ context "with 'REG_EXPAND_SZ'" do
17
+ let ( :type ) { 'REG_EXPAND_SZ' }
18
+ it { should eq ( 2 ) }
19
+ end
20
+ context "with 'REG_MULTI_SZ'" do
21
+ let ( :type ) { 'REG_MULTI_SZ' }
22
+ it { should eq ( 7 ) }
23
+ end
24
+ context "with 'REG_NONE'" do
25
+ let ( :type ) { 'REG_NONE' }
26
+ it { should eq ( 0 ) }
27
+ end
28
+ context "with 'REG_SZ'" do
29
+ let ( :type ) { 'REG_SZ' }
30
+ it { should eq ( 1 ) }
31
+ end
32
+ end
33
+
34
+ end
You can’t perform that action at this time.
0 commit comments