逆向工程 - Hermes-dec - Disassemble Hermes VM bytecode(HBC)



參考資訊:
https://github.com/P1sec/hermes-dec

main.js

alert('Hello, world!');

Disassemble

$ hermes -emit-binary -out main.bundle main.js -output-source-map -O
$ hbc-disassembler main.bundle
    => [Function #0 "global" of 21 bytes]: 1 params, frame size=11, env size=0, read index sz=1, write index sz=0, strict=0, exc handler=0, debug info=0  @ offset 0x000000c0

    Bytecode listing:

    ==> 00000000: <GetGlobalObject>: <Reg8: 0>
    ==> 00000002: <TryGetById>: <Reg8: 2, Reg8: 0, UInt8: 1, string_id: 2>  # String: 'alert' (Identifier)
    ==> 00000008: <LoadConstUndefined>: <Reg8: 1>
    ==> 0000000a: <LoadConstString>: <Reg8: 0, string_id: 0>  # String: 'Hello, world!' (String)
    ==> 0000000e: <Call2>: <Reg8: 0, Reg8: 2, Reg8: 1, Reg8: 0>
    ==> 00000013: <Ret>: <Reg8: 0>