rovellipaolo / NinjaDroid

Ninja Reverse Engineering on Android APK packages
GNU General Public License v3.0
273 stars 49 forks source link

Pip package #19

Open akshatgit opened 3 years ago

akshatgit commented 3 years ago

Hi, Thanks for the awesome repo, I'm planning to use it in one of my projects. I have approx 300 apks to analyse, and I want to use this library from a script to get all the JSON data. Any idea how to do this?

rovellipaolo commented 3 years ago

Hello! I'm deeply sorry for the late reply, somehow I've missed this. :(

To be honest, in the past, I thought more than once about making a python package. However, having a script-like nature and so many external dependencies (java, aapt, apktool, dex2jar, ...), I've opted for "packaging" it with docker and flatpak/snap instead. That said, if you have time and are interested, I'm open for pull requests. :)

Now, coming to your original question, how can you automate NinjaDroid usage? Well, it depends a bit on what exactly you want to achieve but, at first sight, I can think of a couple of possible solutions:

def main(): for file in os.listdir("/path/to/apks/"): print("Processing file: " + file) command = "ninjadroid " + file + " --all --json" with Popen(command, stdout=PIPE, stderr=None, shell=True) as process: output = process.communicate()[0].decode("utf-8") print(output)

if name == "main": sys.exit(main())


  **NOTE:** similarly to the previous example, also here it just prints the output of the command, but you may want to do something with it.

Note that, in both examples, I'm assuming that you've installed NinjaDroid locally (see `make build` and `make install`). That said, you can achieve the same also using the docker or flatpak or snap versions.
You can see some examples of automation here: https://github.com/rovellipaolo/NinjaDroid/blob/master/regression/

Let me know if this solves your issue.