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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
from pychrysalide.gui.panels import PanelItem
import gtk
import os
def _build_permissions_panel_content():
"""Build content for permissions panels."""
scrolled_window = gtk.ScrolledWindow()
scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
scrolled_window.show()
tree = gtk.TreeView()
tree.set_headers_visible(False)
tree.show()
scrolled_window.add_with_viewport(tree)
locations = gtk.TreeViewColumn()
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()
tree.append_column(functions)
cell = gtk.CellRendererPixbuf()
functions.pack_start(cell, False)
functions.add_attribute(cell, 'pixbuf', 2)
cell = gtk.CellRendererText()
functions.pack_start(cell, True)
functions.add_attribute(cell, 'text', 3)
store = gtk.TreeStore(gtk.gdk.Pixbuf, str, gtk.gdk.Pixbuf, str)
tree.set_model(store)
return scrolled_window, tree, store
class PermsPanel(PanelItem):
"""Display all permissions found in the Manifest."""
def __new__(cls):
"""Create the GLib instance relative this class as soon as possible,
for the pygobject registering process."""
scrolled_window, tree, store = _build_permissions_panel_content()
self = super(PermsPanel, cls).__new__(cls, 'Permissions', 'Android Permissions', \
scrolled_window, 'SE')
self._scrolled_window = scrolled_window
self._tree = tree
self._store = store
self._perms = {}
return self
def __init__(self):
"""Initialize the Python instance of the panel."""
self._tree.connect('row-activated', self._on_row_selection)
self.dock()
self.register()
def memorize_permissions(self, binary, perms):
"""Attach found permissions to a new loaded binary."""
self._perms[binary] = perms
def update_for_binary(self, binary):
"""Fill the treeview with all found permissions for the given binary."""
self._store.clear()
used = self._perms[binary]
for p in used:
if len(used[p]) > 0 or True:
img = os.path.dirname(os.path.abspath(__file__)) + '/android.png'
buf = gtk.gdk.pixbuf_new_from_file(img)
it = self._store.append(None, [buf, p, None, None])
img = os.path.dirname(os.path.abspath(__file__)) + '/routine.png'
buf = gtk.gdk.pixbuf_new_from_file(img)
for f in used[p]:
self._store.append(it, [None, "0x%08x" % f[0], buf, f[1]])
self._tree.expand_all()
def _on_row_selection(self, treeview, path, column):
"""Scroll the current view to the selected address."""
selection = treeview.get_selection()
model, it = selection.get_selected()
# On ne traite que les lignes de code
if model.get_value(it, 0) == None:
self.get_current_view().scroll_to_address(int(model.get_value(it, 1), 16))
|