def main(): import argparse parser = argparse.ArgumentParser(description='Prints CCACHE file info') parser.add_argument('ccachefile', help='input CCACHE file') parser.add_argument('-v', '--verbose', action='count', default=0) args = parser.parse_args() ###### VERBOSITY if args.verbose == 0: logging.basicConfig(level=logging.INFO) else: logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.INFO) logging.debug('Opening file %s' % args.ccachefile) cc = CCACHE.from_file(args.ccachefile) table = [] table.append(['id'] + Credential.summary_header()) i = 0 for cred in cc.credentials: table.append([str(i)] + cred.summary()) i += 1 print() #this line intentionally left blank print_table(table)
def main(): import argparse parser = argparse.ArgumentParser( description= 'Parses CCACHE file and outputs all TGS tickets in a hashcat-crackable format' ) parser.add_argument('ccache', help='CCACHE file to roast') args = parser.parse_args() ccache = CCACHE.from_file(args.ccache) for hash in ccache.get_hashes(all_hashes=True): print(hash)
def add_secret(self, st: KerberosSecretType, secret: str): if st == KerberosSecretType.PASSWORD or st == KerberosSecretType.PW or st == KerberosSecretType.PASS: if secret == '' or secret is None: self.password = getpass.getpass( 'Enter Kerberos credential password:') else: self.password = secret elif st == KerberosSecretType.NT or st == KerberosSecretType.RC4: self.nt_hash = secret self.kerberos_key_rc4 = secret elif st == KerberosSecretType.AES128: self.kerberos_key_aes_128 = secret elif st == KerberosSecretType.AES256: self.kerberos_key_aes_256 = secret elif st == KerberosSecretType.DES: self.kerberos_key_des = secret elif st == KerberosSecretType.DES3 or st == KerberosSecretType.TDES: self.kerberos_key_des3 = secret elif st == KerberosSecretType.CCACHE: self.ccache = CCACHE.from_file(secret)
def from_connection_string(s): """ Credential input format: <domain>/<username>/<secret_type>:<secret>@<dc_ip_or_hostname> """ cred = KerberosCredential() cred.domain, t = s.split('/', 1) cred.username, t = t.split('/', 1) secret_type, t = t.split(':', 1) secret, target = t.rsplit('@', 1) st = KerberosSecretType(secret_type.upper()) if st == KerberosSecretType.PASSWORD or st == KerberosSecretType.PW or st == KerberosSecretType.PASS: if secret == '' or secret is None: cred.password = getpass.getpass( 'Enter Kerberos credential password:') else: cred.password = secret elif st == KerberosSecretType.NT or st == KerberosSecretType.RC4: cred.nt_hash = secret cred.kerberos_key_rc4 = secret elif st == KerberosSecretType.AES: cred.kerberos_key_aes_256 = secret cred.kerberos_key_aes_128 = secret elif st == KerberosSecretType.DES: cred.kerberos_key_des = secret elif st == KerberosSecretType.DES3 or st == KerberosSecretType.TDES: cred.kerberos_key_des3 = secret elif st == KerberosSecretType.CCACHE: cred.ccache = CCACHE.from_file(secret) cred.target = target return cred
def main(): import argparse parser = argparse.ArgumentParser( description='Convert ccache file to kirbi file(s)') parser.add_argument('ccache', help='path to the ccache file') parser.add_argument( 'kirbidir', help='output directory fir the extracted kirbi file(s)') parser.add_argument('-v', '--verbose', action='count', default=0) args = parser.parse_args() if args.verbose == 0: logging.basicConfig(level=logging.INFO) elif args.verbose == 1: logging.basicConfig(level=logging.DEBUG) else: logging.basicConfig(level=1) logging.info('Parsing CCACHE file') cc = CCACHE.from_file(args.ccache) logging.info('Extracting kirbi file(s)') cc.to_kirbidir(args.kirbidir) logging.info('Done!')
def main(): import argparse parser = argparse.ArgumentParser( description='Tool to manipulate CCACHE files') subparsers = parser.add_subparsers(help='commands') subparsers.required = True subparsers.dest = 'command' roast_group = subparsers.add_parser( 'roast', help='Lists all tickets in hashcat-friendly format') roast_group.add_argument('-a', '--allhash', action='store_true', help='Process all tickets, regardless of enctype') roast_group.add_argument('-o', '--outfile', help='Output hash file name') list_group = subparsers.add_parser('list', help='List all tickets in the file') delete_group = subparsers.add_parser( 'del', help= 'Delete ticket(s) from file, store the new ccache file in a specified filename, or an automatically generated one' ) delete_group.add_argument('-o', '--outfile', help='Output ccache file name') delete_group.add_argument('-i', '--id', type=int, action='append', help='Ticket ID to delete', required=True) parser.add_argument('ccachefile', help='input CCACHE file') args = parser.parse_args() logging.basicConfig(level=logging.INFO) logging.debug('Opening file %s' % args.ccachefile) cc = CCACHE.from_file(args.ccachefile) if args.command == 'list': table = [] table.append(['id'] + Credential.summary_header()) i = 0 for cred in cc.credentials: table.append([str(i)] + cred.summary()) i += 1 print() #this line intentionally left blank print_table(table) elif args.command == 'roast': if args.outfile: with open(args.outfile, 'wb') as f: for h in cc.get_hashes(all_hashes=args.allhash): f.write(h.encode() + b'\r\n') else: for h in cc.get_hashes(all_hashes=args.allhash): print(h) elif args.command == 'del': #delete output_filename = os.path.join( os.path.dirname(os.path.abspath(args.ccachefile)), '%s.edited.ccache' % ntpath.basename(args.ccachefile)) #sorry for this, im tired now :( id = args.id temp_cc = CCACHE() temp_cc.file_format_version = cc.file_format_version temp_cc.headerlen = cc.headerlen temp_cc.headers = cc.headers temp_cc.primary_principal = cc.primary_principal i = 0 for cred in cc.credentials: if i in id: i += 1 continue temp_cc.credentials.append(cred) i += 1 logging.info('Writing edited file to %s' % output_filename) temp_cc.to_file(output_filename)
) delete_group.add_argument('-o', '--outfile', help='Output ccache file name') delete_group.add_argument('-i', '--id', type=int, action='append', help='Ticket ID to delete', required=True) parser.add_argument('ccachefile', help='input CCACHE file') args = parser.parse_args() logging.basicConfig(level=logging.INFO) logging.debug('Opening file %s' % args.ccachefile) cc = CCACHE.from_file(args.ccachefile) if args.command == 'list': table = [] table.append(['id'] + Credential.summary_header()) i = 0 for cred in cc.credentials: table.append([str(i)] + cred.summary()) i += 1 print() #this line intentionally left blank print_table(table) elif args.command == 'del': #delete output_filename = os.path.join( os.path.dirname(os.path.abspath(args.ccachefile)),
from minikerberos.ccache import CCACHE if __name__ == '__main__': ccache = CCACHE.from_file( '../../ktest/victim_lsass_latest.dmp_229c8765.ccache') print(ccache.get_hashes(all_hashes=True))