Frida is a Dynamic instrumentation toolkit for developers, reverse-engineers, and security researchers.
The Frida framework allows dynamic introspection of running applications and resources. It also has the ability to inject JavaScript in to a black box process, allowing you to hook functions, apis and trace sensitive functions such as cryptographic API’s.
Frida uses Gadget to hook to the required processes. This is in either the form of a .so file or a .dylib file, for mobile devices.
Using Frida.
To use Frida, the device that is being targeted must either have the frida-server installed on the device to allow communication to the device or a “Gadget” embedded in the application. There is two different methods for this.
Jailbroken Device - (iOS)
Non Jailbroken Device - (iOS)
Android Emulator/Rooted Device - (Android)
I typically for most testing purposes use a Genymotion emulator. These run on a x86 architecture so uploading the arm version WILL NOT work. Instead there is a quiet simple process. The script provided below will push a Frida server which will act a “Gadget” to a rooted android device.
There is a slight mod to the script which allows it to upload and detect the architecture that the emulator is running and upload the file directory to the device using android debug bridge or adb for short.
There is a slight mod to the script which allows it to upload and detect the architecture that the emulator is running and upload the file directory to the device using android debug bridge or adb for short.
##Non Rooted - (Android)
Tips:
Set alias to route
This alias will trace the open calls that frida uses.
This will track the recv function calls
###Tip:
using wifi adb and adb connect <deviceIP>:5555 makes some debugging processes less of a hassle.
Objection
Objection is a dynamic instrumentation framework which heavily uses the Frida framework.
Developed and maintained by leonza
Installing objection is extremely simple as pip3 install objection. This will install objection and Frida.
Method Hooking Objection.
There are a number of functions and features objection has one such is the way Objection is able to dynamically hook methods and back trace allowing in runtime. This can allow a researcher to bypass jailbreak and root protections, as well as a many of functions
ios hooking class list will list all the available classes with the assoicated application.
Using the identified classes we can look at the class methods and use objection to hook those and tamper with them
Locating the Jailbroken class by saving output and using grep to find the JailbrokenVC
ios hooking class_method <class> this command will then list the class methods associated to the previously identified classes.
Now we have the knowledge the class method to use for hooking purposes would end up being
+[JailBreakDetection isJailBroken]. This is made up of the + being assoicated with the class method and the class is called first followed by the method.
Now we can use this too hook the class to watch and modify its value using the command
ios hooking watch method "+[JailBreakDetection isJailBroken]" --dump-args --dump-return --dump-backtrace
Now we can see the return value being set to 0x1 which is causes the application to display the device is “Jailbroken” however, we can set the value to 0x0. This will change the return value to the application, causing it to bypass the jailbroken detection and display “This is not jailbroken”
Plugin Code
Writing plugin code for objection is extremely simple the code below, will enumerate the files listed in the directories and download them to the local environment.