diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2011-10-01 17:20:50 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2011-10-01 17:20:50 (GMT) |
commit | 02cb3aa4e7b18b644b034a5c659c332becf99c9b (patch) | |
tree | 8d816e5f93820c6ef5ba804d7c0776a65d78329a /plugins/python | |
parent | e0266175537ec220544c050874be215b11c902fa (diff) |
Defined the first real [python] plugin.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@210 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'plugins/python')
-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 |