Skip to content

Commit 0778b77

Browse files
committed
Cleaned up a little
1 parent 7730e0e commit 0778b77

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

lib/msf/core/post/windows/dotnet.rb

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,36 @@ module Msf
66
class Post
77
module Windows
88

9+
#
10+
# This module serves to hold methods related to .NET framework
11+
#
912
module Dotnet
1013
include ::Msf::Post::Common
1114
include ::Msf::Post::Windows::Registry
12-
15+
1316
def initialize(info = {})
1417
super
1518
register_advanced_options(
1619
[
17-
OptInt.new('Dotnet::Post::timeout', [true, 'Dotnet execution timeout, set < 0 to run async without termination', 15]),
20+
OptInt.new('Dotnet::Post::timeout', [true, 'Dotnet execution timeout, set < 0 to run async without termination', 15]),
1821
OptBool.new('Dotnet::Post::log_output', [true, 'Write output to log file', false]),
1922
OptBool.new('Dotnet::Post::dry_run', [true, 'Return encoded output to caller', false]),
20-
OptBool.new('Dotnet::Post::force_wow64', [true, 'Force WOW64 execution', false]),
21-
], self.class)
23+
OptBool.new('Dotnet::Post::force_wow64', [true, 'Force WOW64 execution', false])
24+
],
25+
self.class
26+
)
2227
end
2328
#
2429
# Searches the subkey for the value 'Version' which contains the
2530
# actual version, rather than the over-arching release
2631
# An alternative would be to query for it, and catch the exception.
2732
#
33+
2834
def search_for_version(dotnet_subkey)
2935
dotnet_version = nil
3036
begin
3137
subkeys = registry_enumvals(dotnet_subkey)
32-
rescue::Exception => e
38+
rescue ::Exception => e
3339
print_status("Encountered exception in search_for_version: #{e.class} #{e}")
3440
end
3541
subkeys.each do |i|
@@ -40,7 +46,7 @@ def search_for_version(dotnet_subkey)
4046
end
4147
return dotnet_version
4248
end
43-
49+
4450
#
4551
# Bruteforce search all subkeys in an over-arching release to
4652
# locate the actual release version.
@@ -49,13 +55,13 @@ def get_versionception(dotnet_vkey)
4955
exact_version = nil
5056
begin
5157
subkeys = registry_enumkeys(dotnet_vkey)
52-
rescue::Exception => e
58+
rescue ::Exception => e
5359
print_status("Encountered exception in get_versionception: #{e.class} #{e}")
5460
end
5561
subkeys.each do |i|
56-
exact_version = search_for_version(dotnet_vkey + '\\' +i)
62+
exact_version = search_for_version(dotnet_vkey + '\\' + i)
5763
unless exact_version.nil?
58-
#if we find a version, stop looking
64+
# if we find a version, stop looking
5965
break
6066
end
6167
end
@@ -67,19 +73,19 @@ def get_versionception(dotnet_vkey)
6773
# a windows host
6874
#
6975
def get_dotnet_versions
70-
ret_val = Array.new
76+
ret_val = []
7177
key = 'HKLM\\SOFTWARE\\Microsoft\NET Framework Setup\\NDP'
7278
begin
7379
dotnet_keys = registry_enumkeys(key)
74-
rescue::Exception => e
80+
rescue ::Exception => e
7581
print_status("Encountered exception in get_dotnet_version: #{e.class} #{e}")
7682
end
7783
unless dotnet_keys.nil?
7884
dotnet_keys.each do |i|
7985
if i[0,1] == 'v'
80-
key = 'HKLM\\SOFTWARE\\Microsoft\NET Framework Setup\\NDP\\'+i
86+
key = 'HKLM\\SOFTWARE\\Microsoft\NET Framework Setup\\NDP\\' + i
8187
dotnet_version = get_versionception(key)
82-
unless dotnet_version.nil?
88+
unless dotnet_version.nil?
8389
ret_val << dotnet_version
8490
end
8591
end

0 commit comments

Comments
 (0)