[Q] [DEV HELP] Baksmali won't load certain classes when using -x option - Android Software/Hacking General [Developers Only]

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.

Related

[APP][DEV][GUIDE] Using the Android Java Internal/Hidden API classes

Using Java Reflection with Eclipse ADT to Access Internal/Hidden API classes.
Purpose
We present a way to access all the Internal and Hidden Java packages/classes
in the AOS. To do this we need to both repackage the Android.jar and hack the
Eclipse ADT plugin, to allow using these internal packages.
Posting
==================================================
Do NOT post general questions/requests on how to
do this or that, they will not be answered here.
DO post if you have additional tricks, hacks or
information that can help/benefit this tutorial.
==================================================
Background
There are two reasons one cannot use internal packages. One reason is that, if
you're using Eclipse as your development platform, those packages are
internally blocked in the Eclipse ADT plugin. Second reason is that the normal
development android.jar runtime does not contain those *.class files that
belong to the internal packages.
"There is no easy way to use com.android.internal package (internal API) or
anything marked with @hide attribute (hidden API) without using reflection.
That’s because android.jar file does not contain classes from internal and
hidden API and because of this nobody can reference those classes in compile
time."
Thus we need to first restore the "original" android.jar which will allow us
to use internal and hidden APIs. But the runtime equivalent of Android SDK’s
android.jar file is framework.jar. This file is located in the
/system/framework/ directory of your device. We will extract and use this for
our pleasure.
The general procedure:
A) Grab the "full" framwork.jar from your device
B) extract the class files
C) add them to "full" android.jar ??
D) Hack the Eclipse ADT plugin jar.
Finally, NOTHING would have been possible without the excellent step-by-step
instructions on the devmaze-blog by senior Android developer Ievgenii Nazaruk
(aka. "inazaruk"). THANK YOU Ievgenii!​References
http://stackoverflow.com/questions/...d-sdk-with-hidden-and-internal-apis-available
http://stackoverflow.com/questions/...-state-permission-for-apps-ran-on-gingerbread
http://code.google.com/p/smali/wiki/DeodexInstructions
http://code.google.com/p/adt-addons/
​
The General Procedure
NOTE: All this was performed on Windows Vista with Cygwin.(1) Grab BOOTCLASSPATH from init.rc
Find the line in your init.rc file that reads something like:
Code:
[SIZE=2]export BOOTCLASSPATH /system/framework/core.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/core-junit.jar[/SIZE]
Extract and reformat the path to:
Code:
[SIZE=2]core.jar:bouncycastle.jar:ext.jar:framework.jar:android.policy.jar:services.jar:core-junit.jar[/SIZE]
(2) Grab the "framework" from your device
Create a working directory somewhere, let's call it "_framework":
Code:
[SIZE=2]mkdir ./_framework[/SIZE]
[SIZE=2]cd _framework[/SIZE]
Grab all the framework files from your device:
Code:
[SIZE=2]adb pull /system/framework .[/SIZE]
Rename directory if needed.
NOTE-1: From now on I'll assume you know where you are!
NOTE-2: Most GB 2.3.4+ devices uses .odex'ed files,
with name pairs like: <package>.jar and <package>.odex.
These need to be converted.
(3) Use baksmali with (1)
You can also use baksmali with the switch: -d <framwork-dir>.
The general command is something like below, but in windows there may be "wrappers"
that allow you to just type "baksmali" without the "java -jar" prefix and without
the ".jar" post fix. Anyway here is the command I used:
Code:
[SIZE=2]java -Xmx1024m -jar ./../../baksmali.jar -a 10 -c :core.jar:bouncycastle.jar:ext.jar:framework.jar:android.policy.jar:services.jar:core-junit.jar -x framework.odex[/SIZE]
==> This results in all files put in the "out" sub-directory.
This directory contain 3 sub-directories (for GB 2.3.4):
Code:
[I]android [/I](Hidden APIs)
[I]com [/I](Internal APIs)
[I]javax [/I](Hidden APIs)
NOTE: If you are using Google's own API's, you will probably also need to add
those packages to the path above. (Eg. Email.jar, etc etc ?)
(4) Then use smali to create a dex file from "out" directory
Code:
java -jar smali.jar out
==> creates out.dex from "out" directory.
(5) Run dex2jar on out.dex
Code:
[SIZE=2]./dex2jar.bat out.dex[/SIZE]
==> creates out_dex2jar.jar
(This .jar contain close to 4900 files at 12 MB!)
(6) Rename "out_dex2jar.jar" to "framework-classes.zip"
Code:
[SIZE=2]mv out_dex2jar.jar framework-classes.zip
unzip framework-classes.zip[/SIZE]
(7) Find and copy your Android SDK's android.jar file
Go to: /path/to/android-sdk-windows/platforms/android-X/android.jar
where X is the API level of interest. This obviously have to match the
API level of the files you extracted from your device in: /system/framework .
This .jar file contain more than 5300 files when expanded, but missing all
the internal packages. Our job is to add them back in.
Let's first make a copy that we can use to expand and add files from (6):
Code:
cp android.jar custom-android.zip
unzip custom-android.zip
(8) Add all *.class files from (6) in to (7)
Copy and replace all existing *.class files from framework-classes.zip into
custom-android.zip:
Code:
[SIZE=2]cp -R /path/to/framework-classes/* /path/to/custom-android/.[/SIZE]
The root content of that directory should then look something like this:
Code:
[SIZE=2]android[/SIZE]
[SIZE=2]assets[/SIZE]
[SIZE=2]com[/SIZE]
[SIZE=2]dalvik[/SIZE]
[SIZE=2]java[/SIZE]
[SIZE=2]javax[/SIZE]
[SIZE=2]junit[/SIZE]
[SIZE=2]META-INF[/SIZE]
[SIZE=2]org[/SIZE]
[SIZE=2]res[/SIZE]
[SIZE=2]AndroidManifest.xml[/SIZE]
[SIZE=2]resources.arsc[/SIZE]
(9) Rename directory and create your new "classy-android.jar"
We rename it so not confuse with the original:
Code:
mv custom-android classy-android
zip classy-android
mv classy-android.zip classy-android.jar
IMPORTANT:
Make absolutely sure that the folder structure of your zip archive
is exactly the same as what you intended. To check, unzip the file
and see if it is what you (and eventually Eclipse) would expect.
(For example, if you use 7zip to zip a directory file called "test",
into "test.zip", you may end-up extracting it to ./test/test/... )
(10) Enabling & Restricting Access to classy-android.jar
Instead of just replacing the android.jar with classy-android.jar, we choose
to create a customized Android platform. This way you can enable the Internal
and Hidden API's for those projects requiring them, while other standard
projects doesn't have access to those.
(a) Go to: /path/to/android-sdk-windows/platforms/
and copy the relevant directory (for example):
Code:
cp -R android-10 android-10-internals
(b) Replace android.jar with your classy-android.jar:
Code:
cp classy-android.jar android.jar
("cp" overwrites!)
(c) Edit the build.prop file:
Edit/replace the following lines:
Code:
[SIZE=2]ro.build.version.sdk=10 ==> ro.build.version.sdk=[COLOR=Black][B]-10[/B][/COLOR][/SIZE]
[SIZE=2]ro.build.version.release=2.3.3 ==> ro.build.version.release=2.3.internal[/SIZE]
(11) Customizing the Eclipse ADT
In order to be able to use com.android.internal packages in the Eclipse ADT,
you have to disable the internal protection mechanism of the plugin, that
prevent you to use these libraries. You can see this by right-clicking on your
project package and navigate to:
Code:
[SIZE=2]==> Properties ==> Java Build Path ==> Libraries (tab) [/SIZE]
[SIZE=2]--> Android 2.x.x --> android.jar [/SIZE]
[SIZE=2]--> "Access rules: 1 rule defined": [B][COLOR=Red](X)[/COLOR][/B] [B]Forbidden: com/android/internal/**[/B][/SIZE]
This can not be removed (bug?), even though the interface allows changing, it
never persists after closing the Properties window. So we have to hack it!
The way to do it, is to hexedit the correct java class file and change the
name from "internal" to "internax". First let's find the correct file. The
plugin file is located in the ./eclipse/plugins/ directory, and its name is
something like:
Code:
com.android.ide.eclipse.adt_18.0.0.v201203301601-306762.jar
(a) make a backup copy of this (with the exact name preserved) in another directory.
(b) make a another copy of this in another directory.
(c) unzip (b) in that directory
Code:
[SIZE=2]cp com.android.ide.eclipse.adt_18.0.0.v201203301601-306762.jar hacked_adt.zip[/SIZE]
[SIZE=2]unzip hacked_adt.zip[/SIZE]
[SIZE=2]cd hacked_adt[/SIZE]
This is a huge directory system, so forget poking around in it,
just go to the correct sub-directory:
Code:
[SIZE=2]cd ./com/android/ide/eclipse/adt/internal/project/[/SIZE]
Then find the correct file and the approximate string location within that file:
Code:
[SIZE=2]strings.exe -f -4 -t x ./*.class |grep "android\/internal"[/SIZE]
It happens to be in "AndroidClasspathContainerInitializer.class". Now, use a
hexeditor to find and change the string "com/android/internal/**"
to "com/android/internax/**". That will do it!
Now zip-up your hacked jar directory and copy it over the old one.
(Remember that "cp" overwrites without warning!)
Code:
[SIZE=2]zip hacked_adt[/SIZE]
[SIZE=2]cp hacked_adt.zip /path/to/eclipse/plugins/com.android.ide.eclipse.adt_18.0.0.v201203301601-306762.jar[/SIZE]
You Are Done!
Enjoy your newly hacked Eclipse! ​Errors
If you get any errors;
1. make sure you have zipped up everything properly as warned before.
2. make sure you have included Google API packages in your BOOTCLASSPATH in step (3).
3. Try to "clean-up" the Java by: "Right-Click" ==> Source ==> "Clean Up...".
4. Google them
5. Ignore them
6. Give up. Not! But I can't help you!
If it still doesn't work, try to download inazaruk's pre-compiled set of internal android.jar's from here.
(For android 7,8,10,15.)
​
WIP! <here be dragons2>
For a project using internal package imports, see my thread:
"[TOOL][APP][WIP] Native AT Command Injector"
<here be more dragons>
Following the instructions in posts 1-2 above, may not always work. It is not known to me at this time, why it shouldn't. One theory is that it can have something to do with how Eclipse and Android.jar is packaging their files and the resulting sizes.
This was mentioned in this Stackoverflow post:
"Jar files: why does extracting then compression a jar file create a file of a different size to the original?"
Then reading the man pages for "jar" we can inform ourselves with:
Code:
[SIZE=2] c Creates a new archive file named jarfile (if f is specified) or to
standard output (if f and jarfile are omitted). Add to it the
files and directories specified by inputfiles.
u Updates an existing file jarfile (when f is specified) by adding
to it files and directories specified by inputfiles.
x Extracts files and directories from jarfile (if f is specified) or
standard input (if f and jarfile are omitted). If inputfiles is
specified, only those specified files and directories are
extracted. Otherwise, all files and directories are extracted.
t Lists the table of contents from jarfile (if f is specified) or
standard input (if f and jarfile are omitted). If inputfiles is
specified, only those specified files and directories are listed.
Otherwise, all files and directories are listed.
i Generate index information for the specified jarfile and its
dependent jar files.
[/SIZE]
More info is provided here:
The JAR Overview @
http://java.sun.com/javase/6/docs/technotes/guides/jar/jarGuide.html
The JAR File Specification @
http://java.sun.com/javase/6/docs/technotes/guides/jar/jar.html
The JARIndex Spec @
http://java.sun.com/javase/6/docs/technotes/guides/jar/jar.html
JAR Tutorial @
http://java.sun.com/docs/books/tutorial/jar/
pack200 Reference Page @
http://java.sun.com/javase/6/docs/technotes/tools/share/pack200.html
Another theory is that it may have something to do with what seem to be, that Google have revoked the the use of MODIFY_PHONE_STATE since Android 2.3, and that this influences the Eclipse behavior, when using and modifying older android.jar's. This was mentioned here and here.
Any help would be very much appreciated!
< bump >
Hi, thanks for the info, I made it using linux and worked really nice, these were the lines that I used, hope be useful.
This is my Android folder at home
Code:
Android/
├── eclipse
├── ndk
├── platforms-internals
├── sdk
└── tools
Start an avd running the desired API to modify in this case API-17
Code:
$ emulator -avd avd_api_17 -no-window &
Get the framework
Code:
$ cd ~/Android/
$ mkdir _framework
$ cd _framework
$ adb -s emulator-5554 pull /system/framework .
Grab BOOTCLASSPATH
Code:
$ adb -s emulator-5554 shell cat init.rc | grep BOOTCLASSPATH > bootclasspath
I didn't have the tools used in this tutorial, so I included the steps for getting them
Decompile with baskmali
Code:
$ cd ~/Android/tools
$ wget https://smali.googlecode.com/files/baksmali-1.4.2.jar
$ cd ~/Android/_framework
$ java -Xmx1024m -jar ../tools/baksmali-1.4.2.jar -a 17 -c core.jar:core-junit.jar:bouncycastle.jar:ext.jar:framework.jar:telephony-common.jar:mms-common.jar:android.policy.jar:services.jar:apache-xml.jar -x framework.odex
The parameter -a for baksmali refers to the API we are working with.
Generate out.dex with smali
Code:
$ cd ~/Android/tools
$ wget https://smali.googlecode.com/files/smali-1.4.2.jar
$ cd ~/Android/_framework
$ java -jar ../tools/smali-1.4.2.jar out
Get internal and hidden classes using dex2jar
Code:
$ cd ~/Android
$ wget https://dex2jar.googlecode.com/files/dex2jar-0.0.9.15.zip
$ unzip dex2jar-0.0.9.15.zip
$ rm dex2jar-0.0.9.15.zip
$ cd _framework/
$ ../tools/dex2jar-0.0.9.15/d2j-dex2jar.sh out.dex
$ unzip out-dex2jar.jar -d framework-classes
Add these classes to plataform's default android.jar
Code:
$ cd ~/Android
$ unzip sdk/platforms/android-17/android.jar -d custom-android
$ cp -r _framework/framework-classes/* custom-android/
$ rm -r _framework
$ cd custom-android
$ zip -r ../custom-android.jar *
$ cd ..
$ rm -r custom-android
Create new extended platform
Code:
$ cd ~/Android
$ cp -r sdk/platforms/android-17 platforms-internals/android-17-internals
$ mv custom-android.jar platforms-internals/android-17-internals/android.jar
$ vi platforms-internals/android-17-internals/build.prop
ro.build.version.release=4.2.2
ro.build.version.release=4.2.2.internal
$ ln -s ~/Android/platforms-internals/android-17-internals ~/Android/sdk/platforms/android-17-internals
I use a symlink for keep it a little organized
Hack ADT
Code:
$ cd ~/Android
$ unzip eclipse/plugins/com.android.ide.eclipse.adt_22.0.4.v201307151829--741630.jar -d hacked_adt
Go to right folder
Code:
$ cd hacked_adt/com/android/ide/eclipse/adt/internal/project/
Find file where is our desired string
Code:
$ strings -f -a -t x * | grep "android\/internal"
Edit with an hex editor
Code:
$ bless AndroidClasspathContainerInitializer.class &
Here we change the l for the x.
Replace original file making a backup
Code:
$ cd ~/Android
$ cp eclipse/plugins/com.android.ide.eclipse.adt_22.0.4.v201307151829--741630.jar eclipse/plugins/com.android.ide.eclipse.adt_22.0.4.v201307151829--741630.jar.original
$ cd hacked_adt/
$ zip -r ../eclipse/plugins/com.android.ide.eclipse.adt_22.0.4.v201307151829--741630.jar *
$ cd ..
$ rm -r hacked_adt
This worked for me... thanks E:V:A
I got just one error related to a dropbox class, but i think this is not important... hope that
lenieto3 said:
...Start an avd running the desired API to modify in this case API-17... This worked for me... I got just one error related to a dropbox class, but i think this is not important...
Click to expand...
Click to collapse
Thanks and sorry for late reply. I'm very happy to hear these instructions still works with API-17! Could you also upload your hacked JAR somewhere so that people can save some time when experimenting?
I was just here to check-in and try to bump this thread to see if it is still useful to anyone.
E:V:A said:
Thanks and sorry for late reply. I'm very happy to hear these instructions still works with API-17! Could you also upload your hacked JAR somewhere so that people can save some time when experimenting?
I was just here to check-in and try to bump this thread to see if it is still useful to anyone.
Click to expand...
Click to collapse
ive got access to ActivityManager's hidden methods.
I want to use the removeTask method, but it keeps saying that I dont have the REMOVE_TASKS permissions even though I added it to the manifest (and turned off lint).
Permission Denial: removeTask() from pid=9963, uid=10179 requires android.permission.REMOVE_TASKS
Does someone know if there are any automated tools to do/performs steps 1-9?
I'd like to see a tool to automatically pull (from phone), extract and create a compatible android.jar.
@Mohammad_Adib: Sorry, this is the wrong thread for those type of questions.
see this link stackoverflow.com|questions|30656933|android-system-framework-jar-files

[App] Netflix HD for Widevine DRM L1 devices

Hey people,
today i wanted to share a post from chenxiaolong, who did some awesome work back at the Galaxy Tab S2 forum. The main problem, was that Netflix didn't want to play HD content on the Galay Tab S2, which was why I researched the requirements of Netflix. They need Widevine L1 implemented on the SoC to allow HD playback. While this is the necessary requirement, Netflix also needs to enable this device in their device list and tell the app it supports Widevine DRM L1. In many cases they don't do that although the device itself would be very capable of displaying HD content. Tried it out on my Galaxy Tab S2 and on the Nexus 5, which both support Widevine DRM L1 and aren't/weren't marked as WV L1 capable. To check DRM capability of your device you can use for example this app https://play.google.com/store/apps/details?id=com.androidfung.drminfo&hl=en
This will not make a non WV L1 capable device run Netflix HD, it will only make the device use the most secure DRM technology!
The whole process doesn't need root, just some tools like apktool, apk-signer and such. Feel free to link the post into your device forum you achieved to get Netflix HD on.
Big Thanks goes out to @chenxiaolong
Link to thread post: http://forum.xda-developers.com/showpost.php?p=65001865&postcount=12
Based on this, I made a script on Ubuntu to patch last version of netflix APK.
It currently works on version up to 5.12.xxx, it doesn't seem to work on more recent versions, we will have probably to wait for a new version of apktool (2.4.0 ?).
First, you need to install some packages
Code:
sudo apt-get install apktool zipalign default-jdk
Then, you have to build you own signature (to do only once)
Code:
keytool -genkeypair -alias androiddebugkey -keypass android -keystore "${HOME}/.netflix.keystore" -storepass android -keyalg RSA -sigalg SHA1withRSA -dname "CN=Android Debug,O=Android,C=US" -validity 9999
Then, download last netflix APK, for instance from apkmirror, and execute this script on downloaded file (for instance "netflixpatch com.netflix.mediaclient_4.16.1.apk" if your script is named "netflixpatch")
Code:
#!/bin/bash
NAME=$(basename "${1}" .apk)
KEYSTORE="${HOME}/.netflix.keystore"
TMPOUT=$(mktemp -d /tmp/tmpdir.netflixpatch.XXXXXXXXXX) || { echo "Failed to create temp file"; exit 1; }
FILEOLD="${TMPOUT}/smali/com/netflix/mediaclient/service/webclient/model/leafs/DeviceConfigData.smali"
FILENEW="${TMPOUT}/smali/com/netflix/mediaclient/service/configuration/DeviceConfiguration.smali"
apktool d -r -f "${1}" -o "${TMPOUT}"
if [ -f "${FILEOLD}" ];then
echo "Patching method 1"
sed -i 's/iget-boolean v0, p0, Lcom\/netflix\/mediaclient\/service\/webclient\/model\/leafs\/DeviceConfigData;->enableWidevineL1:Z/const\/4 v0, 0x1/g' "${FILEOLD}"
elif [ -f "${FILENEW}" ];then
echo "Patching method 2"
sed -i '/isWidevineL1Enabled/c\ const\/4 v0, 0x1\n return v0' "${FILENEW}"
else
echo "File to patch not found !"
rm -rf "${TMPOUT}"
exit 1
fi
# /usr/local/bin/apktool b "${TMPOUT}"
apktool b "${TMPOUT}"
jarsigner -keystore "${KEYSTORE}" -storepass android -keypass android -sigalg MD5withRSA -digestalg SHA1 -sigfile CERT -signedjar "${TMPOUT}/dist/${NAME}-patched-signed.apk" "${TMPOUT}/dist/${NAME}.apk" androiddebugkey
zipalign -f 4 "${TMPOUT}/dist/${NAME}-patched-signed.apk" "${NAME}-patched-signed-zipaligned.apk"
rm -rf "${TMPOUT}"
You'll get a "com.netflix.mediaclient_4.16.1-patched-signed-zipaligned.apk" file, which will play HD content if your device has Widevine DRM L1 libraries, even if not whitelisted by Netflix.
Perfect! It works for me on Medion Tablet. It also enables download offline mode. Tanks.
It doesn´t work for me...I get an error when tryng to reproduce movies
Hi!
Is it possible that this trick doesn't work anymore or doesn't work on all devices? I patched the current Netflix APK (and verified that the changes were made using apktool) but I only get 720p at best. There was also an error message along the lines of "content not allowed in prolog"?
I'm using one of those generic AmLogic S912 boxes ("X92 Smart Box" with the white clock display thing in the front) which supports L3 but neither Netflix nor Prime Video stream 1080p.
GuillaumeBarberousse said:
Based on this, I made a script on Ubuntu to patch last version of netflix APK.
First, you need to install some packages
Code:
sudo apt-get install apktool zipalign default-jdk
Then, you have to build you own signature (to do only once)
Code:
keytool -genkeypair -alias androiddebugkey -keypass android -keystore "${HOME}/.netflix.keystore" -storepass android -keyalg RSA -sigalg SHA1withRSA -dname "CN=Android Debug,O=Android,C=US" -validity 9999
Then, download last netflix APK, for instance from apkmirror, and execute this script on downloaded file (for instance "netflixpatch com.netflix.mediaclient_4.16.1.apk" if your script is named "netflixpatch")
Code:
#!/bin/bash
NAME=$(basename "${1}" .apk)
KEYSTORE="${HOME}/.netflix.keystore"
TMPOUT=$(mktemp -d /tmp/tmpdir.netflixpatch.XXXXXXXXXX) || { echo "Failed to create temp file"; exit 1; }
apktool d -r -f "${1}" -o "${TMPOUT}"
sed -i 's/iget-boolean v0, p0, Lcom\/netflix\/mediaclient\/service\/webclient\/model\/leafs\/DeviceConfigData;->enableWidevineL1:Z/const\/4 v0, 0x1/g' ${TMPOUT}/smali/com/netflix/mediaclient/service/webclient/model/leafs/DeviceConfigData.smali
apktool b ${TMPOUT}
jarsigner -keystore "${KEYSTORE}" -storepass android -keypass android -sigalg MD5withRSA -digestalg SHA1 -sigfile CERT -signedjar "${TMPOUT}/dist/${NAME}-patched-signed.apk" "${TMPOUT}/dist/${NAME}.apk" androiddebugkey
zipalign -f 4 "${TMPOUT}/dist/${NAME}-patched-signed.apk" "${NAME}-patched-signed-zipaligned.apk"
rm -rf $TMPOUT
You'll get a "com.netflix.mediaclient_4.16.1-patched-signed-zipaligned.apk" file, which will play HD content if your device has Widevine DRM L1 libraries, even if not whitelisted by Netflix.
Click to expand...
Click to collapse
Im sorry but with these informations I don't know exactly if and how it will work out for my galaxy s5. Can I use a app on my mobile to sign the backuped Netflix app? Or do I need to sign the apk on my PC?
T0mfield said:
Im sorry but with these informations I don't know exactly if and how it will work out for my galaxy s5. Can I use a app on my mobile to sign the backuped Netflix app? Or do I need to sign the apk on my PC?
Click to expand...
Click to collapse
These are instructions for Linux. What I have done:
1. download Ubuntu from Windows 10 Store
2. open powershell as admin and type:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
3. reboot when prompted
4. open command line and type:
ubuntu
5. create user/password as prompted
6. type:
sudo apt-get upgrade
Then follow the instructions from post #1. I've got my netflix apk from apkmirror: https://www.apkmirror.com/?post_type=app_release&searchtype=apk&s=netflix
You can access the windows filesystem by /mnt/c/
The script worked fine for me with Netflix 5.9.0 build 24858 and my Nexus 10.
The modification was not working anymore on my tablet (Samsung Galaxy Tab A6 SM-T580) giving me an error 0013 and it is now working again, I don't know why (I upgraded firmware to last version T580XXU2BQI9 / T580XEF2BQI9, or maybe Netflix changed something on their servers).
It is tested and working on Netflix apk 5.8.0_build_24642 and 5.9.0_build_24858 with apktool 2.2.1-dirty (Ubuntu 17.04 version), 2.2.3 and 2.3.0
I edited post https://forum.xda-developers.com/showpost.php?p=72178861&postcount=2, it should now work with old and new version of APK, (tested with version 5.11.1_build_25432)
GuillaumeBarberousse said:
I edited post https://forum.xda-developers.com/showpost.php?p=72178861&postcount=2, it should now work with old and new version of APK, (tested with version 5.11.1_build_25432)
Click to expand...
Click to collapse
I'm getting this error:
Code:
sed: can't read /tmp/tmpdir.netflixpatch.1QU3FdHrJ4/smali/com/netflix/mediaclient/service/webclient/model/leafs/DeviceConfigData.smali: No such file or directory
Also, you've changed the keystore value in the script code but not in the signature code.
Also, it didn't work with 5.11.2. Getting an error 5.2. Not sure if it's because it genuinely doesn't work anymore or because I didn't do it correctly on account of the error. Might I add that I'm using a virtual machine, if it makes a difference.
Also, why is there an L before com/?
vleesevlons said:
Also, you've changed the keystore value in the script code but not in the signature code.
Also, it didn't work with 5.11.2. Getting an error 5.2. Not sure if it's because it genuinely doesn't work anymore or because I didn't do it correctly on account of the error. Might I add that I'm using a virtual machine, if it makes a difference.
Also, why is there an L before com/?
Click to expand...
Click to collapse
Thank you, I edited the script to correct keystore path.
The error you were getting was normal, I was trying to patch file for old versions and new versions of netflix apk, I changed the script to prevent the file error message.
I don't know why you've got error 5.2, I had it for some times then it worked again, after uninstalling official apk and reinstalling patched one, maybe something in the cache of the tablet. I tried many version of apktool too, but it doesn't seem related.
For the virtual machine, it shouldn't affect the patching process.
And for the L before com, I don't know, it is smali language, probably to indicate a string value.
GuillaumeBarberousse said:
Thank you, I edited the script to correct keystore path.
The error you were getting was normal, I was trying to patch file for old versions and new versions of netflix apk, I changed the script to prevent the file error message.
I don't know why you've got error 5.2, I had it for some times then it worked again, after uninstalling official apk and reinstalling patched one, maybe something in the cache of the tablet. I tried many version of apktool too, but it doesn't seem related.
For the virtual machine, it shouldn't affect the patching process.
And for the L before com, I don't know, it is smali language, probably to indicate a string value.
Click to expand...
Click to collapse
I have a Nexus 5 (2013).
I've installed DRMinfo to confirm that I have WV L1 and it says it does.
I've been experimenting with liboemcrypto.so, i.e. deleting it or renaming it, and that does get rid of the error 5.2.
However, it appears that if the .so file differs from how a liboemcrypto.so should be, then Netflix will not do the DRM check and it will just give you SD quality.
So, I'm at a loss there...
What build worked for you? I've tried 5.11.2 build 25441 and 5.11.1 build 25432
vleesevlons said:
I have a Nexus 5 (2013).
I've installed DRMinfo to confirm that I have WV L1 and it says it does.
I've been experimenting with liboemcrypto.so, i.e. deleting it or renaming it, and that does get rid of the error 5.2.
However, it appears that if the .so file differs from how a liboemcrypto.so should be, then Netflix will not do the DRM check and it will just give you SD quality.
So, I'm at a loss there...
What build worked for you? I've tried 5.11.2 build 25441 and 5.11.1 build 25432
Click to expand...
Click to collapse
In my understanding, but I'm not sure, if you remove liboemcrypto.so, you lose Widevine level 1, so Netflix won't even try to play HD, so no error 5.2. I tried and got HD by patching 5.11.2_build_25441 and 5.11.1_build_25432.
Thanks for this guide. For me this missed a few instructions, like how to run a script on a file
So this are the steps nessesary to compleat this process:
1. Do everything from OP till it says to run a script on a file
2. For ease name your script netflixpatch and file com.netflix.mediaclient_4.16.1.apk
3. Open terminal in a place where you saved netflix app and this script
4. In terminal type: chmod u+x netflixpatch
5. Then run this script on apk by typing in terminal: ./netflixpatch com.netflix.mediaclient_4.16.1.apk (with ./ in front)
6. If all went you will see new file in your directory, thats the modified app
Now. For me, and I had apk v .12.2 build 25768 this trick seems to not work. I still have video looking like 720
Im on OnePlus 5T (capable of widevine lv.1) and stock rom.
Do I have nessesary libery I don't really know yet.
Need to investigate more but at least I have modified apk now so thanks for that
EDIT: Thers no liboemcrypto.so in /system/vendor/lib/ so that's probably the issue here ...
anybody knows that this code founds with Android TV netflix apk ?
GuillaumeBarberousse said:
Based on this, I made a script on Ubuntu to patch last version of netflix APK.
First, you need to install some packages
Code:
sudo apt-get install apktool zipalign default-jdk
Then, you have to build you own signature (to do only once)
Code:
keytool -genkeypair -alias androiddebugkey -keypass android -keystore "${HOME}/.netflix.keystore" -storepass android -keyalg RSA -sigalg SHA1withRSA -dname "CN=Android Debug,O=Android,C=US" -validity 9999
Then, download last netflix APK, for instance from apkmirror, and execute this script on downloaded file (for instance "netflixpatch com.netflix.mediaclient_4.16.1.apk" if your script is named "netflixpatch")
Code:
#!/bin/bash
NAME=$(basename "${1}" .apk)
KEYSTORE="${HOME}/.netflix.keystore"
TMPOUT=$(mktemp -d /tmp/tmpdir.netflixpatch.XXXXXXXXXX) || { echo "Failed to create temp file"; exit 1; }
FILEOLD="${TMPOUT}/smali/com/netflix/mediaclient/service/webclient/model/leafs/DeviceConfigData.smali"
FILENEW="${TMPOUT}/smali/com/netflix/mediaclient/service/configuration/DeviceConfiguration.smali"
apktool d -r -f "${1}" -o "${TMPOUT}"
if [ -f "${FILEOLD}" ];then
echo "Patching old version"
sed -i 's/iget-boolean v0, p0, Lcom\/netflix\/mediaclient\/service\/webclient\/model\/leafs\/DeviceConfigData;->enableWidevineL1:Z/const\/4 v0, 0x1/g' "${FILEOLD}"
elif [ -f "${FILENEW}" ];then
echo "Patching new version"
sed -i '/isWidevineL1Enabled/c\ const\/4 v0, 0x1\n return v0' "${FILENEW}"
else
echo "File to patch not found !"
rm -rf "${TMPOUT}"
exit 1
fi
# /usr/local/bin/apktool b "${TMPOUT}"
apktool b "${TMPOUT}"
jarsigner -keystore "${KEYSTORE}" -storepass android -keypass android -sigalg MD5withRSA -digestalg SHA1 -sigfile CERT -signedjar "${TMPOUT}/dist/${NAME}-patched-signed.apk" "${TMPOUT}/dist/${NAME}.apk" androiddebugkey
zipalign -f 4 "${TMPOUT}/dist/${NAME}-patched-signed.apk" "${NAME}-patched-signed-zipaligned.apk"
rm -rf "${TMPOUT}"
You'll get a "com.netflix.mediaclient_4.16.1-patched-signed-zipaligned.apk" file, which will play HD content if your device has Widevine DRM L1 libraries, even if not whitelisted by Netflix.
Click to expand...
Click to collapse
------------------------------------------
anyone try to apply this patch and upload to mega to try if this patch found in Mi box Tv
Problems with the script Helpme
[email protected]:/mnt/c/Users/crist/Downloads/netflix# ./net.sh com.netflix.ninja_5.0.4_build_1965.apk
./net.sh: line 2: $'\r': command not found
./net.sh: line 14: syntax error near unexpected token `elif'
'/net.sh: line 14: `elif [ -f "${FILENEW}" ];then
anybody could helme ... I copy this script :
-------------------------------------------------------------
#!/bin/bash
NAME=$(basename "${1}" .apk)
KEYSTORE="${HOME}/.netflix.keystore"
TMPOUT=$(mktemp -d /tmp/tmpdir.netflixpatch.XXXXXXXXXX) || { echo "Failed to create temp file"; exit 1; }
FILEOLD="${TMPOUT}/smali/com/netflix/mediaclient/service/webclient/model/leafs/DeviceConfigData.smali"
FILENEW="${TMPOUT}/smali/com/netflix/mediaclient/service/configuration/DeviceConfiguration.smali"
apktool d -r -f "${1}" -o "${TMPOUT}"
if [ -f "${FILEOLD}" ];then
echo "Patching old version"
sed -i 's/iget-boolean v0, p0, Lcom\/netflix\/mediaclient\/service\/webclient\/model\/leafs\/DeviceConfigData;->enableWidevineL1:Z/const\/4 v0, 0x1/g' "${FILEOLD}"
elif [ -f "${FILENEW}" ];then
echo "Patching new version"
sed -i '/isWidevineL1Enabled/c\ const\/4 v0, 0x1\n return v0' "${FILENEW}"
else
echo "File to patch not found !"
rm -rf "${TMPOUT}"
exit 1
fi
# /usr/local/bin/apktool b "${TMPOUT}"
apktool b "${TMPOUT}"
jarsigner -keystore "${KEYSTORE}" -storepass android -keypass android -sigalg MD5withRSA -digestalg SHA1 -sigfile CERT -signedjar "${TMPOUT}/dist/${NAME}-patched-signed.apk" "${TMPOUT}/dist/${NAME}.apk" androiddebugkey
zipalign -f 4 "${TMPOUT}/dist/${NAME}-patched-signed.apk" "${NAME}-patched-signed-zipaligned.apk"
rm -rf "${TMPOUT}"
-----------------------------------
Don't copy and paste the script into terminal. Create a new file and past this to it then set permission on file and run the script
yes I did that
Friend I Did that. I was copy the script and paste in a white document and save has .sh when I try to execute make me that error . Please help me
Tried the script. First had to get Ubuntu. So I did:
enable Hyper-V, load Ubuntu 16.4.3-server-x64 (so no GUI) on Generation 1
ran the apt-get install commands provided by OP
Code:
[email protected]:~$ ./netflixpatch com.netflix.mediaclient_5.13.0_build_25824.apk
03:21:52 up 17 min, 2 users, load average: 0.05, 0.07, 0.07
USER TTY FROM [email protected] IDLE JCPU PCPU WHAT
sebas tty1 03:04 13:17 0.05s 0.05s -bash
sebas pts/0 192.168.178.72 03:09 0.00s 0.07s 0.00s w
I: Using Apktool 2.0.2-dirty on com.netflix.mediaclient_5.13.0_build_25824.apk
I: Copying raw resources...
I: Baksmaling classes.dex...
I: Baksmaling classes2.dex...
I: Baksmaling classes3.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
Patching old version
Script is running BUT I do not see the output created. Old file has an unmodified timestamp. Any thoughts on how to troubleshoot this?
Recent versions of the Netflix app (starting with 5.13.0) are permanently crashing after being processed. At least on my devices. So you can stop working on the current version or take a 5.12.x release.
See: https://forum.xda-developers.com/showpost.php?p=75479828&postcount=136

Smali/Baksmali

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.

core.jar $BOOTCLASSPATH$ missing

Hi ...
i am try to de-odex my stock rom... when i try auto deodexer, 2 file get error:
SemcContactsProvider.odex and Dialer.odex (both in "/system/priv-app")
I try to manual deodexing
I check my BOOTCLASSPATH:
Code:
adb shell
cat $BOOTCLASSPATH$
and run this commend:
Code:
java -jar baksmali.jar -x -c :core-oj.jar:core-libart.jar:conscrypt.jar:okhttp.jar:core-junit.jar:bouncycastle.jar:ext.jar:framework.jar:telephony-common.jar:voip-common.jar:ims-common.jar:apache-xml.jar:org.apache.http.legacy.boot.jar:tcmiface.jar:telephony-ext.jar:WfdCommon.jar:oem-services.jar:qcmediaplayer.jar Dialer.odex -o Dialer
get error: Cannot locate boot class path file /system/framework/core.jar
But not such file in Sony Stock ROM !!!
How can i deodex the stock nougat? tnx
Okey I solved
close the topic tnx

How to extract data from ADB/twrp (.ab) backup?

Hi guys,
i made a backup using ADB and TWRP, no i have a backup.ab that i cant do anything with. I've been searching for a while and i cant unpack, split, or extract the backup. I tried using windows 10, ubuntu bash (on winows10), and virtual linux.
so far, windows and virtual linuxmint 18 give me about the same error.
I used :
Code:
java -jar abe.jar unpack backup1.ab nexus745544.tar
To unpack it, but i get the following error (both windows and linux):
Code:
Invlaid Magic: TWRPtwstreamheaderöâS·TWRPtwfilename€ÌøÔñ£â/data/media/0/TWRP/BACKUPS/0117111846320501/2017-12-17--02-02-18_NRD90MN920PVPS3DQK1/system.ext4.winTWRPtwdatablockDÝíº/app/00407550000000000000000000000062132154162340010533xustar rootroot50 RHT.security.selinux=u:object_r:system_file:s0
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: Invalid Magic TWRPtwstreamheaderöâS·TWRPtwfilename€ÌøÔñ£â/data/media/0/TWRP/BACKUPS/0117111846320501/2017-12-17--02-02-18_NRD90MN920PVPS3DQK1/system.ext4.winTWRPtwdatablockDÝíº/app/00407550000000000000000000000062132154162340010533xustar rootroot50 RHT.security.selinux=u:object_r:system_file:s0
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:502)
at org.nick.abe.Main.main(Main.java:128)
... 5 more
Caused by: java.lang.IllegalArgumentException: Invalid Magic TWRPtwstreamheaderöâS·TWRPtwfilename€ÌøÔñ£â/data/media/0/TWRP/BACKUPS/0117111846320501/2017-12-17--02-02-18_NRD90MN920PVPS3DQK1/system.ext4.winTWRPtwdatablockDÝíº/app/00407550000000000000000000000062132154162340010533xustar rootroot50 RHT.security.selinux=u:object_r:system_file:s0
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:332)
... 6 more
other commands i tried:
Code:
dd if=backup1.ab bs=1 skip=24 | python -c "import zlib,sys;sys.stdout.write(zlib.decompress(sys.stdin.read()))" > backup11.tar
This command creates a backup11.tar (with 0 bytes) but the terminal just hangs.
Code:
dd if=backup1.ab bs=24 skip=1|openssl zlib -d > mybackup7668.tar
This command also creates the .tar file with 0 bytes but the terminal throws error:
Code:
openssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory
which i'm still trying to fix this error, maybe it fixes it.
if you have any more questions, let me know.
Any help is appreciated. Thanks.
Same problem here,
I think TWRP backups are in some way different from others .ab files.
Just wanted to also say I have the exact same problem as the other two people in the thread.
Only, I also have my efs partitions in there and now when I need them my phone is essentially a tablet.
Same problem here. It is hard to believe that the answer to this question is so hard to find. After all, one only needs to be able to read the source code to find the answer (unfortunately, that's not what I am qualified to do)
For anyone else in trouble, more information can be found here:
github.com/TeamWin/Team-Win-Recovery-Project/issues/898

Categories

Resources