This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
howto:iosfrida [2017/10/17 03:40] czokie [9.2. Implement enhanced SSL pinning hook] |
howto:iosfrida [2017/10/22 00:42] czokie [6.3 Launch in Springboard] |
||
---|---|---|---|
Line 62: | Line 62: | ||
Download this file to ~/Documents | Download this file to ~/Documents | ||
- | < | + | < |
{ | { | ||
" | " | ||
Line 73: | Line 73: | ||
</ | </ | ||
+ | Or, if you're ready to do some on-board hooking without any external comms, use this instead | ||
+ | <code java FridaGadget.config> | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | and create Tweak.js in the same directory with your required hooks. | ||
===== 2. Generate (or renew) signing credentials ===== | ===== 2. Generate (or renew) signing credentials ===== | ||
Line 95: | Line 108: | ||
rm -rf Payload | rm -rf Payload | ||
mkdir -p " | mkdir -p " | ||
- | cp FridaGadget.config " | + | cp FridaGadget.config |
zip -r "DJI GO 4.ipa" Payload | zip -r "DJI GO 4.ipa" Payload | ||
objection patchipa -s "DJI GO 4.ipa" --codesign-signature <your signature> | objection patchipa -s "DJI GO 4.ipa" --codesign-signature <your signature> | ||
Line 121: | Line 134: | ||
After launch is complete, you can disconnect the USB cable. Make sure you promptly launch Frida if you have it in " | After launch is complete, you can disconnect the USB cable. Make sure you promptly launch Frida if you have it in " | ||
==== 6.3 Launch in Springboard ==== | ==== 6.3 Launch in Springboard ==== | ||
- | Ideally, we want to be able to launch | + | We can now launch |
===== 7. Launch objection ===== | ===== 7. Launch objection ===== | ||
Line 157: | Line 170: | ||
The default objection hook code is [[https:// | The default objection hook code is [[https:// | ||
- | We found that this was working for SOME requests, but not all. Particularly it appears on IOS10. Instead, you can replace the default hook with [[https:// | + | We found that this was working for SOME requests, but not all. Particularly it appears on IOS10. Instead, you can replace the default hook with [[https:// |
wget -q -O- https:// | wget -q -O- https:// | ||
Line 165: | Line 178: | ||
==== 9.3. Build our first hook ==== | ==== 9.3. Build our first hook ==== | ||
Frida is new to me - I would like to build a hook that tricks the DJI go app into thinking the terms and conditions have already been accepted - even for a new install. | Frida is new to me - I would like to build a hook that tricks the DJI go app into thinking the terms and conditions have already been accepted - even for a new install. | ||
+ | |||
+ | <code c> | ||
+ | bool __cdecl -[DJITermsNotificationController shouldShowTerms](DJITermsNotificationController *self, SEL a2) | ||
+ | { | ||
+ | void *v2; // x0 | ||
+ | void *v3; // x0 | ||
+ | void *v4; // x21 | ||
+ | BOOL v5; // w22 | ||
+ | |||
+ | objc_msgSend(& | ||
+ | v2 = (void *)objc_retainAutoreleasedReturnValue(); | ||
+ | objc_msgSend(v2, | ||
+ | v3 = (void *)objc_retainAutoreleasedReturnValue(); | ||
+ | objc_msgSend(v3, | ||
+ | v4 = (void *)objc_retainAutoreleasedReturnValue(); | ||
+ | NSLog(); | ||
+ | if ( (unsigned __int64)objc_msgSend(v4, | ||
+ | LOBYTE(v5) = 0; | ||
+ | else | ||
+ | v5 = (unsigned __int64)objc_msgSend(v4, | ||
+ | objc_release(); | ||
+ | objc_release(); | ||
+ | objc_release(); | ||
+ | return v5; | ||
+ | } | ||
+ | // 10276FD28: using guessed type __CFString cfstr_Applelanguages; | ||
+ | // 10279F268: using guessed type __CFString cfstr_Ru_0; | ||
+ | // 1027BEB88: using guessed type __CFString cfstr_Zh_0; | ||
+ | // 102D88FF0: using guessed type __objc2_ivar stru_102D88FF0; | ||
+ | </ | ||
+ | |||
+ | So... What does the frida patch look like... (Thanks jezzab) | ||
+ | |||
+ | <code javascript djihook.js> | ||
+ | //Terms and Conditions Bypass - jezzab | ||
+ | var hook = ObjC.classes.DJITermsNotificationController[" | ||
+ | Interceptor.attach(hook.implementation, | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | }); | ||
+ | </ | ||
+ | |||
+ | Subsequently, | ||
+ | |||
+ | He provided the following as a replacement sample for our simple hook. | ||
+ | <code javascript djihook2.js> | ||
+ | var DJITermsNotificationController = ObjC.classes.DJITermsNotificationController; | ||
+ | |||
+ | var shouldShowTerms = DJITermsNotificationController[' | ||
+ | shouldShowTerms.implementation = ObjC.implement(shouldShowTerms, | ||
+ | return false; | ||
+ | });</ | ||
+ | |||
+ | or if we want to see the original value... | ||
+ | |||
+ | <code javascript djihook3.js> | ||
+ | var DJITermsNotificationController = ObjC.classes.DJITermsNotificationController; | ||
+ | |||
+ | var shouldShowTerms = DJITermsNotificationController[' | ||
+ | var shouldShowTermsImpl = shouldShowTerms.implementation; | ||
+ | shouldShowTerms.implementation = ObjC.implement(shouldShowTerms, | ||
+ | var originalResult = shouldShowTermsImpl(handle, | ||
+ | console.log(' | ||
+ | return false; | ||
+ | }); | ||
+ | </ | ||
+ | |||
+ | Some other comments... What about the original data that comes into this function? What can we do with it? | ||
+ | |||
+ | oleavr: method arguments follow self and sel (the first two implicit arguments). you can use var self = new ObjC.Object(handle); | ||
+ | |||
+ | Lastly - If we need any intrusive hooks in our code - we can add the below if we need to have intrusive hooks for debugging. | ||
+ | if (Process.codeSigningPolicy === ' | ||
==== 9.4. First Standalone Patch ==== | ==== 9.4. First Standalone Patch ==== | ||
- | Install | + | Good news. We accomplished |
+ | * We need to use swizzling instead of intercepting in our hooks | ||
+ | * The author of Frida has agreed to do a patch to the gadget, so that if a phone is not jailbroken | ||
+ | * The above change is now in Frida... To implement this, we need the following frida configuration | ||
+ | <code java> | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | * One more thing... The on_change config item. This is another mod that oleavr made to Frida - In IOS, we can upload a .js file to user space via iTunes or ifunbox etc. When frida loads up, it will look first in the documents location for a JS file. If found, it will use it. If not found, it will look for one in the app from build time. The advantage of this is that we can update the JS without a complete app rebuild. | ||
==== 9.4. Add more Standalone Patches ==== | ==== 9.4. Add more Standalone Patches ==== | ||
Create more hooks and package with a frida tweak' | Create more hooks and package with a frida tweak' | ||
Line 176: | Line 278: | ||
- Login " | - Login " | ||
+ | |||
+ | ==== 9.5. Persistant Configuration ==== | ||
+ | We need a way to store some persistent configuration that can be read by all of these hooks. At first glance, there is SQLite support, which will do the storage, but we really don't want to execute SQL code each time we want to test if a particular widget is enabled or disabled. Taking that forward, the next logical place to go would be to use **frida-compile**, | ||
+ | |||
+ | Some useful details are [[https:// | ||
+ | |||
+ | There are some Frida-specific modules as well - like frida-uikit for UI automation on iOS | ||
+ | |||
+ | ==== 9.6. UI Settings ==== | ||
+ | Having build a persistent configuration object, we now need to think about how we can build our own UI that will allow our custom settings to be changed. | ||
===== 10. General Notes ===== | ===== 10. General Notes ===== | ||
==== 10.1. Useful LLDB commands ==== | ==== 10.1. Useful LLDB commands ==== | ||
Line 208: | Line 320: | ||
* [[https:// | * [[https:// | ||
+ | ==== 10.5. Building Frida ==== | ||
+ | |||
+ | We've worked with the author of Frida for a few things... Below is a simple set of instructions to rebuild the Frida Gadget for IOS, to take advantage of some new tweaks. | ||
+ | |||
+ | * Install Xcode with command-line tools installed (Should already be done above) | ||
+ | * Install Node.js (from nodes.org). | ||
+ | * Do a git clone of the Frida repo | ||
+ | * Set an environment variable IOS_CERTID to be the ID of a valid code-signing certificate | ||
+ | * make gadget-ios | ||
+ | |||
+ | |||
+ | What does that bring us? We have a new config option | ||
+ | |||
+ | { " | ||
+ | |||
+ | This option will allow us to have a frida modified IPA that will run on our device, launched by springboard with no special debug startup sequences required. | ||
+ | ===== 11. Credits ===== | ||
+ | oleavr from Frida has been awesome through this process. Some of our needs were not readily possible in the existing Frida code. He has made changes throughout the process to the Frida-gadget which have been enormously helpful. In addition, he has provided guidance and coaching as we came up to speed with using Frida... so thanks oleavr. |