Add-To-TCC-DB
May 21, 2021 ยท View on GitHub
A JXA script that leverages sqlite3 API calls to add items to the user's TCC database at:
~/Library/Application Support/com.apple.TCC/TCC.db
This is a follow-up repo to Antonio Piazza's JXA code to view TCC db contents at: https://github.com/antman1p/PrintTCCdb
NOTE: Terminal must already have full disk access to write to the user's TCC.db. Additionally, if an app has already been denied access to a specific folder by the user via a TCC prompt, that appears to override even inserting an entry into the TCC database granting access for that program to that folder. So the best scenario of use is for this script is to grant app bundles that have not already been denied access to folders.
This JXA script takes two arguments:
==> First Argument is what TCC access you would like to grant. Examples include:
- kTCCServiceSystemPolicyDownloadsFolder (for Downloads folder access)
- kTCCServiceSystemPolicyDocumentsFolder (for Documents folder access)
- kTCCServiceAppleEvents (for Apple Events)
- kTCCServiceCamera (for Camera)
==> Second argument is the bundleID of the application that you want to grant TCC access to. NOTE: This must be the application bundle identifier, not the application name. To find an app's bundle ID from Terminal you can run:
osascript -e 'id of app "[app_name]"
One this script is run, the specified app will be added with the specified access at the user's TCC.db.
To Use in Mythic C2
This example below is me granting iterm2 access to my Documents folder:
jsimport {"file":"AddToUserTCCDB.js"}
jsimport_call {"command":"insert_item('kTCCServiceSystemPolicyDocumentsFolder','com.googlecode.iterm2')"}
