Skip to content

Commit 6435b43

Browse files
committed
1 parent e3a6782 commit 6435b43

File tree

1 file changed

+32
-27
lines changed

1 file changed

+32
-27
lines changed

modules/post/windows/gather/enum_patches.rb

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
class Metasploit3 < Msf::Post
1111
include Msf::Post::Common
12+
include Msf::Post::Windows::ExtAPI
1213

1314
def initialize(info={})
1415
super(update_info(info,
@@ -28,7 +29,7 @@ def initialize(info={})
2829

2930
register_options(
3031
[
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]),
3233
OptString.new('KB', [ true, 'A comma separated list of KB patches to search for', 'KB2871997, KB2928120'])
3334
], self.class)
3435
end
@@ -53,35 +54,39 @@ def run
5354
patches = patches + msfmodules
5455
end
5556

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")
8169
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
8386
end
8487
end
88+
else
89+
print_error "ExtAPI failed to load"
8590
end
8691
end
8792
end

0 commit comments

Comments
 (0)