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

AttributeError when loading a UEFI image #416

Closed
zolutal opened this issue Aug 16, 2023 · 0 comments · Fixed by #417
Closed

AttributeError when loading a UEFI image #416

zolutal opened this issue Aug 16, 2023 · 0 comments · Fixed by #417

Comments

@zolutal
Copy link

zolutal commented Aug 16, 2023

Description

when loading a UEFI image, an error will occur trying to set the backend's arch attribute.

In [1]: import cle

In [2]: cle.Loader("./FV_RECOVERY.fd")
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In [2], line 1
----> 1 cle.Loader("./FV_RECOVERY.fd")

File ~/.virtualenvs/angr/lib/python3.10/site-packages/cle/loader.py:188, in Loader.__init__(self, main_binary, auto_load_libs, concrete_target, force_load_libs, skip_libs, main_opts, lib_opts, ld_path, use_system_libs, ignore_import_version_numbers, case_insensitive, rebase_granularity, except_missing_libs, aslr, perform_relocations, load_debug_info, page_size, preload_libs, arch)
    186     self._main_opts.update({"arch": arch})
    187 self.preload_libs = []
--> 188 self.initial_load_objects = self._internal_load(
    189     main_binary, *preload_libs, *force_load_libs, preloading=(main_binary, *preload_libs)
    190 )
    192 # cache
    193 self._last_object = None

File ~/.virtualenvs/angr/lib/python3.10/site-packages/cle/loader.py:782, in Loader._internal_load(self, preloading, *args)
    780     log.info("Skipping load request %s - already loaded", main_spec)
    781     continue
--> 782 obj = self._load_object_isolated(main_spec)
    783 objects.append(obj)
    784 objects.extend(obj.child_objects)

File ~/.virtualenvs/angr/lib/python3.10/site-packages/cle/loader.py:986, in Loader._load_object_isolated(self, spec)
    983 # STEP 4: LOAD!
    984 log.debug("... loading with %s", backend_cls)
--> 986 result = backend_cls(binary, binary_stream, is_main_bin=self._main_object is None, loader=self, **options)
    987 result.close()
    988 return result

File ~/.virtualenvs/angr/lib/python3.10/site-packages/cle/backends/uefi_firmware.py:97, in UefiFirmware.__init__(self, *args, **kwargs)
     94         self.child_objects.append(child)
     96 if self.child_objects:
---> 97     self.arch = self.child_objects[0].arch
     98 else:
     99     log.warning("Loaded empty UEFI firmware?")

AttributeError: can't set attribute 'arch'

Steps to reproduce the bug

with: pip install uefi-firmware==1.9

import cle
cle.Loader("./FV_RECOVERY.fd")

FV_RECOVERY.tar.gz

Environment

/home/jmill/.virtualenvs/angr/lib/python3.10/site-packages/angr/misc/bug_report.py:1: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
  import imp
angr environment report
=============================
Date: 2023-08-15 17:46:16.938857
Running in virtual environment at /home/jmill/.virtualenvs/angr
Platform: linux-x86_64
Python version: 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0]
######## angr #########
Python found it in /home/jmill/.virtualenvs/angr/lib/python3.10/site-packages/angr
Pip version angr 9.2.64
Couldn't find git info
######## ailment #########
Python found it in /home/jmill/.virtualenvs/angr/lib/python3.10/site-packages/ailment
Pip version ailment 9.2.64
Couldn't find git info
######## cle #########
Python found it in /home/jmill/.virtualenvs/angr/lib/python3.10/site-packages/cle
Pip version cle 9.2.64
Couldn't find git info
######## pyvex #########
Python found it in /home/jmill/.virtualenvs/angr/lib/python3.10/site-packages/pyvex
Pip version pyvex 9.2.64
Couldn't find git info
######## claripy #########
Python found it in /home/jmill/.virtualenvs/angr/lib/python3.10/site-packages/claripy
Pip version claripy 9.2.64
Couldn't find git info
######## archinfo #########
Python found it in /home/jmill/.virtualenvs/angr/lib/python3.10/site-packages/archinfo
Pip version archinfo 9.2.64
Couldn't find git info
######## z3 #########
Python found it in /home/jmill/.virtualenvs/angr/lib/python3.10/site-packages/z3
Pip version z3-solver 4.10.2.0
Couldn't find git info
######## unicorn #########
Python found it in /home/jmill/.virtualenvs/angr/lib/python3.10/site-packages/unicorn
Pip version unicorn 2.0.1.post1
Couldn't find git info
######### Native Module Info ##########
angr: <CDLL '/home/jmill/.virtualenvs/angr/lib/python3.10/site-packages/angr/state_plugins/../lib/angr_native.so', handle 55c12e4eda10 at 0x7f8b22438af0>
unicorn: <CDLL '/home/jmill/.virtualenvs/angr/lib/python3.10/site-packages/unicorn/lib/libunicorn.so.2', handle 55c12df79160 at 0x7f8b25081d80>
pyvex: <cffi.api._make_ffi_library.<locals>.FFILibrary object at 0x7f8b25da7a00>
z3: <CDLL '/home/jmill/.virtualenvs/angr/lib/python3.10/site-packages/z3/lib/libz3.so', handle 55c12dd13420 at 0x7f8b27cff970>

Additional context

breaking commit: 0833a23
using self.arch = ... is no longer valid for backends, self._arch = ... or self.set_arch(...) should be used instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant