You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Description: Hook the target method with Objection.
183
-
* params: 1. method: the tagrget API. (type: str or method instance) 2. watchArgs: Return Args information if True. (type: boolean) 3. watchBacktrace: Return backtrace information if True. (type: boolean) 4. watchRet: Return the return information of the target API if True (type: boolean).
184
-
* return: none
185
-
186
-
</details>
187
-
188
-
### Analyzing real case (InstaStealer) using Quark Script
189
-
#### Quark Script that dynamic hooks the method containing urls
190
-
The scenario is simple! We'd like to dynamic hooking the methods in the malware that contains urls. We can use APIs above to write Quark Script.
print(f"\nThe detected behavior was called by -> {method.fullName}")
211
-
212
-
print("\nAttempt to hook the method:")
213
-
obj = Objection("127.0.0.1:8888")
214
-
215
-
obj.hookMethod(method,
216
-
watchArgs=True,
217
-
watchBacktrace=True,
218
-
watchRet=True)
219
-
print(f"\tHook -> {method.fullName}")
220
-
221
-
for methodCaller in method.getXrefFrom():
222
-
obj.hookMethod(methodCaller,
223
-
watchArgs=True,
224
-
watchBacktrace=True,
225
-
watchRet=True)
226
-
print(f"\tHook -> {methodCaller.fullName}")
227
-
228
-
for methodCallee, _ in method.getXrefTo():
229
-
obj.hookMethod(methodCallee,
230
-
watchArgs=True,
231
-
watchBacktrace=True,
232
-
watchRet=True)
233
-
print(f"\tHook -> {methodCallee.fullName}")
234
-
235
-
print("\nSee the hook results in Objection's terminal.")
236
-
```
237
-
> Note: Please make sure you have the dynamic analysis environment ready before executing the script.
238
-
> 1. Objection installed and running. Check the guideline [here](https://github.com/sensepost/objection/wiki/Installation).
239
-
> 2. Android Virtual Machine with frida installed. Check the guideline [here](https://frida.re/docs/android/).
240
-
> 3. Or a rooted Android Device (Google Pixel 6) with frida installed.
241
-
> Check the root guideline [here](https://forum.xda-developers.com/t/guide-root-pixel-6-with-magisk-android-12-1.4388733/), frida install guideline is the [same]((https://frida.re/docs/android/)) with Android Virtual Machine.
242
-
243
-
#### Quark Script Result
244
-

245
-
246
-
#### Logs on the Objection terminal (hooking)
247
-

248
-
249
-
#### Method (callComponentMethod) with urls is detected triggered!
250
-

251
-
252
-
### Quark Script used as a vulnerability finder
253
-
254
-
#### Detect CWE-798 in Android Application
255
-
256
-
This scenario seeks to find hard-coded credentials in the APK file. See [CWE-798](https://cwe.mitre.org/data/definitions/798.html) for more details.
257
-
258
-
Let's use this [APK](https://github.com/oversecured/ovaa) and the above APIs to show how Quark script find this vulnerability.
259
-
260
-
First, we design a detection rule `findSecretKeySpec.json` to spot on behavior uses method SecretKeySpec. Then, we get all the parameter values that input to this method. From the returned parameter values, we identify it's a AES key and parse the key out of the values. Finally, we dump all strings in the APK file and check if the AES key is in the strings. If the answer is YES, BINGO!!! We find hard-coded credentials in the APK file.
0 commit comments