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/auxiliary/admin/kerberos/ticket_converter.rb
Views: 11783
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6def initialize(info = {})7super(8update_info(9info,10'Name' => 'Kerberos ticket converter',11'Description' => %q{12This module converts tickets to the ccache format from the kirbi format and vice versa.13},14'Author' => [15'Zer1t0', # Impacket Implementation https://github.com/Zer1t016'Dean Welch', # Metasploit Module17],18'References' => [19['URL', 'https://github.com/SecureAuthCorp/impacket/blob/3c6713e309cae871d685fa443d3e21b7026a2155/examples/ticketConverter.py'],20['URL', 'https://tools.ietf.org/html/rfc4120'],21['URL', 'http://web.mit.edu/KERBEROS/krb5-devel/doc/formats/ccache_file_format.html'],22['URL', 'https://github.com/gentilkiwi/kekeo'],23['URL', 'https://github.com/rvazarkar/KrbCredExport'],24],25'License' => MSF_LICENSE,26'Notes' => {27'Stability' => [],28'Reliability' => [],29'SideEffects' => []30}31)32)33register_options(34[35OptPath.new('InputPath', [ true, 'The file path to ticket in kirbi (KRB-CRED) or ccache format.' ]),36OptString.new('OutputPath', [ true, 'The output path to save the converted ticket.' ]),37]38)39end4041def run42header = File.binread(datastore['InputPath'], 2)43if ccache?(header)44print_status('Converting from ccache to kirbi')45output = ccache_to_kirbi(File.binread(datastore['InputPath']))46elsif kirbi?(header)47print_status('Converting from kirbi to ccache')48output = kirbi_to_ccache(File.binread(datastore['InputPath']))49else50fail_with(Msf::Module::Failure::BadConfig, 'Unknown file format')51end52path = File.expand_path(datastore['OutputPath'])53File.binwrite(path, output.encode)54print_status("File written to #{path}")55end5657def ccache_to_kirbi(input)58ccache = Rex::Proto::Kerberos::CredentialCache::Krb5Ccache.read(input)59Msf::Exploit::Remote::Kerberos::TicketConverter.ccache_to_kirbi(ccache)60end6162def kirbi_to_ccache(input)63krb_cred = Rex::Proto::Kerberos::Model::KrbCred.decode(input)64Msf::Exploit::Remote::Kerberos::TicketConverter.kirbi_to_ccache(krb_cred)65end6667private6869def kirbi?(header)70header[0] == "\x76"71end7273def ccache?(header)74header[0..1] == "\x05\x04"75end76end777879