Skip to content

Commit 11f94a6

Browse files
committed
Do a different wmic query for newer systems
1 parent 3ea3d95 commit 11f94a6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,14 @@ def have_powershell?
3434
# Returns the .Net version
3535
#
3636
def get_dotnet_version
37-
cmd_out = cmd_exec('wmic /namespace:\\\\root\\cimv2 path win32_product where "name like \'%%.NET%%\'" get version')
38-
cmd_out.scan(/[\d\.]+/).flatten.first || ''
37+
case sysinfo['OS']
38+
when /Windows 8|10/
39+
cmd_out = cmd_exec('wmic /namespace:\\\\root\\cimv2 path win32_optionalfeature where "caption like \'.NET Framework%\' and InstallState = 1" get caption')
40+
cmd_out.scan(/(\d\.[\d\.]+)/).flatten.first || ''
41+
else
42+
cmd_out = cmd_exec('wmic /namespace:\\\\root\\cimv2 path win32_product where "name like \'%%.NET%%\'" get version')
43+
cmd_out.scan(/[\d\.]+/).flatten.first || ''
44+
end
3945
end
4046

4147

@@ -61,8 +67,6 @@ def get_powershell_version
6167
end
6268
end
6369

64-
o
65-
6670
o.scan(/[\d \-]+/).last.split[0,2] * '.'
6771
end
6872

0 commit comments

Comments
 (0)