-
Notifications
You must be signed in to change notification settings - Fork 2
Building V8 Disasm
In order to use jsc_deobfuscator and View8 you need to first disassemble the file of your interest. This can be only done with a disassembler relevant to the particular V8 version for which your file was compiled.
This may require building V8 from sources, and then building the disassembler on the top of it.
A pre-built version of the decompiler for V8 10.2.154.26 is available in the releases.
Install depot_tools . It is enough to clone them:
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.gitAdd them to the path:
export PATH=/home/tester/code/depot_tools:$PATHThen we can leave the directory.
Install Ninja build. In my case, installing it from the system repository was giving me errors, so I installed it directly from the github.
git clone https://github.com/ninja-build/ninja.git && cd ninja
git checkout releaseThen follow the README to build it. Make sure that CMake is installed on your system.
The required steps:
./configure.py --bootstrap
cmake -Bbuild-cmake
cmake --build build-cmakeTest that everything built fine by running:
./build-cmake/ninja_testAdd the Ninja directory to the path. Together with depot tools it may look like:
export PATH="/home/tester/code/depot_tools:/home/tester/code/ninja:$PATH"Clone V8 by:
fetch v8
cd v8/
git checkout main
git pull originSelect the tag that you need (the version compatible with the script to be decompiled). In my case I need to build version 10.2.154.26 so this is the tag I am checking out.
git checkout 10.2.154.26
git pull origin
gclient syncNow we are ready to apply the patches required for the V8 code.
The first patch can be found in the View8 fork repository by j4k0xb[*]. We apply it by:
git apply -3 ~/v8.patchCheck for conflicts. Compare the conflicting part with the content of the patch, and remove the lines that were added unnecessarily.
* A modified version of this patch, that should apply on the top of V8 tagged 10.2.154.26 without any modifications, is available here in the repository.
There is one more patch that needs to be applied to fix a bug in the V8 code. This bug is causing some unwanted line breaks inside the strings. This is the patch:
git apply ~/v8_string_patch.diffOnce the patches are applied, we are ready to build it, using depot tools and Ninja.
First issue the command:
python3 tools/dev/v8gen.py x64.releaseIt may happen that some error will occur, showing the error returned by the run commandline. Try to run those commands manually, to see what exactly happened.
/usr/bin/python3 -u tools/mb/mb.py gen -f infra/mb/mb_config.pyl -m developer_default -b x64.release out.gn/x64.releaseIn my case, I had to install the missing application pkd-config
sudo apt-get install pkd-configAfter that, try again. Once the output was successfully generated, edit the file: out.gn/x64.release/args.gn as it is described in the View8 readme.
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 = falseNow we are ready to build View8 with Ninja.
ninja -C out.gn/x64.release v8_monolithOnce it is built, we can copy the v8dasm.cpp file into the directory with V8 and issue the command. It requires LLVM, but this can be installed easily from the package manager.
clang++ v8dasm.cpp -g -std=c++20 -Iinclude -Lout.gn/x64.release/obj -lv8_libbase -lv8_libplatform -lv8_monolith -o v8dasmIt should give us the v8dasm ELF.