P1sec / hermes-dec

A reverse engineering tool for decompiling and disassembling the React Native Hermes bytecode
GNU Affero General Public License v3.0
512 stars 52 forks source link

SHA1 AssertionError #4

Closed ScientiaEtVeritas closed 1 year ago

ScientiaEtVeritas commented 1 year ago

I've run ~/hermes-dec/parsers/hbc_file_parser.py file.js.hbc and it seems, it always returns the following error

  File "~/hermes-dec/parsers/hbc_file_parser.py", line 807, in <module>
    hbc_reader.read_whole_file(file_descriptor)
  File "~/hermes-dec/parsers/hbc_file_parser.py", line 763, in read_whole_file
    self.read_header_from_buffer() # Defines self.header
  File "~/hermes-dec/parsers/hbc_file_parser.py", line 488, in read_header_from_buffer
    assert sha1(file_data[:-SHA1_NUM_BYTES]).digest() == file_data[-SHA1_NUM_BYTES:]
AssertionError
p1-mmr commented 1 year ago

Hello,

Thank you for reporting. I am not encountering this error with my development version of Hermes. Can you please share your sample at or on this issue?

Thank you!

ScientiaEtVeritas commented 1 year ago

I have sent the sample in question to the mentioned address (using WeTransfer).

p1-mmr commented 1 year ago

Should be fixed now, thanks!

Your file contained a non-standard trailer byte string ({"bundle_type":"rn-hbc"}\x00). This should now be ignored through using the file size present in the bytecode file header instead of the actual disk size of the file in order to determine the position of the file footer containing the SHA-1 file hash.