pymobiledevice3 4.27.4__py3-none-any.whl → 5.1.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. misc/plist_sniffer.py +15 -15
  2. misc/remotexpc_sniffer.py +29 -28
  3. pymobiledevice3/__main__.py +123 -98
  4. pymobiledevice3/_version.py +2 -2
  5. pymobiledevice3/bonjour.py +351 -117
  6. pymobiledevice3/ca.py +32 -24
  7. pymobiledevice3/cli/activation.py +7 -7
  8. pymobiledevice3/cli/afc.py +19 -19
  9. pymobiledevice3/cli/amfi.py +4 -4
  10. pymobiledevice3/cli/apps.py +51 -39
  11. pymobiledevice3/cli/backup.py +58 -32
  12. pymobiledevice3/cli/bonjour.py +27 -20
  13. pymobiledevice3/cli/cli_common.py +112 -81
  14. pymobiledevice3/cli/companion_proxy.py +4 -4
  15. pymobiledevice3/cli/completions.py +10 -10
  16. pymobiledevice3/cli/crash.py +37 -31
  17. pymobiledevice3/cli/developer.py +601 -519
  18. pymobiledevice3/cli/diagnostics.py +38 -33
  19. pymobiledevice3/cli/lockdown.py +82 -72
  20. pymobiledevice3/cli/mounter.py +84 -67
  21. pymobiledevice3/cli/notification.py +10 -10
  22. pymobiledevice3/cli/pcap.py +19 -14
  23. pymobiledevice3/cli/power_assertion.py +12 -10
  24. pymobiledevice3/cli/processes.py +10 -10
  25. pymobiledevice3/cli/profile.py +88 -77
  26. pymobiledevice3/cli/provision.py +17 -17
  27. pymobiledevice3/cli/remote.py +188 -111
  28. pymobiledevice3/cli/restore.py +43 -40
  29. pymobiledevice3/cli/springboard.py +30 -28
  30. pymobiledevice3/cli/syslog.py +85 -58
  31. pymobiledevice3/cli/usbmux.py +21 -20
  32. pymobiledevice3/cli/version.py +3 -2
  33. pymobiledevice3/cli/webinspector.py +156 -78
  34. pymobiledevice3/common.py +1 -1
  35. pymobiledevice3/exceptions.py +154 -60
  36. pymobiledevice3/irecv.py +49 -53
  37. pymobiledevice3/irecv_devices.py +1489 -492
  38. pymobiledevice3/lockdown.py +400 -251
  39. pymobiledevice3/lockdown_service_provider.py +5 -7
  40. pymobiledevice3/osu/os_utils.py +18 -9
  41. pymobiledevice3/osu/posix_util.py +28 -15
  42. pymobiledevice3/osu/win_util.py +14 -8
  43. pymobiledevice3/pair_records.py +19 -19
  44. pymobiledevice3/remote/common.py +4 -4
  45. pymobiledevice3/remote/core_device/app_service.py +94 -67
  46. pymobiledevice3/remote/core_device/core_device_service.py +17 -14
  47. pymobiledevice3/remote/core_device/device_info.py +5 -5
  48. pymobiledevice3/remote/core_device/diagnostics_service.py +10 -8
  49. pymobiledevice3/remote/core_device/file_service.py +47 -33
  50. pymobiledevice3/remote/remote_service_discovery.py +53 -35
  51. pymobiledevice3/remote/remotexpc.py +64 -42
  52. pymobiledevice3/remote/tunnel_service.py +383 -297
  53. pymobiledevice3/remote/utils.py +14 -13
  54. pymobiledevice3/remote/xpc_message.py +145 -125
  55. pymobiledevice3/resources/dsc_uuid_map.py +19 -19
  56. pymobiledevice3/resources/firmware_notifications.py +16 -16
  57. pymobiledevice3/restore/asr.py +27 -27
  58. pymobiledevice3/restore/base_restore.py +90 -47
  59. pymobiledevice3/restore/consts.py +87 -66
  60. pymobiledevice3/restore/device.py +11 -11
  61. pymobiledevice3/restore/fdr.py +46 -46
  62. pymobiledevice3/restore/ftab.py +19 -19
  63. pymobiledevice3/restore/img4.py +130 -133
  64. pymobiledevice3/restore/mbn.py +587 -0
  65. pymobiledevice3/restore/recovery.py +125 -135
  66. pymobiledevice3/restore/restore.py +535 -523
  67. pymobiledevice3/restore/restore_options.py +122 -115
  68. pymobiledevice3/restore/restored_client.py +25 -22
  69. pymobiledevice3/restore/tss.py +378 -270
  70. pymobiledevice3/service_connection.py +50 -46
  71. pymobiledevice3/services/accessibilityaudit.py +137 -127
  72. pymobiledevice3/services/afc.py +352 -292
  73. pymobiledevice3/services/amfi.py +21 -18
  74. pymobiledevice3/services/companion.py +23 -19
  75. pymobiledevice3/services/crash_reports.py +61 -47
  76. pymobiledevice3/services/debugserver_applist.py +3 -3
  77. pymobiledevice3/services/device_arbitration.py +8 -8
  78. pymobiledevice3/services/device_link.py +56 -48
  79. pymobiledevice3/services/diagnostics.py +971 -968
  80. pymobiledevice3/services/dtfetchsymbols.py +8 -8
  81. pymobiledevice3/services/dvt/dvt_secure_socket_proxy.py +4 -4
  82. pymobiledevice3/services/dvt/dvt_testmanaged_proxy.py +4 -4
  83. pymobiledevice3/services/dvt/instruments/activity_trace_tap.py +85 -74
  84. pymobiledevice3/services/dvt/instruments/application_listing.py +2 -3
  85. pymobiledevice3/services/dvt/instruments/condition_inducer.py +7 -6
  86. pymobiledevice3/services/dvt/instruments/core_profile_session_tap.py +466 -384
  87. pymobiledevice3/services/dvt/instruments/device_info.py +11 -11
  88. pymobiledevice3/services/dvt/instruments/energy_monitor.py +1 -1
  89. pymobiledevice3/services/dvt/instruments/graphics.py +1 -1
  90. pymobiledevice3/services/dvt/instruments/location_simulation.py +1 -1
  91. pymobiledevice3/services/dvt/instruments/location_simulation_base.py +10 -10
  92. pymobiledevice3/services/dvt/instruments/network_monitor.py +17 -17
  93. pymobiledevice3/services/dvt/instruments/notifications.py +1 -1
  94. pymobiledevice3/services/dvt/instruments/process_control.py +25 -10
  95. pymobiledevice3/services/dvt/instruments/screenshot.py +2 -2
  96. pymobiledevice3/services/dvt/instruments/sysmontap.py +15 -15
  97. pymobiledevice3/services/dvt/testmanaged/xcuitest.py +42 -52
  98. pymobiledevice3/services/file_relay.py +10 -10
  99. pymobiledevice3/services/heartbeat.py +8 -7
  100. pymobiledevice3/services/house_arrest.py +12 -15
  101. pymobiledevice3/services/installation_proxy.py +119 -100
  102. pymobiledevice3/services/lockdown_service.py +12 -5
  103. pymobiledevice3/services/misagent.py +22 -19
  104. pymobiledevice3/services/mobile_activation.py +84 -72
  105. pymobiledevice3/services/mobile_config.py +331 -301
  106. pymobiledevice3/services/mobile_image_mounter.py +137 -116
  107. pymobiledevice3/services/mobilebackup2.py +188 -150
  108. pymobiledevice3/services/notification_proxy.py +11 -11
  109. pymobiledevice3/services/os_trace.py +128 -74
  110. pymobiledevice3/services/pcapd.py +306 -306
  111. pymobiledevice3/services/power_assertion.py +10 -9
  112. pymobiledevice3/services/preboard.py +4 -4
  113. pymobiledevice3/services/remote_fetch_symbols.py +16 -14
  114. pymobiledevice3/services/remote_server.py +176 -146
  115. pymobiledevice3/services/restore_service.py +16 -16
  116. pymobiledevice3/services/screenshot.py +13 -10
  117. pymobiledevice3/services/simulate_location.py +7 -7
  118. pymobiledevice3/services/springboard.py +15 -15
  119. pymobiledevice3/services/syslog.py +5 -5
  120. pymobiledevice3/services/web_protocol/alert.py +3 -3
  121. pymobiledevice3/services/web_protocol/automation_session.py +183 -179
  122. pymobiledevice3/services/web_protocol/cdp_screencast.py +44 -36
  123. pymobiledevice3/services/web_protocol/cdp_server.py +19 -19
  124. pymobiledevice3/services/web_protocol/cdp_target.py +411 -373
  125. pymobiledevice3/services/web_protocol/driver.py +47 -45
  126. pymobiledevice3/services/web_protocol/element.py +74 -63
  127. pymobiledevice3/services/web_protocol/inspector_session.py +106 -102
  128. pymobiledevice3/services/web_protocol/selenium_api.py +3 -3
  129. pymobiledevice3/services/web_protocol/session_protocol.py +15 -10
  130. pymobiledevice3/services/web_protocol/switch_to.py +11 -12
  131. pymobiledevice3/services/webinspector.py +142 -116
  132. pymobiledevice3/tcp_forwarder.py +35 -22
  133. pymobiledevice3/tunneld/api.py +20 -15
  134. pymobiledevice3/tunneld/server.py +310 -193
  135. pymobiledevice3/usbmux.py +197 -148
  136. pymobiledevice3/utils.py +14 -11
  137. {pymobiledevice3-4.27.4.dist-info → pymobiledevice3-5.1.2.dist-info}/METADATA +1 -2
  138. pymobiledevice3-5.1.2.dist-info/RECORD +173 -0
  139. pymobiledevice3-4.27.4.dist-info/RECORD +0 -172
  140. {pymobiledevice3-4.27.4.dist-info → pymobiledevice3-5.1.2.dist-info}/WHEEL +0 -0
  141. {pymobiledevice3-4.27.4.dist-info → pymobiledevice3-5.1.2.dist-info}/entry_points.txt +0 -0
  142. {pymobiledevice3-4.27.4.dist-info → pymobiledevice3-5.1.2.dist-info}/licenses/LICENSE +0 -0
  143. {pymobiledevice3-4.27.4.dist-info → pymobiledevice3-5.1.2.dist-info}/top_level.txt +0 -0
@@ -10,14 +10,14 @@ from pymobiledevice3 import usbmux
10
10
  from pymobiledevice3.exceptions import ConnectionFailedError, NoDeviceConnectedError, PyMobileDevice3Exception
11
11
  from pymobiledevice3.service_connection import ServiceConnection
12
12
 
13
- CTRL_PORT = 0x43a # 1082
14
- CTRLCMD = b'BeginCtrl\0'
15
- HELLOCTRLCMD = b'HelloCtrl\0'
16
- HELLOCMD = b'HelloConn\0'
13
+ CTRL_PORT = 0x43A # 1082
14
+ CTRLCMD = b"BeginCtrl\0"
15
+ HELLOCTRLCMD = b"HelloCtrl\0"
16
+ HELLOCMD = b"HelloConn\0"
17
17
 
18
18
  FDR_SYNC_MSG = 0x1
19
19
  FDR_PROXY_MSG = 0x105
20
- FDR_PLIST_MSG = 0xbbaa
20
+ FDR_PLIST_MSG = 0xBBAA
21
21
  CHUNK_SIZE = 1048576
22
22
 
23
23
  conn_port = None
@@ -43,77 +43,77 @@ class FDRClient:
43
43
  else:
44
44
  raise NoDeviceConnectedError()
45
45
 
46
- logger.debug('connecting to FDR')
46
+ logger.debug("connecting to FDR")
47
47
 
48
48
  if type_ == fdr_type.FDR_CTRL:
49
49
  self.service = ServiceConnection.create_using_usbmux(
50
- device.serial, self.SERVICE_PORT, connection_type='USB'
50
+ device.serial, self.SERVICE_PORT, connection_type="USB"
51
51
  )
52
52
  self.ctrl_handshake()
53
53
  else:
54
- self.service = ServiceConnection.create_using_usbmux(device.serial, conn_port, connection_type='USB')
54
+ self.service = ServiceConnection.create_using_usbmux(device.serial, conn_port, connection_type="USB")
55
55
  self.sync_handshake()
56
56
 
57
- logger.debug('FDR connected')
57
+ logger.debug("FDR connected")
58
58
 
59
59
  def recv_plist(self):
60
- return self.service.recv_plist(endianity='<')
60
+ return self.service.recv_plist(endianity="<")
61
61
 
62
62
  def send_recv_plist(self, plist):
63
- return self.service.send_recv_plist(plist, endianity='<', fmt=plistlib.FMT_BINARY)
63
+ return self.service.send_recv_plist(plist, endianity="<", fmt=plistlib.FMT_BINARY)
64
64
 
65
65
  def ctrl_handshake(self):
66
66
  global conn_port
67
67
 
68
- logger.debug('About to do ctrl handshake')
68
+ logger.debug("About to do ctrl handshake")
69
69
 
70
70
  self.service.sendall(CTRLCMD)
71
71
 
72
72
  if self.ctrlprotoversion != 2:
73
- raise NotImplementedError('TODO')
73
+ raise NotImplementedError("TODO")
74
74
 
75
75
  req = {
76
- 'Command': CTRLCMD,
77
- 'CtrlProtoVersion': self.ctrlprotoversion,
76
+ "Command": CTRLCMD,
77
+ "CtrlProtoVersion": self.ctrlprotoversion,
78
78
  }
79
79
  resp = self.send_recv_plist(req)
80
- conn_port = resp['ConnPort']
80
+ conn_port = resp["ConnPort"]
81
81
 
82
- logger.debug(f'Ctrl handshake done (ConnPort = {conn_port})')
82
+ logger.debug(f"Ctrl handshake done (ConnPort = {conn_port})")
83
83
 
84
84
  def sync_handshake(self):
85
85
  self.service.sendall(HELLOCMD)
86
86
 
87
87
  if self.ctrlprotoversion != 2:
88
- raise NotImplementedError('TODO')
88
+ raise NotImplementedError("TODO")
89
89
 
90
90
  reply = self.recv_plist()
91
- cmd = reply['Command']
92
- identifier = reply['Identifier']
91
+ cmd = reply["Command"]
92
+ identifier = reply["Identifier"]
93
93
 
94
- if cmd != 'HelloConn':
95
- raise PyMobileDevice3Exception('Did not receive HelloConn reply...')
94
+ if cmd != "HelloConn":
95
+ raise PyMobileDevice3Exception("Did not receive HelloConn reply...")
96
96
 
97
97
  if identifier:
98
- logger.debug(f'got device identifier: {identifier}')
98
+ logger.debug(f"got device identifier: {identifier}")
99
99
 
100
100
  def handle_sync_cmd(self):
101
101
  self.service.recvall(2)
102
102
 
103
103
  # Open a new connection and wait for messages on it
104
- logger.debug('FDR connected in reply to sync message, starting command thread')
104
+ logger.debug("FDR connected in reply to sync message, starting command thread")
105
105
  start_fdr_thread(fdr_type.FDR_CONN)
106
106
 
107
107
  def handle_proxy_cmd(self):
108
108
  buf = self.service.recv(1048576)
109
- logger.debug(f'got proxy command with {len(buf)} bytes')
109
+ logger.debug(f"got proxy command with {len(buf)} bytes")
110
110
 
111
111
  # Just return success here unconditionally because we don't know
112
112
  # anything else, and we will eventually abort on failure anyway
113
- self.service.sendall(struct.pack('<H', 5))
113
+ self.service.sendall(struct.pack("<H", 5))
114
114
 
115
115
  if len(buf) < 3:
116
- logger.debug(f'FDR {self} proxy command data too short, retrying')
116
+ logger.debug(f"FDR {self} proxy command data too short, retrying")
117
117
  return self.poll_and_handle_message()
118
118
 
119
119
  # ack command data too
@@ -125,11 +125,11 @@ class FDRClient:
125
125
  # Now try to handle actual messages
126
126
  # Connect: 0 3 hostlen <host> <port>
127
127
  if buf[0] == 0 and buf[1] == 3:
128
- port = struct.unpack('>H', buf[-2:])[0]
128
+ port = struct.unpack(">H", buf[-2:])[0]
129
129
  hostlen = buf[2]
130
- host = buf[3:3 + hostlen]
130
+ host = buf[3 : 3 + hostlen]
131
131
 
132
- logger.debug(f'FDR {self} Proxy connect request to {host}:{port}')
132
+ logger.debug(f"FDR {self} Proxy connect request to {host}:{port}")
133
133
 
134
134
  if host is None:
135
135
  # missing or zero length host name
@@ -139,28 +139,28 @@ class FDRClient:
139
139
  sockfd.connect((host, port))
140
140
 
141
141
  while True:
142
- readable, writable, exceptional = select.select([sockfd, self.service.socket],
143
- [],
144
- [sockfd, self.service.socket])
142
+ readable, _writable, exceptional = select.select(
143
+ [sockfd, self.service.socket], [], [sockfd, self.service.socket]
144
+ )
145
145
 
146
146
  for current_sock in readable:
147
147
  if current_sock == self.service.socket:
148
148
  buf = self.service.recv(CHUNK_SIZE)
149
149
 
150
- logger.debug(f'FDR {self} got payload of {len(buf)} bytes, now try to proxy it')
151
- logger.debug(f'Sending {len(buf)} bytes of data')
150
+ logger.debug(f"FDR {self} got payload of {len(buf)} bytes, now try to proxy it")
151
+ logger.debug(f"Sending {len(buf)} bytes of data")
152
152
 
153
153
  sockfd.sendall(buf)
154
154
  else:
155
155
  buf = sockfd.recv(CHUNK_SIZE)
156
- logger.debug(f'Received {len(buf)} bytes')
156
+ logger.debug(f"Received {len(buf)} bytes")
157
157
  self.service.sendall(buf)
158
158
 
159
159
  if exceptional:
160
160
  if exceptional[0] == sockfd:
161
- logger.debug('Remote closed the connection')
161
+ logger.debug("Remote closed the connection")
162
162
  else:
163
- logger.debug('Local service closed the connection')
163
+ logger.debug("Local service closed the connection")
164
164
  break
165
165
 
166
166
  sockfd.close()
@@ -168,16 +168,16 @@ class FDRClient:
168
168
 
169
169
  def handle_plist_cmd(self):
170
170
  d = self.recv_plist()
171
- command = d['Command']
171
+ command = d["Command"]
172
172
 
173
- if command == 'Ping':
174
- self.send_recv_plist({'Pong': True})
173
+ if command == "Ping":
174
+ self.send_recv_plist({"Pong": True})
175
175
  else:
176
- logger.warning(f'FDR {self} received unknown plist command: {command}')
176
+ logger.warning(f"FDR {self} received unknown plist command: {command}")
177
177
 
178
178
  def poll_and_handle_message(self):
179
179
  # TODO: is it okay?
180
- cmd = struct.unpack('<H', self.service.recvall(2))[0]
180
+ cmd = struct.unpack("<H", self.service.recvall(2))[0]
181
181
 
182
182
  handlers = {
183
183
  FDR_SYNC_MSG: self.handle_sync_cmd,
@@ -188,7 +188,7 @@ class FDRClient:
188
188
  if cmd in handlers:
189
189
  handlers[cmd]()
190
190
  else:
191
- logger.warning(f'ignoring FDR message: {cmd}')
191
+ logger.warning(f"ignoring FDR message: {cmd}")
192
192
 
193
193
 
194
194
  def fdr_listener_thread(type_: fdr_type):
@@ -196,14 +196,14 @@ def fdr_listener_thread(type_: fdr_type):
196
196
  try:
197
197
  client = FDRClient(type_)
198
198
 
199
- logger.debug(f'FDR {client} waiting for message...')
199
+ logger.debug(f"FDR {client} waiting for message...")
200
200
 
201
201
  while True:
202
202
  client.poll_and_handle_message()
203
203
  except ConnectionAbortedError:
204
204
  pass
205
205
 
206
- logger.debug(f'FDR {client} terminating...')
206
+ logger.debug(f"FDR {client} terminating...")
207
207
 
208
208
 
209
209
  def start_fdr_thread(type_: fdr_type):
@@ -1,27 +1,27 @@
1
1
  from construct import Array, Bytes, Const, Default, Int32ub, Int32ul, Pointer, Struct, this
2
2
 
3
3
  ftab_entry = Struct(
4
- 'tag' / Bytes(4),
5
- 'offset' / Int32ul,
6
- 'size' / Int32ul,
7
- 'pad_0x0C' / Default(Int32ul, 0),
8
- 'data' / Pointer(this.offset, Bytes(this.size))
4
+ "tag" / Bytes(4),
5
+ "offset" / Int32ul,
6
+ "size" / Int32ul,
7
+ "pad_0x0C" / Default(Int32ul, 0),
8
+ "data" / Pointer(this.offset, Bytes(this.size)),
9
9
  )
10
10
 
11
11
  ftab_header = Struct(
12
- 'always_01' / Int32ul, # 1
13
- 'always_ff' / Int32ul, # 0xFFFFFFFF
14
- 'unk_0x08' / Int32ub, # 0
15
- 'unk_0x0C' / Int32ub, # 0
16
- 'unk_0x10' / Int32ub, # 0
17
- 'unk_0x14' / Int32ub, # 0
18
- 'unk_0x18' / Int32ub, # 0
19
- 'unk_0x1C' / Int32ub, # 0
20
- 'tag' / Bytes(4), # e.g. 'rkos'
21
- 'magic' / Const(b'ftab'), # 'ftab' magic
22
- 'num_entries' / Int32ul,
23
- 'pad_0x2C' / Int32ub,
24
- 'entries' / Array(this.num_entries, ftab_entry)
12
+ "always_01" / Int32ul, # 1
13
+ "always_ff" / Int32ul, # 0xFFFFFFFF
14
+ "unk_0x08" / Int32ub, # 0
15
+ "unk_0x0C" / Int32ub, # 0
16
+ "unk_0x10" / Int32ub, # 0
17
+ "unk_0x14" / Int32ub, # 0
18
+ "unk_0x18" / Int32ub, # 0
19
+ "unk_0x1C" / Int32ub, # 0
20
+ "tag" / Bytes(4), # e.g. 'rkos'
21
+ "magic" / Const(b"ftab"), # 'ftab' magic
22
+ "num_entries" / Int32ul,
23
+ "pad_0x2C" / Int32ub,
24
+ "entries" / Array(this.num_entries, ftab_entry),
25
25
  )
26
26
 
27
27
 
@@ -41,7 +41,7 @@ class Ftab:
41
41
 
42
42
  def add_entry(self, tag: bytes, data: bytes):
43
43
  new_offset = self.parsed.entries[-1].offset + self.parsed.entries[-1].size
44
- new_entry = {'tag': tag, 'offset': new_offset, 'size': len(data), 'data': data}
44
+ new_entry = {"tag": tag, "offset": new_offset, "size": len(data), "data": data}
45
45
 
46
46
  self.parsed.num_entries += 1
47
47
  self.parsed.entries.append(new_entry)
@@ -6,125 +6,126 @@ from pyimg4 import IM4P, IM4R, IMG4, RestoreProperty
6
6
  logger = logging.getLogger(__name__)
7
7
 
8
8
  COMPONENT_FOURCC = {
9
- 'ACIBT': 'acib',
10
- 'ACIBTLPEM': 'lpbt',
11
- 'ACIWIFI': 'aciw',
12
- 'ANE': 'anef',
13
- 'ANS': 'ansf',
14
- 'AOP': 'aopf',
15
- 'AVE': 'avef',
16
- 'Alamo': 'almo',
17
- 'Ap,ANE1': 'ane1',
18
- 'Ap,ANE2': 'ane2',
19
- 'Ap,ANE3': 'ane3',
20
- 'Ap,AudioAccessibilityBootChime': 'auac',
21
- 'Ap,AudioBootChime': 'aubt',
22
- 'Ap,AudioPowerAttachChime': 'aupr',
23
- 'Ap,BootabilityBrainTrustCache': 'trbb',
24
- 'Ap,CIO': 'ciof',
25
- 'Ap,HapticAssets': 'hpas',
26
- 'Ap,LocalBoot': 'lobo',
27
- 'Ap,LocalPolicy': 'lpol',
28
- 'Ap,NextStageIM4MHash': 'nsih',
29
- 'Ap,RecoveryOSPolicyNonceHash': 'ronh',
30
- 'Ap,RestoreANE1': 'ran1',
31
- 'Ap,RestoreANE2': 'ran2',
32
- 'Ap,RestoreANE3': 'ran3',
33
- 'Ap,RestoreCIO': 'rcio',
34
- 'Ap,RestoreDCP2': 'rdc2',
35
- 'Ap,RestoreTMU': 'rtmu',
36
- 'Ap,Scorpius': 'scpf',
37
- 'Ap,SystemVolumeCanonicalMetadata': 'msys',
38
- 'Ap,TMU': 'tmuf',
39
- 'Ap,VolumeUUID': 'vuid',
40
- 'Ap,rOSLogo1': 'rlg1',
41
- 'Ap,rOSLogo2': 'rlg2',
42
- 'AppleLogo': 'logo',
43
- 'AudioCodecFirmware': 'acfw',
44
- 'BatteryCharging': 'glyC',
45
- 'BatteryCharging0': 'chg0',
46
- 'BatteryCharging1': 'chg1',
47
- 'BatteryFull': 'batF',
48
- 'BatteryLow0': 'bat0',
49
- 'BatteryLow1': 'bat1',
50
- 'BatteryPlugin': 'glyP',
51
- 'CFELoader': 'cfel',
52
- 'CrownFirmware': 'crwn',
53
- 'DCP': 'dcpf',
54
- 'Dali': 'dali',
55
- 'DeviceTree': 'dtre',
56
- 'Diags': 'diag',
57
- 'EngineeringTrustCache': 'dtrs',
58
- 'ExtDCP': 'edcp',
59
- 'GFX': 'gfxf',
60
- 'Hamm': 'hamf',
61
- 'Homer': 'homr',
62
- 'ISP': 'ispf',
63
- 'InputDevice': 'ipdf',
64
- 'KernelCache': 'krnl',
65
- 'LLB': 'illb',
66
- 'LeapHaptics': 'lphp',
67
- 'Liquid': 'liqd',
68
- 'LoadableTrustCache': 'ltrs',
69
- 'LowPowerWallet0': 'lpw0',
70
- 'LowPowerWallet1': 'lpw1',
71
- 'LowPowerWallet2': 'lpw2',
72
- 'MacEFI': 'mefi',
73
- 'MtpFirmware': 'mtpf',
74
- 'Multitouch': 'mtfw',
75
- 'NeedService': 'nsrv',
76
- 'OS': 'OS\0\0',
77
- 'OSRamdisk': 'osrd',
78
- 'PEHammer': 'hmmr',
79
- 'PERTOS': 'pert',
80
- 'PHLEET': 'phlt',
81
- 'PMP': 'pmpf',
82
- 'PersonalizedDMG': 'pdmg',
83
- 'RBM': 'rmbt',
84
- 'RTP': 'rtpf',
85
- 'Rap,SoftwareBinaryDsp1': 'sbd1',
86
- 'Rap,RTKitOS': 'rkos',
87
- 'Rap,RestoreRTKitOS': 'rrko',
88
- 'RecoveryMode': 'recm',
89
- 'RestoreANS': 'rans',
90
- 'RestoreDCP': 'rdcp',
91
- 'RestoreDeviceTree': 'rdtr',
92
- 'RestoreExtDCP': 'recp',
93
- 'RestoreKernelCache': 'rkrn',
94
- 'RestoreLogo': 'rlgo',
95
- 'RestoreRTP': 'rrtp',
96
- 'RestoreRamDisk': 'rdsk',
97
- 'RestoreSEP': 'rsep',
98
- 'RestoreTrustCache': 'rtsc',
99
- 'SCE': 'scef',
100
- 'SCE1Firmware': 'sc1f',
101
- 'SEP': 'sepi',
102
- 'SIO': 'siof',
103
- 'StaticTrustCache': 'trst',
104
- 'SystemLocker': 'lckr',
105
- 'SystemVolume': 'isys',
106
- 'WCHFirmwareUpdater': 'wchf',
107
- 'ftap': 'ftap',
108
- 'ftsp': 'ftsp',
109
- 'iBEC': 'ibec',
110
- 'iBSS': 'ibss',
111
- 'iBoot': 'ibot',
112
- 'iBootData': 'ibdt',
113
- 'iBootDataStage1': 'ibd1',
114
- 'iBootTest': 'itst',
115
- 'rfta': 'rfta',
116
- 'rfts': 'rfts',
117
- 'Ap,DCP2': 'dcp2',
118
- 'Ap,RestoreSecureM3Firmware': 'rsm3',
119
- 'Ap,RestoreSecurePageTableMonitor': 'rspt',
120
- 'Ap,RestoreTrustedExecutionMonitor': 'rtrx',
121
- 'Ap,RestorecL4': 'rxcl',
9
+ "ACIBT": "acib",
10
+ "ACIBTLPEM": "lpbt",
11
+ "ACIWIFI": "aciw",
12
+ "ANE": "anef",
13
+ "ANS": "ansf",
14
+ "AOP": "aopf",
15
+ "AVE": "avef",
16
+ "Alamo": "almo",
17
+ "Ap,ANE1": "ane1",
18
+ "Ap,ANE2": "ane2",
19
+ "Ap,ANE3": "ane3",
20
+ "Ap,AudioAccessibilityBootChime": "auac",
21
+ "Ap,AudioBootChime": "aubt",
22
+ "Ap,AudioPowerAttachChime": "aupr",
23
+ "Ap,BootabilityBrainTrustCache": "trbb",
24
+ "Ap,CIO": "ciof",
25
+ "Ap,HapticAssets": "hpas",
26
+ "Ap,LocalBoot": "lobo",
27
+ "Ap,LocalPolicy": "lpol",
28
+ "Ap,NextStageIM4MHash": "nsih",
29
+ "Ap,RecoveryOSPolicyNonceHash": "ronh",
30
+ "Ap,RestoreANE1": "ran1",
31
+ "Ap,RestoreANE2": "ran2",
32
+ "Ap,RestoreANE3": "ran3",
33
+ "Ap,RestoreCIO": "rcio",
34
+ "Ap,RestoreDCP2": "rdc2",
35
+ "Ap,RestoreTMU": "rtmu",
36
+ "Ap,Scorpius": "scpf",
37
+ "Ap,SystemVolumeCanonicalMetadata": "msys",
38
+ "Ap,TMU": "tmuf",
39
+ "Ap,VolumeUUID": "vuid",
40
+ "Ap,rOSLogo1": "rlg1",
41
+ "Ap,rOSLogo2": "rlg2",
42
+ "AppleLogo": "logo",
43
+ "AudioCodecFirmware": "acfw",
44
+ "BatteryCharging": "glyC",
45
+ "BatteryCharging0": "chg0",
46
+ "BatteryCharging1": "chg1",
47
+ "BatteryFull": "batF",
48
+ "BatteryLow0": "bat0",
49
+ "BatteryLow1": "bat1",
50
+ "BatteryPlugin": "glyP",
51
+ "CFELoader": "cfel",
52
+ "CrownFirmware": "crwn",
53
+ "DCP": "dcpf",
54
+ "Dali": "dali",
55
+ "DeviceTree": "dtre",
56
+ "Diags": "diag",
57
+ "EngineeringTrustCache": "dtrs",
58
+ "ExtDCP": "edcp",
59
+ "GFX": "gfxf",
60
+ "Hamm": "hamf",
61
+ "Homer": "homr",
62
+ "ISP": "ispf",
63
+ "InputDevice": "ipdf",
64
+ "KernelCache": "krnl",
65
+ "LLB": "illb",
66
+ "LeapHaptics": "lphp",
67
+ "Liquid": "liqd",
68
+ "LoadableTrustCache": "ltrs",
69
+ "LowPowerWallet0": "lpw0",
70
+ "LowPowerWallet1": "lpw1",
71
+ "LowPowerWallet2": "lpw2",
72
+ "MacEFI": "mefi",
73
+ "MtpFirmware": "mtpf",
74
+ "Multitouch": "mtfw",
75
+ "NeedService": "nsrv",
76
+ "OS": "OS\0\0",
77
+ "OSRamdisk": "osrd",
78
+ "PEHammer": "hmmr",
79
+ "PERTOS": "pert",
80
+ "PHLEET": "phlt",
81
+ "PMP": "pmpf",
82
+ "PersonalizedDMG": "pdmg",
83
+ "RBM": "rmbt",
84
+ "RTP": "rtpf",
85
+ "Rap,SoftwareBinaryDsp1": "sbd1",
86
+ "Rap,RTKitOS": "rkos",
87
+ "Rap,RestoreRTKitOS": "rrko",
88
+ "RecoveryMode": "recm",
89
+ "RestoreANS": "rans",
90
+ "RestoreDCP": "rdcp",
91
+ "RestoreDeviceTree": "rdtr",
92
+ "RestoreExtDCP": "recp",
93
+ "RestoreKernelCache": "rkrn",
94
+ "RestoreLogo": "rlgo",
95
+ "RestoreRTP": "rrtp",
96
+ "RestoreRamDisk": "rdsk",
97
+ "RestoreSEP": "rsep",
98
+ "RestoreTrustCache": "rtsc",
99
+ "SCE": "scef",
100
+ "SCE1Firmware": "sc1f",
101
+ "SEP": "sepi",
102
+ "SIO": "siof",
103
+ "StaticTrustCache": "trst",
104
+ "SystemLocker": "lckr",
105
+ "SystemVolume": "isys",
106
+ "WCHFirmwareUpdater": "wchf",
107
+ "ftap": "ftap",
108
+ "ftsp": "ftsp",
109
+ "iBEC": "ibec",
110
+ "iBSS": "ibss",
111
+ "iBoot": "ibot",
112
+ "iBootData": "ibdt",
113
+ "iBootDataStage1": "ibd1",
114
+ "iBootTest": "itst",
115
+ "rfta": "rfta",
116
+ "rfts": "rfts",
117
+ "Ap,DCP2": "dcp2",
118
+ "Ap,RestoreSecureM3Firmware": "rsm3",
119
+ "Ap,RestoreSecurePageTableMonitor": "rspt",
120
+ "Ap,RestoreTrustedExecutionMonitor": "rtrx",
121
+ "Ap,RestorecL4": "rxcl",
122
122
  }
123
123
 
124
124
 
125
- def stitch_component(name: str, im4p_data: bytes, tss: dict, build_identity: BuildIdentity,
126
- ap_parameters: dict) -> bytes:
127
- logger.info(f'Personalizing IMG4 component {name}...')
125
+ def stitch_component(
126
+ name: str, im4p_data: bytes, tss: dict, build_identity: BuildIdentity, ap_parameters: dict
127
+ ) -> bytes:
128
+ logger.info(f"Personalizing IMG4 component {name}...")
128
129
 
129
130
  im4p = IM4P(data=im4p_data)
130
131
 
@@ -134,33 +135,29 @@ def stitch_component(name: str, im4p_data: bytes, tss: dict, build_identity: Bui
134
135
  im4p.fourcc = fourcc
135
136
 
136
137
  # check if we have a *-TBM entry for the given component
137
- tbm_dict = tss.get(f'{name}-TBM')
138
+ tbm_dict = tss.get(f"{name}-TBM")
138
139
 
139
- info = build_identity['Info']
140
- nonce_slot_required = info.get('RequiresNonceSlot', False) and name in ('SEP', 'SepStage1', 'LLB')
140
+ info = build_identity["Info"]
141
+ nonce_slot_required = info.get("RequiresNonceSlot", False) and name in ("SEP", "SepStage1", "LLB")
141
142
 
142
143
  im4r = None
143
144
  if tbm_dict is not None or nonce_slot_required:
144
145
  im4r = IM4R()
145
146
 
146
147
  if nonce_slot_required:
147
- logger.debug(f'{name}: RequiresNonceSlot for {name}')
148
- if name in ('SEP', 'SepStage1'):
149
- snid = ap_parameters.get('SepNonceSlotID', info.get('SepNonceSlotID', 2))
150
- logger.debug(f'snid: {snid}')
151
- im4r.add_property(
152
- RestoreProperty(fourcc='snid', value=snid)
153
- )
148
+ logger.debug(f"{name}: RequiresNonceSlot for {name}")
149
+ if name in ("SEP", "SepStage1"):
150
+ snid = ap_parameters.get("SepNonceSlotID", info.get("SepNonceSlotID", 2))
151
+ logger.debug(f"snid: {snid}")
152
+ im4r.add_property(RestoreProperty(fourcc="snid", value=snid))
154
153
  else:
155
- anid = ap_parameters.get('ApNonceSlotID', info.get('ApNonceSlotID', 0))
156
- logger.debug(f'anid: {anid}')
157
- im4r.add_property(
158
- RestoreProperty(fourcc='anid', value=anid)
159
- )
154
+ anid = ap_parameters.get("ApNonceSlotID", info.get("ApNonceSlotID", 0))
155
+ logger.debug(f"anid: {anid}")
156
+ im4r.add_property(RestoreProperty(fourcc="anid", value=anid))
160
157
 
161
158
  if tbm_dict is not None:
162
- for key in tbm_dict.keys():
163
- logger.debug(f'{name}: Adding property {key}')
159
+ for key in tbm_dict:
160
+ logger.debug(f"{name}: Adding property {key}")
164
161
  im4r.add_property(RestoreProperty(fourcc=key, value=tbm_dict[key]))
165
162
 
166
163
  return IMG4(im4p=im4p, im4m=tss.ap_img4_ticket, im4r=im4r).output()