#!/usr/bin/python # -*- coding: utf-8 -*- from pychrysalide import Plugin import zipfile class ApkFiles(Plugin): """Open and process APK files.""" def get_action(self): """Register the plugin for given actions.""" return Plugin.PGA_FORMAT_MATCHER def is_matching(self, filename, data): """Define if the given file can be handled.""" if not zipfile.is_zipfile(filename): return Plugin.MFA_NONE, None, None zf = zipfile.ZipFile(filename) if zf.namelist().count('classes.dex') > 0 \ and zf.namelist().count('AndroidManifest.xml') > 0: f = zf.open('classes.dex', 'r') data = f.read() f.closed return Plugin.MFA_RELOAD, None, bytearray(data) else: return Plugin.MFA_NONE, None, None