2014-05-24 23:37:17 -04:00
|
|
|
##
|
2017-07-24 06:26:21 -07:00
|
|
|
# This module requires Metasploit: https://metasploit.com/download
|
2014-05-24 23:37:17 -04:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
|
|
|
##
|
|
|
|
|
|
|
|
|
|
require 'msf/core/post/common'
|
2014-05-25 10:45:09 -04:00
|
|
|
require 'msf/core/post/windows/extapi'
|
2014-05-24 23:37:17 -04:00
|
|
|
|
2016-03-08 14:02:44 +01:00
|
|
|
class MetasploitModule < Msf::Post
|
2014-05-24 23:37:17 -04:00
|
|
|
include Msf::Post::Common
|
2014-05-25 10:40:23 -04:00
|
|
|
include Msf::Post::Windows::ExtAPI
|
2014-05-24 23:37:17 -04:00
|
|
|
|
|
|
|
|
def initialize(info={})
|
|
|
|
|
super(update_info(info,
|
2014-09-16 16:17:22 -05:00
|
|
|
'Name' => "Windows Gather Applied Patches",
|
2014-05-24 23:37:17 -04:00
|
|
|
'Description' => %q{
|
|
|
|
|
This module will attempt to enumerate which patches are applied to a windows system
|
2020-01-14 20:49:39 -05:00
|
|
|
based on the result of the WMI query: SELECT HotFixID FROM Win32_QuickFixEngineering.
|
2014-05-24 23:37:17 -04:00
|
|
|
},
|
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
|
'Platform' => ['win'],
|
|
|
|
|
'SessionTypes' => ['meterpreter'],
|
2014-09-16 16:17:22 -05:00
|
|
|
'Author' =>
|
|
|
|
|
[
|
2014-05-24 23:37:17 -04:00
|
|
|
'zeroSteiner', # Original idea
|
|
|
|
|
'mubix' # Post module
|
2014-09-16 16:17:22 -05:00
|
|
|
],
|
|
|
|
|
'References' =>
|
|
|
|
|
[
|
|
|
|
|
['URL', 'http://msdn.microsoft.com/en-us/library/aa394391(v=vs.85).aspx']
|
2014-05-24 23:37:17 -04:00
|
|
|
]
|
|
|
|
|
))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def run
|
2019-02-02 15:33:48 +00:00
|
|
|
unless load_extapi
|
|
|
|
|
print_error 'ExtAPI failed to load'
|
|
|
|
|
return
|
2014-05-24 23:37:17 -04:00
|
|
|
end
|
|
|
|
|
|
2019-02-02 15:33:48 +00:00
|
|
|
begin
|
|
|
|
|
objects = session.extapi.wmi.query("SELECT HotFixID FROM Win32_QuickFixEngineering")
|
|
|
|
|
rescue RuntimeError
|
|
|
|
|
print_error "Known bug in WMI query, try migrating to another process"
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if objects[:values].nil?
|
|
|
|
|
kb_ids = []
|
2014-05-25 19:36:40 -05:00
|
|
|
else
|
2019-02-02 15:33:48 +00:00
|
|
|
kb_ids = objects[:values].reject(&:nil?).map { |kb| kb[0] }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if kb_ids.empty?
|
|
|
|
|
print_status 'Found no patches installed'
|
2020-01-14 20:49:39 -05:00
|
|
|
return
|
2014-05-25 19:36:40 -05:00
|
|
|
end
|
2019-02-02 15:33:48 +00:00
|
|
|
|
2020-01-14 20:49:39 -05:00
|
|
|
l = store_loot('enum_patches', 'text/plain', session, kb_ids.join("\n"))
|
|
|
|
|
print_status("Patch list saved to #{l}")
|
|
|
|
|
kb_ids.each do |kb|
|
|
|
|
|
print_status("#{kb} applied")
|
2014-05-24 23:37:17 -04:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|