ipsw-parser 1.8.1__tar.gz → 1.8.3__tar.gz
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.
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/PKG-INFO +2 -2
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/ipsw_parser/_version.py +3 -3
- ipsw_parser-1.8.3/ipsw_parser/dsc.py +87 -0
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/ipsw_parser/ipsw.py +38 -35
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/ipsw_parser.egg-info/PKG-INFO +2 -2
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/ipsw_parser.egg-info/SOURCES.txt +1 -0
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/ipsw_parser.egg-info/requires.txt +1 -1
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/ipsw_parser.egg-info/scm_file_list.json +1 -0
- ipsw_parser-1.8.3/ipsw_parser.egg-info/scm_version.json +8 -0
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/requirements.txt +1 -1
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/tests/test_archive_backends.py +34 -1
- ipsw_parser-1.8.3/tests/test_dsc.py +87 -0
- ipsw_parser-1.8.1/ipsw_parser/dsc.py +0 -62
- ipsw_parser-1.8.1/ipsw_parser.egg-info/scm_version.json +0 -8
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/.gitattributes +0 -0
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/.github/workflows/codeql.yml +0 -0
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/.github/workflows/python-app.yml +0 -0
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/.github/workflows/python-publish.yml +0 -0
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/.gitignore +0 -0
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/.pre-commit-config.yaml +0 -0
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/CODE_OF_CONDUCT.md +0 -0
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/LICENSE +0 -0
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/README.md +0 -0
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/ipsw_parser/__init__.py +0 -0
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/ipsw_parser/__main__.py +0 -0
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/ipsw_parser/archive.py +0 -0
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/ipsw_parser/build_identity.py +0 -0
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/ipsw_parser/build_manifest.py +0 -0
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/ipsw_parser/component.py +0 -0
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/ipsw_parser/exceptions.py +0 -0
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/ipsw_parser/firmware.py +0 -0
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/ipsw_parser/process.py +0 -0
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/ipsw_parser.egg-info/dependency_links.txt +0 -0
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/ipsw_parser.egg-info/entry_points.txt +0 -0
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/ipsw_parser.egg-info/top_level.txt +0 -0
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/pyproject.toml +0 -0
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/pytest.ini +0 -0
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/setup.cfg +0 -0
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/tests/test_process.py +0 -0
- {ipsw_parser-1.8.1 → ipsw_parser-1.8.3}/tests/test_sandbox_profiles.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ipsw-parser
|
|
3
|
-
Version: 1.8.
|
|
3
|
+
Version: 1.8.3
|
|
4
4
|
Summary: python3 utility for parsing and extracting data from IPSW
|
|
5
5
|
Author-email: doronz88 <doron88@gmail.com>
|
|
6
6
|
Maintainer-email: doronz88 <doron88@gmail.com>
|
|
@@ -695,7 +695,7 @@ Classifier: Programming Language :: Python :: 3 :: Only
|
|
|
695
695
|
Requires-Python: >=3.9
|
|
696
696
|
Description-Content-Type: text/markdown
|
|
697
697
|
License-File: LICENSE
|
|
698
|
-
Requires-Dist:
|
|
698
|
+
Requires-Dist: bytestruct>=0.1.0
|
|
699
699
|
Requires-Dist: coloredlogs
|
|
700
700
|
Requires-Dist: pyimg4>=0.8.8
|
|
701
701
|
Requires-Dist: requests
|
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '1.8.
|
|
22
|
-
__version_tuple__ = version_tuple = (1, 8,
|
|
21
|
+
__version__ = version = '1.8.3'
|
|
22
|
+
__version_tuple__ = version_tuple = (1, 8, 3)
|
|
23
23
|
|
|
24
|
-
__commit_id__ = commit_id = '
|
|
24
|
+
__commit_id__ = commit_id = 'gc9b1581ba'
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import plistlib
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from ipsw_parser.process import ProcessExecutionError, run
|
|
7
|
+
|
|
8
|
+
logger = logging.getLogger(__name__)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
DSC_DIRECTORIES = (
|
|
12
|
+
"System/Library/Caches/com.apple.dyld",
|
|
13
|
+
"private/preboot/Cryptexes/OS/System/Library/Caches/com.apple.dyld",
|
|
14
|
+
# Some devices report the cryptex through its /System/Cryptexes/OS symlink instead
|
|
15
|
+
"System/Cryptexes/OS/System/Library/Caches/com.apple.dyld",
|
|
16
|
+
)
|
|
17
|
+
DSC_NAMES = ("dyld_shared_cache_arm64", "dyld_shared_cache_arm64e")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def split_dsc(root: Path) -> list[Path]:
|
|
21
|
+
"""
|
|
22
|
+
Split dyld shared caches found under ``root`` into their images.
|
|
23
|
+
|
|
24
|
+
``ipsw dyld split`` does it using Xcode's own extractor, which refuses a cache whose code
|
|
25
|
+
signature does not match (a patched one, for instance). Such a cache is extracted using
|
|
26
|
+
``ipsw dyld extract`` instead.
|
|
27
|
+
|
|
28
|
+
:returns: The shared caches which were split.
|
|
29
|
+
"""
|
|
30
|
+
split: list[Path] = []
|
|
31
|
+
for directory in DSC_DIRECTORIES:
|
|
32
|
+
for name in DSC_NAMES:
|
|
33
|
+
dsc = root / directory / name
|
|
34
|
+
if not dsc.exists():
|
|
35
|
+
continue
|
|
36
|
+
|
|
37
|
+
logger.info(f"splitting DSC: {dsc}")
|
|
38
|
+
try:
|
|
39
|
+
run("ipsw", "dyld", "split", dsc, "-o", root)
|
|
40
|
+
except ProcessExecutionError as e:
|
|
41
|
+
logger.warning(f"`ipsw dyld split` failed, extracting the images of {dsc} instead: {e}")
|
|
42
|
+
run("ipsw", "dyld", "extract", dsc, "--all", "--output", root)
|
|
43
|
+
split.append(dsc)
|
|
44
|
+
return split
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def get_device_support_path(product_type: str, product_version: str, product_build_version: str) -> Path:
|
|
48
|
+
"""Return the Xcode DeviceSupport path for the given product metadata."""
|
|
49
|
+
device_support_path = Path("~/Library/Developer/Xcode/iOS DeviceSupport").expanduser()
|
|
50
|
+
device_support_path /= f"{product_type} {product_version} ({product_build_version})"
|
|
51
|
+
return device_support_path
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def create_device_support_layout(
|
|
55
|
+
product_type: str, product_version: str, product_build_version: str, root_path: Path
|
|
56
|
+
) -> Path:
|
|
57
|
+
"""
|
|
58
|
+
Create the Xcode DeviceSupport layout for extracted symbol files.
|
|
59
|
+
|
|
60
|
+
:raises FileNotFoundError: if ``root_path`` holds no dyld shared cache to split.
|
|
61
|
+
"""
|
|
62
|
+
device_support_path = get_device_support_path(product_type, product_version, product_build_version)
|
|
63
|
+
|
|
64
|
+
# Split DSC files
|
|
65
|
+
if not split_dsc(root_path):
|
|
66
|
+
raise FileNotFoundError(f"no dyld shared cache was found under {root_path}")
|
|
67
|
+
|
|
68
|
+
# Clean up the cryptex DSC files after splitting
|
|
69
|
+
for directory in DSC_DIRECTORIES[1:]:
|
|
70
|
+
cryptex_dsc_dir = root_path / directory
|
|
71
|
+
if cryptex_dsc_dir.exists():
|
|
72
|
+
for file in cryptex_dsc_dir.iterdir():
|
|
73
|
+
file.unlink()
|
|
74
|
+
|
|
75
|
+
# Create the device support metadata files
|
|
76
|
+
(device_support_path / "Info.plist").write_bytes(
|
|
77
|
+
plistlib.dumps({
|
|
78
|
+
"DSC Extractor Version": "1228.0.0.0.0",
|
|
79
|
+
"DateCollected": datetime.now(),
|
|
80
|
+
"Version": "16.0",
|
|
81
|
+
})
|
|
82
|
+
)
|
|
83
|
+
(device_support_path / ".finalized").write_bytes(plistlib.dumps({}))
|
|
84
|
+
(device_support_path / ".processed_dyld_shared_cache_arm64e").touch()
|
|
85
|
+
(device_support_path / ".processing_lock").touch()
|
|
86
|
+
|
|
87
|
+
return device_support_path
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
from contextlib import contextmanager
|
|
3
|
+
from dataclasses import dataclass, field
|
|
3
4
|
from functools import cached_property
|
|
4
5
|
from pathlib import Path
|
|
5
|
-
from typing import Optional
|
|
6
|
+
from typing import Annotated, Optional
|
|
6
7
|
from zipfile import ZipFile
|
|
7
8
|
|
|
8
|
-
from
|
|
9
|
+
from bytestruct import BinaryStruct, Bytes, Const
|
|
9
10
|
from remotezip2 import RemoteZip
|
|
10
11
|
|
|
11
12
|
from ipsw_parser.archive import Archive, ArchiveMember, DirectoryArchive, ZipArchive
|
|
@@ -15,23 +16,39 @@ from ipsw_parser.firmware import Firmware
|
|
|
15
16
|
|
|
16
17
|
logger = logging.getLogger(__name__)
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
19
|
+
|
|
20
|
+
@dataclass
|
|
21
|
+
class CpioOdcHeader(BinaryStruct):
|
|
22
|
+
"""A POSIX.1 portable ("odc") cpio header: every field is zero-padded octal ASCII."""
|
|
23
|
+
|
|
24
|
+
c_magic: Annotated[bytes, Bytes(6), Const(b"070707")] = field(default=b"070707", init=False)
|
|
25
|
+
c_dev: Annotated[bytes, Bytes(6)]
|
|
26
|
+
c_ino: Annotated[bytes, Bytes(6)]
|
|
27
|
+
c_mode: Annotated[bytes, Bytes(6)]
|
|
28
|
+
c_uid: Annotated[bytes, Bytes(6)]
|
|
29
|
+
c_gid: Annotated[bytes, Bytes(6)]
|
|
30
|
+
c_nlink: Annotated[bytes, Bytes(6)]
|
|
31
|
+
c_rdev: Annotated[bytes, Bytes(6)]
|
|
32
|
+
c_mtime: Annotated[bytes, Bytes(11)]
|
|
33
|
+
c_namesize: Annotated[bytes, Bytes(6)]
|
|
34
|
+
c_filesize: Annotated[bytes, Bytes(11)]
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _build_cpio_odc_header(ino: int, mode: int, nlink: int, namesize: int, filesize: int = 0) -> bytes:
|
|
38
|
+
"""Build an odc cpio header; device, owner, rdev and mtime are always zero."""
|
|
39
|
+
zero6 = b"0" * 6
|
|
40
|
+
return CpioOdcHeader(
|
|
41
|
+
c_dev=zero6,
|
|
42
|
+
c_ino=f"{ino:06o}".encode(),
|
|
43
|
+
c_mode=f"{mode:06o}".encode(),
|
|
44
|
+
c_uid=zero6,
|
|
45
|
+
c_gid=zero6,
|
|
46
|
+
c_nlink=f"{nlink:06o}".encode(),
|
|
47
|
+
c_rdev=zero6,
|
|
48
|
+
c_mtime=b"0" * 11,
|
|
49
|
+
c_namesize=f"{namesize:06o}".encode(),
|
|
50
|
+
c_filesize=f"{filesize:011o}".encode(),
|
|
51
|
+
).build()
|
|
35
52
|
|
|
36
53
|
|
|
37
54
|
class IPSW:
|
|
@@ -105,13 +122,7 @@ class IPSW:
|
|
|
105
122
|
filename = subpath
|
|
106
123
|
filename = f"{filename}\0".encode()
|
|
107
124
|
mode = e.external_attr >> 16
|
|
108
|
-
result +=
|
|
109
|
-
"c_ino": f"{inode:06o}",
|
|
110
|
-
"c_nlink": f"{nlink:06o}",
|
|
111
|
-
"c_mode": f"{mode:06o}",
|
|
112
|
-
"c_namesize": f"{len(filename):06o}",
|
|
113
|
-
"c_filesize": f"{e.file_size:011o}",
|
|
114
|
-
})
|
|
125
|
+
result += _build_cpio_odc_header(inode, mode, nlink, len(filename), e.file_size)
|
|
115
126
|
inode += 1
|
|
116
127
|
result += filename
|
|
117
128
|
if not e.file_size:
|
|
@@ -123,15 +134,7 @@ class IPSW:
|
|
|
123
134
|
filename = b"TRAILER!!!\0"
|
|
124
135
|
inode = 0
|
|
125
136
|
mode = 0
|
|
126
|
-
result += (
|
|
127
|
-
cpio_odc_header.build({
|
|
128
|
-
"c_ino": f"{inode:06o}",
|
|
129
|
-
"c_mode": f"{mode:06o}",
|
|
130
|
-
"c_nlink": f"{nlink:06o}",
|
|
131
|
-
"c_namesize": f"{len(filename):06o}",
|
|
132
|
-
})
|
|
133
|
-
+ filename
|
|
134
|
-
)
|
|
137
|
+
result += _build_cpio_odc_header(inode, mode, nlink, len(filename)) + filename
|
|
135
138
|
return result
|
|
136
139
|
|
|
137
140
|
def read(self, path: str) -> bytes:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ipsw-parser
|
|
3
|
-
Version: 1.8.
|
|
3
|
+
Version: 1.8.3
|
|
4
4
|
Summary: python3 utility for parsing and extracting data from IPSW
|
|
5
5
|
Author-email: doronz88 <doron88@gmail.com>
|
|
6
6
|
Maintainer-email: doronz88 <doron88@gmail.com>
|
|
@@ -695,7 +695,7 @@ Classifier: Programming Language :: Python :: 3 :: Only
|
|
|
695
695
|
Requires-Python: >=3.9
|
|
696
696
|
Description-Content-Type: text/markdown
|
|
697
697
|
License-File: LICENSE
|
|
698
|
-
Requires-Dist:
|
|
698
|
+
Requires-Dist: bytestruct>=0.1.0
|
|
699
699
|
Requires-Dist: coloredlogs
|
|
700
700
|
Requires-Dist: pyimg4>=0.8.8
|
|
701
701
|
Requires-Dist: requests
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import plistlib
|
|
2
2
|
from pathlib import Path
|
|
3
|
-
from zipfile import ZipFile
|
|
3
|
+
from zipfile import ZipFile, ZipInfo
|
|
4
4
|
|
|
5
5
|
from ipsw_parser.archive import DirectoryArchive, ZipArchive
|
|
6
6
|
from ipsw_parser.ipsw import IPSW
|
|
@@ -68,3 +68,36 @@ def test_directory_extractall_copies_requested_members(tmp_path: Path) -> None:
|
|
|
68
68
|
|
|
69
69
|
assert (output / "Firmware" / "devel-file.bin").read_bytes() == b"dev"
|
|
70
70
|
assert not (output / "Release" / "normal-file.bin").exists()
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def _cpio_header(ino: int, mode: int, namesize: int, filesize: int) -> bytes:
|
|
74
|
+
return f"070707000000{ino:06o}{mode:06o}000000000000000001000000{0:011o}{namesize:06o}{filesize:011o}".encode()
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def test_bootability_builds_odc_cpio_archive(tmp_path: Path) -> None:
|
|
78
|
+
archive_path = tmp_path / "sample.ipsw"
|
|
79
|
+
with ZipFile(archive_path, "w") as archive:
|
|
80
|
+
archive.writestr("BuildManifest.plist", _build_manifest())
|
|
81
|
+
for name, mode, data in (
|
|
82
|
+
("BootabilityBundle/Restore/Bootability/payload.bin", 0o100644, b"hello"),
|
|
83
|
+
("BootabilityBundle/Restore/Bootability/empty", 0o100600, b""),
|
|
84
|
+
("BootabilityBundle/Restore/Firmware/Bootability.dmg.trustcache", 0o100644, b"trust"),
|
|
85
|
+
("Firmware/unrelated.bin", 0o100644, b"ignored"),
|
|
86
|
+
):
|
|
87
|
+
info = ZipInfo(name)
|
|
88
|
+
info.external_attr = mode << 16
|
|
89
|
+
archive.writestr(info, data)
|
|
90
|
+
|
|
91
|
+
with ZipFile(archive_path) as archive:
|
|
92
|
+
bootability = IPSW(ZipArchive(archive)).bootability
|
|
93
|
+
|
|
94
|
+
assert bootability == (
|
|
95
|
+
_cpio_header(1, 0o100644, 12, 5)
|
|
96
|
+
+ b"payload.bin\0hello"
|
|
97
|
+
+ _cpio_header(2, 0o100600, 6, 0)
|
|
98
|
+
+ b"empty\0"
|
|
99
|
+
+ _cpio_header(3, 0o100644, 23, 5)
|
|
100
|
+
+ b"Bootability.trustcache\0trust"
|
|
101
|
+
+ _cpio_header(0, 0, 11, 0)
|
|
102
|
+
+ b"TRAILER!!!\0"
|
|
103
|
+
)
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from ipsw_parser import dsc
|
|
6
|
+
from ipsw_parser.process import ProcessExecutionError
|
|
7
|
+
|
|
8
|
+
CRYPTEX_SYMLINK_DSC = "System/Cryptexes/OS/System/Library/Caches/com.apple.dyld/dyld_shared_cache_arm64e"
|
|
9
|
+
CRYPTEX_DSC = "private/preboot/Cryptexes/OS/System/Library/Caches/com.apple.dyld/dyld_shared_cache_arm64e"
|
|
10
|
+
SYSTEM_DSC = "System/Library/Caches/com.apple.dyld/dyld_shared_cache_arm64e"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _create(root: Path, path: str) -> Path:
|
|
14
|
+
file = root / path
|
|
15
|
+
file.parent.mkdir(parents=True)
|
|
16
|
+
file.write_bytes(b"dsc")
|
|
17
|
+
return file
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@pytest.fixture
|
|
21
|
+
def commands(monkeypatch: pytest.MonkeyPatch) -> list[tuple[str, ...]]:
|
|
22
|
+
commands: list[tuple[str, ...]] = []
|
|
23
|
+
|
|
24
|
+
def run(*argv: object) -> str:
|
|
25
|
+
commands.append(tuple(str(arg) for arg in argv))
|
|
26
|
+
return ""
|
|
27
|
+
|
|
28
|
+
monkeypatch.setattr(dsc, "run", run)
|
|
29
|
+
return commands
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@pytest.mark.parametrize("path", [SYSTEM_DSC, CRYPTEX_DSC, CRYPTEX_SYMLINK_DSC])
|
|
33
|
+
def test_split_dsc_finds_the_cache(tmp_path: Path, commands: list[tuple[str, ...]], path: str) -> None:
|
|
34
|
+
cache = _create(tmp_path, path)
|
|
35
|
+
|
|
36
|
+
assert dsc.split_dsc(tmp_path) == [cache]
|
|
37
|
+
assert commands == [("ipsw", "dyld", "split", str(cache), "-o", str(tmp_path))]
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def test_split_dsc_extracts_a_cache_the_splitter_refuses(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
41
|
+
cache = _create(tmp_path, CRYPTEX_DSC)
|
|
42
|
+
commands: list[tuple[str, ...]] = []
|
|
43
|
+
|
|
44
|
+
def run(*argv: object) -> str:
|
|
45
|
+
commands.append(tuple(str(arg) for arg in argv))
|
|
46
|
+
if argv[2] == "split":
|
|
47
|
+
raise ProcessExecutionError(list(commands[-1]), 1, "", "code signature for page 0 is incorrect")
|
|
48
|
+
return ""
|
|
49
|
+
|
|
50
|
+
monkeypatch.setattr(dsc, "run", run)
|
|
51
|
+
|
|
52
|
+
assert dsc.split_dsc(tmp_path) == [cache]
|
|
53
|
+
assert commands == [
|
|
54
|
+
("ipsw", "dyld", "split", str(cache), "-o", str(tmp_path)),
|
|
55
|
+
("ipsw", "dyld", "extract", str(cache), "--all", "--output", str(tmp_path)),
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
@pytest.mark.parametrize("path", [CRYPTEX_DSC, CRYPTEX_SYMLINK_DSC])
|
|
60
|
+
def test_device_support_layout_removes_the_split_cryptex_cache(
|
|
61
|
+
tmp_path: Path, monkeypatch: pytest.MonkeyPatch, commands: list[tuple[str, ...]], path: str
|
|
62
|
+
) -> None:
|
|
63
|
+
device_support = tmp_path / "DeviceSupport"
|
|
64
|
+
symbols = device_support / "Symbols"
|
|
65
|
+
cache = _create(symbols, path)
|
|
66
|
+
monkeypatch.setattr(dsc, "get_device_support_path", lambda *args: device_support)
|
|
67
|
+
|
|
68
|
+
assert dsc.create_device_support_layout("iPhone15,2", "16.0", "20A362", symbols) == device_support
|
|
69
|
+
|
|
70
|
+
assert len(commands) == 1
|
|
71
|
+
assert not cache.exists()
|
|
72
|
+
assert (device_support / ".finalized").exists()
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def test_device_support_layout_is_not_finalized_without_a_cache(
|
|
76
|
+
tmp_path: Path, monkeypatch: pytest.MonkeyPatch, commands: list[tuple[str, ...]]
|
|
77
|
+
) -> None:
|
|
78
|
+
device_support = tmp_path / "DeviceSupport"
|
|
79
|
+
symbols = device_support / "Symbols"
|
|
80
|
+
symbols.mkdir(parents=True)
|
|
81
|
+
monkeypatch.setattr(dsc, "get_device_support_path", lambda *args: device_support)
|
|
82
|
+
|
|
83
|
+
with pytest.raises(FileNotFoundError):
|
|
84
|
+
dsc.create_device_support_layout("iPhone15,2", "16.0", "20A362", symbols)
|
|
85
|
+
|
|
86
|
+
assert commands == []
|
|
87
|
+
assert not (device_support / ".finalized").exists()
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
import plistlib
|
|
3
|
-
from datetime import datetime
|
|
4
|
-
from pathlib import Path
|
|
5
|
-
|
|
6
|
-
from ipsw_parser.process import run
|
|
7
|
-
|
|
8
|
-
logger = logging.getLogger(__name__)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def split_dsc(root: Path) -> None:
|
|
12
|
-
"""Split dyld shared caches found under ``root`` using ``ipsw dyld split``."""
|
|
13
|
-
dsc_paths = [
|
|
14
|
-
root / "System/Library/Caches/com.apple.dyld/dyld_shared_cache_arm64",
|
|
15
|
-
root / "System/Library/Caches/com.apple.dyld/dyld_shared_cache_arm64e",
|
|
16
|
-
root / "private/preboot/Cryptexes/OS/System/Library/Caches/com.apple.dyld/dyld_shared_cache_arm64",
|
|
17
|
-
root / "private/preboot/Cryptexes/OS/System/Library/Caches/com.apple.dyld/dyld_shared_cache_arm64e",
|
|
18
|
-
]
|
|
19
|
-
|
|
20
|
-
for dsc in dsc_paths:
|
|
21
|
-
if not dsc.exists():
|
|
22
|
-
continue
|
|
23
|
-
|
|
24
|
-
logger.info(f"splitting DSC: {dsc}")
|
|
25
|
-
run("ipsw", "dyld", "split", dsc, "-o", root)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def get_device_support_path(product_type: str, product_version: str, product_build_version: str) -> Path:
|
|
29
|
-
"""Return the Xcode DeviceSupport path for the given product metadata."""
|
|
30
|
-
device_support_path = Path("~/Library/Developer/Xcode/iOS DeviceSupport").expanduser()
|
|
31
|
-
device_support_path /= f"{product_type} {product_version} ({product_build_version})"
|
|
32
|
-
return device_support_path
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def create_device_support_layout(
|
|
36
|
-
product_type: str, product_version: str, product_build_version: str, root_path: Path
|
|
37
|
-
) -> Path:
|
|
38
|
-
"""Create the Xcode DeviceSupport layout for extracted symbol files."""
|
|
39
|
-
device_support_path = get_device_support_path(product_type, product_version, product_build_version)
|
|
40
|
-
|
|
41
|
-
# Split DSC files
|
|
42
|
-
split_dsc(root_path)
|
|
43
|
-
|
|
44
|
-
# Clean up the cryptex DSC files after splitting
|
|
45
|
-
cryptex_dsc_dir = root_path / "private/preboot/Cryptexes/OS/System/Library/Caches/com.apple.dyld"
|
|
46
|
-
if cryptex_dsc_dir.exists():
|
|
47
|
-
for file in cryptex_dsc_dir.iterdir():
|
|
48
|
-
file.unlink()
|
|
49
|
-
|
|
50
|
-
# Create the device support metadata files
|
|
51
|
-
(device_support_path / "Info.plist").write_bytes(
|
|
52
|
-
plistlib.dumps({
|
|
53
|
-
"DSC Extractor Version": "1228.0.0.0.0",
|
|
54
|
-
"DateCollected": datetime.now(),
|
|
55
|
-
"Version": "16.0",
|
|
56
|
-
})
|
|
57
|
-
)
|
|
58
|
-
(device_support_path / ".finalized").write_bytes(plistlib.dumps({}))
|
|
59
|
-
(device_support_path / ".processed_dyld_shared_cache_arm64e").touch()
|
|
60
|
-
(device_support_path / ".processing_lock").touch()
|
|
61
|
-
|
|
62
|
-
return device_support_path
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|