jeb4frida icon indicating copy to clipboard operation
jeb4frida copied to clipboard

Broken Script Output for Non Ascii/Non Printable Named Method

Open apkunpacker opened this issue 3 years ago • 4 comments
trafficstars

Small Sample Apk With Non Printable Method Name :

newtest_1.0_flows.apk.zip

jeb4frida

Exact Error -

🔥 Jeb4frida...
IJavaSourceUnit / IDexUnit detected
🔥 Here's a fresh Frida hook...
----------------------------------------------------------------------------------------------------
// Usage: frida -U -f com.example.myapplication -l hook.js --no-pause
[E] Script execution error: com.pnfsoftware.jeb.client.script.ScriptExecutionException: Traceback (most recent call last):
[E]   File "E:\JEB4.12\scripts\samples\Jeb4frida.py", line 39, in run
[E]     self.handle_java_dex(ctx, dexdec)
[E]   File "E:\JEB4.12\scripts\samples\Jeb4frida.py", line 73, in handle_java_dex
[E]     print(self.gen_java_hook(java_class, java_methods))
[E]   File "E:\JEB4.12\scripts\samples\Jeb4frida.py", line 79, in gen_java_hook
[E]     frida_hook = "    var {} = Java.use('{}');\n".format(class_name_var, class_name)
[E] UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)
[E] 

Possible Fix - Put method name in " " like ClassName["MethodName"].overload......

apkunpacker avatar Mar 17 '22 12:03 apkunpacker

I forgot the u prefix on a bunch of strings. So now it is trying to format these ASCII strings with Unicode characters, hence it fails. Adding u fixes the issue but makes the Frida script still look funky...

Hamz-a avatar Mar 17 '22 13:03 Hamz-a

https://github.com/Hamz-a/jeb4frida/commit/094830df8c129582baf80cd5af8129b7ebd6b371 Fixes the "JEB error", but would be better to encode "weird" characters for cleaner Frida scripts.

Hamz-a avatar Mar 17 '22 13:03 Hamz-a

Jeb4frida.zip [+] add Auto copy frida functio to clipBoard [+] removed gen_how_to function (the frida hook was not generated because it didn't have IApkUnit and getMainProject) i working with lots of dump.dex that not have project and its function interfered

Thank you very much for the project, it helps a lot :D

kinetikFR avatar Dec 12 '23 05:12 kinetikFR

about jadX generates a simple variable reading example

.method static constructor ()V .registers 1 00000000 const/16 v0, 18 00000004 new-array v0, v0, [I 00000008 fill-array-data v0, :14 0000000E sput-object v0, A->AMLDZHTU:[I 00000012 return-void

JadX output : let A = Java.use("o.A"); AMLDZHTU = A.AMLDZHTU.value;

kinetikFR avatar Dec 12 '23 05:12 kinetikFR