Beispiel #1
0
    def _get_iconname_by_id(self, _id):
        _id = int(_id, 16)

        _zipfd = zipfile.ZipFile(self.apkfilepath, 'r')
        _d = _zipfd.read("resources.arsc")

        _p = ResourceParser(_d)
        _m = _p.parse_resources()
        _r = ResObject()
        _r.update(_m)

        parser = ResourceParser("")
        parser.set_restable(_r)
        result = parser.dereference_resource(_id)
        _draw_dir = result[1]

        #find iconpath by iconname using regex
        _filelist = _zipfd.namelist()
        _iconpath = "res/drawable-hdpi/" + result[2] + ".png"
        import re
        _p = re.compile("res/drawable.+/" + result[2] + ".png")
        for _file in _filelist:
            if _p.match(_file):
                _iconpath = _file
                break

        print "try to find iconpath:" + _iconpath
        _zipfd.close()
        return _iconpath
Beispiel #2
0
    def _get_string_by_id(self, _id):
        _id = int(_id, 16)

        _zipfd = zipfile.ZipFile(self.apkfilepath, 'r')
        _d = _zipfd.read("resources.arsc")
        _zipfd.close()

        _p = ResourceParser(_d)
        _m = _p.parse_resources()
        _r = ResObject()
        _r.update(_m)

        parser = ResourceParser("")
        parser.set_restable(_r)
        result = parser.dereference_resource(_id)
        _name = result[2]

        package = _r.name_map.values()[0]
        _p.set_restable(_r)
        _value = _p.resolve_string(package.name, _name)

        return _value