apkpatcher package

Submodules

apkpatcher.cli module

apkpatcher.cli.main()

apkpatcher.conf module

Module contents

class apkpatcher.Patcher(apk: str, sdktools: str, version: str)

Bases: object

ARCH_ARM = 'arm'
ARCH_ARM64 = 'arm64'
ARCH_X64 = 'x64'
ARCH_X86 = 'x86'
AUTOLOAD_BIT = 2
CONFIG_BIT = 1
DEFAULT_GADGET_NAME = 'libfrida-gadget.so'
INTERNET_PERMISSION = 'android.permission.INTERNET'
add_network_certificate(cert)
check_binaries_tools_installed()
check_libextract()
create_lib_arch_folders(arch)

make lib folder in the apk to put native lib

create_security_config_xml(path_network: str)
delete_existing_gadget(arch_folder, delete_custom_files=0)

delete existing gadget inside the apk

enable_user_certificates(rsc)
extract_apk()

Extract the apk on the temporary folder

static get_default_config_file()
get_entrypoint_class_name()

get the class name of the entrypoint

get_entrypoint_smali_path()

get the path of apk entrypoint on the smali files

has_permission(permission_name: str) bool

Check if the apk have ‘permission_name’ as permission

Parameters:

permission_name (str): name of the permission with format: android.permission.XXX

Returns:

has_permission (bool): permission is present

inject_custom_network_certificate(rsc, path_network: str)
inject_permission_manifest(permission: str)

Inject permission on the Manifest

inject_user_certificates_label(rsc: ARSC)
insert_frida_lib(gadget_path: str, arch: str, config_file_path=None, auto_load_script_path=None)

Insert native lib inside the apk

Parameters:
  • gadget_path (str): the path of the gadget to insert

insert_frida_loader(frida_lib_name='frida-gadget')

inject snippet to load frida-gadget in smali code

patching(gadget_to_use=None, output_file=None, user_certificate=False, splits_apk=[], entrypoint=None)

patch the apk with gadget ‘gadget_to_use’

pause(pause)
repackage_apk(target_file=None)

repackage the apk

Parameters:
  • target_file (str) : the path of the new apk created if none, a new apk will be created with suffix “_patched.apk”

set_arch(arch)
set_plugin(plugin)
sign_and_zipalign(apk_path, splits_apk)

sign and zipalign file

apkpatcher.plba(filename, arch)