Skip to content

Commit 81f30ca

Browse files
committed
Land rapid7#6966, Microsoft Office Trusted Locations Enumeration
2 parents 718f36f + 674470c commit 81f30ca

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
##
2+
# This module requires Metasploit: http://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
require 'rex'
8+
require 'msf/core/post/common'
9+
10+
class MetasploitModule < Msf::Post
11+
include Msf::Post::Windows::Registry
12+
include Msf::Post::Common
13+
14+
OFFICE_REGISTRY_PATH = 'HKCU\\SOFTWARE\\Microsoft\\Office'
15+
TRUSTED_LOCATIONS_PATH = 'Security\\Trusted Locations'
16+
17+
def initialize(info = {})
18+
super(update_info(info,
19+
'Name' => 'Windows Gather Microsoft Office Trusted Locations',
20+
'Description' => %q( This module will enumerate the Microsoft Office trusted locations on the target host. ),
21+
'License' => MSF_LICENSE,
22+
'Author' => [ 'vysec <vincent.yiu[at]mwrinfosecurity.com>' ],
23+
'Platform' => [ 'win' ],
24+
'SessionTypes' => [ 'meterpreter' ]
25+
))
26+
end
27+
28+
def print_status(msg='')
29+
super("#{peer} - #{msg}")
30+
end
31+
32+
def print_good(msg='')
33+
super("#{peer} - #{msg}")
34+
end
35+
36+
def run
37+
locations = ""
38+
[REGISTRY_VIEW_64_BIT, REGISTRY_VIEW_32_BIT].each do |registry_arch|
39+
arch = registry_arch == REGISTRY_VIEW_64_BIT ? 'x64' : 'x86'
40+
reg_keys = registry_enumkeys(OFFICE_REGISTRY_PATH, registry_arch)
41+
if reg_keys.nil?
42+
print_status("Failed to enumerate Office in #{arch} registry hive.")
43+
return
44+
end
45+
46+
reg_keys.each do |version|
47+
next if /[0-9][0-9].0/.match(version).nil?
48+
49+
print_status("Version found: #{version}")
50+
version_path = "#{OFFICE_REGISTRY_PATH}\\#{version}"
51+
applications = registry_enumkeys(version_path, registry_arch)
52+
53+
if applications.nil?
54+
print_status('Failed to enumerate applications.')
55+
next
56+
end
57+
58+
vprint_status('Found applications.')
59+
#find version to use
60+
applications.each do |application|
61+
trusted_locations_path = "#{version_path}\\#{application}\\#{TRUSTED_LOCATIONS_PATH}"
62+
trusted_locations = registry_enumkeys(trusted_locations_path, registry_arch)
63+
next if trusted_locations.nil?
64+
65+
print_good("Found trusted locations in #{application}")
66+
#find version to use
67+
trusted_locations.each do |location|
68+
location_path = "#{trusted_locations_path}\\#{location}"
69+
description = registry_getvaldata(location_path, 'Description', registry_arch)
70+
allow_subfolders = registry_getvaldata(location_path, 'AllowSubFolders', registry_arch)
71+
path = registry_getvaldata(location_path, 'Path', registry_arch)
72+
vprint_status("Description: #{description}")
73+
result = "Application: #{application}, Path: #{path}, AllSubFolders: #{!!allow_subfolders}"
74+
locations << "#{result}\n"
75+
print_status(result)
76+
end
77+
end
78+
end
79+
path = store_loot('host.trusted_locations', 'text/plain', session, locations, 'trusted_locations.txt', 'Trusted Locations')
80+
print_good("Results stored in: #{path}")
81+
end
82+
end
83+
end

0 commit comments

Comments
 (0)