About Evasi0n Userland Component
The tool is based on MobileBackup daemon that is capable of backing up and restoring backups on the Apple gadget. These backups are seen as untrusted data and in order to function the correct way the daemon uses MediaDomain along with a static path that can identify each file and correspond to the domain. The jailbreaking utility’s files are located within /var/mobile/Media. Here is how the whole thing works.Evasi0n Functionality: First Stage
At this point the tool creates a fresh backup to restore to Apple devices. It contains just the files listed below withing the MediaDomain.- directory: Media/
- directory: Media/Recordings/
- symlink: Media/Recordings/.haxx -> /var/mobile
- directory: Media/Recordings/.haxx/DemoApp.app/
- file: Media/Recordings/.haxx/DemoApp.app/Info.plist
- file: Media/Recordings/.haxx/DemoApp.app/DemoApp
- file: Media/Recordings/.haxx/DemoApp.app/Icon.png
- file: Media/Recordings/.haxx/DemoApp.app/[email protected]
- file: Media/Recordings/.haxx/DemoApp.app/Icon-72.png
- file: Media/Recordings/.haxx/DemoApp.app/[email protected]
- file: Media/Recordings/.haxx/Library/Caches/com.apple.mobile.installation.plist
- The symlink in .haxx to /var/mobile is created to escape the MobileBackup domain’s normal path restriction. When the symlink appears all files in .haxx are restored not in /var/mobile/Media. They appear in /var/mobile and this method was used in different jailbreaking programs in the past.
- #!/bin/launchctl submit -l remount -o /var/mobile/Media/mount.stdout -e /var/mobile/Media/mount.stderr -- /sbin/mount -v -t hfs -o rw /dev/disk0s1s1
EnvironmentVariables LAUNCHD_SOCKET /private/var/tmp/launchd/sock
How evasi0n Works: Second Stage
This stage is long so it can be split up into three parts. Let’s name them Stage 2.1, 2.2 and 2.3. Here is what happens during each stage. 2.1 At this point, an empty backup is created. Your gadget gets more files restored.- directory: Media/
- directory: Media/Recordings/
- symlink: Media/Recordings/.haxx -> /var/db
- symlink: Media/Recordings/.haxx/timezone -> /var/tmp/launchd
- A new symlink is created. It is called /var/db/timezone that points to /var/tmp/launchd.
- The normal permissions on /var/tmp/launchd are:
- drwx------ 2 root wheel 102 Feb 4 12:17 launchd
- Symlink: Media/Recordings/.haxx/timezone -> /var/tmp/launchd
- To
- Symlink: Media/Recordings/.haxx/timezone -> /var/tmp/launchd/sock
- Then evasi0n sends another malformed PairRequest packet to lockdownd, causing /var/tmp/launchd/sock to become accessible to the mobile user.
- #!/bin/launchctl submit -l remount -o /var/mobile/Media/mount.stdout -e /var/mobile/Media/mount.stderr -- /sbin/mount -v -t hfs -o rw /dev/disk0s1s1
- With the environment variable
- LAUNCHD_SOCKET = /private/var/tmp/launchd/sock
- -l label
- What unique label to assign this job to launchd
- -p program
- What program to really execute, regardless of what follows the -- in the submit sub-command.
- -o path
- Where to send the stdout of the program.
- -e path
- Where to send the stderr of the program.
- ENVIRONMENTAL VARIABLES
- LAUNCHD_SOCKET
How Evasi0n Jailbreak Components Work: Third Stage
This is the last part of the article that explains how Evasi0n tool operates. It starts with jailbreak accessing the system partition through MobileBackup:- directory: Media/
- directory: Media/Recordings/
- symlink: Media/Recordings/.haxx -> /
- symlink: Media/Recordings/.haxx/private/etc/launchd.conf -> /private/var/evasi0n/launchd.conf
- directory: Media/Recordings/.haxx/var/evasi0n
- file: Media/Recordings/.haxx/var/evasi0n/evasi0n
- file: Media/Recordings/.haxx/var/evasi0n/amfi.dylib
- file: Media/Recordings/.haxx/var/evasi0n/udid
- file: Media/Recordings/.haxx/var/evasi0n/launchd.conf
- bsexec .. /sbin/mount -u -o rw,suid,dev /
- setenv DYLD_INSERT_LIBRARIES /private/var/evasi0n/amfi.dylib
- load /System/Library/LaunchDaemons/com.apple.MobileFileIntegrity.plist
- bsexec .. /private/var/evasi0n/evasi0n
- unsetenv DYLD_INSERT_LIBRARIES
- bsexec .. /bin/rm -f /private/var/evasi0n/sock
- bsexec .. /bin/ln -f /var/tmp/launchd/sock /private/var/evasi0n/sock
- Here’s what that does, line by line:
- bsexec .. /sbin/mount -u -o rw,suid,dev /
- Mount system partition read-write again
- setenv DYLD_INSERT_LIBRARIES /private/var/evasi0n/amfi.dylib
- Insert amfi.dylib into any executable that launches after this point
- load /System/Library/LaunchDaemons/com.apple.MobileFileIntegrity.plist
- Load the MobileFileIntegrity daemon
- bsexec .. /private/var/evasi0n/evasi0n
- Execute the malicious code, previously dropped in /var/evasi0n/evasi0n
- unsetenv DYLD_INSERT_LIBRARIES
- Unset DYLD_INSERT_LIBRARIES, so that amfi.dylib will no longer be inserted into every executable after this point
- bsexec .. /bin/rm -f /private/var/evasi0n/sock
- Delete any pre-existing socket file at /private/var/evasi0n/sock
- bsexec .. /bin/ln -f /var/tmp/launchd/sock /private/var/evasi0n/sock
- Create a symlink from /var/tmp/launchd/sock to /private/var/evasi0n/sock, allowing other code direct access to the root launchd socket
- $ dyldinfo -export amfi.dylib
- export information (from trie):
- [re-export] _kMISValidationOptionValidateSignatureOnly (_kCFUserNotificationTokenKey from CoreFoundation)
- [re-export] _kMISValidationOptionExpectedHash (_kCFUserNotificationTimeoutKey from CoreFoundation)
- [re-export] _MISValidateSignature (_CFEqual from CoreFoundation)
“If we can force MISValidateSignature() to always return 0, any binaries will pass the test. This function is part of libmis.dylib, which is now part of the shared cache, so you can't binary patch this file. Replacing the implementation of a function is a perfect job with MobileSubstrate, unfortunately, no matter how I tried MS can't be injected. Therefore I use a trick: create a "proxy dynamic library" that changes only the MISValidateSignature function, and let the rest pass through.”By clever usage of a codeless dynamic library, existing valid methods (such as CFEqual()) can be re-exported as different methods with the same method signature, such that MISValidateSignature will always return 0, allowing any unsigned binary to run. P.S. The tool developed by the Evad3rs is a great discovery. This utility escalates privileges. It is capable of fully accessing the system partition and it doesn’t corrupt your memory because it can exploit the /var/db/timezone vulnerability in order to get to the root user’s launchd socket. Then it just abuses launchd to load MobileFileIntegrity with an inserted codeless library, which is overriding MISValidateSignature to always return 0. Was it interesting to get to the insides of this exploit? We hope you like it. Thanks, AccuvantLabs blog for this curious information.
Recent Blog
Ultimate Guide: How to turn Off Restricted Mode on iPhone?
Automate Apple GSX check result obtaining?
iRemove Unlock iPhone 5S, 5C, 5, SE, 4S/4 Software
MacOS High Sierra Features: Set Up Websites in Safari on Mac
How to Enable iOS 11 Mail Reply Notification on iPhone 7
How to Bypass Apple Watch Passcode Problem
LetsUnlock Services List
iPhone & iPad Activation Lock Bypass
Use LetsUnlock iCloud Tool to bypass Activation Lock Screen on iPhone and iPad running on iOS version up to 14.6.
Read MoreUnlock Passcode Disabled iPhone or iPad
LetsUnlock iCloud Tool is ready to remove Find My and unlock your passcode disable device running on iOS 13.x.x in one click!
Read MoreMacOS iCloud Activation Lock Bypass
The LetsUnlock Mac iCloud Activation Lock Bypass Tool will help you to remove Activation Lock on an iCloud locked Mac which is stuck on Activation Lock Screen with no need to enter the correct Apple ID and password.
Read MoreMac EFI Firmware Passcode Bypass
The LetsUnlock EFI Bypass Tool is a one button solution, which you click to start the EFI Unlock process. Bypass EFI with out password! Everything else does the software.
Read MoreMacOS iCloud System PIN Bypass
The LetsUnlock MacOS iCloud System PIN Bypass Tool was designed to bypass iCloud PIN lock on macOS without passcode!
Read More