Skip to content

Instantly share code, notes, and snippets.

@kasnder
Created March 10, 2023 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kasnder/7076fe8eaea51948e5cda7a01e343ff5 to your computer and use it in GitHub Desktop.
Save kasnder/7076fe8eaea51948e5cda7a01e343ff5 to your computer and use it in GitHub Desktop.
Grant the local network permission to an iOS app. More permissions here: https://gist.github.com/kasnder/3eb32449512a4dba4a92949c8d337a92
#!/bin/bash
# Todo: This currently fails to update the file signature. It still seems to work but should not be used on a production device.
# Usage:./grant_ios_local_network_permission.sh.sh [bundleId]
# Example: ./grant_ios_local_network_permission.sh.sh com.spotify.client
if [ -z "$1" ]; then
echo "Please pass bundleId"
exit -1
fi
# Create backup (-n makes sure to not overwrite existing backup)
ssh -T -p 2222 root@localhost "cp -n /Library/Preferences/com.apple.networkextension.plist ~/com.apple.networkextension.backup.plist"
# Download binary plist file
scp -P 2222 root@localhost:/Library/Preferences/com.apple.networkextension.plist ./com.apple.networkextension.old.plist
# Cleanup if exists
rm ./com.apple.networkextension.new.xml || true
rm ./com.apple.networkextension.new.plist || true
# Convert binary to XML plist
plistutil -i com.apple.networkextension.old.plist -o com.apple.networkextension.new.xml -f xml
# Grant permission
xmlstarlet ed -r "//string[text() = '$1']/preceding-sibling::*[1]/key[text() = 'MulticastPreferenceSet' or text() = 'DenyMulticast']/following-sibling::*[1]" -v true com.apple.networkextension.new.xml
# Convert plist back to binary
plistutil -i com.apple.networkextension.new.xml -o com.apple.networkextension.new.plist -f bin
echo "Created new network configuration at ./com.apple.networkextension.new.plist"
echo "Now copy this file to your device"
# Stop nehelper service
#ssh -T -p 2222 root@localhost "launchctl unload /System/Library/LaunchDaemons/com.apple.nehelper-embedded.plist"
#sleep 1
# Copy over new plist file
#scp -P 2222 ./com.apple.networkextension.new.plist /Library/Preferences/com.apple.networkextension.plist
# Restart nehelper service
#ssh -T -p 2222 root@localhost "launchctl load /System/Library/LaunchDaemons/com.apple.nehelper-embedded.plist"
# Cleanup
#rm ./com.apple.networkextension.new.xml || true
#rm ./com.apple.networkextension.new.plist || true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment