Smali/Baksmali - T-Mobile LG G5 Questions & Answers

Hey guys I'm wondering if someone could help me setup smali/baksmali on linux.
I downloaded the jar. Put the jar, the odex file, and the folder containing my framework files inside the same folder opened a command window inside that folder.
But when I try to call baksmali with
java -jar baksmali-2.2b4.jar -x LGEIME.odex -d ddt -o outclass
I get an error saying -x is an unknown command.
Thanks for any help anyone can provide.

Figured out the new smali/baksmali has new commands. Haben't had to deodex anything, but have smalied a dex file.

Related

[Fix] Mobile Hotspot Hack Reposted for OTA 4.24.651.1

I didn't write this hack, but it appears to work with the new stock GB update.
I did edit the script and zip archive so it wouldn't need any external exe's or libs to apply. Just copy the newest framework.jar file to the script directory and run the HackHotspot.bat file. Then simply run these ADB commands from a dos window.
------
adb shell
mount /system
exit
adb push framework.jar /system/framework.jar
-------
clear Dalvik and fix permissions if desired
Reboot Phone
Done!
Much appreciated but way over my head (I've never done anything with ADB). Any chance of getting this, and the USB debugging notification fix, in a flashable form?
The debug fix is the one that doesn't display the statusbar icon when connected?
I'll see what I can do for ya
townsenk said:
Just copy the newest framework.jar file to the script directory and run the HackHotspot.bat file.
Click to expand...
Click to collapse
Awesome script. Thanks.
will this work for the revolutionary?
CAn i do this on a MAC?....
Can n e one verify that this works?
im getting errors in the script:
Code:
Extracting framework.jar
7-Zip 4.65 Copyright (c) 1999-2009 Igor Pavlov 2009-02-03
Processing archive: framework.jar
Extracting META-INF
Extracting META-INF\MANIFEST.MF
Extracting preloaded-classes
Everything is Ok
Folders: 1
Files: 2
Size: 65651
Compressed: 12413
Unpacking classes.dex
Can't find the file classes.dex
Putting HotspotHack into place
The system cannot find the path specified.
The system cannot find the path specified.
0 file(s) copied.
Repacking classes.dex
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Cannot find file or directory "out/"
at org.jf.smali.main.main(main.java:173)
Could Not Find C:\AddHotspotHack\classes.dex
The system cannot find the file specified.
Updating framework.jar
1 file(s) copied.
classes.dex : no such file or directory
Cleaning up...
Could Not Find C:\AddHotspotHack\classes.dex
The system cannot find the file specified.
Done if no errors listed above!
C:\AddHotspotHack>
and shouldnt it be
adb push framework.jar /system/framework/framework.jar

[Q] [DEV HELP] Baksmali won't load certain classes when using -x option

Hi all,
I am attempting to manually deodex a couple files using smali/baksmali. I've been able to successfully deodex all but 5 apps of a stock ROM. When I try to baksmali any of the 5 apps with this command (I got the bootclasspath from my init.rc):
Code:
baksmali -a 10 -c ../deps/core.jar:../deps/bouncycastle.jar:../deps/ext.jar:../deps/framework.jar:../deps/android.policy.jar:../deps/services.jar:../deps/core-junit.jar:../deps/com.motorola.android.frameworks.jar:../deps/com.motorola.android.widget.jar -x filename.odex
I get:
Code:
Error occured while loading boot class path files. Aborting.
org.jf.dexlib.Code.Analysis.ClassPath$ClassNotFoundException: Could not find interface Landroid/app/ActionBar$OnNavigationListener;
at org.jf.dexlib.Code.Analysis.ClassPath$ClassDef.loadAllImplementedInterfaces(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:163)
at org.jf.dexlib.Code.Analysis.ClassPath.InitializeClassPath(ClassPath.java:131)
at org.jf.baksmali.baksmali.disassembleDexFile(baksmali.java:111)
at org.jf.baksmali.main.main(main.java:293)
Error while loading class Lcom/google/android/maps/driveabout/app/Q; from file ././Maps.zip
Error while loading ClassPath class Lcom/google/android/maps/driveabout/app/Q;
So it seems I just have to add com.google.android.maps.jar to the bootclasspath and it should work, right?
Code:
baksmali -a 10 -c ../deps/core.jar:../deps/bouncycastle.jar:../deps/ext.jar:../deps/framework.jar:../deps/android.policy.jar:../deps/services.jar:../deps/core-junit.jar:../deps/com.motorola.android.frameworks.jar:../deps/com.motorola.android.widget.jar:../deps/com.google.android.maps.jar -x filename.apk
But I get the same exception above. To make sure I added the right jar, I did "baksmali -a 10 com.google.android.maps.jar" and searched for com.google.android.maps.driveabout.app.Q.smali and found nothing. Eventually I discovered that the Maps application holds that class, so...
Code:
baksmali -a 10 -c ../deps/core.jar:../deps/bouncycastle.jar:../deps/ext.jar:../deps/framework.jar:../deps/android.policy.jar:../deps/services.jar:../deps/core-junit.jar:../deps/com.motorola.android.frameworks.jar:../deps/com.motorola.android.widget.jar:Maps.odex -x filename.odex
(since Maps.odex is one of the files that wouldn't deodex) but I STILL got the same error, except the 2nd-to-last line changed to "Error while loading class Lcom/google/android/maps/driveabout/app/Q; from file Maps.odex."
So now I am very confused. I seem to have done it correctly... according to the error, the dependency com.google.android.maps.driveabout.app.Q was missing, so I found out what .odex file held it and then appended it to the bootclasspath and tried again... but to no avail . My phone is a Motorola Atrix 2 running GB 2.3.6. Here is the odexed build that I am attempting to deodex.
Does anyone know what I could be doing wrong? Or if using the -I (ignore) argument would work?
Thanks for any help you can provide.

[Q] Edit java source from Apk and recompile it

Goodmorning,
I use apktool to decompile the apk. I edit some file in res folder, now I want to edit some java source file from apk and recompile with apktool to run the "new" android application.
With Dex2jar & jd-gui i extract the java source code.
Now i want to edit and covert into .smali because Apktool can build the application with smali code.
I found a script that uses 2 file(dx.jar and backsmali.jar)
1- javac myClass.java //compile myClass.java in myClass.dex
2-java -jar tools/dx.jar --dex --output= myClass.dex myClass.class // convert myClass.class in myClass.dex
3-java -jar tools/baksmali.jar -o myClass.smali myClass.dex //convert myClass.dex in myClass.smali
Javac work great it produce the file myClass.class.
The step 2 and 3 makes me trouble,the prompt show me a message:
trouble processing:
bad class file magic (cafebabe) or version (0034.0000)
...while parsing BuildConfig.class
...while processing BuildConfig.class
1 warning
no classfiles specified
Can't find the file BuildConfig.dex
impossible find C:\Users\Lorenzo\Desktop\java2smali\BuildConfig.dex
impossible find the file .
Please someone can help me?
sorry for my english....

[Tutorial] How to Deodex Lollipop System Files - One by One

Hey guys,
I write this tutorial to help guys deodex individual apps and not all apps or not to do batch deodex.
There are few good tools to Batch Deodex Roms but I found one by one tutorial which was not properly framed...
Though the credits goes to the creator of the tool.
I dont take any credits for that tool and here I just write up a tutorail on how to do it.
Step by Step Tutorial:
- First of all download this zip file of the tools required for the process - Link
- Now, extract the files of the zip to any folder.
- Head over to the directory you extracted the tools. It will contain many files such as baksmali, smali, 7zip etc..
- Now press Shift+Right Click and select Open Command Window Here.
- Now just copy the apk and the .odex.art.xz and odex.xz files in that directory.
- Now in command prompt type the following commands.
Note: Replace * With the name of the apk. (If you dont get it see the Post #2 for eg)
Code:
7za x *.odex.xz
Code:
oat2dex.bat *.odex
Code:
oat2dex.bat *.odex temp.dex
Code:
java -jar baksmali-2.0.3.jar -a 21 -x temp.dex -o deodex
Code:
java -jar smali-2.0.3.jar -a 21 deodex -o classes.dex
Code:
7za u -tzip *.apk classes.dex
Now, the apk you initially coppied is now dexoded. Now you can use that apk the way you want
See post #2 for example
Reserved
Example:
Say I want to Deodex SystemUI for any lollipop rom.
Then, I would do the following
Code:
7za x SystemUI.odex.xz
Code:
oat2dex.bat SystemUI.odex
Code:
oat2dex.bat SystemUI.odex temp.dex
Code:
java -jar baksmali-2.0.3.jar -a 21 -x temp.dex -o deodex
Code:
java -jar smali-2.0.3.jar -a 21 deodex -o classes.dex
Code:
7za u -tzip SystemUI.apk classes.dex
The apk is now deodexed successfully. Enjoy!
hey mate, any chance you can upload a few small .apk files and matching .odex.xz files?
ive got a few test to run for a tool i made but cant because i dont have any android 5.0 devices

Lollipop APK deodexing [commandline][scripts]

Lollipop deodexing
Deodexing apk's on lollipop is almost as simple as API < 21 and only invoves two extra steps.
The workflow for the new deodex process is as follows below. The <arch> is the architecture for the apk being deodexed.
oat2dex boot system/framework/<arch>/boot.oat
oat2dex <path/to/app/<arch>/app.odex> system/framework/<arch>/odex
baksmali as normal
smali as normal
The actual behind-the-scenes info
ART changes things with its 'Ahead of Time Compiling'. Android creates a boot.oat on boot containing the classpath jars that apks
link against for functionality. Before these the .odex for the classpath was compatible with baksmali/smali, but due to changes with
ART vs Dalvik this is no longer the case now. The classpath needs to extracted from the boot.oat. The resulting dex/ and odex/ are then
used to create a bootclasspath that can be used to create a baksmali/smali compatible odex, by essentially deoptimizing it. Once
the compatible odex is created, baksmali and smali can be used like normal - even allowing smali edits to exisiting APKs.
A working (manual) example
To get started you will need to pull the framework directory off the device.
Code:
mkdir framework
cd framework
adb pull system/framework
The next step is to pull the app's folder from system/app or system/priv-app.
For this example I will be using SecSettings2.apk from a Samsung Galaxy S6.
Code:
mkdir SecSettings2
cd SecSettings2
adb pull /system/priv-app/SecSettings2
The next step is to determine the architecture of the apk to be deodexed. This is done checking whether the directory that the
apk's folder contents were extracted to contains an arm or arm64 folder (32-bit or 64-bit, respectively).
The SecSettings2.apk is 64-bit as its folder contains an arm64 folder.
Once the architecture is determined, the next step is to extract the classpath from boot.oat. Replace arm64 with arm below
if your app is only 32-bit.
Code:
oat2dex boot framework/arm64/boot.oat
This will extract the classpath from the boot.oat and place the dex and odex into separate directories in framework/<arch>.
Now the classpath can be used to create a compatible odex that baksmali and smali is compatible with. Note that the result odex
will have a .dex extension. This is NOT to be placed into the apk as the app will NOT work.
Code:
oat2dex SecSettings2/arm64/SecSettings2.odex framework/arm64/odex
We now have a odex (labled SecSettings2.dex in SecSettings2/) that is compatible with baksmali and smali.
To baksmali the odex:
Code:
baksmali -a 21 -x SecSettings2.dex -d framework -o smali/SecSettings2
To deodex the smali into a dex:
Code:
smali smali/SecSettings2
The last command outputs a classes.dex that is going to go into the apk.
Code:
zip -gjq SecSettings2 classes.dex
Now we need to remove the arm or arm64 folder from the apk's location on the device.
Code:
adb shell su -c 'mount -o remount,rw /system'
adb shell su -c 'rm -rf system/priv-app/SecSettings2/arm64'
Now we simply need to push the apk to the device, fix permissions, and reboot.
Code:
adb push SecSettings2.apk /data/local/tmp/
adb shell su -c 'dd if=/data/local/tmp/SecSettings2.apk of=/system/priv-app/SecSettings2/SecSettings2.apk'
adb shell su -c 'chmod 644 /system/priv-app/SecSettings2/SecSettings2.apk'
adb reboot (You may need to wipe data depending on the app being deodexed)
That's it. Happy modding
But I have made it easy for ya.....
deodex-app makes it stupid simple to deodex an apk from the device by running one command
Code:
./deodex-app SecSettings2.apk
That's it. The script will determine the apk's location in system, check if it's already deodexed, pull the neccessary
files to perform the deodexing, and will push the apk back to the device and reboot.
/lazydev
Huge credits to @JesusFreke for baksmali and smali, and credit to @svadev for the updated oat2dex

Categories

Resources