Open akshatgit opened 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:
Using a bash script:
#!/bin/bash
FILES=/path/to/apks/*
for file in $FILES
do
echo "Processing file: $file"
ninjadroid $file --all --json
done
NOTE: the above is just an example, which simply executes the command, but you may want to store the output somewhere (e.g. redirecting the stdout to something like > "/path/to/output/$file.json"
or using NinjaDroid --extract
option).
Using a python script:
#!/usr/bin/env python3
import os
from subprocess import PIPE, Popen
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.
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?