Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
H

hermes_rs

> 编程语言
Open source

Hermes bytecode disassembler and assembler

181 stars0 likes1 views
WebsiteGitHub

About

Hermes bytecode disassembler and assembler

hermes_rs

A nearly dependency-free disassembler and assembler for the Hermes bytecode, written in Rust.

Note: Still a WIP - A PR is always welcome. The API is subject to change as I iterate over use cases and improve the design.

For the sake transparency, the current dependencies are:

  • sha1
    • This is required for generating the footer hash.
  • serde - Optional
    • So you can serialize/deserialize in your app
  • specta - Optional
    • To generate TS types for tauri or wasm use cases
  • specta-util - Optional
    • Same as above

A special thanks to P1sec for digging through the Hermes git repo, pulling all of the BytecodeDef files out, and tagging them. This made writing this tool much easier.


Bytecode Studio

I created and launched Bytecode Studio - a comprehensive tool built for reverse engineering, analyzing, disassembling, and decompiling React Native applications and Hermes binaries.

If you're using hermes_rs or any other tool for static analysis for an engagement or want a more comprehensive analysis and workflow, I'd use Bytecode Studio!


  • hermes_rs
  • Bytecode Studio
    • Supported HBC Versions
      • Known Issues & Weirdness
        • Slow(er) Performance on Large Files
        • HBC File Size Differences
      • Project Goals
        • Potential Use cases
      • Features
    • Installation
    • Usage
      • CLI Binaries
        • Dump bytecode
        • Dump strings
        • Dump Metro bundler modules
        • Dump array values
        • Dump object keys and values
        • Generate r2 Script
      • API
        • Reading File Header
        • Reading Strings
        • Reading Function Headers
        • Dumping Bytecode
        • Encoding Instructions
        • Creating Binaries From Scratch
        • Using specific HBC Versions
  • Hermes Resources
  • Development
    • Debugging Existing Functionality
    • Supporting new versions of Hermes

Supported HBC Versions

HBC Version Disassembler (Binary) Assembler (Textual) Assembler Decompiler
76 ✅ ✅ ❌ ❌
89 ✅ ✅ ❌ ❌
90 ✅ ✅ ❌ ❌
93 ✅ ✅ ❌ ❌
94 ✅ ✅ ❌ ❌
95 ✅ ✅ ❌ ❌
96 ✅ ✅ ❌ ❌

A couple of features are missing currently, as they're low priority for me at the moment.

  • Regular Expression deserialization and serialization*
  • Debug Info deserialization and serialization*

* Supports u8 buffer for manual population


Known Issues & Weirdness

Slow(er) Performance on Large Files

Chances are you need to compile the program that uses this crate with the --release flag and run the binary directly.

HBC File Size Differences

The size of a binary produced with hermes_rs is going to be a bit larger than one compiled directly with hermes. This is primarily due to the fact that hermes does some string merging to keep bundles down.

Example: If car and racecar are both strings within the app, only racecar will be written. Two StringTableEntry objects are created: Entry { offset: 0, length: 7 } and Entry { offset: 4, length: 3 }.

As of right now, hermes_rs does not implement this functionality. It's pretty literal when it comes to strings, and doesn't try to be clever or save space.


Project Goals

  • Full coverage for all public HBC versions
  • The ability to inject code stubs directly into the .hbc file for instrumentation
  • Textual HBC assembly
  • Eventually a halfway decent decompiler, but that may be another project that uses this one as a base
Potential Use cases
  • Find which functions reference specific strings
  • Generate frida hooks for mobile implementations
    • hermes loader -> hook loading the package -> feed to hermes_rs -> patch code for bidirectional communication or even just logging
  • Writing fuzzers

Features

  • Disassemble Hermes Bytecode (HBC)
  • Assemble Hermes Bytecode (HBC)
  • Type-safe instruction building across multiple versions of HBC
  • The ability to reduce binary size by only enabling certain versions of HBC
  • Utilities
    • Dump Bytecode
      • cargo run --bin bytecode index.android.bundle
    • Dump Strings
      • cargo run --bin strings index.android.bundle

Installation

To add hermes_rs to your project, simply run:

cargo add hermes_rs

  • Specific HBC Versions - enable any of ["v89","v90","v93","v94","v95", "v96"]
    • Default: ["v94","v95", "v96"]
  • Serde Support (Optional) - enable the serde feature
  • Generate TS Types (Optional) - enable the specta feature
    • cargo run --bin gen_ts --features specta will output *.d.ts to ./ts.
    • Note: Only one HBC version can be used at a time for this due to a limitiation in specta.

Usage

CLI Binaries

Dump bytecode

Dumps the entire applications bytecode - definitely direct it to a file since it's probably going to be huge.

bash
cargo run --bin bytecode ./path/to/file/index.android.bundle > bytecode_ouput.txt

Dump strings

Dumps all string definitions

bash
cargo run --bin strings ./path/to/file/index.android.bundle > strings_output.txt

Dump Metro bundler modules

Most React Native applications use the Metro bundler as a pre-Hermes compilation step. This utility finds the bundler function and where it's used, then outputs JavaScript-like representation of calls to it.

bash
cargo run --bin modules ./path/to/file/index.android.bundle > output.txt

Example output:

…

Dump array values

Parses and dumps the contents of the Array storage buffer within the bundle in a JavaScript-like representation.

bash
cargo run --bin arrays ./path/to/file/index.android.bundle > output.txt

Example Output:

…

Dump object keys and values

Dump the raw object keys and values from an application bundle.

Note: The object keys and values aren't joined with this utility, as they're correlated by individual indexes with the NewObjectWithBuffer or NewObjectWithBufferLong instructions. To see proper Object key/value pairs, use the Dump Bytecode utility. When you disassemble the binary with this utility, it'll print out the full object next to the two instructions above in the output.

bash
cargo run --bin objects ./path/to/file/index.android.bundle > output.txt

Example Output:

javascript
const objkeys_7 = ["trace", "info", "warn"];
const objkeys_9 = ["error"];
const objkeys_12 = ["value", "enumerable"];
const objkeys_16 = ["message", "title", "color"];
const objkeys_19 = ["channelId"];
const objkeys_22 = ["value", "enumerable"];
const objkeys_27 = ["configurable", "writable"];
....
const objvals_17 = [0, 1, 2, 3];
const objvals_18 = [true];
const objvals_19 = [false];
const objvals_24 = ["You have new messages", "Kustomer Support"];
const objvals_25 = [null];

Generate r2 Script

Special thanks to AbhiTheModder for this one!

Generate a r2 script for a hermes binary to take advantage of all of the amazing features r2 has to offer.

bash
cargo run --bin r2_script ./path/to/file/index.android.bundle > my_script.r2

Example Output:

r2
# R2 script for Hermes bytecode file: ./index.android.bundle
# Generated by hermes_rs

# Hermes File Version: 84
# File Size: 5471568 bytes
# Function Count: 27835

f hbc.header=0x0
f hbc.header.size=0x537d50

# Function flags
'f func.hermes.global 32 0x1cb368
'f func.hermes.func_1 16 0x1dd8b4
'f func.hermes.clear 16 0x1dd9b1
'f func.hermes.define 16 0x1dd9ce
'f func.hermes.metroRequire 16 0x1dda2b

... 

# String flags
'f str.API_STATUS_0 10 0x28
'f str.ActionCreator_1 13 0x17a
'f str.Actions_2 7 0x1c9
'f str.Animated_3 8 0x2ac
'f str.d_4 1 0x2b3

... 

API

Reading File Header

rust
let filename = "./input_data/index.android.bundle";

let f = File::open(filename).expect("no file found");
let mut reader = io::BufReader::new(f);

let mut hermes_file = HermesFile::deserialize(&mut reader);

println!("{:?}", hermes_file.header);

Output:

…

Reading Strings

rust
println!("Strings: {:?}", hermes_file.get_strings());

Output:

bash
Strings: ["$$typeof", "type", "API", "isArray", "Array", ... ]

Reading Function Headers

…

Dumping Bytecode

Single Function

Call print_bytecode_for_fn(fidx), where fidx is the function index of the element in hermes_file.function_headers.

rust
hermes_file.parse_bytecode_for_fn(1337);

Output:

asm
Function(3 params, 11 registers, 0 symbols):
0x00000000	GetEnvironment  r0,  0
0x00000001	LoadFromEnvironment  r2,  r0,  6
0x00000002	LoadConstUndefined  r0
0x00000003	LoadParam  r1,  1
0x00000004	Call2  r2,  r2,  r0,  r1
0x00000005	LoadConstNull  r1
0x00000006	PutById  r2,  r1,  1,  "currentTarget"
0x00000007	Ret  r0

Entire File

Printing out the bytecode for the entire executable in a human-readable format is possible by calling print_bytecode.

rust
hermes_file.print_bytecode();

Which outputs:

…

Raw Bytes

In the event that you want to access just the raw bytes for a specific function, you can use hermes_file.get_bytecode() and iterate. The function returns a Vec, which has the function index and bytecode (Vec) pairing.

rust
let bc = hermes_file.get_bytecode();

for func in bc {
  println!("{:?}", func);
}

Output:

…

Encoding Instructions

Encoding instructions is trivial - each Instruction implements a trait with deserialize and serialize methods.

…

Creating Binaries From Scratch

Take a look at the Creating Binaries example.

Working example: cargo run --example create

Using specific HBC Versions

Want to use a specific version of the Hermes bytecode and reduce your binary size?

In Cargo.toml, find the hermes_rs dependency and select which HBC version(s) you'd like to use in your application.

Example:

toml
[dependencies]
hermes_rs = { features = ["v89", "v90", "v93", "v94", "v95", "v96"] }

Hermes Resources

My Stuff

  • Github.io Page: https://pilfer.github.io/mobile-reverse-engineering/react-native/

Other Resources

  • Official docs: https://hermesengine.dev/
    • Source: https://github.com/facebook/hermes
  • hermes-dec disassembler/decompiler:
    • https://github.com/P1sec/hermes-dec
    • Opcode Docs: https://p1sec.github.io/hermes-dec/opcodes_table.html
  • hbctool: https://github.com/b

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rust

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言