summaryrefslogtreecommitdiff
path: root/plugins/python/androperms
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2012-09-15 08:19:09 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2012-09-15 08:19:09 (GMT)
commit944fc0a5638bfe77fc65e514fbdd945d8a652635 (patch)
treecaad1d6c5f001dd02380aa2fae0c6dc8d67d9b60 /plugins/python/androperms
parent09d07908465d462101d27ecb1b60df52d63bbe5d (diff)
Shown all Android permissions with links to the code.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@262 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'plugins/python/androperms')
-rw-r--r--plugins/python/androperms/androperms.py67
-rw-r--r--plugins/python/androperms/panel.py78
2 files changed, 88 insertions, 57 deletions
diff --git a/plugins/python/androperms/androperms.py b/plugins/python/androperms/androperms.py
index 0d70edc..6d65ca4 100644
--- a/plugins/python/androperms/androperms.py
+++ b/plugins/python/androperms/androperms.py
@@ -1,9 +1,10 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-from pychrysalide import Plugin
from manifest import AndroidManifest
from panel import PermsPanel
+from pychrysalide import Plugin
+from pychrysalide.gui.panels import PanelItem
from xml.dom import minidom
import gtk
@@ -45,27 +46,69 @@ class AndroPerms(Plugin):
print
- button = gtk.Button("Hello World")
- button.show()
-
- treestore = gtk.TreeStore(str, str, str)
panel = PermsPanel()
+ self._build_panel_item()
+
+
panel.filter_permissions(plist)
- #self.add_wgt(panel.get_widget())
instrs = binary.get_instructions()
+ buffer = binary.disassembled_buffer
+
+
+
+
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 i.keyword.startswith("invoke"):
+
+ 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.CellRendererText()
+ locations.pack_start(cell, False)
+ locations.add_attribute(cell, "text", 0)
+
+ functions = gtk.TreeViewColumn()
+ self._tree.append_column(functions)
+
+ cell = gtk.CellRendererText()
+ functions.pack_start(cell, True)
+ functions.add_attribute(cell, "text", 1)
+
+ self._store = gtk.TreeStore(str, str)
+ self._tree.set_model(self._store)
- if text.startswith("invoke"):
- #print "[0x%08lx] " % i.address, text
- pass
+ pi = PanelItem(name="Permissions", lname="Permissions", widget=self._scrolled_window, path="S")
+ pi.dock()
diff --git a/plugins/python/androperms/panel.py b/plugins/python/androperms/panel.py
index b852049..ca7bb90 100644
--- a/plugins/python/androperms/panel.py
+++ b/plugins/python/androperms/panel.py
@@ -1,5 +1,6 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
-import gtk
import os
@@ -8,50 +9,12 @@ class PermsPanel:
def __init__(self):
-
- tree = gtk.TreeView()
-
- languages = gtk.TreeViewColumn()
- languages.set_title("Programming languages")
-
- cell = gtk.CellRendererText()
- languages.pack_start(cell, True)
- languages.add_attribute(cell, "text", 0)
-
- treestore = gtk.TreeStore(str)
-
- it = treestore.append(None, ["Scripting languages"])
- treestore.append(it, ["Python"])
- treestore.append(it, ["PHP"])
- treestore.append(it, ["Perl"])
- treestore.append(it, ["Ruby"])
-
- it = treestore.append(None, ["Compiling languages"])
- treestore.append(it, ["C#"])
- treestore.append(it, ["C++"])
- treestore.append(it, ["C"])
- treestore.append(it, ["Java"])
-
- tree.append_column(languages)
- tree.set_model(treestore)
-
- tree.show()
-
- self._view = tree
-
self._perms = { }
+ self._used = { }
self._load_all_definitions()
- def get_widget(self):
-
- return self._view
-
-
-
-
-
def _load_all_definitions(self):
"""Load the database in memory."""
@@ -69,7 +32,10 @@ class PermsPanel:
if p not in self._perms:
self._perms[p] = []
- self._perms[p].append(perm[0])
+ call = perm[0].split("(")[0]
+
+ if call not in self._perms[p]:
+ self._perms[p].append(call)
def filter_permissions(self, used):
@@ -83,7 +49,29 @@ class PermsPanel:
self._perms = keep
- # for p in self._perms:
- # print p
- # for v in self._perms[p]:
- # print " - ", v
+ for p in keep:
+ self._used[p] = []
+
+
+ def check_call(self, addr, line):
+ """Check if a call requires some rights."""
+
+ for p in self._perms:
+
+ for c in self._perms[p]:
+
+ if line.find(c) > -1:
+ self._used[p].append([addr, c + "()"])
+
+
+ def fill_tree(self, store):
+ """Fill a treeview with all found permissions."""
+
+ for p in self._used:
+
+ if len(self._used[p]) > 0:
+
+ it = store.append(None, [p, None])
+
+ for f in self._used[p]:
+ store.append(it, ["0x%08x" % f[0], f[1]])