diff options
Diffstat (limited to 'plugins/python/apkfiles')
-rw-r--r-- | plugins/python/apkfiles/__init__.py | 2 | ||||
-rw-r--r-- | plugins/python/apkfiles/apkfiles.py | 34 |
2 files changed, 36 insertions, 0 deletions
diff --git a/plugins/python/apkfiles/__init__.py b/plugins/python/apkfiles/__init__.py new file mode 100644 index 0000000..2ebf824 --- /dev/null +++ b/plugins/python/apkfiles/__init__.py @@ -0,0 +1,2 @@ + +from apkfiles import ApkFiles as apkfiles diff --git a/plugins/python/apkfiles/apkfiles.py b/plugins/python/apkfiles/apkfiles.py new file mode 100644 index 0000000..fe7deb8 --- /dev/null +++ b/plugins/python/apkfiles/apkfiles.py @@ -0,0 +1,34 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +from pyoida 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: + + 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 |