Apps, files & profiles¶
App-container file access, configuration profiles, and provisioning profiles.
(InstallationProxyService and AfcService live under Lockdown services.)
pymobiledevice3.services.house_arrest.HouseArrestService ¶
Bases: AfcService
AFC access to an installed application's container.
house_arrest vends an application sandbox over the AFC protocol, allowing the
container's files to be browsed and transferred. The container is selected by
calling send_command (or via the create factory) with the target app's
bundle id; documents_only controls whether the whole container or only its
Documents subtree is exposed.
Being an AfcService, instances may be used as an async context manager::
async with await HouseArrestService.create(lockdown, bundle_id) as house_arrest:
...
Source code in pymobiledevice3/services/house_arrest.py
create
async
classmethod
¶
create(lockdown: LockdownServiceProvider, bundle_id: str, documents_only: bool = False) -> HouseArrestService
Create a service already vending the container of the given application.
Instantiates the service and immediately issues the vend command, leaving the AFC session rooted at the application's container. On failure the service is closed before the error propagates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lockdown
|
LockdownServiceProvider
|
service provider used to start the service and reach the device. |
required |
bundle_id
|
str
|
bundle identifier of the application whose container to vend. |
required |
documents_only
|
bool
|
when True, vend only the container's |
False
|
Returns:
| Type | Description |
|---|---|
HouseArrestService
|
a connected |
Raises:
| Type | Description |
|---|---|
AppNotInstalledError
|
if no application with |
PyMobileDevice3Exception
|
if the device reports any other vend error. |
Source code in pymobiledevice3/services/house_arrest.py
send_command
async
¶
Vend an application's container so subsequent AFC operations act on it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bundle_id
|
str
|
bundle identifier of the application to vend. |
required |
cmd
|
str
|
vend command, either |
'VendContainer'
|
Raises:
| Type | Description |
|---|---|
AppNotInstalledError
|
if no application with |
PyMobileDevice3Exception
|
if the device reports any other error. |
Source code in pymobiledevice3/services/house_arrest.py
shell ¶
Launch an interactive AFC shell over the vended container.
The shell starts in the container's Documents directory when the service was
created with documents_only, otherwise at the container root.
Source code in pymobiledevice3/services/house_arrest.py
pymobiledevice3.services.mobile_config.MobileConfigService ¶
Bases: LockdownService
Manage configuration profiles and cloud (supervision) configuration.
Wraps the com.apple.mobile.MCInstall lockdown service used by MDM/Apple
Configurator. It can list, install and remove configuration profiles, drive
supervision and cloud-configuration state, and erase the device. Some operations
require supervised/silent installation, which is unlocked by escalate using a
supervision identity (a PEM keybag holding both certificate and private key).
Being a LockdownService, instances may be used as an async context manager::
async with MobileConfigService(lockdown) as mc:
profiles = await mc.get_profile_list()
Source code in pymobiledevice3/services/mobile_config.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 | |
hello
async
¶
flush
async
¶
escalate
async
¶
Authenticate as a supervisor to unlock silent/supervised operations.
Runs the Escalate challenge-response handshake using the supervision identity,
then requests keybag migration. Must be called before silent profile installation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keybag_file
|
Path
|
path to a PEM file containing both the supervisor certificate and its (unencrypted) private key. |
required |
Source code in pymobiledevice3/services/mobile_config.py
get_stored_profile
async
¶
Retrieve a profile stored on the device for a given purpose.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
purpose
|
Purpose
|
purpose the profile was stored under. |
PostSetupInstallation
|
Returns:
| Type | Description |
|---|---|
dict
|
the device's response plist. |
Source code in pymobiledevice3/services/mobile_config.py
store_profile
async
¶
Store a profile on the device for later use under a given purpose.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profile_data
|
bytes
|
raw profile bytes to store. |
required |
purpose
|
Purpose
|
purpose to store the profile under. |
PostSetupInstallation
|
Source code in pymobiledevice3/services/mobile_config.py
get_cloud_configuration
async
¶
Retrieve the device's cloud (supervision) configuration.
Returns:
| Type | Description |
|---|---|
dict
|
the |
Source code in pymobiledevice3/services/mobile_config.py
set_cloud_configuration
async
¶
Set the device's cloud (supervision) configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cloud_configuration
|
dict
|
cloud configuration dictionary to apply. |
required |
Source code in pymobiledevice3/services/mobile_config.py
establish_provisional_enrollment
async
¶
Establish a provisional MDM enrollment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nonce
|
bytes
|
enrollment nonce. |
required |
Source code in pymobiledevice3/services/mobile_config.py
set_wifi_power_state
async
¶
Turn the device's Wi-Fi radio on or off.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
bool
|
True to power Wi-Fi on, False to power it off. |
required |
Source code in pymobiledevice3/services/mobile_config.py
erase_device
async
¶
Erase all content and settings from the device.
The connection is normally terminated by the device as it begins erasing; that termination is suppressed so the call returns cleanly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
preserve_data_plan
|
bool
|
whether to preserve the cellular data plan across the erase. |
required |
disallow_proximity_setup
|
bool
|
whether to disallow proximity setup after the erase. |
required |
Source code in pymobiledevice3/services/mobile_config.py
get_profile_list
async
¶
List the configuration profiles installed on the device.
Returns:
| Type | Description |
|---|---|
dict
|
the device's response plist (including |
Source code in pymobiledevice3/services/mobile_config.py
install_profile
async
¶
Install a configuration profile, prompting the user for confirmation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
bytes
|
raw configuration profile bytes to install. |
required |
Source code in pymobiledevice3/services/mobile_config.py
install_profile_silent
async
¶
Install a configuration profile silently, without user interaction.
Escalates to supervisor privileges with the supervision identity, then installs the profile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keybag_file
|
Path
|
path to a PEM file containing the supervisor certificate and its private key, used to escalate. |
required |
profile
|
bytes
|
raw configuration profile bytes to install. |
required |
Source code in pymobiledevice3/services/mobile_config.py
remove_profile
async
¶
Remove an installed configuration profile by its identifier.
Looks up the profile's metadata in the installed profile list and, if present, sends a signed-free removal request. Does nothing if no profiles are installed or the identifier is not currently installed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identifier
|
str
|
payload identifier of the profile to remove. |
required |
Source code in pymobiledevice3/services/mobile_config.py
install_wifi_profile
async
¶
install_wifi_profile(encryption_type: str, ssid: str, password: str, auto_join: bool = True, captive_bypass: bool = False, disable_association_mac_randomization: bool = False, hidden_network: bool = False, is_hotspot: bool = False, keybag_file: Optional[Path] = None) -> None
Build and install a com.apple.wifi.managed profile for a Wi-Fi network.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encryption_type
|
str
|
Wi-Fi encryption type (e.g. |
required |
ssid
|
str
|
network SSID. |
required |
password
|
str
|
network password. |
required |
auto_join
|
bool
|
whether the device should automatically join the network. |
True
|
captive_bypass
|
bool
|
whether to bypass the captive portal check. |
False
|
disable_association_mac_randomization
|
bool
|
whether to disable MAC-address randomization when associating. |
False
|
hidden_network
|
bool
|
whether the network is hidden (does not broadcast its SSID). |
False
|
is_hotspot
|
bool
|
whether the network is treated as a personal hotspot. |
False
|
keybag_file
|
Optional[Path]
|
when provided, install silently using this supervision identity; otherwise install with a user prompt. |
None
|
Source code in pymobiledevice3/services/mobile_config.py
install_http_proxy
async
¶
Build and install a global manual HTTP-proxy profile.
The profile uses the fixed GLOBAL_HTTP_PROXY_UUID so it can later be removed by
remove_http_proxy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
server
|
str
|
proxy server host. |
required |
server_port
|
int
|
proxy server port. |
required |
keybag_file
|
Optional[Path]
|
when provided, install silently using this supervision identity; otherwise install with a user prompt. |
None
|
Source code in pymobiledevice3/services/mobile_config.py
remove_http_proxy
async
¶
Remove the global HTTP-proxy profile previously installed by install_http_proxy.
supervise
async
¶
Place the device under supervision by writing a cloud configuration.
Sets a supervised cloud configuration that names the organization, registers the supervisor certificate, and skips all setup-assistant panes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
organization
|
str
|
organization name recorded in the cloud configuration. |
required |
keybag_file
|
Path
|
path to a PEM file containing the supervisor certificate whose DER public bytes are registered as a supervisor host certificate. |
required |
Source code in pymobiledevice3/services/mobile_config.py
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
install_managed_profile
async
¶
install_managed_profile(display_name: str, payload_content: dict[str, Any], payload_uuid: str = str(uuid4()), keybag_file: Optional[Path] = None) -> None
Wrap a single payload in a Configuration profile and install it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
profile display name. |
required |
payload_content
|
dict[str, Any]
|
the inner payload dictionary to wrap. |
required |
payload_uuid
|
str
|
UUID used as both the profile identifier and UUID. |
str(uuid4())
|
keybag_file
|
Optional[Path]
|
when provided, install silently using this supervision identity; otherwise install with a user prompt. |
None
|
Source code in pymobiledevice3/services/mobile_config.py
install_restrictions_profile
async
¶
install_restrictions_profile(enforced_software_update_delay: int = 0, payload_uuid: str = GLOBAL_RESTRICTIONS_UUID, keybag_file: Optional[Path] = None) -> None
Build and install a com.apple.applicationaccess restrictions profile.
The profile permits essentially every restricted capability; only the software update delay is parameterized.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enforced_software_update_delay
|
int
|
number of days to delay visibility of software updates. |
0
|
payload_uuid
|
str
|
UUID used as the profile identifier and UUID. |
GLOBAL_RESTRICTIONS_UUID
|
keybag_file
|
Optional[Path]
|
when provided, install silently using this supervision identity; otherwise install with a user prompt. |
None
|
Source code in pymobiledevice3/services/mobile_config.py
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 | |
pymobiledevice3.services.misagent.MisagentService ¶
Bases: LockdownService
Manage provisioning profiles installed on the device.
Wraps the com.apple.misagent lockdown service to install, remove and enumerate
provisioning profiles. Being a LockdownService, instances may be used as an async
context manager::
async with MisagentService(lockdown) as misagent:
profiles = await misagent.copy_all()
Source code in pymobiledevice3/services/misagent.py
install
async
¶
Install a provisioning profile on the device.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plist
|
BytesIO
|
stream whose contents are the raw provisioning profile to install; read in full and sent to the device. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
the device's response plist. |
Raises:
| Type | Description |
|---|---|
PyMobileDevice3Exception
|
if the device reports a non-zero status. |
Source code in pymobiledevice3/services/misagent.py
remove
async
¶
Remove an installed provisioning profile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profile_id
|
str
|
identifier of the profile to remove. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
the device's response plist. |
Raises:
| Type | Description |
|---|---|
PyMobileDevice3Exception
|
if the device reports a non-zero status. |
Source code in pymobiledevice3/services/misagent.py
copy_all
async
¶
Retrieve all provisioning profiles installed on the device.
Returns:
| Type | Description |
|---|---|
list[ProvisioningProfile]
|
list of |
Raises:
| Type | Description |
|---|---|
PyMobileDevice3Exception
|
if the device reports a non-zero status. |
Source code in pymobiledevice3/services/misagent.py
pymobiledevice3.services.file_relay.FileRelayService ¶
Bases: LockdownService
Retrieve diagnostic data archives from the device.
Wraps the legacy com.apple.mobile.file_relay service, which bundles one or more
named data sources (see SRCFILES for known source names) into a single gzip-compressed
CPIO archive returned by request_sources.
Being a LockdownService, instances may be used as an async context manager::
async with FileRelayService(lockdown) as file_relay:
archive = await file_relay.request_sources(["UserDatabases"])
Source code in pymobiledevice3/services/file_relay.py
stop_session
async
¶
request_sources
async
¶
Request one or more data sources and return the combined archive.
Sends the requested source names and, once the device acknowledges, reads the full response stream into memory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sources
|
list of source names to request (see |
None
|
Returns:
| Type | Description |
|---|---|
|
the gzip-compressed CPIO archive bytes on success, or None if the device did not acknowledge the request. |