1""" Please make sure you read the README file COMPLETELY BEFORE reading anything below. 2 It is very critical that you read coding guidelines in Section E in README file. 3""" 4from xnu import * 5from utils import * 6 7# Macro: walkkauthcache 8@lldb_command('walkkauthcache') 9def WalkKauthCache(cmd_args=None): 10 """ Walks the bins of the kauth credential hash cache and prints out the 11 number of bins and bin usage information. 12 """ 13 PrintKauthCache() 14# EndMacro: walkkauthcache 15 16def PrintKauthCache(cmd_args=None): 17 """ Routine to determine the size of the kauth cache, walk the bins 18 and print out usage information. 19 """ 20 anchor = unsigned(kern.globals.kauth_cred_table_anchor) 21 table_entries = 128 # KAUTH_CRED_TABLE_SIZE 22 anchor = kern.globals.kauth_cred_table_anchor 23 print("Cred cache has: " + str(table_entries) + " buckets\n") 24 print("Number of items in each bucket ... \n") 25 for i in range(0, table_entries): 26 numinbucket = 0 27 for kauth_cred in IterateListEntry(anchor[i], "crw_link"): 28 numinbucket += 1 29 #print str(kauth_cred.cr_posix) 30 #print str(kauth_cred.cr_ref) 31 print(str(numinbucket) + "\n") 32