File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
lib/msf/core/post/windows Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,42 @@ def have_powershell?
30
30
return false
31
31
end
32
32
33
+ #
34
+ # Returns the .Net version
35
+ #
36
+ 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 || ''
39
+ end
40
+
41
+
42
+ #
43
+ # Returns the Powershell version
44
+ #
45
+ def get_powershell_version
46
+ return nil unless have_powershell?
47
+
48
+ process , pid , c = execute_script ( '$PSVersionTable.PSVersion' )
49
+
50
+ o = ''
51
+
52
+ while ( d = process . channel . read )
53
+ if d == ""
54
+ if ( Time . now . to_i - start < time_out ) && ( o == '' )
55
+ sleep 0.1
56
+ else
57
+ break
58
+ end
59
+ else
60
+ o << d
61
+ end
62
+ end
63
+
64
+ o
65
+
66
+ o . scan ( /[\d \- ]+/ ) . last . split [ 0 , 2 ] * '.'
67
+ end
68
+
33
69
#
34
70
# Get/compare list of current PS processes - nested execution can spawn many children
35
71
# doing checks before and after execution allows us to kill more children...
You can’t perform that action at this time.
0 commit comments