예제 #1
0
    def setUp(self):
        file_path = os.path.abspath(
            os.path.join(os.path.dirname(__file__), "..", 'data', 'test'))
        with zipfile.ZipFile(file_path, mode="r") as zf:
            data = zf.read('resources.arsc')
            self.arscobj = ARSCParser(data)

        self.package = self.arscobj.get_packages_names()[0]
예제 #2
0
 def _init_arsc(self):
     ARSC_NAME = 'resources.arsc'
     try:
         with apkfile.ZipFile(self.apk_path, mode="r") as zf:
             if ARSC_NAME in zf.namelist():
                 data = zf.read(ARSC_NAME)
                 self.arsc = ARSCParser(data)
     except Exception as e:
         raise e
예제 #3
0
 def _init_app_icon(self):
     files = self.get_files()
     result = re.search(r':icon="@(.*?)"', self.get_org_manifest())
     ids = '0x' + result.groups()[0].lower()
     try:
         with apkfile.ZipFile(self.apk_path, 'r') as z:
             data = z.read('resources.arsc')
             self.arscobj = ARSCParser(data)
             self.package = self.arscobj.get_packages_names()[0]
             datas = xmltodict.parse(
                 self.arscobj.get_public_resources(self.package))
             for item in datas['resources']['public']:
                 if ids != item['@id']:
                     continue
                 for f in files:
                     name = f['name']
                     if item['@type'] in name and item['@name'] in name:
                         self.app_icon = name
     except Exception as ex:
         raise ex
예제 #4
0
 def resources(self):
     with zipfile.ZipFile(self.apk_path, mode="r") as zf:
         data = zf.read('resources.arsc')
         return ARSCParser(data)