Hello, i want to know how can i assemble the DEX Files after extracting them out? i tried the command :
Code:
java -jar baksmali.jar out
but i get this error
Code:
C:\>java -jar baksmali.jar out
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: out: not a file
at org.jf.dexlib.Util.FileUtils.readFile(FileUtils.java:77)
at org.jf.dexlib.DexFile.<init>(DexFile.java:288)
at org.jf.baksmali.main.main(main.java:161)
i can extract it out using :
Code:
java -jar smali.jar classes.dex
any help will be appreciated
instead out out, put the filename? classes.dex? see if that works. I havent used baksmali/smali but i would imagine thats whats happening as the exception says not a file lol
I think the Command you're Looking for is
run following from command line: java -jar baksmali.jar -o classout/ classes.dex
that just extracts the file ;/ i need to put the extracted files back ;(
I think the Command you're Looking for is
run following from command line: java -jar baksmali.jar -o classout/ classes.dex
Click to expand...
Click to collapse
Fails on the same files using both Rom kitchen and xUltimate. Happy I've followed both tutorials to the letter. What do you suggest I do next? I'm just eager to learn. Who knows where that will lead.
Here's the five files from kitchens log.
smali/baksmali version: 1.3.2
Folder: app
-------------------
* Warning: GoogleQuickSearchBox.odex (trying brute-force method)
* ERROR: Aborting GoogleQuickSearchBox.odex!
* Warning: Maps.odex (trying brute-force method)
* ERROR: Aborting Maps.odex!
* Warning: Phonesky.odex (trying brute-force method)
* ERROR: Aborting Phonesky.odex!
* Warning: PlusOne.odex (trying brute-force method)
* ERROR: Aborting PlusOne.odex!
* Warning: VoiceSearch.odex (trying brute-force method)
* ERROR: Aborting VoiceSearch.odex!
NOW AT FILE 2 OF 5 IN system/app: Maps.odex
Disassembling Maps.odex ...
java -Xmx512m -jar baksmali.jar -a 10 -d ../framework -x Maps.odex
Error occured while loading boot class path files. Aborting.
org.jf.dexlib.Code.Analysis.ClassPath$ClassNotFoundException: Could not find int
erface Landroid/os/Parcelable$ClassLoaderCreator;
at org.jf.dexlib.Code.Analysis.ClassPath$ClassDef.loadAllImplementedInte
rfaces(ClassPath.java:865)
at org.jf.dexlib.Code.Analysis.ClassPath$ClassDef.<init>(ClassPath.java:
690)
at org.jf.dexlib.Code.Analysis.ClassPath.loadClassDef(ClassPath.java:280
)
at org.jf.dexlib.Code.Analysis.ClassPath.initClassPath(ClassPath.java:16
3)
at org.jf.dexlib.Code.Analysis.ClassPath.InitializeClassPathFromOdex(Cla
ssPath.java:110)
at org.jf.baksmali.baksmali.disassembleDexFile(baksmali.java:104)
at org.jf.baksmali.main.main(main.java:293)
Error while loading class Landroid/support/v4/os/ParcelableCompatCreatorHoneycom
bMR2; from file Maps.odex
Error while loading ClassPath class Landroid/support/v4/os/ParcelableCompatCreat
orHoneycombMR2;
-> Using brute-force method (ignore above error if successful):
Disassembling Maps.odex ...
java -Xmx512m -jar baksmali.jar -a 10 -d ../framework -c :am.jar:android.policy.
jar:android.test.runner.jar:bmgr.jar:bouncycastle.jar:com.android.location.provi
der.jar:com.google.android.maps.jar:core-junit.jar:core.jar:ext.jar:framework.ja
r:ime.jar:input.jar:javax.obex.jar:monkey.jarm.jar:services.jar:sqlite-jdbc.ja
r:svc.jar -x Maps.odex
Error occured while loading boot class path files. Aborting.
org.jf.dexlib.Code.Analysis.ClassPath$ClassNotFoundException: Could not find int
erface Landroid/os/Parcelable$ClassLoaderCreator;
at org.jf.dexlib.Code.Analysis.ClassPath$ClassDef.loadAllImplementedInte
rfaces(ClassPath.java:865)
at org.jf.dexlib.Code.Analysis.ClassPath$ClassDef.<init>(ClassPath.java:
690)
at org.jf.dexlib.Code.Analysis.ClassPath.loadClassDef(ClassPath.java:280
)
at org.jf.dexlib.Code.Analysis.ClassPath.initClassPath(ClassPath.java:16
3)
at org.jf.dexlib.Code.Analysis.ClassPath.InitializeClassPathFromOdex(Cla
ssPath.java:110)
at org.jf.baksmali.baksmali.disassembleDexFile(baksmali.java:104)
at org.jf.baksmali.main.main(main.java:293)
Error while loading class Landroid/support/v4/os/ParcelableCompatCreatorHoneycom
bMR2; from file Maps.odex
Error while loading ClassPath class Landroid/support/v4/os/ParcelableCompatCreat
orHoneycombMR2;
ERROR: Aborting Maps.odex
Hi,
I got myself the android.policy.jar (313bytes) and android.policy.odex (350.584bytes) from the /system/framework.
I then copied the whole /system/framework folder from my P880 for baksmali, also.
I then baksmalied the android.policy.odex with:
java -Xmx512m -jar baksmali.jar -x android.policy.odex -d framework -o output
and resmalied it (this is a test) with:
java -Xmx512m -jar smali.jar output/ -o classes.dex
This all works without an error message.
I end up with the classes.dex (314.716bytes).
Here my trouble begins. I put classes.dex with 7zip and normal compression into the original android.policy.jar (now 143.886bytes)
I removed the ORIGINAL android.policy.odex and android.policy.jar from my phone and copied the new android.policy.jar (143.886bytes) into the their place (/system/framework).
After reboot I am stuck with a bricked phone
To investigate, I then reodexed android.policy.jar with
dexopt-wrapper android.policy.jar new.android.policy.odex /system/framework/core.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/framework2.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/apache-xml.jar:/system/framework/filterfw.jar:/system/framework/com.lge.bluetooth.jar:/system/framework/com.lge.core.jar
which works fine, but my NEW android.policy.odex is not the original 350.584bytes, but 322.368bytes
I added the file signature from the old odex, but the size remains the same.
My questions:
Why did my android.policy.jar (143.886bytes) not work, although I changed none of the coding?
Why did my android.policy.odex (322.368bytes) not have the same size as the original odex in the rom?
I attach these two files for you. Please help me. :crying:
Thank you!
PS: I had to rename the odex to txt, because it cant be attached otherwise.
I had a look at LG GearBox for Optimus 4X application source code and saw that it uses functions in com.lge.systemservice.core.jar file which is located in /system/framework folder.
Since this application does not work on JB, I thought I could find similar functions for JB in other jar files of the framework and copied the whole framework folder to my PC and tried to baksmali/smali com.lge.systemservice.core.odex file.
These are the commands I tried: (I have the latest versions of smali and baksmali)
java -jar baksmali.jar -x -o .\out com.lge.systemservice.core.odex
java -jar smali.jar out
The first line works OK and creates the smali files but I need to put them back to an "out.dex" file with the second line so that I can use dex2jar application to turn the smali files to java .class files to read the source code better. (dex2jar works on dex files, not on odex files)
The second line does not work and outputs lots of error messages.
Is there any developer out there who has ever done this operation to reverse engineer framework odex files?
A second question: Do the source files for the framework exist in the source code of v20A which is on LG Open web site?
My questions may be a bit complicated but I'm sure they will mean something to those who have worked with these tools.
As far as I understand, nobody in this forum has had experience with decompiling Android applications.
Have you tried specifying the framework path on the baksmali line?
I've never got errors from running smali before.
Sent from my LG-P880 using Tapatalk 4 Beta
arararagi said:
Have you tried specifying the framework path on the baksmali line?
I've never got errors from running smali before.
Sent from my LG-P880 using Tapatalk 4 Beta
Click to expand...
Click to collapse
Baksmali is ok. I have errors with smali line.
Sent from my LG-P880
google virtous ten studio a nice tool to decompile/compile jars/apks
or java -Xmx512M –jar smali.jar dex –o classes.dex
Sent from my LG-P880 using xda app-developers app
postacik said:
Baksmali is ok. I have errors with smali line.
Sent from my LG-P880
Click to expand...
Click to collapse
Does the error on the smali line go away if you specify the framework path on the baksmali line?
arararagi said:
Does the error on the smali line go away if you specify the framework path on the baksmali line?
Click to expand...
Click to collapse
No, it doesn't.
Can you try to baksmali and then smali the file I specified in the first post?
By the way, thank you all very much for the replies.
Sent from my LG-P880
postacik said:
No, it doesn't.
Can you try to baksmali and then smali the file I specified in the first post?
By the way, thank you all very much for the replies.
Sent from my LG-P880
Click to expand...
Click to collapse
Works fine.
Code:
$ baksmali -x -d eur_open_jb_system/system/framework -o com.lge.systemservice.core eur_open_jb_system/system/framework/com.lge.systemservice.core.odex
$ smali -o com.lge.systemservice.core.dex com.lge.systemservice.core
$ ls -ln com.lge.systemservice.core.dex
-rw-rw-r-- 1 1000 1000 98816 Jun 11 12:46 com.lge.systemservice.core.dex
arararagi said:
Works fine.
Code:
$ baksmali -x -d eur_open_jb_system/system/framework -o com.lge.systemservice.core eur_open_jb_system/system/framework/com.lge.systemservice.core.odex
$ smali -o com.lge.systemservice.core.dex com.lge.systemservice.core
$ ls -ln com.lge.systemservice.core.dex
-rw-rw-r-- 1 1000 1000 98816 Jun 11 12:46 com.lge.systemservice.core.dex
Click to expand...
Click to collapse
So you are awake at this time of the night.(Well, the sun is rising here in Turkey)
I tried it again with your syntax, thinking I might have misspelled some of the options but it's still the same. I get errors like the following:
Code:
java -jar baksmali.jar -x -d ./framework -o com.lge.systemservice.core ./framework/com.lge.systemservice.core.odex
java -jar smali.jar -o com.lge.systemservice.core.dex com.lge.systemservice.core
Code:
com.lge.systemservice.core\com\lge\systemservice\core\nfclgmanager\NfcLgManager.
smali[181,15] no viable alternative at input 'e'
com.lge.systemservice.core\com\lge\systemservice\core\nfclgmanager\NfcLgManager.
smali[181,17] no viable alternative at input 'Landroid/os/RemoteException;'
com.lge.systemservice.core\com\lge\systemservice\core\nfclgmanager\NfcLgManager.
smali[193,4] Error for input '.parameter': Invalid directive
com.lge.systemservice.core\com\lge\systemservice\core\nfclgmanager\NfcLgManager.
smali[194,4] Error for input '.parameter': Invalid directive
com.lge.systemservice.core\com\lge\systemservice\core\nfclgmanager\NfcLgManager.
smali[193,15] mismatched input '"command"' expecting END_METHOD_DIRECTIVE
I am working on Windows. Are you on cygwin or Linux?
Anyway, thank your for the attached file. Now I will try dex2jar on that.
postacik said:
So you are awake at this time of the night.(Well, the sun is rising here in Turkey)
I tried it again with your syntax, thinking I might have misspelled some of the options but it's still the same. I get errors like the following:
Code:
java -jar baksmali.jar -x -d ./framework -o com.lge.systemservice.core ./framework/com.lge.systemservice.core.odex
java -jar smali.jar -o com.lge.systemservice.core.dex com.lge.systemservice.core
Code:
com.lge.systemservice.core\com\lge\systemservice\core\nfclgmanager\NfcLgManager.
smali[181,15] no viable alternative at input 'e'
com.lge.systemservice.core\com\lge\systemservice\core\nfclgmanager\NfcLgManager.
smali[181,17] no viable alternative at input 'Landroid/os/RemoteException;'
com.lge.systemservice.core\com\lge\systemservice\core\nfclgmanager\NfcLgManager.
smali[193,4] Error for input '.parameter': Invalid directive
com.lge.systemservice.core\com\lge\systemservice\core\nfclgmanager\NfcLgManager.
smali[194,4] Error for input '.parameter': Invalid directive
com.lge.systemservice.core\com\lge\systemservice\core\nfclgmanager\NfcLgManager.
smali[193,15] mismatched input '"command"' expecting END_METHOD_DIRECTIVE
I am working on Windows. Are you on cygwin or Linux?
Anyway, thank your for the attached file. Now I will try dex2jar on that.
Click to expand...
Click to collapse
Linux, but it's all Java so it doesn't matter. I'm using 1.4.2.
I used dex2jar on the dex file you provided and unfortunately it does not contain the functions that LG GearBox for Optimus 4X uses so I think I have to look elsewhere.
But the file contains a class which contains functions about bootloader unlocking.
I have not followed the bootloader unlock discussions lately but I think it may help somebody to better understand how it works.
The file is attached to this post.
arararagi said:
Linux, but it's all Java so it doesn't matter. I'm using 1.4.2.
Click to expand...
Click to collapse
I'm also using 1.4.2 version of smali and baksmali.
In theory yes, it should not matter since it's all Java but I tried the same commands on cygwin and it worked without any problems.
On cygwin, I could use the smali and baksmali scripts provided along with tha jar files. I don't have time to investigate why, but with the scripts it worked flawlessly.
Thank you very much for the enlightment.
Code:
./baksmali -x -d ./framework -o com.lge.systemservice.core ./framework/com.lge.systemservice.core.odex
./smali -o com.lge.systemservice.core.dex com.lge.systemservice.core
tobixdev said:
google virtous ten studio a nice tool to decompile/compile jars/apks
or java -Xmx512M –jar smali.jar dex –o classes.dex
Sent from my LG-P880 using xda app-developers app
Click to expand...
Click to collapse
I wasn't aware of Virtous Ten Studio until you wrote here. Thank you very much.
It is a great GUI which uses baksmali, smali, dex2jar, apktool and signapk under cover.
All the things I've learned by reading many documents have been packed into one application.
Hello,
I'm currently trying to run apktool using dalvikvm in the customize.sh script:
Bash:
apktool_d() {
#ANDROID_DATA=$TMPDIR_JCD ANDROID_ROOT=/system LD_LIBRARY_PATH=/system/lib dalvikvm -Xbootclasspath:/system/framework/core.jar:/system/framework/conscrypt.jar:/system/framework/apache-xml.jar -classpath $BIN/apktool_*-dexed.jar brut.apktool.Main d --frame-path $TMPDIR_JCD/framework --no-src -o $TMPDIR_JCD/resout $1
dalvikvm -classpath $BIN/apktool_*-dexed.jar brut.apktool.Main d --no-src -o $TMPDIR_JCD/resout $1
test $? != 0 && abort "Decoding APK resources failed. Aborting..."
}
I've tried to port that code from an outdated template: https://github.com/djb77/magisk-module-template-apkpatcher
When using the commented out method the command aborts with "Decoding APK resources failed" and logcat *:E is telling me the following:
Code:
04-17 21:11:53.649 11641 11641 E dalvikvm: Could not create image space with image file '/system/framework/boot.art'. Attempting to fall back to imageless running. Error was: Unexpected component count in /system/framework/arm/boot.art, received 11, expected non-zero and <= 3
04-17 21:11:53.677 11641 11641 E dalvikvm: Could not initialize without image: Boot classpath is empty.
When trying the second approach without -Xbootclasspath and so on I'm getting a NullPointerException directly in the magisk log (saved file):
Code:
I: Using Apktool 2.3.4 on Bluetooth.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
Exception in thread "main" java.lang.ExceptionInInitializerError
at brut.util.OSDetection.isMacOSX(OSDetection.java:28)
at brut.androlib.res.AndrolibResources.getFrameworkDir(AndrolibResources.java:913)
at brut.androlib.res.AndrolibResources.getFrameworkApk(AndrolibResources.java:754)
at brut.androlib.res.AndrolibResources.loadFrameworkPkg(AndrolibResources.java:116)
at brut.androlib.res.data.ResTable.getPackage(ResTable.java:84)
at brut.androlib.res.data.ResTable.getResSpec(ResTable.java:67)
at brut.androlib.res.data.ResTable.getResSpec(ResTable.java:63)
at brut.androlib.res.decoder.ResAttrDecoder.decode(ResAttrDecoder.java:39)
at brut.androlib.res.decoder.AXmlResourceParser.getAttributeValue(AXmlResourceParser.java:385)
at org.xmlpull.v1.wrapper.classic.XmlPullParserDelegate.getAttributeValue(XmlPullParserDelegate.java:69)
at brut.androlib.res.decoder.XmlPullStreamDecoder$1.parseManifest(XmlPullStreamDecoder.java:97)
at brut.androlib.res.decoder.XmlPullStreamDecoder$1.event(XmlPullStreamDecoder.java:65)
at brut.androlib.res.decoder.XmlPullStreamDecoder.decode(XmlPullStreamDecoder.java:141)
at brut.androlib.res.decoder.XmlPullStreamDecoder.decodeManifest(XmlPullStreamDecoder.java:153)
at brut.androlib.res.decoder.ResFileDecoder.decodeManifest(ResFileDecoder.java:155)
at brut.androlib.res.AndrolibResources.decodeManifestWithResources(AndrolibResources.java:204)
at brut.androlib.Androlib.decodeManifestWithResources(Androlib.java:136)
at brut.androlib.ApkDecoder.decode(ApkDecoder.java:122)
at brut.apktool.Main.cmdDecode(Main.java:164)
at brut.apktool.Main.main(Main.java:73)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
at brut.util.OSDetection.<clinit>(OSDetection.java:21)
... 20 more
Decoding APK resources failed. Aborting...
! Installation failed
After some research I tried to find out if the customize.sh is running as root because some posts telling that setting LD_LIBRARY_PATH setting as root fixed those "Could not create image space" dalvikvm errors but can't find any info about that. see https://github.com/termux/termux-packages/issues/900#issuecomment-322207233
I'm out of ideas and happy for any help.
Thanks in advance
Danny.