androlyze.model.android.apk package

Submodules

androlyze.model.android.apk.Apk module

class androlyze.model.android.apk.Apk.Apk[source]

Bases: androlyze.model.Hashable.Hashable

Defines an object for the basic attributes of an Apk file.

See also

http
//developer.android.com/guide/topics/manifest/manifest-intro.html

Attributes

Methods

app_code_comparator(other)[source]

Comparator for app code size

build_date

datetime.datetime : the build date (last timestamp of classes.dex) in zipfile

del_build_date()[source]
del_import_date()[source]
del_package_name()[source]
del_size_app_code()[source]
del_tag()[source]
del_version_name()[source]
detailed_description()[source]

Get a detailed description of the Apk. Includes package name, version name, hash, import date and path

get_apk_filename_from_manifest()[source]

Build the filename based on the manifest information (packageName and versionName)

get_build_date()[source]

Get the date of the classes.dex file (build date).

Returns:

datetime.datetime

The build date.

get_hash()[source]

Get the sha256 message digest of the apk file and store it.

Returns:

str

sha256 message digest as hexstring

None

If path is None

Raises:

CouldNotOpenApk

If the APK could no be opened

get_import_date()[source]
get_manifest_components_with_intent_filter()[source]

Get the package names which define an intent-filter.

Returns:

set<str>

Set of package names.

get_manifest_exported_components()[source]

Get the package names which are exported.

Therefore the manifest looks like: “

<activity android:name=”.SQLDemo”
android:exported=”true”>

Returns:

set<str>

Set of package names.

get_manifest_intent_filters(package_name, dalvik_syntax=True)[source]

Check if the component specified through the package_name is callable from outside.

Parameters:

apk : Apk

package_name: str

dalvik_syntax: bool, optional (default is True)

Expects the package name in the dalvik bytecode form like e.g. (“Lde/nachtmaar/myapp/myclass;”)

Returns:

list<dict>

Lists the public components with their intent filters

get_manifest_public_components()[source]

Get the package names which are publicly available. Either through an intent or through an explicit export

Returns:

set<str>

Set of package names.

get_package_name()[source]
get_size_app_code()[source]
get_tag()[source]
get_version_name()[source]
import_date

datetime.datetime : the import date (default is None)

meta_dict()[source]

Returns a sorted dictionary holding meta information of the APK file

package_name

str - Package name of the apk. Unique apk identifier (at least in the store)

set_build_date(value)[source]
set_import_date(value)[source]
set_meta(apk)[source]

Set the meta information from apk.

Parameters:

apk : Apk

The apk from which the meta information will be taken

set_package_name(value)[source]
set_size_app_code(value)[source]
set_tag(value)[source]
set_version_name(value)[source]
short_description()[source]
size_app_code

int : size of the uncompressed .dex file

tag

str : some tag

version_name

str - version

androlyze.model.android.apk.EAndroApk module

class androlyze.model.android.apk.EAndroApk.EAndroApk(*args, **kwargs)[source]

Bases: androlyze.model.android.apk.Apk.Apk, androguard.core.bytecodes.apk.APK

Extends the androguard APK class with a sha256 hash function and implements the Apk interface.

Attributes

Methods

build_date

datetime.dateime : build date (inferred from classes.dex timestamp)

del_import_date()[source]
del_package_name()[source]
del_path()[source]
del_tag()[source]
del_version_name()[source]
get_build_date()[source]

Get the date of the classes.dex file (build date).

Returns:

datetime.datetime

The build date.

get_hash()[source]

Get the sha256 message digest of the APK file. The hash will be computed from memory.

get_import_date()[source]
get_package_name()[source]
get_path()[source]
get_size_app_code()[source]

Get size of app code on demand (uncompressed .dex) file

get_tag()[source]
get_version_name()[source]
hash

str - sha256 of raw apk file (hexstring)

import_date

datetime.datetime : the import date (default is None)

package_name

str - unique apk identifier (at least in the store)

path

str - path to apk file

set_import_date(value)[source]
set_package_name(value)[source]
set_path(value)[source]
set_tag(value)[source]
set_version_name(value)[source]
size_app_code

int : size of the uncompressed .dex file

tag

str : some tag

version_name

str - version

androlyze.model.android.apk.FastApk module

class androlyze.model.android.apk.FastApk.FastApk(package_name, version_name, path=None, _hash=None, import_date=None, tag=None, size_app_code=0, build_date=None)[source]

Bases: androlyze.model.android.apk.Apk.Apk, object

Provides a fast way to access the basic attributes of an APK file.

See also

http
//developer.android.com/guide/topics/manifest/manifest-intro.html

Attributes

Methods

static androguard_load_from_io(file_like_object=None, apk_file_path=None, calculate_hash=True)[source]

Load a FastApk from file-like object or path by using androgaurd. Parameters ———- file_like_object : file-like-object, optional (default is None)

A file-like obj that points to the apk. If non given, try to open a file_like_object from the given apk_file_path.
apk_file_path: str, optional (default is “not set”)
Path of apk
calculate_hash : bool
If true calculate the hash. This means the file has be to loaded completely into memory. If False, the hash will be calculated the first time it gets retrieved.
Returns:

apk: FastApk

Raises:

CouldNotOpenApk

If the apk file could not be opened

static androguard_load_from_path(apk_file_path)[source]

Load a FastApk from path with the help of androguard.

Parameters:

apk_file_path: str

path of apk

Returns:

apk: FastApk

Notes

Androguard cannot read data properly from manifest files which do not have the android prefix.

static fast_load_from_io(file_like_object=None, apk_file_path=None, calculate_hash=True)[source]

Load a FastApk from file-like object or path by unzipping only the manifest file and calculating the hash.

Parameters:

file_like_object : file-like-object, optional (default is None)

A file-like obj that points to the apk. If non given, try to open a file_like_object from the given apk_file_path.

apk_file_path: str, optional (default is “not set”)

Path of apk

calculate_hash : bool

If true calculate the hash. This means the file has be to loaded completely into memory. If False, the hash will be calculated the first time it gets retrieved.

Returns:

apk: FastApk

Raises:

CouldNotOpenApk

If the apk file could not be opened

CouldNotReadManifest

If the manifest file could not be read

static load_from_androguard_apk(andro_apk)[source]

Load a FastApk from androguard APK

Parameters:andro_apk: APK (androguard apk)
Returns:FastApk
static load_from_eandroapk(eandro_apk)[source]

Load a FastApk from an EAndroApk.

Parameters:eandro_apk: EAndroApk
Returns:FastApk
static load_from_result_dict(res_dict)[source]

Load a FastApk from the res_dict.

Parameters:

res_dict : dict

See ResultObject.description_dict

Module contents