9
9
10
10
class Metasploit3 < Msf ::Post
11
11
include Msf ::Post ::Common
12
+ include Msf ::Post ::Windows ::ExtAPI
12
13
13
14
def initialize ( info = { } )
14
15
super ( update_info ( info ,
@@ -28,7 +29,7 @@ def initialize(info={})
28
29
29
30
register_options (
30
31
[
31
- OptBool . new ( 'MSFLOCALS' , [ false , 'Search for missing patchs for which there is a MSF local module' , true ] ) ,
32
+ OptBool . new ( 'MSFLOCALS' , [ true , 'Search for missing patchs for which there is a MSF local module' , true ] ) ,
32
33
OptString . new ( 'KB' , [ true , 'A comma separated list of KB patches to search for' , 'KB2871997, KB2928120' ] )
33
34
] , self . class )
34
35
end
@@ -53,35 +54,39 @@ def run
53
54
patches = patches + msfmodules
54
55
end
55
56
56
- client . core . use ( "extapi" ) if not client . ext . aliases . include? ( "extapi" )
57
- begin
58
- objects = client . extapi . wmi . query ( "SELECT HotFixID FROM Win32_QuickFixEngineering" )
59
- rescue RuntimeError
60
- print_error "Known bug in WMI query, try migrating to another process"
61
- return
62
- end
63
- kb_ids = objects [ :values ] . map { |kb | kb [ 0 ] }
64
- patches . each do |kb |
65
- if kb_ids . include? ( kb )
66
- print_status ( "#{ kb } applied" )
67
- else
68
- case kb
69
- when "KB977165"
70
- print_good ( "KB977165 - Possibly vulnerable to MS10-015 kitrap0d if Windows 2K SP4 - Windows 7 (x86)" )
71
- when "KB2305420"
72
- print_good ( "KB2305420 - Possibly vulnerable to MS10-092 schelevator if Vista, 7, and 2008" )
73
- when "KB2592799"
74
- print_good ( "KB2592799 - Possibly vulnerable to MS11-080 afdjoinleaf if XP SP2/SP3 Win 2k3 SP2" )
75
- when "KB2778930"
76
- print_good ( "KB2778930 - Possibly vulnerable to MS13-005 hwnd_broadcast, elevates from Low to Medium integrity" )
77
- when "KB2850851"
78
- print_good ( "KB2850851 - Possibly vulnerable to MS13-053 schlamperei if x86 Win7 SP0/SP1" )
79
- when "KB2870008"
80
- print_good ( "KB2870008 - Possibly vulnerable to MS13-081 track_popup_menu" )
57
+ extapi_loaded = load_extapi
58
+ if extapi_loaded
59
+ begin
60
+ objects = session . extapi . wmi . query ( "SELECT HotFixID FROM Win32_QuickFixEngineering" )
61
+ rescue RuntimeError
62
+ print_error "Known bug in WMI query, try migrating to another process"
63
+ return
64
+ end
65
+ kb_ids = objects [ :values ] . map { |kb | kb [ 0 ] }
66
+ patches . each do |kb |
67
+ if kb_ids . include? ( kb )
68
+ print_status ( "#{ kb } applied" )
81
69
else
82
- print_good ( "#{ kb } is missing" )
70
+ case kb
71
+ when "KB977165"
72
+ print_good ( "KB977165 - Possibly vulnerable to MS10-015 kitrap0d if Windows 2K SP4 - Windows 7 (x86)" )
73
+ when "KB2305420"
74
+ print_good ( "KB2305420 - Possibly vulnerable to MS10-092 schelevator if Vista, 7, and 2008" )
75
+ when "KB2592799"
76
+ print_good ( "KB2592799 - Possibly vulnerable to MS11-080 afdjoinleaf if XP SP2/SP3 Win 2k3 SP2" )
77
+ when "KB2778930"
78
+ print_good ( "KB2778930 - Possibly vulnerable to MS13-005 hwnd_broadcast, elevates from Low to Medium integrity" )
79
+ when "KB2850851"
80
+ print_good ( "KB2850851 - Possibly vulnerable to MS13-053 schlamperei if x86 Win7 SP0/SP1" )
81
+ when "KB2870008"
82
+ print_good ( "KB2870008 - Possibly vulnerable to MS13-081 track_popup_menu" )
83
+ else
84
+ print_good ( "#{ kb } is missing" )
85
+ end
83
86
end
84
87
end
88
+ else
89
+ print_error "ExtAPI failed to load"
85
90
end
86
91
end
87
92
end
0 commit comments