Skip to content

capstone 4.x could not be found, is the capstone backend installed? #10

@MRW01F

Description

@MRW01F

I am trying advance analysis example from the readme.md without changing anything.
i have installed capstone with pip install capstone
running on mac M2 chip

$ pip3 show capstone
Name: capstone
Version: 4.0.2
Summary: Capstone disassembly engine
Home-page: http://www.capstone-engine.org
Author: Nguyen Anh Quynh
Author-email: aquynh@gmail.com
License: UNKNOWN
Location: /Users/<user>/Library/Python/3.9/lib/python/site-packages
Requires: 
Required-by: strongarm-dataflow, strongarm-ios

when i run this particular script I am facing this error.

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
File /opt/anaconda3/lib/python3.11/site-packages/strongarm/macho/macho_analyzer.py:237, in MachoAnalyzer._compute_function_basic_blocks(self, entry_point, end_address)
    236 try:
--> 237     from strongarm_dataflow.dataflow import compute_function_basic_blocks_fast
    238 except ImportError as e:

ImportError: dlopen(/opt/anaconda3/lib/python3.11/site-packages/strongarm_dataflow/dataflow.cpython-311-darwin.so, 0x0002): Library not loaded: /opt/homebrew/opt/capstone/lib/libcapstone.4.dylib
  Referenced from: <227343E6-529F-3E5C-B807-54436434ECF9> /opt/anaconda3/lib/python3.11/site-packages/strongarm_dataflow/dataflow.cpython-311-darwin.so
  Reason: tried: '/opt/homebrew/opt/capstone/lib/libcapstone.4.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/capstone/lib/libcapstone.4.dylib' (no such file), '/opt/homebrew/opt/capstone/lib/libcapstone.4.dylib' (no such file), '/usr/local/lib/libcapstone.4.dylib' (no such file), '/usr/lib/libcapstone.4.dylib' (no such file, not in dyld cache), '/opt/homebrew/Cellar/capstone/5.0.1/lib/libcapstone.4.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/capstone/5.0.1/lib/libcapstone.4.dylib' (no such file), '/opt/homebrew/Cellar/capstone/5.0.1/lib/libcapstone.4.dylib' (no such file), '/usr/local/lib/libcapstone.4.dylib' (no such file), '/usr/lib/libcapstone.4.dylib' (no such file, not in dyld cache)

During handling of the above exception, another exception occurred:

SystemExit                                Traceback (most recent call last)
    [... skipping hidden 1 frame]

Cell In[1], line 7
      6 # A MachoAnalyzer wraps a binary and allows deeper analysis
----> 7 analyzer = MachoAnalyzer.get_analyzer(binary)
      9 # Find all calls to -[UIAlertView init] in the binary

File /opt/anaconda3/lib/python3.11/site-packages/strongarm/macho/macho_analyzer.py:415, in MachoAnalyzer.get_analyzer(cls, binary)
    414     return cls._ANALYZER_CACHE[binary]
--> 415 return MachoAnalyzer(binary)

File /opt/anaconda3/lib/python3.11/site-packages/strongarm/macho/macho_analyzer.py:183, in MachoAnalyzer.__init__(self, binary)
    182 self._build_callable_symbol_index()
--> 183 self._build_function_boundaries_index()
    185 self._cfstring_to_stringref_map = self._build_cfstring_map()

File /opt/anaconda3/lib/python3.11/site-packages/strongarm/macho/macho_analyzer.py:286, in MachoAnalyzer._build_function_boundaries_index(self)
    284 for entry_point, end_address in pairwise(sorted_entry_points):
    285     # The end address of the function is the last instruction in the last basic block
--> 286     basic_blocks = [x for x in self._compute_function_basic_blocks(entry_point, end_address)]
    287     # If we found a function with no code, just skip it
    288     # This can happen in the assembly unit tests, where we insert a jump to a dummy __text label

File /opt/anaconda3/lib/python3.11/site-packages/strongarm/macho/macho_analyzer.py:243, in MachoAnalyzer._compute_function_basic_blocks(self, entry_point, end_address)
    242     print("\ncapstone 4.x could not be found, is the capstone backend installed?\n")
--> 243     sys.exit(1)
    244 raise

SystemExit: 1

During handling of the above exception, another exception occurred:

AttributeError                            Traceback (most recent call last)
    [... skipping hidden 1 frame]

File /opt/anaconda3/lib/python3.11/site-packages/IPython/core/interactiveshell.py:2121, in InteractiveShell.showtraceback(self, exc_tuple, filename, tb_offset, exception_only, running_compiled_code)
   2118 if exception_only:
   2119     stb = ['An exception has occurred, use %tb to see '
   2120            'the full traceback.\n']
-> 2121     stb.extend(self.InteractiveTB.get_exception_only(etype,
   2122                                                      value))
   2123 else:
   2125     def contains_exceptiongroup(val):

File /opt/anaconda3/lib/python3.11/site-packages/IPython/core/ultratb.py:710, in ListTB.get_exception_only(self, etype, value)
    702 def get_exception_only(self, etype, value):
    703     """Only print the exception type and message, without a traceback.
    704 
    705     Parameters
   (...)
    708     value : exception value
    709     """
--> 710     return ListTB.structured_traceback(self, etype, value)

File /opt/anaconda3/lib/python3.11/site-packages/IPython/core/ultratb.py:568, in ListTB.structured_traceback(self, etype, evalue, etb, tb_offset, context)
    565     chained_exc_ids.add(id(exception[1]))
    566     chained_exceptions_tb_offset = 0
    567     out_list = (
--> 568         self.structured_traceback(
    569             etype,
    570             evalue,
    571             (etb, chained_exc_ids),  # type: ignore
    572             chained_exceptions_tb_offset,
    573             context,
    574         )
    575         + chained_exception_message
    576         + out_list)
    578 return out_list

File /opt/anaconda3/lib/python3.11/site-packages/IPython/core/ultratb.py:1435, in AutoFormattedTB.structured_traceback(self, etype, evalue, etb, tb_offset, number_of_lines_of_context)
   1433 else:
   1434     self.tb = etb
-> 1435 return FormattedTB.structured_traceback(
   1436     self, etype, evalue, etb, tb_offset, number_of_lines_of_context
   1437 )

File /opt/anaconda3/lib/python3.11/site-packages/IPython/core/ultratb.py:1326, in FormattedTB.structured_traceback(self, etype, value, tb, tb_offset, number_of_lines_of_context)
   1323 mode = self.mode
   1324 if mode in self.verbose_modes:
   1325     # Verbose modes need a full traceback
-> 1326     return VerboseTB.structured_traceback(
   1327         self, etype, value, tb, tb_offset, number_of_lines_of_context
   1328     )
   1329 elif mode == 'Minimal':
   1330     return ListTB.get_exception_only(self, etype, value)

File /opt/anaconda3/lib/python3.11/site-packages/IPython/core/ultratb.py:1173, in VerboseTB.structured_traceback(self, etype, evalue, etb, tb_offset, number_of_lines_of_context)
   1164 def structured_traceback(
   1165     self,
   1166     etype: type,
   (...)
   1170     number_of_lines_of_context: int = 5,
   1171 ):
   1172     """Return a nice text document describing the traceback."""
-> 1173     formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context,
   1174                                                            tb_offset)
   1176     colors = self.Colors  # just a shorthand + quicker name lookup
   1177     colorsnormal = colors.Normal  # used a lot

File /opt/anaconda3/lib/python3.11/site-packages/IPython/core/ultratb.py:1063, in VerboseTB.format_exception_as_a_whole(self, etype, evalue, etb, number_of_lines_of_context, tb_offset)
   1060 assert isinstance(tb_offset, int)
   1061 head = self.prepare_header(str(etype), self.long_header)
   1062 records = (
-> 1063     self.get_records(etb, number_of_lines_of_context, tb_offset) if etb else []
   1064 )
   1066 frames = []
   1067 skipped = 0

File /opt/anaconda3/lib/python3.11/site-packages/IPython/core/ultratb.py:1131, in VerboseTB.get_records(self, etb, number_of_lines_of_context, tb_offset)
   1129 while cf is not None:
   1130     try:
-> 1131         mod = inspect.getmodule(cf.tb_frame)
   1132         if mod is not None:
   1133             mod_name = mod.__name__

AttributeError: 'tuple' object has no attribute 'tb_frame'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions