Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/restrictions #1174

Merged
merged 3 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions pymobiledevice3/cli/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ def profile_install_wifi_profile(service_provider: LockdownServiceProvider, encr

This will enable the device to auto-connect to given network
"""
if keybag is not None:
keybag = Path(keybag)
MobileConfigService(lockdown=service_provider).install_wifi_profile(
encryption_type=encryption_type, ssid=ssid, password=password, keybag_file=keybag)

Expand All @@ -156,10 +158,24 @@ def profile_install_wifi_profile(service_provider: LockdownServiceProvider, encr
def profile_install_http_proxy(service_provider: LockdownServiceProvider, server: str, port: int,
keybag: Optional[str]) -> None:
""" Install HTTP Proxy profile """
if keybag is not None:
keybag = Path(keybag)
MobileConfigService(lockdown=service_provider).install_http_proxy(server, port, keybag_file=keybag)


@profile_group.command('remove-http-proxy', cls=Command)
def profile_remove_http_proxy(service_provider: LockdownServiceProvider) -> None:
""" Remove HTTP Proxy profile that was previously installed using pymobiledevice3 """
MobileConfigService(lockdown=service_provider).remove_http_proxy()


@profile_group.command('install-restrictions-profile', cls=Command)
@click.option('--keybag', type=click.Path(file_okay=True, dir_okay=False, exists=True))
@click.option('--enforced-software-update-delay', type=click.IntRange(0, 90), default=0)
def profile_install_restrictions_profile(
service_provider: LockdownServiceProvider, keybag: Optional[str], enforced_software_update_delay: int) -> None:
""" Install restrictions profile (can be used for delayed OTA) """
if keybag is not None:
keybag = Path(keybag)
MobileConfigService(lockdown=service_provider).install_restrictions_profile(
enforced_software_update_delay=enforced_software_update_delay, keybag_file=Path(keybag))
127 changes: 124 additions & 3 deletions pymobiledevice3/services/mobile_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ def supervise(self, organization: str, keybag_file: Path) -> None:
]
})

def install_managed_profile(self, display_name: str, payload_content: Mapping[str, Any],
payload_uuid: str = str(uuid4()),
keybag_file: Optional[Path] = None) -> None:
def install_managed_profile(
self, display_name: str, payload_content: Mapping[str, Any], payload_uuid: str = str(uuid4()),
keybag_file: Optional[Path] = None) -> None:
profile_data = plistlib.dumps({
'PayloadContent': [
payload_content
Expand All @@ -242,3 +242,124 @@ def install_managed_profile(self, display_name: str, payload_content: Mapping[st
self.install_profile_silent(keybag_file, profile_data)
else:
self.install_profile(profile_data)

def install_restrictions_profile(
self, enforced_software_update_delay: int = 0, payload_uuid: str = str(uuid4()),
keybag_file: Optional[Path] = None) -> None:
self.install_managed_profile('Restrictions', {
'PayloadDescription': 'Configures restrictions',
'PayloadDisplayName': 'Restrictions',
'PayloadIdentifier': f'com.apple.applicationaccess.{payload_uuid}',
'PayloadType': 'com.apple.applicationaccess',
'PayloadUUID': payload_uuid,
'PayloadVersion': 1,
'allowActivityContinuation': True,
'allowAddingGameCenterFriends': True,
'allowAirPlayIncomingRequests': True,
'allowAirPrint': True,
'allowAirPrintCredentialsStorage': True,
'allowAirPrintiBeaconDiscovery': True,
'allowAppCellularDataModification': True,
'allowAppClips': True,
'allowAppInstallation': True,
'allowAppRemoval': True,
'allowApplePersonalizedAdvertising': True,
'allowAssistant': True,
'allowAssistantWhileLocked': True,
'allowAutoCorrection': True,
'allowAutoUnlock': True,
'allowAutomaticAppDownloads': True,
'allowBluetoothModification': True,
'allowBookstore': True,
'allowBookstoreErotica': True,
'allowCamera': True,
'allowCellularPlanModification': True,
'allowChat': True,
'allowCloudBackup': True,
'allowCloudDocumentSync': True,
'allowCloudPhotoLibrary': True,
'allowContinuousPathKeyboard': True,
'allowDefinitionLookup': True,
'allowDeviceNameModification': True,
'allowDeviceSleep': True,
'allowDictation': True,
'allowESIMModification': True,
'allowEnablingRestrictions': True,
'allowEnterpriseAppTrust': True,
'allowEnterpriseBookBackup': True,
'allowEnterpriseBookMetadataSync': True,
'allowEraseContentAndSettings': True,
'allowExplicitContent': True,
'allowFilesNetworkDriveAccess': True,
'allowFilesUSBDriveAccess': True,
'allowFindMyDevice': True,
'allowFindMyFriends': True,
'allowFingerprintForUnlock': True,
'allowFingerprintModification': True,
'allowGameCenter': True,
'allowGlobalBackgroundFetchWhenRoaming': True,
'allowInAppPurchases': True,
'allowKeyboardShortcuts': True,
'allowManagedAppsCloudSync': True,
'allowMultiplayerGaming': True,
'allowMusicService': True,
'allowNews': True,
'allowNotificationsModification': True,
'allowOpenFromManagedToUnmanaged': True,
'allowOpenFromUnmanagedToManaged': True,
'allowPairedWatch': True,
'allowPassbookWhileLocked': True,
'allowPasscodeModification': True,
'allowPasswordAutoFill': True,
'allowPasswordProximityRequests': True,
'allowPasswordSharing': True,
'allowPersonalHotspotModification': True,
'allowPhotoStream': True,
'allowPredictiveKeyboard': True,
'allowProximitySetupToNewDevice': True,
'allowRadioService': True,
'allowRemoteAppPairing': True,
'allowRemoteScreenObservation': True,
'allowSafari': True,
'allowScreenShot': True,
'allowSharedStream': True,
'allowSpellCheck': True,
'allowSpotlightInternetResults': True,
'allowSystemAppRemoval': True,
'allowUIAppInstallation': True,
'allowUIConfigurationProfileInstallation': True,
'allowUSBRestrictedMode': True,
'allowUnpairedExternalBootToRecovery': False,
'allowUntrustedTLSPrompt': True,
'allowVPNCreation': True,
'allowVideoConferencing': True,
'allowVoiceDialing': True,
'allowWallpaperModification': True,
'allowiTunes': True,
'enforcedSoftwareUpdateDelay': enforced_software_update_delay,
'forceAirDropUnmanaged': False,
'forceAirPrintTrustedTLSRequirement': False,
'forceAssistantProfanityFilter': False,
'forceAuthenticationBeforeAutoFill': False,
'forceAutomaticDateAndTime': False,
'forceClassroomAutomaticallyJoinClasses': False,
'forceClassroomRequestPermissionToLeaveClasses': False,
'forceClassroomUnpromptedAppAndDeviceLock': False,
'forceClassroomUnpromptedScreenObservation': False,
'forceDelayedSoftwareUpdates': True,
'forceEncryptedBackup': False,
'forceITunesStorePasswordEntry': False,
'forceLimitAdTracking': False,
'forceWatchWristDetection': False,
'forceWiFiPowerOn': False,
'forceWiFiWhitelisting': False,
'ratingApps': 1000,
'ratingMovies': 1000,
'ratingRegion': 'us',
'ratingTVShows': 1000,
'safariAcceptCookies': 2.0,
'safariAllowAutoFill': True,
'safariAllowJavaScript': True,
'safariAllowPopups': True,
'safariForceFraudWarning': False
}, payload_uuid=payload_uuid, keybag_file=keybag_file)
Loading