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: module 'capstone' has no attribute 'CS_ARCH_ARM64' #25

Open
1392081456 opened this issue Oct 6, 2024 · 2 comments
Open

Comments

@1392081456
Copy link

System information:Linux kali 6.10.9-amd64 ReFirmLabs#1 SMP PREEMPT_DYNAMIC Kali 6.10.9-1kali1 (2024-09-09) x86_64 GNU/Linux
python information: 3.12.6

When I run binwalk, it appears:
Traceback (most recent call last):
File "/usr/bin/binwalk", line 33, in
sys.exit(load_entry_point('binwalk==2.4.2', 'console_scripts', 'binwalk')())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/bin/binwalk", line 25, in importlib_load_entry_point
return next(matches).load()
^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/importlib/metadata/init.py", line 205, in load
module = import_module(match.group('module'))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/importlib/init.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1387, in _gcd_import
File "", line 1360, in _find_and_load
File "", line 1331, in _find_and_load_unlocked
File "", line 935, in _load_unlocked
File "", line 995, in exec_module
File "", line 488, in _call_with_frames_removed
File "/usr/lib/python3/dist-packages/binwalk/main.py", line 24, in
import binwalk.modules
File "/usr/lib/python3/dist-packages/binwalk/modules/init.py", line 3, in
from binwalk.modules.disasm import Disasm
File "/usr/lib/python3/dist-packages/binwalk/modules/disasm.py", line 21, in
class Disasm(Module):
File "/usr/lib/python3/dist-packages/binwalk/modules/disasm.py", line 60, in Disasm
Architecture(type=capstone.CS_ARCH_ARM64,
^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'capstone' has no attribute 'CS_ARCH_ARM64'. Did you mean: 'CS_ARCH_ARM'?

I try to update binwalk,but it is the newest. Then I followed the instructions to find the corresponding disasm.py and modify it。I modify the "ARM64" to "ARM", just like:
ARCHITECTURES =[
Architecture(type=capstone.CS_ARCH_ARM,
mode=capstone.CS_MoDE_ARM,
endiannesS=capstone.CS_MODE_BIG_ENDIAN,
description="ARM executable code, 32-bit, big endian"),
Architecture(type=capstone.CS_ARCH_ARM,
mode=capstone.CS_MoDE_ARM,
endiannesS=capstone.CS_MODE_LITTLE_ENDIAN,
description="ARM executable code, 32-bit, little endian"),
Architecture(type=capstone.CS_ARCH_ARM,
mode=capstone.CS_MODE_ARM,
endianness=capstone.CS_MODE_BIG_ENDIAN,
description="ARM executable code, 64-bit, big endian"),
Architecture(type=capstone.CS_ARCH_ARM,
mode=capstone.CS_MODE_ARM,
romendiannesS=capstone.CS_MODE_LITTLE_ENDIAN,
Devicesdescription="ARM executable code, 64-bit, little endian"),

binwalk is then ready to run。

I would like to know why this is, and does my modification affect binwalk?

@1392081456
Copy link
Author

Do I need to uninstall it and reinstall it?

@stkw0
Copy link
Member

stkw0 commented Oct 7, 2024

binwalk requires capstone >= 5.0 but the latest version on Kali Linux is capstone-4.0.2. Please report this issue to Kali Linux too.

btw, capstone is not a required dependency of binwalk, it can work properly without it. If you want to use capstone you could install it from pip as a workaround.

I would think about adding a check and print a warning if the correct capstone version is not found to be more user-friendly.

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

No branches or pull requests

2 participants