2015-11-06 01:43:30 +00:00
|
|
|
##
|
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
require 'rex'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Post
|
|
|
|
include Msf::Post::Windows::Registry
|
|
|
|
|
2015-12-03 23:55:12 +00:00
|
|
|
def initialize(info = {})
|
|
|
|
super(
|
|
|
|
update_info(
|
|
|
|
info,
|
2015-11-06 01:43:30 +00:00
|
|
|
'Name' => 'Windows Antivirus Excluded Locations Enumeration',
|
2015-12-03 23:55:12 +00:00
|
|
|
'Description' => 'This module will enumerate all excluded directories within supported AV products',
|
2015-11-06 01:43:30 +00:00
|
|
|
'License' => MSF_LICENSE,
|
2015-12-04 00:07:49 +00:00
|
|
|
'Author' => [
|
|
|
|
'Andrew Smith', # original metasploit module
|
|
|
|
'Jon Hart <jon_hart[at]rapid7.com>' # improved metasploit module
|
|
|
|
],
|
2015-11-06 01:43:30 +00:00
|
|
|
'Platform' => [ 'win' ],
|
|
|
|
'SessionTypes' => [ 'meterpreter' ]
|
2015-12-03 23:55:12 +00:00
|
|
|
)
|
|
|
|
)
|
2015-12-04 00:07:49 +00:00
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptBool.new('DEFENDER', [true, 'Enumerate exclusions for Microsoft Defener', true]),
|
2015-12-04 18:27:14 +00:00
|
|
|
OptBool.new('ESSENTIALS', [true, 'Enumerate exclusions for Microsoft Security Essentials/Antimalware', true]),
|
2015-12-04 00:07:49 +00:00
|
|
|
OptBool.new('SEP', [true, 'Enumerate exclusions for Symantec Endpoint Protection (SEP)', true])
|
|
|
|
]
|
|
|
|
)
|
2015-11-06 01:43:30 +00:00
|
|
|
end
|
|
|
|
|
2015-12-04 18:27:14 +00:00
|
|
|
DEFENDER_BASE_KEY = 'HKLM\\SOFTWARE\\Microsoft\\Windows Defender'
|
|
|
|
ESSENTIALS_BASE_KEY = 'HKLM\\SOFTWARE\\Microsoft\\Microsoft Antimalware'
|
|
|
|
SEP_BASE_KEY = 'HKLM\\SOFTWARE\\Symantec\\Symantec Endpoint Protection'
|
2015-11-06 01:43:30 +00:00
|
|
|
|
2015-12-04 18:27:14 +00:00
|
|
|
def av_installed?(base_key, product)
|
|
|
|
if registry_key_exist?(base_key)
|
|
|
|
print_status("Found #{product}")
|
|
|
|
true
|
2015-11-27 21:41:40 +00:00
|
|
|
else
|
2015-12-04 18:27:14 +00:00
|
|
|
false
|
2015-11-27 21:41:40 +00:00
|
|
|
end
|
|
|
|
end
|
2015-12-03 23:55:12 +00:00
|
|
|
|
2015-11-27 21:41:40 +00:00
|
|
|
def excluded_sep
|
2015-11-06 01:43:30 +00:00
|
|
|
print_status "Excluded Locations:"
|
2015-11-27 21:41:40 +00:00
|
|
|
keyadm = "HKLM\\SOFTWARE\\Symantec\\Symantec Endpoint Protection\\AV\\Exclusions\\ScanningEngines\\Directory\\Admin"
|
2015-12-03 23:55:12 +00:00
|
|
|
if (found_keysadm = registry_enumkeys(keyadm))
|
|
|
|
found_keysadm.each do |vals|
|
|
|
|
full = keyadm + "\\" + vals
|
|
|
|
values = registry_getvaldata(full, "DirectoryName")
|
|
|
|
print_good "#{values}"
|
|
|
|
end
|
|
|
|
else
|
|
|
|
print_error "No Admin Locations Found"
|
|
|
|
end
|
|
|
|
|
2015-11-27 21:41:40 +00:00
|
|
|
keycli = "HKLM\\SOFTWARE\\Symantec\\Symantec Endpoint Protection\\AV\\Exclusions\\ScanningEngines\\Directory\\Client"
|
2015-12-03 23:55:12 +00:00
|
|
|
if (found_keyscli = registry_enumkeys(keycli))
|
|
|
|
found_keyscli.each do |vals|
|
|
|
|
full = keycli + "\\" + vals
|
|
|
|
values = registry_getvaldata(full, "DirectoryName")
|
|
|
|
print_good "#{values}"
|
|
|
|
end
|
|
|
|
else
|
|
|
|
print_error "No Client Locations Found"
|
|
|
|
end
|
2015-11-27 21:41:40 +00:00
|
|
|
end
|
2015-12-03 23:55:12 +00:00
|
|
|
|
2015-11-27 21:45:52 +00:00
|
|
|
def excluded_mssec
|
2015-11-27 21:41:40 +00:00
|
|
|
print_status "Excluded Locations:"
|
2015-12-03 23:55:12 +00:00
|
|
|
keyms = "HKLM\\SOFTWARE\\Microsoft\\Microsoft Antimalware\\Exclusions\\Paths\\"
|
|
|
|
if (found = registry_enumvals(keyms))
|
|
|
|
found.each do |num|
|
|
|
|
print_good "#{num}"
|
|
|
|
end
|
2015-11-27 21:41:40 +00:00
|
|
|
else
|
2015-12-03 23:55:12 +00:00
|
|
|
print_error "No Excluded Locations Found"
|
2015-11-06 01:43:30 +00:00
|
|
|
end
|
2015-11-27 21:41:40 +00:00
|
|
|
end
|
2015-12-03 23:55:12 +00:00
|
|
|
|
2015-11-27 21:41:40 +00:00
|
|
|
def excluded_defender
|
|
|
|
print_status "Excluded Locations:"
|
2015-12-03 23:55:12 +00:00
|
|
|
keyms = "HKLM\\SOFTWARE\\Microsoft\\Windows Defender\\Exclusions\\Paths\\"
|
|
|
|
if (found = registry_enumvals(keyms))
|
|
|
|
found.each do |num|
|
|
|
|
print_good "#{num}"
|
|
|
|
end
|
2015-11-27 21:41:40 +00:00
|
|
|
else
|
2015-12-03 23:55:12 +00:00
|
|
|
print_error "No Excluded Locations Found"
|
2015-11-06 01:43:30 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-12-04 00:07:49 +00:00
|
|
|
def setup
|
|
|
|
unless datastore['DEFENDER'] || datastore['ESSENTIALS'] || datastore['SEP']
|
|
|
|
fail_with(Failure::BadConfig, 'Must set one or more of DEFENDER, ESSENTIALS or SEP to true')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-11-06 01:43:30 +00:00
|
|
|
def run
|
2015-12-04 00:07:49 +00:00
|
|
|
if sysinfo['Architecture'] =~ /WOW64/
|
2015-12-03 23:55:12 +00:00
|
|
|
print_error "You are running this module from a 32-bit process on a 64-bit machine. Migrate to a 64-bit process and try again"
|
|
|
|
return
|
2015-11-06 01:43:30 +00:00
|
|
|
end
|
2015-12-04 00:07:49 +00:00
|
|
|
|
|
|
|
print_status("Enumerating Excluded Paths for AV on #{sysinfo['Computer']}")
|
|
|
|
found = false
|
2015-12-04 18:27:14 +00:00
|
|
|
if datastore['DEFENDER'] && av_installed?(DEFENDER_BASE_KEY, 'Microsoft Defender')
|
2015-12-04 00:07:49 +00:00
|
|
|
found = true
|
|
|
|
excluded_defender
|
|
|
|
end
|
2015-12-04 18:27:14 +00:00
|
|
|
if datastore['ESSENTIALS'] && av_installed?(ESSENTIALS_BASE_KEY, 'Microsoft Security Essentials / Antimalware')
|
2015-12-04 00:07:49 +00:00
|
|
|
found = true
|
|
|
|
excluded_mssec
|
|
|
|
end
|
2015-12-04 18:27:14 +00:00
|
|
|
if datastore['SEP'] && av_installed?(SEP_BASE_KEY, 'Symantec Endpoint Protection')
|
2015-12-04 00:07:49 +00:00
|
|
|
found = true
|
|
|
|
excluded_sep
|
|
|
|
end
|
|
|
|
|
|
|
|
print_error "No supported AV identified" unless found
|
2015-11-06 01:43:30 +00:00
|
|
|
end
|
|
|
|
end
|