With the rise of open source PoC exploits like Ian Beer's past exploits in 10.1.1, 10.2 and 11.1.2, it's become a simple enough matter to built on existing code obtaining kernel memory read/write access (via the SEND right to the kernel_task port, commonly referred to as "TFP0"). But the kernel_task alone does not a jailbreak make*.
Many developers have already built on Beer's code, adding in elements from various PatchFinders like @Xerub's and others - but the resulting code is often messy, prone to fragmentation, relies on multiple magic values and is insufficiently commented, and - most importantly - unmaintainable in the face of shifting symbol offsets and structure offsets. Further, not all code provided in such jailbreaks passes the tests of stability, as kernel memory overwriting needs to be done with extreme care, so as to avoid locks, data aborts, and other potential causes of panics.
The QiLin Jailbreak ToolKit is a simple code base, which standardizes all the common tasks required for jailbreaking - from breaking out of the sandbox and assuming root capabilities, remounting the root file system, unpacking binaries, and more - in a way that is stable, safe, and reduces the amount of code to about 10 lines. It is aimed at researchers and jailbreak enthusiasts, who wish to learn more about the intricacies of kernel tinkering without being bogged down by the nooks and crannies of setting up a stable work environment.
In other words, the toolkit handles the complicated tasks, and you can build whatever UI/customization/tweaking/modding of the jailbreak you want.
By the way, for those people wondering what a QiLin (in Japanese and western languages, "Kirin") is - it's an auspicious, unique, highly magical and extremely powerful creature which takes the form of a cross between a dragon and lion (and sometimes, horse). Wikipedia gets the gist of it, though I'm more a fan of the AD&D interpretation.
The API
All you have to do in order to build on QiLin is to call:
int initQiLin (mach_port_t TFP0, uint64_t KernelBase);
with the kernel send right (TFP0) and the kernelbase (i.e address of kernel Mach-O + slide). And now you don't even have to do that anymore since QiLin can figure out the slide with just your own task address (which exploits use anyway). The rest is provided by numerous functions - Let the .h file speak for itself:
I'm working on stabilizing a few things and bullet-proofing them, and as soon as I do QiLin will (削除) be fully open source and (削除ここまで) NOT BE OPEN SOURCE because of nasty folk (see LICENSE below) but will forever be FREE, and - for the time being - maintained by me . In the meanwhile, Here's the object file you can drop into your project to start using it! And the above .h file is here as well
For iOS 12, you need this file, since structures have changed. THIS FILE IS RELATIVELY STABLE AT THE MOMENT (July 15th, 2019). I'm working on making a universal 10-12 one. See forum post for details.
To compile: Drop qilin.o and sha256.o in same directory. Then gcc -arch arm64 ...c qilin.o sha256.o -o .... and that's it (assuming you fix the broken iOS headers by copying them over from MacOS first!).
ChangeLog
07/16/19 - Works with SockPuppet, network server. Enabling entirely invisible jailbreak with built-in shell and absolutely no files put in device outside of application directory
Updated API with exported KMR/KMW functions for true kernel_task-less operation! (Although @jaakerblom's hacks work really well!)
integrated sha1/sha256 so that you now have one .o
LICENSE
Johnny's (semi) open source license, v0.4
-----------------------------------------
This is (well, will be, at the time of writing) open source, and I can't but appeal to your sense of decency.
You might try compile this and try to pass it as your own. Heck, you might even try to run it through llvm-obfuscator.
But that would be stealing code. And obfuscate as you will, you can't obfuscate enough to hide the methods.
So, primum non nocere. Do no harm, and do not steal.
To be fully clear:
- Yes, you may use this source or code library as you see fit, PROVIDED THAT:
- IT IS NOT USED COMMERCIALLY IN ANY WAY. For this, I ask that you contact my company, @Technologeeks,
and ask for proper licensing - they'll also provide official support.
- IT IS NOT USED AS A COMPONENT OF AN APT IN ANY KIND FORM OR MANNER.
(NSO/Hackin9/Finfisher/Equus/etc - that means you)
- WHEN YOU DO USE IT, I ASK THAT YOU MENTION THAT YOUR TOOL IS "powered by the QiLin Toolkit",
or otherwise provide a user facing indication that it is using this code.
I'd appreciate it if you tweeted with #QiLin, too.
- If you spread lies about other people, propaganda or false claims, while using this toolkit, then you must renounce your ways, and apologize. Then you can use it freely.
- There are no limitation on nationality, (削除) specific people exclusions (削除ここまで) ((削除) i.e. this is AISE (削除ここまで), subject to last condition, above ;-),
or any other race, color or creed - provided the above are met.
- QiLin comes with NO LIABILITY WHATSOEVER. YOU USE THIS AT YOUR OWN RISK.
I CANNOT AND WILL NOT BE HELD ACCOUNTABLE FOR ANY DAMAGE, SOFTWARE OR HARDWARE OR YOUR DATA OR OTHERWISE,
WHICH MAY OR MAY NOT RESULT TO YOUR IOS DEVICE BY USING THIS.
- Remember I'm doing this AS A FAVOR. I AM NO IN WAY INDEBTED OR COMMITTED TO SUPPORT THIS, OR ANY OTHER OF MY TOOLS.
You don't have to thank for this (you're welcome) but please don't slander me either.
- Should you wish to contribute/donate, you may do so in one of the following ways:
- Monetary: Pick a charity. Any charity. Of your choice. Pay them however money you want.
Optionally, tweet/fb/insta/snap-whatever a screen capture stating "#QiLin".
- Development: Through http://NewOSXBook.com/forum - you are welcome to ask (proper technical, not lame wen eta)
questions and engage in discussions
First, do no harm. Next, have fun :-)
Changelog:
- v0.1 Was AISE but SE is being more of an ass than usual and slandering fake claims directly attacking me. So this was updated with new condition excluding him until he grows up and behaves like the decent, talented researcher he can be.
- v0.3 adds request to tweet #QiLin.
- v0.4 states what should be obvious - NO LIABILITY WHATSOEVER