androlyze.loader package

Submodules

androlyze.loader.ApkImporter module

class androlyze.loader.ApkImporter.ApkImporter(apk_paths, storage)[source]

Bases: object

Class for loading/importing a list of apk files

Attributes

Methods

apk_paths

iterable<str> : List of apk files (paths)

del_apk_paths()[source]
del_storage()[source]
get_apk_paths()[source]
static get_apks_from_dir(apk_dir)[source]

Get a list of apk files from the given directory (recursive).

Parameters:

apk_dir: str

the directory from which to import the apk files

Returns:

generator<str>

Apk file names

static get_apks_from_list(apk_list)[source]

Filter the files in the list by checking if they have the APK file extension.

Parameters:

apk_paths : list<str>

List of APK files

Returns:

itertools.ifilter<str>

Generator over apk files

static get_apks_from_list_or_dir(apks)[source]

Get a list of apk files from directory or list by checking the .apk file extension.

Parameters:

apks: generator<str>

List of directories or apk files.

Returns:

generator<str>

Path to Apks.

Examples

>>> from androlyze.loader.ApkImporter import ApkImporter
>>> ApkImporter.get_apks_from_list_or_dir["foo.apk", "bar.apk"]
>>> ApkImporter.get_apks_from_list_or_dir["foo/", "bar/"]
>>> ApkImporter.get_apks_from_list_or_dir["foo.apk", "apk_dir/"]
get_storage()[source]
import_apks(copy_apk=False, copy_to_mongodb=False, update=False, tag=None)[source]

Import APKs.

Create a storage entry and copy the apk if copy_apk and not already in the storage.

Will also set the path of the Apk`s (the directory to which it got imported) at least if `copy_apk is true.

Parameters:

copy_apk : bool, optional (default is False)

If true also import the apk file (copy it)

copy_to_mongodb : bool, optional (default is False)

Also import into MongoDB. Needed for the distributed analysis.

update : bool, optional (default is False)

Update apks that have already been imported.

tag : str, optional (default is None)

Tag the apks.

Returns:

generator<Apk>

The imported `Apk`s. Even if you don’t want the result value, you have to force the generator to continue until it’s empty to get the import process finished.

import_from_flo(file_like_object, import_path_str='file-like object', copy2disk=False, copy2mongodb=False, update=False, tag=None)[source]

Import an apk from a file_like_object if not already in the storage.

Will also set the path (absolute) of the returned Apk (the directory to which it got imported) at least if copy2disk is true. Also sets the import date and tag.

Parameters:

file_like_object

import_path_str : str, optional (default is “file-like object”)

Optional string which will be passed to the Exceptions if they get raised. Describes from which the import failed.

copy2disk : bool, optional (default is False)

If true also import the apk file (copy it)

copy2mongodb : bool, optional (default is False)

Also import into MongoDB. Needed for the distributed analysis.

update : bool, optional (default is False)

Update apks that have already been imported.

tag : str, optional (default is None)

Tag the apks.

Returns:

Apk

If no error occurred.

Raises:

ApkImportError

static is_apk_file(filename)[source]

Check if the filename has the .apk extension

set_apk_paths(value)[source]
set_storage(value)[source]
storage

StorageInterface : storage for audit results of apks

Module contents