Cleaned up a little

bug/bundler_fix
Brendan 2016-08-15 12:20:28 -07:00
parent 7730e0eb27
commit 0778b77f7b
1 changed files with 19 additions and 13 deletions

View File

@ -6,30 +6,36 @@ module Msf
class Post
module Windows
#
# This module serves to hold methods related to .NET framework
#
module Dotnet
include ::Msf::Post::Common
include ::Msf::Post::Windows::Registry
def initialize(info = {})
super
register_advanced_options(
[
OptInt.new('Dotnet::Post::timeout', [true, 'Dotnet execution timeout, set < 0 to run async without termination', 15]),
OptInt.new('Dotnet::Post::timeout', [true, 'Dotnet execution timeout, set < 0 to run async without termination', 15]),
OptBool.new('Dotnet::Post::log_output', [true, 'Write output to log file', false]),
OptBool.new('Dotnet::Post::dry_run', [true, 'Return encoded output to caller', false]),
OptBool.new('Dotnet::Post::force_wow64', [true, 'Force WOW64 execution', false]),
], self.class)
OptBool.new('Dotnet::Post::force_wow64', [true, 'Force WOW64 execution', false])
],
self.class
)
end
#
# Searches the subkey for the value 'Version' which contains the
# actual version, rather than the over-arching release
# An alternative would be to query for it, and catch the exception.
#
def search_for_version(dotnet_subkey)
dotnet_version = nil
begin
subkeys = registry_enumvals(dotnet_subkey)
rescue::Exception => e
rescue ::Exception => e
print_status("Encountered exception in search_for_version: #{e.class} #{e}")
end
subkeys.each do |i|
@ -40,7 +46,7 @@ module Dotnet
end
return dotnet_version
end
#
# Bruteforce search all subkeys in an over-arching release to
# locate the actual release version.
@ -49,13 +55,13 @@ module Dotnet
exact_version = nil
begin
subkeys = registry_enumkeys(dotnet_vkey)
rescue::Exception => e
rescue ::Exception => e
print_status("Encountered exception in get_versionception: #{e.class} #{e}")
end
subkeys.each do |i|
exact_version = search_for_version(dotnet_vkey + '\\' +i)
exact_version = search_for_version(dotnet_vkey + '\\' + i)
unless exact_version.nil?
#if we find a version, stop looking
# if we find a version, stop looking
break
end
end
@ -67,19 +73,19 @@ module Dotnet
# a windows host
#
def get_dotnet_versions
ret_val = Array.new
ret_val = []
key = 'HKLM\\SOFTWARE\\Microsoft\NET Framework Setup\\NDP'
begin
dotnet_keys = registry_enumkeys(key)
rescue::Exception => e
rescue ::Exception => e
print_status("Encountered exception in get_dotnet_version: #{e.class} #{e}")
end
unless dotnet_keys.nil?
dotnet_keys.each do |i|
if i[0,1] == 'v'
key = 'HKLM\\SOFTWARE\\Microsoft\NET Framework Setup\\NDP\\'+i
key = 'HKLM\\SOFTWARE\\Microsoft\NET Framework Setup\\NDP\\' + i
dotnet_version = get_versionception(key)
unless dotnet_version.nil?
unless dotnet_version.nil?
ret_val << dotnet_version
end
end