A small macOS utility that toggles the system Screen Sharing and
Remote Login permission by talking directly to tccd via XPC.
./build.shthere are 2 modes supported for running this tool.
- executable
- injectable dynamic library
for both of the modes, SIP needs to be disabled, and the binaries should be run as root.
because this is a self signed executable, amfi needs to be disabled,
either with amfi_get_out_of_my_way boot arg or the recommended way using
amfidont to allow this specific executable.
then it will be possible to run as a regular executable from command line. for example:
# toggling on
sudo ./bin/screen_sharing --screen-sharing on
# toggling off
sudo ./bin/screen_sharing --screen-sharing offwith this mode the library needs to be injected into another binary
with the right entitlements.
for enabling screen sharing you need com.apple.private.tcc.manager.access.modify entitlement
with both kTCCServicePostEvent and kTCCServiceScreenCapture.
for enabling remote login you need kTCCServiceSystemPolicyAllFiles.
you can search for such a binary with in here.
for example using writeconfig since it has these requirements under the current
newest macOS 26.3:
# toggling on
sudo env SCREEN_SHARING_TOGGLE=on REMOTE_LOGIN_TOGGLE=on "DYLD_INSERT_LIBRARIES=./bin/libscreen_sharing.dylib" /System/Library/PrivateFrameworks/SystemAdministration.framework/XPCServices/writeconfig.xpc/Contents/MacOS/writeconfig
# toggling off
sudo env SCREEN_SHARING_TOGGLE=off REMOTE_LOGIN_TOGGLE=off "DYLD_INSERT_LIBRARIES=./bin/libscreen_sharing.dylib" /System/Library/PrivateFrameworks/SystemAdministration.framework/XPCServices/writeconfig.xpc/Contents/MacOS/writeconfig- move from manually creating XPC to calling private TCC framework APIs
- change so only provided toggle flags are used (e.g. if only remote login is used then only send remote login requests)
- add kill for services when disabling them