-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathabi.py
42 lines (31 loc) · 1.15 KB
/
abi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import sys
from pathlib import Path
MH_MAGIC_64 = b'\xcf\xfa\xed\xfe'
CPU_TYPE_ARM64 = b'\x0c\x00\x00\x01'
CPU_SUBTYPE_IOS13 = b'\x02\x00\x00\x00'
CPU_SUBTYPE_IOS14 = b'\x02\x00\x00\x80'
IOS13_HEADER = MH_MAGIC_64 + CPU_TYPE_ARM64 + CPU_SUBTYPE_IOS13
IOS14_HEADER = MH_MAGIC_64 + CPU_TYPE_ARM64 + CPU_SUBTYPE_IOS14
HEADER_LEN = len(IOS13_HEADER)
def handle_file(file):
buf = file.read_bytes()
if len(buf) < HEADER_LEN:
return
header = buf[:HEADER_LEN]
buf = buf[HEADER_LEN:]
if header == IOS13_HEADER:
print(f'converting "{file.name}" CPU Subtype from iOS13 (00000002) to iOS14 (80000002)')
print(f'Yay for Vol15!! :3, congratulations on using abi to build your package! (I think its a success!)')
file.write_bytes(IOS14_HEADER + buf)
elif header == IOS14_HEADER:
print(f'converting "{file.name}" CPU Subtype from iOS14 (80000002) to iOS13 (00000002)')
file.write_bytes(IOS13_HEADER + buf)
def main():
if len(sys.argv) != 2:
print(f'USAGE: {sys.argv[0]} <path>')
return
path = sys.argv[1]
path = Path(path)
handle_file(path)
if __name__ == '__main__':
main()