Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Decompile React Native index.android.bundle

I am using React Native and integrated library react-native-obfuscating-transformer to obfuscate my code. Now after decompiling my APK, I believe my whole js code is under assets/index.android.bundle.

How can I debundle it and see my code whether obfuscation worked or not.

like image 273
FaisalAhmed Avatar asked Dec 07 '22 10:12

FaisalAhmed


2 Answers

For Macbook

brew install apktool

after install apktool, unzip apk file by run this command on terminal like this:

apktool  d /pathOfApkFile.apk

After that you will get index.android.bundle file at pathOfApkFile/assets/index.android.bundle

than you can use react-native-decompiler for decompile index.android.bundle file

Decompile index.android.bundle File

you can decompile index.android.bundle by run this command

npx react-native-decompiler -i ./index.android.bundle -o ./output

after that, you will get JS decompiled file in ./output directory

JS Code Decompile

React Native is already doing uglify js code.

and react-native-obfuscating-transformer is also make complex uglifying code

It is something like MD5 and SHA256 encryption and there is no the tool available right know when make machine learning and bruteforce to give us estimated code

If you want to varify react-native-obfuscating-transformer is implemented or not then you can edit index.android.bundle and save code then implement react-native-obfuscating-transformer and edit and compare both file

you can make more uglify code by adding flag in build.gradle called bundleInRelease: true and add Hermes which turns js bundle to bytecode for efficiency

REF

Note: There is no way to decompile index.android.bundle because this file contains uglify code which has many reverses possible of one line

Java Code Decompile

you can use DEX2JAR to convert apk to java code and you can view that code from JD-GUI

you can see this VIDEO

like image 84
Muhammad Numan Avatar answered Dec 27 '22 07:12

Muhammad Numan


See https://android.jlelse.eu/getting-inside-apk-files-21dbd01529d4 :

If your app is written on React Native, using the same apktool you can find index.android.bundle file inside assets folder of decompiled APK folder. To open it using IntelliJ IDEA, right click on the file, Associate with File Type… and choose JavaScript. And it is usual minified .js file.

In other words, opening the .bundle file in an IDE such as Intellij will yield a minified .js file, which can then be formatted and compared with your source code. I hope this helps!

like image 45
Troll Z. Or Avatar answered Dec 27 '22 06:12

Troll Z. Or