blob: fea9c07f4838148795065c284b984c91199fc2f5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
from pychrysalide import PluginModule
from pychrysalide import core
from pychrysalide.analysis.contents import EncapsulatedContent
from pychrysalide.analysis.contents import MemoryContent
import io
import zipfile
class ApkFiles(PluginModule):
"""Open and process APK files."""
def __init__(self):
"""Initialize the plugin for Chrysalide."""
interface = {
'name' : 'ApkFiles',
'desc' : 'Add suppport for the APK file format',
'version' : '0.1',
'actions' : ( PluginModule.PGA_CONTENT_EXPLORER, )
}
super(ApkFiles, self).__init__(**interface)
def handle_binary_content(self, action, content, wid, status):
"""Process an operation on a binary content."""
assert(action == PluginModule.PGA_CONTENT_EXPLORER)
pseudo_file = io.BytesIO(content.data)
if zipfile.is_zipfile(pseudo_file):
zf = zipfile.ZipFile(pseudo_file)
if zf.namelist().count('classes.dex') > 0 \
and zf.namelist().count('AndroidManifest.xml') > 0:
explorer = core.get_content_explorer()
for name in zf.namelist():
f = zf.open(name, 'r')
data = f.read()
f.close()
mem_content = MemoryContent(data)
encaps_content = EncapsulatedContent(content, name, mem_content)
explorer.populate_group(wid, encaps_content)
|