Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TOOL] Adding hermes-dec as a general tool for React Native static analysis #2798

Merged
merged 7 commits into from
Jul 16, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions tools/generic/MASTG-TOOL-0104.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
title: hermes-dec
platform: generic
source: https://github.com/P1sec/hermes-dec/
---

[Hermes-dec](https://github.com/P1sec/hermes-dec/) is a tool for reverse-engineering compiled [hermes](https://reactnative.dev/docs/hermes) bytecode for both Android and iOS apps. It supports decompilation and disassembly of [Hermes VM bytecode (HBC)](https://lucasbaizer2.github.io/hasmer/hasm/instruction-docs/hbc86.html) format, typically seen in apps developed in [React Native](https://reactnative.dev/).

If you encounter either of the following files during static analysis, hermes-dec provides a way to recover a legible version of the file's contents:
- index.android.bundle
cpholguera marked this conversation as resolved.
Show resolved Hide resolved
- main.jsbundle

Use file to check the type and confirm you are dealing with actual Hermes bytecode:
cpholguera marked this conversation as resolved.
Show resolved Hide resolved
saulpanders marked this conversation as resolved.
Show resolved Hide resolved
```bash
file main.jsbundle
saulpanders marked this conversation as resolved.
Show resolved Hide resolved
main.jsbundle: Hermes JavaScript bytecode, version 90
```
If instead you see that its a plain text file, it can likely just be opened with any text editor and hermes-dec isn't needed:
cpholguera marked this conversation as resolved.
Show resolved Hide resolved
cpholguera marked this conversation as resolved.
Show resolved Hide resolved
```bash
file main.jsbundle
saulpanders marked this conversation as resolved.
Show resolved Hide resolved
main.jsbundle: Unicode text, UTF-8 text
```

You can try using hermes-dec in situations where you are doing static analysis on a React Native mobile app, and [react-native-decompiler](https://github.com/numandev1/react-native-decompiler) fails.