Skip to content

eladciuraru/toggle-screen-sharing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

toggle-screen-sharing

A small macOS utility that toggles the system Screen Sharing and Remote Login permission by talking directly to tccd via XPC.

How to build

./build.sh

How to run

there are 2 modes supported for running this tool.

  1. executable
  2. injectable dynamic library

for both of the modes, SIP needs to be disabled, and the binaries should be run as root.

Executable Mode

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 off

Dynamic Library

with 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

TODO

  • 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

About

small macOS utility to toggle the system Screen Sharing permission

Resources

License

Stars

3 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors