Decompiling .apk file created in Appcelerator and getting to .js files
Asked Answered
N

4

6

Is there any way to get to .js files with code created with Appcelerator from compiled .apk? I lost a source coude of one of projects and now have only .apk files and would like not to rewrite the whole code. Thank in advance

Nikaniki answered 18/1, 2016 at 11:27 Comment(2)
Have you looked inside the apk assets folder?Sheath
@Antimony: Yes. JS files won't be visible.Nikaniki
C
3

If you would like to do this manually:

In release version of the app, Titanium puts all of the assets into Java class called AssetCryptImpl, you would have to decompile apk and look for that class file in the sources.

AssetCryptImpl file will contain private method called initAssetsBytes, which returns one large chunk of data as CharBuffer, which contains encrypted data for all of the asset files. The other method called initAssets, will contain all of the original asset filenames and also ranges for each of the asset files.

Asset data is encrypted using AES in ECB mode, and last 16 bytes from asset data are the decryption key. Asset decryption method implementation is inside JNI library but its not hard to rewrite. filterDataInRange will call native code to decrypt the resource.

You can easily rewrite filterDataInRange method, with your implementation, which will get the key and decrypt the resource data and write it to file. And write a method which will call readAsset for each filename from HashMap, from initAssets method.

If you want one click solution:

You can use the tool called ti_recover.

Install it with node package manager:

npm install ti_recover

Than use it from terminal/command line:

ti_recover apkfile.apk outputdir
Cigar answered 14/11, 2019 at 1:25 Comment(0)
C
1

Depends on how the Titanium app was built. If it's an emulator build, then yes, you can get the JavaScript files. If the apk is from a device or dist build, then no.

For device and dist builds, Titanium minifies and encrypts all JavaScript, then injects it into the Java code before compiling it.

So if you have an apk from an emulator build, you can just rename the .apk to .zip and unzip and the JS files will be there.

One thing to note is if your app is an Alloy app, then you'll only get the compiled Alloy code, not the original Alloy code. That means you won't find any .xml views, .tss styles, etc.

Coachman answered 19/1, 2016 at 17:55 Comment(0)
G
-2

This Website might be your best bet. It uses a range of technologies to decompile .apk files.

Gambol answered 18/1, 2016 at 19:53 Comment(3)
can not decompile compiled js files.Mooring
@e-info128, JavaScript files cannot be compiled or decompiled. The best that can be done from the security point of view is obfuscating. You can find more information here: #194897. Obfuscation is an irreversible process. Once this is done, you cannot go back unless you have the original source code.Gambol
Appcelerator is a hibrid Framework with controllers writed in Javascript, when compile the app the js files are compiled and ofuscated with a rsa certificate. the web site decompile only native files, great work, but not clean all precompiled assets from frameworks. For full decompile apk i using dex2jar, apktool, cfr, adus and ti recover.Mooring
D
-2

You can try making a new folder and copy over the .apk file that you want to decode. Rename the extension of this .apk file to .zip (e.g. rename from filename.apk to filename.zip) and save it. After extructing, Now you can access the classes.dex files, etc. Also, in Asset folder you will get the resources. Though you can't get the .js file by following this process. You can use this http://www.javadecompilers.com/apk website. But still it will give you a java dicompilation.

Dough answered 19/1, 2016 at 8:52 Comment(1)
can not decompile compiled js filesMooring

© 2022 - 2024 — McMap. All rights reserved.