Giter VIP home page Giter VIP logo

ti_recover's Introduction

ti_recover

license lines

Package and command-line (CLI) that helps you recover your lost source code from almost any APK made using Appcelerator Titanium, either be in development or distribution mode.

INSTALL

npm install -g puntorigen/ti_recover

USAGE

It comes with a command-line (CLI), that uses all methods of this package, and that you can use as follows:

ti_recover apkfile.apk outputdir

As part of my blog post: link to my blog
As a package contains the following methods:

init (config, onReadyCB).

Initializes the component.
Can have the keys:
apk (apkfile to open),
apk_dir (optional apk_unpack dir already create to re-utilize it),
out_dir (outputdir)

test (onReadyCB).

This returns true/false on the callback, indicating the given APK was made or not using Titanium.

extract (onReadyCB).

This does the extraction of assets and js sources into memory.

reconstruct (onReadyCB). in progress

This attempts to rebuild the source code from memory into a structure that can be opened as a Titanium Project. Can be called before writeToDisk to have a well formed Titanium project.

writeToDisk ().

This creates the files and directories of the source code in memory to the given outputdir.

copyAssets ().

This retrieves the APK image and resources assets into the outputdir.

clean ().

This cleanses the temporal directory used to process the files.

info (callback(err,data)). in progress

Retrieves Titanium information about the current APK using the extracted resources. Must be called after 'extract' method.

UPDATES

version 1.1.1:

  • now assets are put on the correct directories.

version 1.0.9:

  • updated to latest apk_unpack to use jadx.
  • now resources and manifest are also copied to outputdir

version 1.0.6:

  • added ability to recover APKs created in development mode.

version 1.0.5:

  • improved readability of CLI, added prettyfier to source code, and bugfix several issues.

version 1.0.4:

  • fixed tmp dir location bug. Now CLI works ok.

version 1.0.2-3:

  • added delay before decrypting files, to account for slower hdd disks

version 1.0.1:

  • fixed console debug

version 1.0.0:

  • first version
  • Add readme.md file

ti_recover's People

Contributors

creador avatar puntorigen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ti_recover's Issues

Output and maximum call stack problem

For whatever reason when I was using it it was trying to output things to:
C:\Users\admin\AppData\Roaming\npm\node_modules\ti_recover\C:\Users\admin\Documents\output_dir (_tmp_file would equal this)

Instead of:
C:\Users\admin\Documents\output_dir

When I was debugging a problem with ti_recover.js:158 with mkdirp I found that problem because I kept hitting "Maximum call stack reached!" when it got to extracting file ranges.

image

Unpacking zip failed

I get the following error on windows & mac with clean install

Error: Error running instance method
brut.androlib.AndrolibException: brut.directory.DirectoryException: java.util.zip.ZipException: error in opening zip file
at brut.androlib.ApkDecoder.hasResources(ApkDecoder.java:272)
at brut.androlib.ApkDecoder.decode(ApkDecoder.java:96)
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)
Caused by: brut.directory.DirectoryException: java.util.zip.ZipException: error in opening zip file
at brut.directory.ZipRODirectory.(ZipRODirectory.java:55)
at brut.directory.ZipRODirectory.(ZipRODirectory.java:38)
at brut.directory.ExtFile.getDirectory(ExtFile.java:51)
at brut.androlib.ApkDecoder.hasResources(ApkDecoder.java:270)
... 5 more
Caused by: java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:219)
at java.util.zip.ZipFile.(ZipFile.java:149)
at java.util.zip.ZipFile.(ZipFile.java:163)
at brut.directory.ZipRODirectory.(ZipRODirectory.java:53)
... 8 more

at Error (native)
at Object.extractAPK [as extract] (C:\Projecten\daisy\ti_recover-master\node_modules\apk_unpack\apk_unpack.js:64:11)
at Object.init (C:\Projecten\daisy\ti_recover-master\ti_recover.js:41:7)
at Object.<anonymous> (C:\Projecten\daisy\ti_recover-master\cli:25:10)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)

All good except my controllers

I installed ti_recover globally as you suggested, worrked perfectly, but now everything is recovered except the .js controllers

this is the error

`preparing -> ready
decoding bytes ...
converting into java array of bytes ... takes some time
extracting file ranges ...
file:alloy/CFG.js, decrypted !
file:app.js, decrypted !
file:alloy/backbone.js, decrypted !
file:alloy/constants.js, decrypted !
file:alloy/controllers/aviso.js, decrypted !
file:alloy/controllers/BaseController.js, decrypted !
file:alloy/controllers/cliente.js, decrypted !
file:alloy/controllers/cuenta.js, decrypted !
file:alloy/controllers/index.js, decrypted !
file:alloy/controllers/info.js, decrypted !
file:alloy/controllers/informacion.js, decrypted !
file:alloy/controllers/login.js, decrypted !
file:alloy/controllers/registro.js, decrypted !
file:alloy/styles/aviso.js, decrypted !
file:alloy/styles/cliente.js, decrypted !
file:alloy/styles/cuenta.js, decrypted !
file:alloy/styles/index.js, decrypted !
file:alloy/styles/info.js, decrypted !
file:alloy/styles/login.js, decrypted !
file:alloy/styles/registro.js, decrypted !
file:alloy/sync/localStorage.js, decrypted !
file:alloy/sync/properties.js, decrypted !
file:alloy/sync/sql.js, decrypted !
file:alloy/underscore.js, decrypted !
file:alloy/widget.js, decrypted !
file:alloy.js, decrypted !
file:ti.cloud/ti.cloud.js, decrypted !
file:app_props.json, decrypted !
C:---USER----\AppData\Roaming\npm\node_modules\ti_recover\node_modules\mkdirp\index.js:90
throw err0;
^

Error: EEXIST: file already exists, mkdir 'C:---USER----\AppData\Roaming\npm\node_modules\ti_recover'`

Any suggestions?

Installation issue on apk_unpack

i have some problem when installing ti_recover. From the repo in npm, im tracing that there is
dependency apk_unpack, so i do some separate installation npm i apk_unpack and the error is the same

443 error code 1
444 error path /home/kali/node_modules/ti_recover/node_modules/java
445 error command failed
446 error command sh -c node-gyp rebuild
447 error make: Entering directory '/home/kali/node_modules/ti_recover/node_modules/java/build'
447 error CXX(target) Release/obj.target/nodejavabridge_bindings/src/java.o
447 error make: Leaving directory '/home/kali/node_modules/ti_recover/node_modules/java/build'
448 error gyp info it worked if it ends with ok
448 error gyp info using [email protected]
448 error gyp info using [email protected] | linux | x64
448 error gyp info find Python using Python version 3.9.1 found at "/usr/bin/python3"
448 error gyp info spawn /usr/bin/python3
448 error gyp info spawn args [
448 .. and so on

My env : kali linux version 2021.1 (64 bit), npm 7.5.2, node v12.20.2, javac 17-ea, node-gyp v8.0.0
if you read this @creador, i would like to know what is your environtment to install ti_recover.
Much Appreciate for the reply

I have generated a similarity of the environment you describe in Docker

I share the Dockerfile and the error, I am working with compatible versions

FROM centos:7 USER root WORKDIR /app RUN yum install epel-release -y RUN yum install dnf -y RUN dnf install java-1.8.0-openjdk-devel -y RUN yum install git -y RUN yum install -y python RUN yum groupinstall 'Development Tools' -y RUN curl -sL https://rpm.nodesource.com/setup_4.x | bash - RUN yum install nodejs -y RUN npm config set unsafe-perm true RUN npm install -g puntorigen/ti_recover COPY ./MyApp.apk ./App.apk CMD [ "ti_recover", "./App.apk", "./AppDecoder" ]

It throws the following error:

`
Appcelerator Titanium - APK Source Code Recovery Tool

/usr/lib/node_modules/ti_recover/node_modules/apk_unpack/apk_unpack.js:67

var _res = decoder.getResTableSync();

^

Error: Error running instance method

java.lang.NullPointerException

at brut.androlib.res.data.value.ResValueFactory.factory(ResValueFactory.java:74)

at brut.androlib.res.decoder.ARSCDecoder.readValue(ARSCDecoder.java:315)

at brut.androlib.res.decoder.ARSCDecoder.readEntry(ARSCDecoder.java:241)

at brut.androlib.res.decoder.ARSCDecoder.readTableType(ARSCDecoder.java:226)

at brut.androlib.res.decoder.ARSCDecoder.readTableTypeSpec(ARSCDecoder.java:156)

at brut.androlib.res.decoder.ARSCDecoder.readTablePackage(ARSCDecoder.java:118)

at brut.androlib.res.decoder.ARSCDecoder.readTableHeader(ARSCDecoder.java:80)

at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:47)

at brut.androlib.res.AndrolibResources.getResPackagesFromApk(AndrolibResources.java:559)

at brut.androlib.res.AndrolibResources.loadMainPkg(AndrolibResources.java:72)

at brut.androlib.res.AndrolibResources.getResTable(AndrolibResources.java:64)

at brut.androlib.Androlib.getResTable(Androlib.java:72)

at brut.androlib.ApkDecoder.getResTable(ApkDecoder.java:230)

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 Error (native)

at Object.extractAPK [as extract] (/usr/lib/node_modules/ti_recover/node_modules/apk_unpack/apk_unpack.js:67:22)

at Object.init (/usr/lib/node_modules/ti_recover/ti_recover.js:41:7)

at Object. (/usr/lib/node_modules/ti_recover/cli:25:10)

at Module._compile (module.js:409:26)

at Object.Module._extensions..js (module.js:416:10)

at Module.load (module.js:343:32)

at Function.Module._load (module.js:300:12)

at Function.Module.runMain (module.js:441:10)

at startup (node.js:140:18)
`

HELP

image

Please could you help me ????

Writting command - No Error?

Hello i followed step by step the README file
now i use the command

node ti_recover C:DIR\APK.apk DIR

Nothing appears, no error, no decompile, no unpack, nothing.

Any idea..?

i lost my code and i have only the APK i really need it

Error during installation or run

Hi,

I'm trying to install this on Kali and get the following error:

npm i ti_recover

> [email protected] install /root/Documents/ti_recover/node_modules/java
> node-gyp rebuild

make: Entering directory '/root/Documents/ti_recover/node_modules/java/build'
  CXX(target) Release/obj.target/nodejavabridge_bindings/src/java.o
In file included from ../../nan/nan.h:190,
                 from ../src/java.h:9,
                 from ../src/java.cpp:1:
../../nan/nan_maybe_43_inl.h: In function ‘Nan::Maybe<bool> Nan::ForceSet(v8::Local<v8::Object>, v8::Local<v8::Value>, v8::Local<v8::Value>, v8::PropertyAttribute)’:
../../nan/nan_maybe_43_inl.h:88:15: error: ‘class v8::Object’ has no member named ‘ForceSet

any advice?

I also tried on node v8 as I saw the above issue with other projects, and it installs, but I get this error when running:

ti_recover /mnt/hgfs/Host\ Home/x.apk ./output

Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
Appcelerator Titanium - APK Source Code Recovery Tool
/opt/node-v8.17.0-linux-x64/lib/node_modules/ti_recover/node_modules/java/lib/nodeJavaBridge.js:233
    return java.newInstanceSync.apply(java, args);
                                ^

Error: Error creating class
java.lang.NullPointerException
	at java.io.File.<init>(File.java:277)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

    at new javaClassConstructorProxy (/opt/node-v8.17.0-linux-x64/lib/node_modules/ti_recover/node_modules/java/lib/nodeJavaBridge.js:233:33)
    at Object.extractAPK [as extract] (/opt/node-v8.17.0-linux-x64/lib/node_modules/ti_recover/node_modules/apk_unpack/apk_unpack.js:59:18)
    at Object.init (/opt/node-v8.17.0-linux-x64/lib/node_modules/ti_recover/ti_recover.js:41:7)
    at Object.<anonymous> (/opt/node-v8.17.0-linux-x64/lib/node_modules/ti_recover/cli:25:10)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Function.Module.runMain (module.js:694:10)

A solution to either problem would be good, but seems like I got further by downgrading Node to v8?

Your help is much appreciated

Not working, entry point not found?

I have an apk here where it is not going to decrypt.
Its running until

preparing->ready.

from my observations, it just never finds the "bytesC.start" part.
i have also seen that my apk has two classes (classes.dex and classes2.dex) files.

Could you help me with this?

Add java/node requirements in the readme

Hi!

Could you please add the java and node versions you're using for this? I can't for the life of me get it to run. I used it once a year ago, and everything went fine, but now I have a new machine, can't get past the node-gyp rebuild phase on install. I've tried different versions of Java (8, 11, 12), and node but no success.

I've installed it locally and tried to bump the version of node-java in this package and apk_unpack to match my version of Java (11), and it's installing fine, but I'm getting a core dump on run.

Any help to replicate your setup would be appreciated.

Thanks!

No output

Hi again,

As per your comments on #8, I have downloaded an Android 6 version of the application to run through the tool.

I made the output directory in the cwd, and then ran

ti_recover app.apk output

However, the output directory is not populated? There is a _tmp directory, but this contains .js.bin files rather than decompiled .js.

Any help is appreciated!

Kind regards,

Rob

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.