summaryrefslogtreecommitdiff
path: root/plugins/python/androperms/androperms.py
blob: 0d70edc199e695f4d90598696218802fa743cff0 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/python
# -*- coding: utf-8 -*-

from pychrysalide import Plugin
from manifest import AndroidManifest
from panel import PermsPanel
from xml.dom import minidom

import gtk
import zipfile


class AndroPerms(Plugin):
    """List all permissions given to an APK files."""


    def get_action(self):
        """Register the plugin for given actions."""

        return Plugin.PGA_DISASS_PROCESS


    def execute_on_binary(self, binary, action):
        """Process once a binary is disassembled."""

        zf = zipfile.ZipFile(binary.get_filename())

        f = zf.open('AndroidManifest.xml', 'r')
        data = f.read()
        f.closed

        manifest = AndroidManifest(data)
        xml = minidom.parseString(manifest.getXML())

        print
        print "Permissions for ", binary.get_filename(), " :"
        print "-------------"
        print

        plist = []

        for p in xml.getElementsByTagName("uses-permission"):
            plist.append(p.getAttribute("android:name"))
            print p.getAttribute("android:name")

        print

        button = gtk.Button("Hello World")
        button.show()

        treestore = gtk.TreeStore(str, str, str)


        panel = PermsPanel()


        panel.filter_permissions(plist)

        #self.add_wgt(panel.get_widget())

        instrs = binary.get_instructions()

        for i in instrs:
        #    print i, " :: 0x%08lx" % i.address

            line = binary.disassembled_buffer.find_line_by_addr(i.address)
            text = line.get_text()

            if text.startswith("invoke"):
                #print "[0x%08lx] " % i.address, text
                pass