The best of OpenSource.Apple.Com for iOS
02/05/2016, Jonathan Levin, http://NewOSXBook.com/ @Morpheus______
What is this?
You already know that Apple releases most components of Darwin (at least, the trivial ones) as open sources on OpenSource.Apple.com. What you may or may not know is that compiling them often runs into annoying challenges, which stem from all sorts of
#ifdef blocks and private headers. Some of the private headers are simply portable from XNU's own (usually along with a
#define PRIVATE or
#define KERNEL_PRIVATE to unlock them for user mode use). Others are not as simple to figure out, containing references to constants that need to be reverse-engineered out of the compiled binary.
iOS users have long relied on Cydia packages to bring back that functionality. I also did, for the longest time, but ran into minor annoyances, namely:
- Aside from the "Erica Utilities" I couldn't find a compilation of all the "must-have" commonly used utilities. Everything is in separate packages. Not finding simple utilities like "more" on the device really riled me. I mean, what, as a separate download? Come on! I expect less, if not more!
- The binaries in Cydia aren't always the exact Apple binaries. Sometimes they're GNU core utilities or other clones, which results in slightly different functionality. In some cases (notably,
brings color butremoves xattr support, and in others it results in slightly different behavior.
- The binaries are 32-bit. I learned that the hard way when I %$#%$# up a 64-bit jailbroken phone - messing with its shared library cache, then effectively killing SSH, and a host of other apps.
- Some are just .. wrong. Notable here is
kextstat, which someone compiled way back without even bothering to check if works. It doesn't. the kmod_ API has been removed a long while ago.
sysctlis also bad.
- Not all the binaries I use are actually there.
lsmp, and a host of other really useful binaries (which aren't at all easy to compile) can't be found on Cydia.
I do a LOT of work on the i-Devices directly, thus decided to compile my own versions. Before certain crazy attention-seeking libel-spreading (but nonethless highly talented) individuals accuse me of any piracy (false claims, but you never know), I'll state that what I'm doing is within the realms of the Apple Public Source License. In fact, I went to great lengths to maintain the source information. This will be evident in the LC_SOURCE_VERSION, and the little known but rather useful
what(1) command (also included):
Now, why is that output shown three times? Because all commands I'm supplying here are multi-architecture fat binaries - x86_64, arm64, and arm32. That way you can plop them into any device (arguably, the x86_64 version is redundant..). If you need the disk space, simply use
jtool -arch ... -e arch (or
lipo -thin) to extract the architecture slice you need.
All binaries are also self signed (
jtool --sign) for iOS, and with appropriate entitlements, if necessary. The OS X versions are not signed, because SIP on 10.11 will actually kill (invalid) self-signed binaries. And for the most part, you can use the default OS X binaries - at least in theory my binaries should be largely (up to addressing) identical.
List of binaries:
- Dropbear - a minimal SSH clone which you can use instead of Cydia's OpenSSH. Note you will need to create your public key, etc
- lsmp - a little known utility to list mach ports. Of course
procexp portsdoes a far better job at it (including naming ports!) nowadays :-)
- ltop - Lists ledger stats
kextunload(*grin*) for iOS
- Zsh - my favorite shell, including config files.
- Most of
- Most of
- netstat, ifconfig and ping from network_cmds
- syslog and dmesg
- screen - super useful (screen -r will resume disc'ed sessions)
DownloadThe full tgz pack. You can always open and remove stuff you don't want
The 64-bit tgz pack. Also with login fix for 9.2 + The 64-bit tgz pack, signed in SHA-256 (for iOS 11)
SCP to your iOS device, go to root directory (
cd /), and
tar -k xvf. BE CAREFUL NOT TO OVERRIDE ANY EXISTING BINARIES.
- Why can't I just use the cydia utilities? - I'm not saying you can't. But if you want 64-bit versions, Cydia has none (AFAIK). Plus I think mine are more recent.
- Why don't you start a Cydia Repository for this? - I think
.debis an overkill. I like my Jailbroken iOS as close as possible to the stock version, too, which is why a simple
tar xvfmakes more sense for me.
- Can I embed them in my own Cydia Repository/package? - ABSOLUTELY. Please do! While you're at it, it would be nice if someone took my other tools (procexp and jtool) and put them into a package too! It would be cool if you drop me a line and let me know, so I can link to you. And - If somebody can/wants to reach out to Saurik (hey, Jay, big fan :-) so he can replace the
*_cmdspackages with these binaries - even cooler!
- Hey! a specific_binary is misbehaving/doesn't work/getting killed/etc - Err.. Might be the case for some 32 bit. Or a
jtool --signbug. I tested most on all platforms, but there's so many, and I stick to 64 myself. Let me know via the Book Forum and I'll fix.
- Why isn't my_favorite_binary here? - Because apparently I don't use it as much as you do. Drop me a line via the Book Forum and I'll gladly compile and add it
- is the source to the iosbinpack available somewhere? Yes. OpenSource.Apple.com. Note that some sources will require massaging (subtle hacks) and/or private header reconstruction to compile neatly.
- When is MOXiI 2 coming out?!?!?! Volume III is out. Volume I will be out hopefully by July 2017. There is now an official update page here. In the interim, check out TechnoloGeeks' OSX/iOS training.
- FOR THOSE PEOPLE NOT WATCHING THE FORUM: DO NOT BLINDLY OVERWRITE EXISTING BINARIES UNLESS YOU ARE USING A FULLY UNTETHERED JAILBREAK. Doing so will get those binaries killed on next reboot, and may prevent you from booting.
- 02/06/2015 - Added du, xxd, mknod, ln and linked to Will's questions (kextunload does work, yeah :-)
- 02/09/2015 - Fixed the screen binary (mismatch in signature for arm64 version corrected)..
- 02/12/2016 - Recompiled ls w/colors, added
date(so that those of you using
zshwon't get errors from
- 02/29/2016 - Actually *signed* zsh. Somehow the version before that didn't have
jtool --signon it, which would make it bad if, say, you wanted a shell on certain devices :-) Also symlinked it as bash (it's compatible). Also signed
- 03/01/2016 - Added useful command like
cat(1)- and even
sqlite3, so you can analyze all those .db files right on the device.
- 03/04/2016 - Added
/usr/share/terminfoso that procexp, vim, and zsh can work on the Apple TV 4G (AAPL, shame on you for not adding shell support files to it! :-). Created
/etc/dropbear(empty directory, so SSH could install cleanly in an untethered TV JB). Also added
wget(no SSL yet), and *sigh*
- 03/09/2016 - Dropping x86_64 (aside from my own binaries and some non-Apple compiled ones, like
wget: and instead providing ARMv7k - for WatchOS! So now
jtoolwork NATIVELY on the Apple Watch! How cool is that????????? Luca - I salute you!
- 03/10/2016 - Fixed broken links (those happen sometime when I forget to rebuild the universal), as per @avivmuss's request. Added
seqand the trivial
- 03/16/2016 - Fixed SCP with armv7 slice (sorry Sara!), kextstat (for David)
- 08/07/2016 - Fixed /usr/bin/login to be interoperable with MTerminal! (Important, since SSH post Pangu 9.2 is a tad flaky). Also updated my tools (jtool, procexp, jlaunchctl)
- 09/01/2017 - Updated with iOS 11 compatible SHA-256 hashes, 64-bit only
[root@Qilin ~]# openssl sha1 /NewOSXBook/tools/iosbinpack6* SHA1(/NewOSXBook/tools/iosbinpack64.tar)= 2e75a03abe030ddab1b1d078e1f35149f47464b0 SHA1(/NewOSXBook/tools/iosbinpack64.tgz)= a8e3f6bd87a90b0f83577594b803b9205e62f47e [root@Qilin ~]# openssl sha1 /NewOSXBook/tools/binpack64-256.tgz SHA1(/NewOSXBook/tools/binpack64-256.tgz)= f0942db35c5a8f421b70863a33485ca7f9de34b8