Skip to main content

Python wrapper to use FlowDroid APK analyzer.

Project description

PyFlowDroid

Python wrappers for FlowDroid Apk analyzer. This project was built with two goals in mind:

  1. Automate the creation of a FlowDroid environment out-of-the-box
  2. Allow the usage of FlowDroid from Python code

1. Installation

1.1 Prerequisites

Make sure you have:

  1. A working version of java in the PATH of your environment.
  2. A working version of python in the PATH of your environment.
  3. A working version of git in the PATH of your environment.

1.2 Installing pyFlowDroid

You can get it from pypi using pip:

$ pip install pyflowdroid

Then, you need to run an additional command to make pyflowdroid download and install FlowDroid and the required resources to use it:

$ python -m pyflowdroid install

2. Using pyflowdroid as a Python library

You can use this script as a guide for downloading and analyzing apk files with pyflowdroid:

import pyflowdroid

# Path to a folder where the apks are stored
apkfolder = "./apks"

# If you need test apks, you can dowload the desired amount
# from a given provider into a destination folder
pyflowdroid.fetch(10, 'cubapk.com', apkfolder)

# Analyze all the apks in a folder
apk_count, leaks_count, leaky_apps = pyflowdroid.analyze(apkfolder)

# Analyze a single apk
flowdroid_logs = pyflowdroid.analyze_apk('./apks/test.apk')

3. Using pyflowdroid as a command line tool

The main advantage of using pyflowdroid as a command line tool over using FlowDroid directly is the automatic gathering of resources required to execute the flow analysis. pyflowdroid comes bundled with all the required resources to allow a quick analysis of apk files.

To analyze an .apk file with the default pyflowdroid setup, just run:

$ python -m pyflowdroid analyze path/to/file.apk

Similarly, you can perform a flow analysis on all the apks inside a folder:

$ python -m pyflowdroid analyze path/to/folder/

This should store raw FlowDroid logs for each analyzed apk and then show a general report like the following:

################################################################################
#                              PYFLOWDROID REPORT                              #
################################################################################
Analized: 5
Leaks found: 2

Leaky apps:
 - 'path/to/folder/app1.apk'
 - 'path/to/folder/app3.apk'

If you want to get some test apks, pyflowdroid includes a download function to fetch apks from a given provider. Current available providers are:

To fetch apks from a provider, just run:

$ python -m pyflowdroid download amount path/to/store/apks/ provider_name

For instance, to download 10 apk files from cubapk.com, run:

$ python -m pyflowdroid download 10 ./myapks/ cubapk.com

4. Contributing to pyflowdroid

If you want to add any features to pyflowdroid you will need to get a development enviroment.

4.1 Fetching the project source code

You can clone the github repository by executing:

$ git clone https://github.com/gvieralopez/pyFlowDroid
$ cd pyFlowDroid

4.2 Installing pyFlowDroid dependencies

You can install them with poetry by executing:

$ poetry shell
$ poetry install
$ poetry build

4.3 Download FlowDroid and its dependencies

This step will download and install FlowDroid. After doing this you can use FlowDroid with or without pyFlowDroid wrappers. Simply run:

$ python -m pyflowdroid install

4.4 Making your changes appear in the project

Just make a Pull Request.

4.5 Quality Assurance:

Run tests:

$ pytest

Type checking:

$ mypy

Code style:

$ flake8

4.6 Pending features

  • Improve cli interface with hints on the parameters
  • Improve cli interface with parameters all supported API functions
  • Recognize in runtime when Flowdroid and depencies were not installed
  • Add new apk providers
  • Write pytest unit tests
  • Write documentation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyflowdroid-0.2.0.tar.gz (442.1 kB view details)

Uploaded Source

Built Distribution

pyflowdroid-0.2.0-py3-none-any.whl (456.5 kB view details)

Uploaded Python 3

File details

Details for the file pyflowdroid-0.2.0.tar.gz.

File metadata

  • Download URL: pyflowdroid-0.2.0.tar.gz
  • Upload date:
  • Size: 442.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.10.4 Windows/10

File hashes

Hashes for pyflowdroid-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c6cbdf53fa985a2b5126aedf4393fa50a8e518f0686a2c18409d917e3ed358a7
MD5 5e70ec8ee5ca2364bb37d5cf443c7e7b
BLAKE2b-256 4254c1f6afefba8ea89378b9017e27156a531d45c45a85fa048ebd82dd375b39

See more details on using hashes here.

File details

Details for the file pyflowdroid-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pyflowdroid-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 456.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.10.4 Windows/10

File hashes

Hashes for pyflowdroid-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5385f40c0803873de6fc8463ed0635fcc3228d2f7a954ad1dea7486898ba6d79
MD5 74babb19055b50bad91f40a9be61e690
BLAKE2b-256 2b73b65f5f23680973627344f60fd60a27f52edee02cd7422a796251f29f5d83

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page