APK

Contents:

class androguard.core.bytecodes.apk.APK(filename, raw=False, mode='r', magic_file=None, zipmodule=1)

This class can access to all elements in an APK file

Parameters:
  • filename (string) – specify the path of the file, or raw data
  • raw (boolean) – specify if the filename is a path or raw data (optional)
  • mode (string) – specify the mode to open the file (optional)
  • magic_file (string) – specify the magic file (optional)
  • zipmodule (int) – specify the type of zip module to use (0:chilkat, 1:zipfile, 2:patch zipfile)
Example :

APK(“myfile.apk”) APK(open(“myfile.apk”, “rb”).read(), raw=True)

get_AndroidManifest()

Return the Android Manifest XML file

Return type:xml object
get_activities()

Return the android:name attribute of all activities

Return type:a list of string
get_android_manifest_axml()

Return the AXMLPrinter object which corresponds to the AndroidManifest.xml file

Return type:AXMLPrinter
get_android_manifest_xml()

Return the xml object which corresponds to the AndroidManifest.xml file

Return type:object
get_android_resources()

Return the ARSCParser object which corresponds to the resources.arsc file

Return type:ARSCParser
get_androidversion_code()

Return the android version code

Return type:string
get_androidversion_name()

Return the android version name

Return type:string
get_certificate(filename)

Return a certificate object by giving the name in the apk file

get_details_permissions()

Return permissions with details

Return type:list of string
get_dex()

Return the raw data of the classes dex file

Return type:string
get_element(tag_name, attribute)

Return element in xml files which match with the tag name and the specific attribute

Parameters:
  • tag_name (string) – specify the tag name
  • attribute (string) – specify the attribute
Return type:

string

get_elements(tag_name, attribute)

Return elements in xml files which match with the tag name and the specific attribute

Parameters:
  • tag_name – a string which specify the tag name
  • attribute – a string which specify the attribute
get_file(filename)

Return the raw data of the specified filename

Return type:string
get_filename()

Return the filename of the APK

Return type:string
get_files()

Return the files inside the APK

Return type:a list of strings
get_files_information()

Return the files inside the APK with their associated types and crc32

Return type:string, string, int
get_files_types()

Return the files inside the APK with their associated types (by using python-magic)

Return type:a dictionnary
get_libraries()

Return the android:name attributes for libraries

Return type:list
get_main_activity()

Return the name of the main activity

Return type:string
get_max_sdk_version()

Return the android:maxSdkVersion attribute

Return type:string
get_min_sdk_version()

Return the android:minSdkVersion attribute

Return type:string
get_package()

Return the name of the package

Return type:string
get_permissions()

Return permissions

Return type:list of string
get_providers()

Return the android:name attribute of all providers

Return type:a list of string
get_raw()

Return raw bytes of the APK

Return type:string
get_receivers()

Return the android:name attribute of all receivers

Return type:a list of string
get_services()

Return the android:name attribute of all services

Return type:a list of string
get_target_sdk_version()

Return the android:targetSdkVersion attribute

Return type:string
is_valid_APK()

Return true if the APK is valid, false otherwise

Return type:boolean
new_zip(filename, deleted_files=None, new_files={})

Create a new zip file

Parameters:
  • filename (string) – the output filename of the zip
  • deleted_files (None or a string) – a regex pattern to remove specific file
  • new_files (a dictionnary (key:filename, value:content of the file)) – a dictionnary of new files

Previous topic

Welcome to Androguard’s documentation!

Next topic

DVM

This Page