summaryrefslogtreecommitdiff
path: root/plugins/python/androperms
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2012-08-06 20:29:20 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2012-08-06 20:29:20 (GMT)
commitfc49e98dc2b3e0ae08a5874ecacaef046a0f3ec1 (patch)
treee121c5eb5dd0629554a498f8e1a1cce3fc0715b4 /plugins/python/androperms
parentfacec716100f598a8694889274a4589c75c14722 (diff)
Saved progress toward the Android permissions display.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@258 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'plugins/python/androperms')
-rw-r--r--plugins/python/androperms/Makefile.am8
-rw-r--r--plugins/python/androperms/androperms.py30
-rw-r--r--plugins/python/androperms/panel.py89
3 files changed, 127 insertions, 0 deletions
diff --git a/plugins/python/androperms/Makefile.am b/plugins/python/androperms/Makefile.am
index 3d1755c..f44be3c 100644
--- a/plugins/python/androperms/Makefile.am
+++ b/plugins/python/androperms/Makefile.am
@@ -3,10 +3,18 @@ andropermsdir = $(datadir)/openida/plugins/python/androperms
androperms_DATA = \
__init__.py \
+ androperms.db \
androperms.py \
defs.py \
manifest.py \
+ panel.py \
parser.py \
reader.py \
stack.py \
string.py
+
+androperms.db:
+ @tmpzip=`tempfile` ; \
+ wget http://www.android-permissions.org/permissionmap.zip -O $$tmpzip ; \
+ unzip -p $$tmpzip permissionmap/APICalls.txt | tail -n +2 - > androperms.db ; \
+ rm $$tmpzip
diff --git a/plugins/python/androperms/androperms.py b/plugins/python/androperms/androperms.py
index f85d402..0d70edc 100644
--- a/plugins/python/androperms/androperms.py
+++ b/plugins/python/androperms/androperms.py
@@ -3,8 +3,10 @@
from pychrysalide import Plugin
from manifest import AndroidManifest
+from panel import PermsPanel
from xml.dom import minidom
+import gtk
import zipfile
@@ -35,7 +37,35 @@ class AndroPerms(Plugin):
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
diff --git a/plugins/python/androperms/panel.py b/plugins/python/androperms/panel.py
new file mode 100644
index 0000000..b852049
--- /dev/null
+++ b/plugins/python/androperms/panel.py
@@ -0,0 +1,89 @@
+
+import gtk
+import os
+
+
+class PermsPanel:
+ """Display all permissions found in the Manifest."""
+
+ 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._load_all_definitions()
+
+
+ def get_widget(self):
+
+ return self._view
+
+
+
+
+
+ def _load_all_definitions(self):
+ """Load the database in memory."""
+
+ with open(os.path.dirname(__file__) + '/androperms.db', 'r') as f:
+
+ for line in f.readlines():
+
+ perm = line.strip("\n").split("\t")
+
+ for p in perm[1].split(" "):
+
+ if not p.startswith("android.permission."):
+ continue
+
+ if p not in self._perms:
+ self._perms[p] = []
+
+ self._perms[p].append(perm[0])
+
+
+ def filter_permissions(self, used):
+ """Forget all permissions which are not used."""
+
+ keep = {}
+
+ for p in self._perms:
+ if p in used:
+ keep[p] = self._perms[p]
+
+ self._perms = keep
+
+ # for p in self._perms:
+ # print p
+ # for v in self._perms[p]:
+ # print " - ", v