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