bongtrop / hbctool

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

The HBC version (84) is not supported. #28

Closed BaseMax closed 1 year ago

BaseMax commented 1 year ago
C:\Users\Max\feeld\co.feeld\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.
jieunboy0516 commented 1 year ago

its not supported yet i think

jieunboy0516 commented 1 year ago

just found this https://github.com/niosega/hbctool/tree/draft/hbc-v84

hab12335 commented 1 year ago

just found this https://github.com/niosega/hbctool/tree/draft/hbc-v84

https://github.com/niosega/hbctool/commit/ac6fabb69a7229ed9764997d153d4f703d1381aa

parser is from 76 (no good)

V

stuxctf commented 1 year ago

@BaseMax run with poetry, the pip package generate this error.

Clone the repo

poetry install poetry run hbctool [options]

BaseMax commented 1 year ago

@BaseMax run with poetry, the pip package generate this error.

Clone the repo

poetry install poetry run hbctool [options]

Thanks, do you mean HBC version 84 now supported?

martooy commented 1 year ago

I tried this with some version 84 code with the above steps and get this error:

bash-5.2$ poetry run hbctool  disasm ~/index.android.bundle disassembly
[*] Disassemble '/Users/msells/index.android.bundle' to 'disassembly' path
[*] Hermes Bytecode [ Source Hash: d17705580035ede988df772ff322104fc925d6cc, HBC Version: 84 ]
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/msells/src/hbctool/hbctool/__init__.py", line 61, in main
    disasm(args['<HBC_FILE>'], args['<HASM_PATH>'])
  File "/Users/msells/src/hbctool/hbctool/__init__.py", line 41, in disasm
    hasm.dump(hbco, hasmpath)
  File "/Users/msells/src/hbctool/hbctool/hasm.py", line 67, in dump
    write_func(f, hbc.getFunction(i), i, hbc)
  File "/Users/msells/src/hbctool/hbctool/hbc/hbc84/__init__.py", line 59, in getFunction
    insts = disassemble(bc)
  File "/Users/msells/src/hbctool/hbctool/hbc/hbc84/translator.py", line 33, in disassemble
    opcode = opcode_mapper[bc[i]]
IndexError: list index out of range

$ file index.android.bundle
index.android.bundle: Hermes JavaScript bytecode, version 84

I'll look at this later today and see if I can figure out why it's unhappy.

hexpwn commented 1 year ago

I submitted a pull request (https://github.com/bongtrop/hbctool/pull/31) that fixes this. Until it is merged you can check out the changes I made or clone my fork.

bongtrop commented 1 year ago

related to #31, thank to @hexpwn. this issue have closed.

BaseMax commented 1 year ago

@BaseMax run with poetry, the pip package generate this error.

Clone the repo

poetry install poetry run hbctool [options]

Thanks, I am trying.

C:\Users\Max\hbctool>git pull

C:\Users\Max\hbctool>poetry run hbctool disasm "C:/Users/Max/appname/co.appname/assets/index.android.bundle" test_hasm
running disasm
[*] Disassemble 'C:/Users/Max/appname/co.appname/assets/index.android.bundle' to 'test_hasm' path
C:/Users/Max/appname/co.appname/assets/index.android.bundle
Load function
{85: <class 'hbctool.hbc.hbc85.HBC85'>, 84: <class 'hbctool.hbc.hbc84.HBC84'>, 76: <class 'hbctool.hbc.hbc76.HBC76'>, 74: <class 'hbctool.hbc.hbc74.HBC74'>, 62: <class 'hbctool.hbc.hbc62.HBC62'>, 59: <class 'hbctool.hbc.hbc59.HBC59'>}
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\Max\hbctool\hbctool\__init__.py", line 69, in main
    disasm(args['<HBC_FILE>'], args['<HASM_PATH>'])
  File "C:\Users\Max\hbctool\hbctool\__init__.py", line 34, in disasm
    hbco = hbc.load(f)
  File "C:\Users\Max\hbctool\hbctool\hbc\__init__.py", line 30, in load
    print(version)
UnboundLocalError: local variable 'version' referenced before assignment
Hiltoness commented 1 year ago

I tried this with some version 84 code with the above steps and get this error:

bash-5.2$ poetry run hbctool  disasm ~/index.android.bundle disassembly
[*] Disassemble '/Users/msells/index.android.bundle' to 'disassembly' path
[*] Hermes Bytecode [ Source Hash: d17705580035ede988df772ff322104fc925d6cc, HBC Version: 84 ]
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/msells/src/hbctool/hbctool/__init__.py", line 61, in main
    disasm(args['<HBC_FILE>'], args['<HASM_PATH>'])
  File "/Users/msells/src/hbctool/hbctool/__init__.py", line 41, in disasm
    hasm.dump(hbco, hasmpath)
  File "/Users/msells/src/hbctool/hbctool/hasm.py", line 67, in dump
    write_func(f, hbc.getFunction(i), i, hbc)
  File "/Users/msells/src/hbctool/hbctool/hbc/hbc84/__init__.py", line 59, in getFunction
    insts = disassemble(bc)
  File "/Users/msells/src/hbctool/hbctool/hbc/hbc84/translator.py", line 33, in disassemble
    opcode = opcode_mapper[bc[i]]
IndexError: list index out of range

$ file index.android.bundle
index.android.bundle: Hermes JavaScript bytecode, version 84

I'll look at this later today and see if I can figure out why it's unhappy.

Did you resolve it? I also encountered this in version 89