diff options
Diffstat (limited to 'plugins/python/androperms/androperms.py')
-rw-r--r-- | plugins/python/androperms/androperms.py | 91 |
1 files changed, 24 insertions, 67 deletions
diff --git a/plugins/python/androperms/androperms.py b/plugins/python/androperms/androperms.py index 569558a..18443fc 100644 --- a/plugins/python/androperms/androperms.py +++ b/plugins/python/androperms/androperms.py @@ -2,18 +2,25 @@ # -*- coding: utf-8 -*- from manifest import AndroidManifest +from db import PermsDataBase from panel import PermsPanel from pychrysalide import Plugin -from pychrysalide.gui.panels import PanelItem from xml.dom import minidom -import gtk +import re import zipfile class AndroPerms(Plugin): """List all permissions given to an APK files.""" + def init(self, ref): + """Initialize the plugin.""" + + self._panel = PermsPanel() + + return True + def get_action(self): """Register the plugin for given actions.""" @@ -33,36 +40,26 @@ class AndroPerms(Plugin): manifest = AndroidManifest(data) xml = minidom.parseString(manifest.getXML()) - print - print "Permissions for ", binary.get_filename(), " :" - print "-------------" - print + # 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 - - - - panel = PermsPanel() + # print p.getAttribute("android:name") - self._build_panel_item() - - - - panel.filter_permissions(plist) + # print + db = PermsDataBase() + db.filter_permissions(plist) instrs = binary.get_instructions() buffer = binary.disassembled_buffer - - - + pfn = re.compile('<.* ([^ ]*)\(') for i in instrs: @@ -71,52 +68,12 @@ class AndroPerms(Plugin): line = buffer.find_line_by_addr(i.address) text = line.get_text() - panel.check_call(i.address, text) - - - - - - panel.fill_tree(self._store) - self._tree.expand_all() - - - - def _build_panel_item(self): - - self._scrolled_window = gtk.ScrolledWindow() - self._scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) - self._scrolled_window.show() - - self._tree = gtk.TreeView() - self._tree.set_headers_visible(False) - self._tree.show() - self._scrolled_window.add_with_viewport(self._tree) - - locations = gtk.TreeViewColumn() - self._tree.append_column(locations) - - cell = gtk.CellRendererPixbuf() - locations.pack_start(cell, False) - locations.add_attribute(cell, 'pixbuf', 0) - - cell = gtk.CellRendererText() - locations.pack_start(cell, False) - locations.add_attribute(cell, 'text', 1) - - functions = gtk.TreeViewColumn() - self._tree.append_column(functions) - - cell = gtk.CellRendererPixbuf() - functions.pack_start(cell, False) - functions.add_attribute(cell, 'pixbuf', 2) + #print "check %s" % text - cell = gtk.CellRendererText() - functions.pack_start(cell, True) - functions.add_attribute(cell, 'text', 3) + name = pfn.search(text) - self._store = gtk.TreeStore(gtk.gdk.Pixbuf, str, gtk.gdk.Pixbuf, str) - self._tree.set_model(self._store) + if name != None: + #print " --> ", name.group(1) + db.check_call(i.address, name.group(1)) - pi = PanelItem('Permissions', 'Permissions', self._scrolled_window, 'SE') - pi.dock() + self._panel.memorize_permissions(binary, db.get_used_permissions()) |