Skip to content

Commit e3a6782

Browse files
committed
add post module based on @zeroSteiner idea
1 parent dc7ec45 commit e3a6782

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
##
2+
# This module requires Metasploit: http//metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
7+
require 'msf/core'
8+
require 'msf/core/post/common'
9+
10+
class Metasploit3 < Msf::Post
11+
include Msf::Post::Common
12+
13+
def initialize(info={})
14+
super(update_info(info,
15+
'Name' => "Windows Enumerate Applied Patches",
16+
'Description' => %q{
17+
This module will attempt to enumerate which patches are applied to a windows system
18+
based on the result of the WMI query: SELECT HotFixID FROM Win32_QuickFixEngineering
19+
},
20+
'License' => MSF_LICENSE,
21+
'Platform' => ['win'],
22+
'SessionTypes' => ['meterpreter'],
23+
'Author' => [
24+
'zeroSteiner', # Original idea
25+
'mubix' # Post module
26+
]
27+
))
28+
29+
register_options(
30+
[
31+
OptBool.new('MSFLOCALS', [ false, 'Search for missing patchs for which there is a MSF local module', true]),
32+
OptString.new('KB', [ true, 'A comma separated list of KB patches to search for', 'KB2871997, KB2928120'])
33+
], self.class)
34+
end
35+
36+
# The sauce starts here
37+
def run
38+
patches = []
39+
msfmodules = [
40+
'KB977165', # MS10-015 kitrap0d
41+
'KB2305420', # MS10-092 schelevator
42+
'KB2592799', # MS11-080 afdjoinleaf
43+
'KB2778930', # MS13-005 hwnd_broadcast
44+
'KB2850851', # MS13-053 schlamperei
45+
'KB2870008' # MS13-081 track_popup_menu
46+
]
47+
48+
datastore['KB'].split(',').each do |kb|
49+
patches << kb.strip
50+
end
51+
52+
if datastore['MSFLOCALS']
53+
patches = patches + msfmodules
54+
end
55+
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")
81+
else
82+
print_good("#{kb} is missing")
83+
end
84+
end
85+
end
86+
end
87+
end

0 commit comments

Comments
 (0)