OTA: Episode VIII : (not really) The Last OTA
pbzx built in, multi-file operation, symlinks, and SHA-1
Jonathan Levin, (@Morpheus______ ), http://newosxbook.com/ - 12/01/2018
About
With AAPL moving to multiple payload.000-payload.03x files, I figured it's time to add multiple file support. And then some.
First, as per my good friend and master Jailbreaker @S1guza 's request, I integrated his quick fix t
o allow OTA to recognize symlinks.
Second, I realized that maintaining both pbzx AND ota is stupid - they're both in open source, so why not put them together? From no
w on, when ota detects a 'pbzx' magic, it will automatically unpack the file in memory, and operate on it.
Third, because AAPL now uses multiple payload.0?? files, ota now recognizes multiple filenames, following all the switches on the command line. So you can now do something like:
morpheus@Bifröst (~) % mkdir /tmp/xx; cd /tmp/xx; unzip ~/Downloads/6206a506727413f6aac2546821dad5ab684cc538.zip
Archive: /Users/morpheus/Downloads/6206a506727413f6aac2546821dad5ab684cc538.zip
inflating: META-INF/com.apple.ZipMetadata.plist
....
inflating: AssetData/payloadv2/app_patches/Weather.app
extracting: AssetData/payloadv2/data_payload
extracting: AssetData/payloadv2/links.txt
extracting: AssetData/payloadv2/payload.000
extracting: AssetData/payloadv2/payload.000.ecc
extracting: AssetData/payloadv2/payload.001
...
#
# Note multiple files:
#
morpheus@Bifröst (/tmp/xx) % ls AssetData/payloadv2/payload.0??
AssetData/payloadv2/payload.000 AssetData/payloadv2/payload.012 AssetData/payloadv2/payload.024
AssetData/payloadv2/payload.001 AssetData/payloadv2/payload.013 AssetData/payloadv2/payload.025
AssetData/payloadv2/payload.002 AssetData/payloadv2/payload.014 AssetData/payloadv2/payload.026
AssetData/payloadv2/payload.003 AssetData/payloadv2/payload.015 AssetData/payloadv2/payload.027
AssetData/payloadv2/payload.004 AssetData/payloadv2/payload.016 AssetData/payloadv2/payload.028
AssetData/payloadv2/payload.005 AssetData/payloadv2/payload.017 AssetData/payloadv2/payload.029
AssetData/payloadv2/payload.006 AssetData/payloadv2/payload.018 AssetData/payloadv2/payload.030
AssetData/payloadv2/payload.007 AssetData/payloadv2/payload.019 AssetData/payloadv2/payload.031
AssetData/payloadv2/payload.008 AssetData/payloadv2/payload.020 AssetData/payloadv2/payload.032
AssetData/payloadv2/payload.009 AssetData/payloadv2/payload.021 AssetData/payloadv2/payload.033
AssetData/payloadv2/payload.010 AssetData/payloadv2/payload.022 AssetData/payloadv2/payload.034
AssetData/payloadv2/payload.011 AssetData/payloadv2/payload.023
#
# Operate over all payload.0?? files, *without needing to compress them*!
#
morpheus@Bifröst (/tmp/xx) % ota -l AssetData/payloadv2/payload.0??
Processing AssetData/payloadv2/payload.000 # this goes to stderr, 2>/dev/null to quiesce
.Trashes
.ba
.file
.mb
Applications
..
Processing /tmp/xx/AssetData/payloadv2/payload.001
System/Library/Health/FeedItemPlugins/MenstrualCyclesAppPlugin.healthplugin/vi.lproj
usr/standalone/update
usr/standalone/update/all_flash
..
Processing /tmp/xx/AssetData/payloadv2/payload.003
....
... etc..
#
# Search now works multiple files as well:
#
morpheus@Bifröst (/tmp/xx) % ota -s task_for_pid-allow /tmp/xx/AssetData/payloadv2/payload.0??
Processing /tmp/xx/AssetData/payloadv2/payload.000
..
Processing /tmp/xx/AssetData/payloadv2/payload.026
Found in Entry: usr/bin/sysdiagnose, relative offset: 0xe1ee4 (Absolute: 8f86980)
Processing /tmp/xx/AssetData/payloadv2/payload.027
Processing /tmp/xx/AssetData/payloadv2/payload.028
Found in Entry: System/Library/CoreServices/ReportCrash, relative offset: 0x2568f (Absolute: 2ecdc2b)
Found in Entry: usr/bin/footprint, relative offset: 0x2fd2f (Absolute: ab1f129)
Found in Entry: usr/sbin/spindump, relative offset: 0x41e84 (Absolute: b7b6468)
Processing /tmp/xx/AssetData/payloadv2/payload.029
Found in Entry: usr/libexec/sysdiagnose_helper, relative offset: 0x232d1 (Absolute: b8ea703)
Processing /tmp/xx/AssetData/payloadv2/payload.030
Found in Entry: bin/ps, relative offset: 0x115a7 (Absolute: b87c32d)
Found in Entry: usr/bin/tailspin, relative offset: 0x12da6 (Absolute: b8c729b)
Found in Entry: usr/libexec/tailspind, relative offset: 0x17613 (Absolute: bb32f6b)
Processing /tmp/xx/AssetData/payloadv2/payload.031
Found in Entry: usr/bin/zprint, relative offset: 0xd167 (Absolute: a9f2b9d)
Processing /tmp/xx/AssetData/payloadv2/payload.032
Processing /tmp/xx/AssetData/payloadv2/payload.033
Processing /tmp/xx/AssetData/payloadv2/payload.034
Note, you could do that with the original tool, with a bit of shell scripting (for i in payload.0??; do ota ... $i
), but this saves you from pbzx
ing first. You can still use pbzx to expand the files (which will inevitably save you lots of time if you do lots of searches. It's simple enough to add a "pbzx only" feature, to just extract - I leave that as an exercise to the reader.
Another great features is to generate SHA-1 hashes of all files, or particular ones, as per the same arguments for extraction, with -H
morpheus@Bifröst (/tmp/xx)% ota -H WallpaperKit AssetData/payloadv2/payload.001
Processing /tmp/xx/AssetData/payloadv2/payload.001
System/Library/PrivateFrameworks/WallpaperKit.framework/en.lproj/WallpaperKit.strings (142 bytes): 10B3B11C2646496495AC62A4AA0DE908C1813303
System/Library/PrivateFrameworks/WallpaperKit.framework/en_AU.lproj/WallpaperKit.strings (142 bytes): 10B3B11C2646496495AC62A4AA0DE908C1813303
System/Library/PrivateFrameworks/WallpaperKit.framework/en_GB.lproj/WallpaperKit.strings (142 bytes): 10B3B11C2646496495AC62A4AA0DE908C1813303
System/Library/PrivateFrameworks/WallpaperKit.framework/ja.lproj/WallpaperKit.strings (125 bytes): B1C625C72E450E68D99CED6C2B3E9312606B8B0C
System/Library/PrivateFrameworks/WallpaperKit.framework/ko.lproj/WallpaperKit.strings (137 bytes): DC951B825DDA5C0B0F90C270524EE43109F3B6B6
System/Library/PrivateFrameworks/WallpaperKit.framework/zh_CN.lproj/WallpaperKit.strings (121 bytes): 555453DB60562D56E8C494E4315E6A11DFA987B4
System/Library/PrivateFrameworks/WallpaperKit.framework/zh_HK.lproj/WallpaperKit.strings (131 bytes): 14F9CC3E798A2C2031CF5193D9FC51CE9B45A525
System/Library/PrivateFrameworks/WallpaperKit.framework/zh_TW.lproj/WallpaperKit.strings (129 bytes): 9536A9D9BE08A89F1296420C23803F615A899028
Other articles in series
I
II
III
Episode IV
Episode V
Episode VI
Episode VII
Episode IX
Sources
Updated ota.c (compiles cleanly on Linux, MacOS)
Binaries
A Tar.gz holding sources, MacOS and Linux binaries
License
All yours. A nice greet would be nice if you end up github'ing it like some people do. Plagiarism is low.
And you can always ask for features, though I think at this point there aren't any to add.
P.S.
Yes, I discuss OTAs in the Appendix to Volume I, which I've made free
And I also talk about this stuff in The Tg Training - the next one in November 2019 right in the heart of Manhattan :)