-
Notifications
You must be signed in to change notification settings - Fork 13.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add enum_trusted_locations.rb #6966
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2e03c35
Add enum_trusted_locations.rb
vysec a2a97d0
Update enum_trusted_locations.rb
vysec 1ba33ff
Fixed MSFTidy
vysec 4871418
Update enum_trusted_locations.rb
vysec 8a68e86
Update enum_trusted_locations.rb
vysec 0451d4f
Cleanup
Meatballs1 674470c
Merge pull request #1 from Meatballs1/trusted_locations
vysec File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
## | ||
# This module requires Metasploit: http://metasploit.com/download | ||
# Current source: https://github.com/rapid7/metasploit-framework | ||
## | ||
|
||
require 'msf/core' | ||
require 'rex' | ||
require 'msf/core/post/common' | ||
|
||
class MetasploitModule < Msf::Post | ||
include Msf::Post::Windows::Registry | ||
include Msf::Post::Common | ||
|
||
def initialize(info = {}) | ||
super(update_info(info, | ||
'Name' => 'Windows Gather Microsoft Office Trusted Locations', | ||
'Description' => %q( This module will enumerate the Microsoft Office trusted locations on the target host.), | ||
'License' => MSF_LICENSE, | ||
'Author' => [ 'vysec <vincent.yiu[at]mwrinfosecurity.com>' ], | ||
'Platform' => [ 'win' ], | ||
'SessionTypes' => [ 'meterpreter' ] | ||
)) | ||
end | ||
|
||
def print_status(msg='') | ||
super("#{peer} - #{msg}") | ||
end | ||
|
||
def print_good(msg='') | ||
super("#{peer} - #{msg}") | ||
end | ||
|
||
def run | ||
reg_view = sysinfo['Architecture'] =~ /x64/ ? REGISTRY_VIEW_64_BIT : REGISTRY_VIEW_32_BIT | ||
reg_keys = registry_enumkeys('HKCU\\SOFTWARE\\Microsoft\\Office', reg_view) | ||
if reg_keys.nil? | ||
print_status('Failed to enumerate Office.') | ||
else | ||
print_status('') | ||
print_status('Found Office:') | ||
#find version to use | ||
reg_keys.each do |path| | ||
if not /[0-9][0-9].0/.match(path).nil? | ||
val1 = path | ||
print_status("Version found: #{val1}") | ||
reg_keys2 = registry_enumkeys("HKCU\\SOFTWARE\\Microsoft\\Office\\#{val1}", reg_view) | ||
if reg_keys2.nil? | ||
print_status('Failed to enumerate applications.') | ||
else | ||
print_status('Found applications.') | ||
#find version to use | ||
reg_keys2.each do |path2| | ||
val2 = path2 | ||
reg_keys3 = registry_enumkeys("HKCU\\SOFTWARE\\Microsoft\\Office\\#{val1}\\#{val2}\\Security\\Trusted Locations", reg_view) | ||
if not reg_keys3.nil? | ||
print_status('Found trusted locations.') | ||
#find version to use | ||
reg_keys3.each do |path3| | ||
val3 = path3 | ||
#print_status(path3) | ||
print_status('') | ||
reg_vals = registry_getvaldata("HKCU\\SOFTWARE\\Microsoft\\Office\\#{val1}\\#{val2}\\Security\\Trusted Locations\\#{val3}", "Description", reg_view) | ||
if not reg_vals.nil? | ||
print_status("Description: #{reg_vals}") | ||
end | ||
reg_vals2 = registry_getvaldata("HKCU\\SOFTWARE\\Microsoft\\Office\\#{val1}\\#{val2}\\Security\\Trusted Locations\\#{val3}", "AllowSubFolders", reg_view) | ||
reg_vals = registry_getvaldata("HKCU\\SOFTWARE\\Microsoft\\Office\\#{val1}\\#{val2}\\Security\\Trusted Locations\\#{val3}", "Path", reg_view) | ||
if not reg_vals.nil? | ||
if not reg_vals2.nil? | ||
print_status("Path: #{reg_vals}, AllowSub: True") | ||
else | ||
print_status("Path: #{reg_vals}, AllowSub: False") | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
path = store_loot('host.trusted_locations', 'text/plain', session, reg_keys.join("\r\n"), 'trusted_locations.txt', 'Trusted Locations') | ||
print_good("Results stored in: #{path}") | ||
end | ||
end | ||
end | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the end, beautiful friend / This is the end, my only friend, the end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or hopefully not as I want to write more :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can refactor the level of nesting here. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my Ruby sucks but any advice hugely appreciated.