Giter VIP home page Giter VIP logo

view8's Introduction

View8

View8 is a static analysis tool designed to decompile serialized V8 bytecode objects (JSC files) into high-level readable code. To parse and disassemble these serialized objects, View8 utilizes a patched compiled V8 binary. As a result, View8 produces a textual output similar to JavaScript.

Requirements

  • Python 3.x
  • Disassembler binary. Available versions:
    • V8 Version 9.4.146.24 (Used in Node V16.x)
    • V8 Version 10.2.154.26 (Used in Node V18.x)
    • V8 Version 11.3.244.8 (Used in Node V20.x)

For compiled versions, visit the releases page.

Usage

Command-Line Arguments

  • input_file: The input file name.
  • output_file: The output file name.
  • --path, -p: Path to disassembler binary (optional).
  • --disassembled, -d: Indicate if the input file is already disassembled (optional).
  • --export_format, -e: Specify the export format(s). Options are v8_opcode, translated, and decompiled. Multiple options can be combined (optional, default: decompiled).

Basic Usage

To decompile a V8 bytecode file and export the decompiled code:

python view8.py input_file output_file

Disassembler Path

By default, view8 detects the V8 bytecode version of the input file (using VersionDetector.exe) and automatically searches for a compatible disassembler binary in the Bin folder. This can be changed by specifing a different disassembler binary, use the --path (or -p) option:

python view8.py input_file output_file --path /path/to/disassembler

Processing Disassembled Files

To skip the disassembling process and provide an already disassembled file as the input, use the --disassembled (or -d) flag:

python view8.py input_file output_file --disassembled

Export Formats

Specify the export format(s) using the --export_format (or -e) option. You can combine multiple formats:

  • v8_opcode
  • translated
  • decompiled

For example, to export both V8 opcodes and decompiled code side by side:

python view8.py input_file output_file -e v8_opcode decompiled

By default, the format used is decompiled.

VersionDetector.exe

The V8 bytecode version is stored as a hash at the beginning of the file. Below are the options available for VersionDetector.exe:

  • -h: Retrieves a version and returns its hash.
  • -d: Retrieves a hash (little-endian) and returns its corresponding version using brute force.
  • -f: Retrieves a file and returns its version.

Building The Disassembler

Guide/disassembler/patch based on v8dasm and https://github.com/v8/v8/tree/11.3.244.8.

  1. Check out your V8 version: https://v8.dev/docs/source-code

  2. Apply the patch:

    git apply v8.patch
  3. Create a build configuration:

    ./tools/dev/v8gen.py x64.release
  4. Edit the build flags in out.gn/x64.release/args.gn (copied the necessary ones from Node.js):

    dcheck_always_on = false
    is_component_build = false
    is_debug = false
    target_cpu = "x64"
    use_custom_libcxx = false
    v8_monolithic = true
    v8_use_external_startup_data = false
    
    v8_static_library = true
    v8_enable_disassembler = true
    v8_enable_object_print = true
    v8_enable_pointer_compression = false
  5. Build the static library:

    ninja -C out.gn/x64.release v8_monolith
  6. Compile the disassembler:

    g++ -g -I. -Iinclude v8dasm.cpp -o v8dasm -fno-rtti -lv8_monolith -lv8_libbase -lv8_libplatform -ldl -Lout.gn/x64.release/obj/ -pthread -std=c++17

view8's People

Contributors

j4k0xb avatar suleram avatar

Stargazers

Eric The Cat avatar

view8's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.