diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2012-08-03 13:03:26 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2012-08-03 13:03:26 (GMT) |
commit | b7c83221f2a60be8ee5d44a7599dbe6869af005f (patch) | |
tree | 814e294533920d18f8734baa9aaef47c676e520a /plugins/python/androperms/reader.py | |
parent | 7d2b7ca95966c2d687526cd75a96d1ea67d3f503 (diff) |
Loaded the permissions used by an APK file.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@255 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'plugins/python/androperms/reader.py')
-rw-r--r-- | plugins/python/androperms/reader.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/plugins/python/androperms/reader.py b/plugins/python/androperms/reader.py new file mode 100644 index 0000000..f126850 --- /dev/null +++ b/plugins/python/androperms/reader.py @@ -0,0 +1,41 @@ +#!/usr/bin/python -u +# -*- coding: utf-8 -*- + + +from struct import unpack + + +class AXMLReader(): + """Provide various read helpers.""" + + def __init__(self, data): + + self._data = data + + self._position = 0 + self._length = len(self._data) + + + def readInt(self): + """Read a 4-bytes value.""" + + self.skipInt() + + value = unpack('<L', self._data[self._position - 4 : self._position])[0] + + return value + + + def skipInt(self): + """Skip a 4-bytes value.""" + + self._position += 4 + + if self._position > self._length: + raise Exception("Reader out of bound (%d > %d)!" % (self._position, self._length)) + + + def readIntArray(self, length): + """Read an array composed of 4-bytes values.""" + + return [ self.readInt() for i in range(0, length) ] |