JesusFreke / smali

smali/baksmali
6.34k stars 1.07k forks source link

Cannot get working #602

Closed RickyDivjakovski closed 6 years ago

RickyDivjakovski commented 6 years ago

Please correct me if im doing wrong.. file structure -system --framework ---arm64 ----boot.oat --app ---Gallery2 ----oat -----arm64 ------Gallery2.odex

Executing- java -jar baksmali.jar system/app/Gallery2/oat/arm64/Gallery2.odex -a 25 -x -c /system/framework/arm64/boot.oat -d system/framework

Returns- Exception in thread "main" com.beust.jcommander.MissingCommandException: Expected a command, got system/app/Gallery2/oat/arm64/Gallery2.odex at com.beust.jcommander.JCommander.parseValues(JCommander.java:783) at com.beust.jcommander.JCommander.parse(JCommander.java:282) at com.beust.jcommander.JCommander.parse(JCommander.java:265) at org.jf.baksmali.Main.main(Main.java:90)

What am i doing wrong?

Android 7.1.2 api level 25

salvogiangri commented 6 years ago

Before the .odex file you must write the action you wanna execute. So "d" to disassemble, "x" to deodex

RickyDivjakovski commented 6 years ago

output is

Error occurred while loading class path files. Aborting. org.jf.dexlib2.analysis.ClassPathResolver$ResolveException: org.jf.dexlib2.analysis.ClassPathResolver$NotFoundException: Could not find classpath entry /system/framework/core.jar at org.jf.dexlib2.analysis.ClassPathResolver.(ClassPathResolver.java:145) at org.jf.dexlib2.analysis.ClassPathResolver.(ClassPathResolver.java:105) at org.jf.baksmali.AnalysisArguments.loadClassPathForDexFile(AnalysisArguments.java:129) at org.jf.baksmali.AnalysisArguments.loadClassPathForDexFile(AnalysisArguments.java:86) at org.jf.baksmali.DisassembleCommand.getOptions(DisassembleCommand.java:207) at org.jf.baksmali.DeodexCommand.getOptions(DeodexCommand.java:72) at org.jf.baksmali.DisassembleCommand.run(DisassembleCommand.java:181) at org.jf.baksmali.Main.main(Main.java:102) Caused by: org.jf.dexlib2.analysis.ClassPathResolver$NotFoundException: Could not find classpath entry /system/framework/core.jar at org.jf.dexlib2.analysis.ClassPathResolver.loadLocalOrDeviceBootClassPathEntry(ClassPathResolver.java:216) at org.jf.dexlib2.analysis.ClassPathResolver.(ClassPathResolver.java:120) ... 7 more

JesusFreke commented 6 years ago

See baksmali help classpath for more information

I think you want something like

java -jar baksmali.jar x system/app/Gallery2/oat/arm64/Gallery2.odex -a 25 -d system/framework/arm64/boot.oat
RickyDivjakovski commented 6 years ago

Exact same result.. tried with multiple versions of baksmali too?

JesusFreke commented 6 years ago

sorry, my command was wrong:

java -jar baksmali.jar x system/app/Gallery2/oat/arm64/Gallery2.odex -a 25 -b system/framework/arm64/boot.oat

(-b, not -d)

JesusFreke commented 6 years ago

Closing due to inactivity. Feel free to reopen if you have more info.

realyukii commented 1 year ago

Hi @JesusFreke ! I try your suggestion on stackoverflow

image

I am facing same issue, and want to know the byte offset of 0x9 image

$ adb logcat -v brief -s *:E
--------- beginning of crash
E/AndroidRuntime(19726): FATAL EXCEPTION: main
E/AndroidRuntime(19726): Process: com.telkomsel.roli, PID: 19726
E/AndroidRuntime(19726): java.lang.VerifyError: Verifier rejected class com.telkomsel.roli.optin.helpers.RbHelperClass: okhttp3.OkHttpClient com.telkomsel.roli.optin.helpers.RbHelperClass.h0(android.content.Context) failed to verify: okhttp3.OkHttpClient com.telkomsel.roli.optin.helpers.RbHelperClass.h0(android.content.Context): [0x9] 'this' argument 'Reference: android.content.Context' not instance of 'Precise Reference: okhttp3.OkHttpClient$Builder' (declaration of 'com.telkomsel.roli.optin.helpers.RbHelperClass' appears in /data/app/~~vPoOYvv_Tn1HUymmJsfHqw==/com.telkomsel.roli-Lqo9U1OW5Ph8WEX_ifM4Sw==/base.apk!classes5.dex)

$ baksmali d -r ARGS,DEST,FULLMERGE --off classes5.dex -a 31 -c "C:\Android\platforms\android-31\android.jar"

Error occurred while loading class path files. Aborting.
org.jf.dexlib2.analysis.ClassPathResolver$ResolveException: org.jf.dexlib2.analysis.ClassPathResolver$NotFoundException: Could not find classpath entry /system/framework/core-oj.jar
        at org.jf.dexlib2.analysis.ClassPathResolver.<init>(ClassPathResolver.java:114)
        at org.jf.dexlib2.analysis.ClassPathResolver.<init>(ClassPathResolver.java:154)
        at org.jf.baksmali.AnalysisArguments.loadClassPathForDexFile(AnalysisArguments.java:134)
        at org.jf.baksmali.AnalysisArguments.loadClassPathForDexFile(AnalysisArguments.java:89)
        at org.jf.baksmali.DisassembleCommand.getOptions(DisassembleCommand.java:209)
        at org.jf.baksmali.DisassembleCommand.run(DisassembleCommand.java:183)
        at org.jf.baksmali.Main.main(Main.java:102)
Caused by: org.jf.dexlib2.analysis.ClassPathResolver$NotFoundException: Could not find classpath entry /system/framework/core-oj.jar
        at org.jf.dexlib2.analysis.ClassPathResolver.loadLocalOrDeviceBootClassPathEntry(ClassPathResolver.java:203)
        at org.jf.dexlib2.analysis.ClassPathResolver.<init>(ClassPathResolver.java:89)
        ... 6 more

$ baksmali d -r ARGS,DEST,FULLMERGE --off classes5.dex -a 31 -b "C:\Android\platforms\android-31\android.jar"

Error occurred while loading class path files. Aborting.
org.jf.dexlib2.analysis.ClassPathResolver$ResolveException: org.jf.dexlib2.analysis.ClassPathResolver$NotFoundException: Could not find classpath entry C
        at org.jf.dexlib2.analysis.ClassPathResolver.<init>(ClassPathResolver.java:114)
        at org.jf.baksmali.AnalysisArguments.loadClassPathForDexFile(AnalysisArguments.java:140)
        at org.jf.baksmali.AnalysisArguments.loadClassPathForDexFile(AnalysisArguments.java:89)
        at org.jf.baksmali.DisassembleCommand.getOptions(DisassembleCommand.java:209)
        at org.jf.baksmali.DisassembleCommand.run(DisassembleCommand.java:183)
        at org.jf.baksmali.Main.main(Main.java:102)
Caused by: org.jf.dexlib2.analysis.ClassPathResolver$NotFoundException: Could not find classpath entry C
        at org.jf.dexlib2.analysis.ClassPathResolver.loadLocalOrDeviceBootClassPathEntry(ClassPathResolver.java:203)
        at org.jf.dexlib2.analysis.ClassPathResolver.<init>(ClassPathResolver.java:89)
        ... 5 more

I try to disassemble classes5.dex But got an error as shown above 😢

realyukii commented 1 year ago

After reading through baksmali help classpath I followed these instructions and succeeded in generating the disassembled version of classes5.dex

adb pull /system/framework/framework.jar
baksmali d -r ARGS,DEST,FULLMERGE --off classes5.dex -a 31 -b ./framework.jar
realyukii commented 1 year ago

in the smali file, does #@9 correspond to 0x9 mentioned in logcat?

realyukii commented 1 year ago

Ah! looks like the smali shown in the jadx image is correct, and I installed the apk wrong, I didn't even install the latest apk patches