Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: 4 is not a valid HiddenApiClassDataItem.DomapiApiFlag #1002

Open
taylor00541 opened this issue Feb 11, 2024 · 0 comments
Open

ValueError: 4 is not a valid HiddenApiClassDataItem.DomapiApiFlag #1002

taylor00541 opened this issue Feb 11, 2024 · 0 comments

Comments

@taylor00541
Copy link

Describe what you wanted to do

Parse the dex-es in this framework.jar file, taken from a lineageos custom rom.

  1. Download lineage-20.0-20240126-nightly-lynx-signed.zip from here.
  2. Extract system.img from the OTA, and then get /system/framework/framework.jar
    framework.jar.zip
  3. Use androguard.misc.AnalyzeDex to analyze any of the .dex inside this jar.
  4. An exception is raised there, either ValueError: 4 is not a valid HiddenApiClassDataItem.DomapiApiFlag or ValueError: 6 is not a valid HiddenApiClassDataItem.DomapiApiFlag.

System Information

  • Androguard Version: 4.0.2, tried also with master.
  • Python Version: 3.11
  • Operating System: Windows 11, tried also with Ubuntu 22

Further Log Files and Output

ValueError                                Traceback (most recent call last)
Cell In[2], line 1
----> 1 androguard.misc.AnalyzeDex("./classes4.dex")

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\androguard\misc.py:96, in AnalyzeDex(filename, session, raw)
     93     with open(filename, "rb") as fd:
     94         data = fd.read()
---> 96 return session.addDEX(filename, data)

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\androguard\session.py:175, in Session.addDEX(self, filename, data, dx, postpone_xref)
    172 self.table_information.insert(dict(session_id=str(self.session_id), filename=filename, digest=digest, type="DEX"))
    174 logger.debug("Parsing format ...")
--> 175 d = dex.DEX(data)
    176 logger.info("added DEX:{}".format(digest))
    178 self.analyzed_files[filename].append(digest)

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\androguard\core\dex\__init__.py:7669, in DEX.__init__(self, buff, decompiler, config, using_api)
   7666 self.CM.set_decompiler(decompiler)
   7668 self._preload(buff)
-> 7669 self._load(buff)

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\androguard\core\dex\__init__.py:7681, in DEX._load(self, buff)
   7679     logger.warning("no map list! This DEX file is probably empty.")
   7680 else:
-> 7681     self.map_list = MapList(self.CM, self.header.map_off, self.raw)
   7683     self.classes = self.map_list.get_item_type(TypeMapItem.CLASS_DEF_ITEM)
   7684     self.methods = self.map_list.get_item_type(TypeMapItem.METHOD_ID_ITEM)

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\androguard\core\dex\__init__.py:7554, in MapList.__init__(self, cm, off, buff)
   7551 ordered = sorted(self.map_item, key=lambda mi: load_order[mi.get_type()])
   7553 for mi in ordered:
-> 7554     mi.parse()
   7556     c_item = mi.get_item()
   7557     if c_item is None:

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\androguard\core\dex\__init__.py:7085, in MapItem.parse(self)
   7082 elif TypeMapItem.HIDDENAPI_CLASS_DATA_ITEM == self.type:
   7083     # Byte aligned
   7084     buff.seek(self.offset)
-> 7085     self.item = HiddenApiClassDataItem(buff, cm)
   7087 elif TypeMapItem.ANNOTATION_SET_REF_LIST == self.type:
   7088     # 4-byte aligned
   7089     buff.seek(self.offset + (self.offset % 4))

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\androguard\core\dex\__init__.py:1217, in HiddenApiClassDataItem.__init__(self, buff, cm)
   1213 for i in range(offsets_size):
   1214     flag = readuleb128(cm, buff)
   1215     self.flags.append((
   1216         self.RestrictionApiFlag(flag & 0b111),
-> 1217         self.DomapiApiFlag(flag >> 3)))

File ~\AppData\Local\Programs\Python\Python311\Lib\enum.py:712, in EnumType.__call__(cls, value, names, module, qualname, type, start, boundary)
    687 """
    688 Either returns an existing member, or creates a new enum class.
    689
   (...)
    709 `type`, if set, will be mixed in as the first base class.
    710 """
    711 if names is None:  # simple value lookup
--> 712     return cls.__new__(cls, value)
    713 # otherwise, functional API: we're creating a new Enum type
    714 return cls._create_(
    715         value,
    716         names,
   (...)
    721         boundary=boundary,
    722         )

File ~\AppData\Local\Programs\Python\Python311\Lib\enum.py:1135, in Enum.__new__(cls, value)
   1133 ve_exc = ValueError("%r is not a valid %s" % (value, cls.__qualname__))
   1134 if result is None and exc is None:
-> 1135     raise ve_exc
   1136 elif exc is None:
   1137     exc = TypeError(
   1138             'error in %s._missing_: returned %r instead of None or a valid member'
   1139             % (cls.__name__, result)
   1140             )

ValueError: 6 is not a valid HiddenApiClassDataItem.DomapiApiFlag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant