bongtrop / hbctool

Hermes Bytecode Reverse Engineering Tool (Assemble/Disassemble Hermes Bytecode)
MIT License
444 stars 71 forks source link

Fix parsing for Hermes Bytecode Version 84 #31

Closed hexpwn closed 1 year ago

hexpwn commented 1 year ago
bongtrop commented 1 year ago

Ohh, I miss this. Thank you for your contribution.

BaseMax commented 1 year ago

Would you please help me? I am trying to check an android application.

C:\Users\Max\appname\co.appname\assets>pip uninstall hbctool
Found existing installation: hbctool 0.1.5
Uninstalling hbctool-0.1.5:
  Would remove:
    c:\users\max\appdata\local\programs\python\python310\lib\site-packages\hbctool-0.1.5.dist-info\*
    c:\users\max\appdata\local\programs\python\python310\lib\site-packages\hbctool\*
    c:\users\max\appdata\local\programs\python\python310\scripts\hbctool.exe
  Would not remove (might be manually added):
    c:\users\max\appdata\local\programs\python\python310\lib\site-packages\hbctool\hbc\hbc84\__init__.py
    c:\users\max\appdata\local\programs\python\python310\lib\site-packages\hbctool\hbc\hbc84\data\opcode.json
    c:\users\max\appdata\local\programs\python\python310\lib\site-packages\hbctool\hbc\hbc84\data\structure.json
    c:\users\max\appdata\local\programs\python\python310\lib\site-packages\hbctool\hbc\hbc84\parser.py
    c:\users\max\appdata\local\programs\python\python310\lib\site-packages\hbctool\hbc\hbc84\raw\BytecodeFileFormat.h
    c:\users\max\appdata\local\programs\python\python310\lib\site-packages\hbctool\hbc\hbc84\raw\BytecodeList.def
    c:\users\max\appdata\local\programs\python\python310\lib\site-packages\hbctool\hbc\hbc84\raw\SerializedLiteralGenerator.h
    c:\users\max\appdata\local\programs\python\python310\lib\site-packages\hbctool\hbc\hbc84\tool\opcode_generator.py
    c:\users\max\appdata\local\programs\python\python310\lib\site-packages\hbctool\hbc\hbc84\translator.py
    c:\users\max\appdata\local\programs\python\python310\lib\site-packages\hbctool\hbc\hbc85\__init__.py
    c:\users\max\appdata\local\programs\python\python310\lib\site-packages\hbctool\hbc\hbc85\data\opcode.json
    c:\users\max\appdata\local\programs\python\python310\lib\site-packages\hbctool\hbc\hbc85\data\structure.json
    c:\users\max\appdata\local\programs\python\python310\lib\site-packages\hbctool\hbc\hbc85\parser.py
    c:\users\max\appdata\local\programs\python\python310\lib\site-packages\hbctool\hbc\hbc85\raw\BytecodeFileFormat.h
    c:\users\max\appdata\local\programs\python\python310\lib\site-packages\hbctool\hbc\hbc85\raw\BytecodeList.def
    c:\users\max\appdata\local\programs\python\python310\lib\site-packages\hbctool\hbc\hbc85\raw\SerializedLiteralGenerator.h
    c:\users\max\appdata\local\programs\python\python310\lib\site-packages\hbctool\hbc\hbc85\tool\opcode_generator.py
    c:\users\max\appdata\local\programs\python\python310\lib\site-packages\hbctool\hbc\hbc85\translator.py
    c:\users\max\appdata\local\programs\python\python310\lib\site-packages\hbctool\index.android.bundle
Proceed (Y/n)? y
  Successfully uninstalled hbctool-0.1.5

C:\Users\Max\appname\co.appname\assets>python -m pip install --upgrade  hbctool
Collecting hbctool
  Using cached hbctool-0.1.5-py3-none-any.whl (9.8 MB)
Requirement already satisfied: docopt<0.7.0,>=0.6.2 in c:\users\max\appdata\local\programs\python\python310\lib\site-packages (from hbctool) (0.6.2)
Installing collected packages: hbctool
Successfully installed hbctool-0.1.5

C:\Users\Max\appname\co.appname\assets>hbctool disasm index.android.bundle test_hasm
[*] Disassemble 'index.android.bundle' to 'test_hasm' path
Traceback (most recent call last):
  File "C:\Users\Max\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\Max\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\Max\AppData\Local\Programs\Python\Python310\Scripts\hbctool.exe\__main__.py", line 7, in <module>
  File "C:\Users\Max\AppData\Local\Programs\Python\Python310\lib\site-packages\hbctool\__init__.py", line 61, in main
    disasm(args['<HBC_FILE>'], args['<HASM_PATH>'])
  File "C:\Users\Max\AppData\Local\Programs\Python\Python310\lib\site-packages\hbctool\__init__.py", line 33, in disasm
    hbco = hbc.load(f)
  File "C:\Users\Max\AppData\Local\Programs\Python\Python310\lib\site-packages\hbctool\hbc\__init__.py", line 29, in load
    assert version in HBC, f"The HBC version ({version}) is not supported."
AssertionError: The HBC version (84) is not supported.
BaseMax commented 1 year ago

Maybe because the Python PIP repository is not up to date. I am trying to manually put the new files of this project in C:\Users\Max\AppData\Local\Programs\Python\Python310\Lib\site-packages\hbctool. I deleted all files inside this directory and cloned this project there.

Now I got another new error:

>hbctool disasm index.android.bundle test_hasm
Traceback (most recent call last):
  File "C:\Users\Max\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\Max\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\Max\AppData\Local\Programs\Python\Python310\Scripts\hbctool.exe\__main__.py", line 4, in <module>
ImportError: cannot import name 'main' from 'hbctool' (unknown location)

Any kind of suggestions and help would be great. Thanks in advance.