首页 > 其他分享 >v8 study

v8 study

时间:2023-01-28 16:22:17浏览次数:45  
标签:elements study 0x1e840025a7bd length pwndbg v8 properties

v8环境搭建看这里
现在的v8采用的是Ignition(JIT生成) + TurboFan(优化)

v8调试

安装pwngdb

git clone https://github.com/pwndbg/pwndbg
cd pwndbg
./setup.sh

将v8/tools/目录下的gdbinit和gdb-v8-support.py添加到~/.gdbinit

source /path/to/v8/tools/gdbinit
source /path/to/v8/tools/gdb-v8-support.py

之后就可以使用%DebugPrint(x)来输出调试信息,使用%SystemBreak()来对程序下断点。
但是js本身是没有%这种语法的,执行时要加上--allow-natives-syntax
写个脚本测试下

$ cat ./example/test.js 
arr = [1, 2, 3]
%DebugPrint(a);
%SystemBreak();
$ ./d8 --allow-natives-syntax ./example/test.js 
DebugPrint: 0x7900010bdfd: [JSArray]
 - map: 0x07900024e0b5 <Map[16](PACKED_SMI_ELEMENTS)> [FastProperties]
 - prototype: 0x07900024e2f9 <JSArray[0]>
 - elements: 0x07900025a7bd <FixedArray[3]> [PACKED_SMI_ELEMENTS (COW)]
 - length: 3
 - properties: 0x0790000022a9 <FixedArray[0]>
 - All own properties (excluding elements): {
    0x79000006e61: [String] in ReadOnlySpace: #length: 0x079000204285 <AccessorInfo name= 0x079000006e61 <String[6]: #length>, data= 0x0790000022e1 <undefined>> (const accessor descriptor), location: descriptor
 }
 - elements: 0x07900025a7bd <FixedArray[3]> {
           0: 1
           1: 2
           2: 3
 }
0x7900024e0b5: [Map] in OldSpace
 - type: JS_ARRAY_TYPE
 - instance size: 16
 - inobject properties: 0
 - elements kind: PACKED_SMI_ELEMENTS
 - unused property fields: 0
 - enum length: invalid
 - back pointer: 0x0790000022e1 <undefined>
 - prototype_validity cell: 0x079000003875 <Cell value= 1>
 - instance descriptors #1: 0x07900024e865 <DescriptorArray[1]>
 - transitions #1: 0x07900024e881 <TransitionArray[4]>Transition array #1:
     0x079000007d55 <Symbol: (elements_transition_symbol)>: (transition to HOLEY_SMI_ELEMENTS) -> 0x07900024e899 <Map[16](HOLEY_SMI_ELEMENTS)>

 - prototype: 0x07900024e2f9 <JSArray[0]>
 - constructor: 0x07900024e021 <JSFunction Array (sfi = 0x7900021d455)>
 - dependent code: 0x0790000022b9 <Other heap object (WEAK_ARRAY_LIST_TYPE)>
 - construction counter: 0

可以看出打印出了数组大小,内容以及数据类型等相关信息,数组成员被存储为了SMI(small integer)类型

使用GDB调试

$ gdb d8
pwndbg> r --allow-natives-syntax ./example/test.js
[New Thread 0x7f7491b4a700 (LWP 2571)]
DebugPrint: 0x1e840010be29: [JSArray]
 - map: 0x1e840024e0b5 <Map[16](PACKED_SMI_ELEMENTS)> [FastProperties]
 - prototype: 0x1e840024e2f9 <JSArray[0]>
 - elements: 0x1e840025a7bd <FixedArray[3]> [PACKED_SMI_ELEMENTS (COW)]
 - length: 3
 - properties: 0x1e84000022a9 <FixedArray[0]>
 - All own properties (excluding elements): {
    0x1e8400006e61: [String] in ReadOnlySpace: #length: 0x1e8400204285 <AccessorInfo name= 0x1e8400006e61 <String[6]: #length>, data= 0x1e84000022e1 <undefined>> (const accessor descriptor), location: descriptor
 }
 - elements: 0x1e840025a7bd <FixedArray[3]> {
           0: 1
           1: 2
           2: 3
 }
0x1e840024e0b5: [Map] in OldSpace
 - type: JS_ARRAY_TYPE
 - instance size: 16
 - inobject properties: 0
 - elements kind: PACKED_SMI_ELEMENTS
 - unused property fields: 0
 - enum length: invalid
 - back pointer: 0x1e84000022e1 <undefined>
 - prototype_validity cell: 0x1e8400003875 <Cell value= 1>
 - instance descriptors #1: 0x1e840024e865 <DescriptorArray[1]>
 - transitions #1: 0x1e840024e881 <TransitionArray[4]>Transition array #1:
     0x1e8400007d55 <Symbol: (elements_transition_symbol)>: (transition to HOLEY_SMI_ELEMENTS) -> 0x1e840024e899 <Map[16](HOLEY_SMI_ELEMENTS)>

 - prototype: 0x1e840024e2f9 <JSArray[0]>
 - constructor: 0x1e840024e021 <JSFunction Array (sfi = 0x1e840021d455)>
 - dependent code: 0x1e84000022b9 <Other heap object (WEAK_ARRAY_LIST_TYPE)>
 - construction counter: 0
pwndbg> job 0x1e840010be29
0x1e840010be29: [JSArray]
 - map: 0x1e840024e0b5 <Map[16](PACKED_SMI_ELEMENTS)> [FastProperties]
 - prototype: 0x1e840024e2f9 <JSArray[0]>
 - elements: 0x1e840025a7bd <FixedArray[3]> [PACKED_SMI_ELEMENTS (COW)]
 - length: 3
 - properties: 0x1e84000022a9 <FixedArray[0]>
 - All own properties (excluding elements): {
    0x1e8400006e61: [String] in ReadOnlySpace: #length: 0x1e8400204285 <AccessorInfo name= 0x1e8400006e61 <String[6]: #length>, data= 0x1e84000022e1 <undefined>> (const accessor descriptor), location: descriptor
 }
 - elements: 0x1e840025a7bd <FixedArray[3]> {
           0: 1
           1: 2
           2: 3
 }
pwndbg> job 0x1e840025a7bd
0x1e840025a7bd: [FixedArray] in OldSpace
 - map: 0x1e84000021e1 <Map(FIXED_ARRAY_TYPE)>
 - length: 3
           0: 1
           1: 2
           2: 3
pwndbg> x/8gx 0x1e840010be29-1
0x1e840010be28:	0x000022a90024e0b5	0x000000060025a7bd
0x1e840010be38:	0xbeadbeefbeadbeef	0xbeadbeefbeadbeef
0x1e840010be48:	0xbeadbeefbeadbeef	0xbeadbeefbeadbeef
0x1e840010be58:	0xbeadbeefbeadbeef	0xbeadbeefbeadbeef
pwndbg> x/8gx 0x1e840025a7bd-1
0x1e840025a7bc:	0x00000006000021e1	0x0000000400000002
0x1e840025a7cc:	0x000024d100000006	0x0025a7bd00000000
0x1e840025a7dc:	0x0000000400002169	0x0025a7290025a7d1
0x1e840025a7ec:	0x0000002e0000320d	0x00003f790025a7dd

job命令可以查看js object的内存分布。但是job命令的地址是真实地址+1
在v8中地址进行了压缩,只保存低32bit,高位地址都一样
可以看出在0x1e840010be29-1就是存储的arr这个数组的信息,依次分别是map|properties|elements|length

 - map: 0x1e840024e0b5 
 - elements: 0x1e840025a7bd
 - length: 3
 - properties: 0x1e84000022a9
0x1e840010be28:	0x000022a9|0024e0b5	0x00000006|0025a7bd

这里的length乘了2,后面存储的数组元素也乘了2,应该是v8的特性吧
在elements-1即0x1e840025a7bc出可以看出存储的分别是map|length|arr

- map: 0x1e84000021e1 <Map(FIXED_ARRAY_TYPE)>
 - length: 3
           0: 1
           1: 2
           2: 3
0x1e840025a7bc:	0x00000006|000021e1	0x00000004|00000002
0x1e840025a7cc:	0x000024d1|00000006	

上边有两个length,第一个是申请的长度,第二个是已使用的长度
存储double类型时按64bit的长度存储,存储的是真实值不会像integer一样乘2

标签:elements,study,0x1e840025a7bd,length,pwndbg,v8,properties
From: https://www.cnblogs.com/awesome-red/p/17069105.html

相关文章

  • upload-labs pass3,phpstudy中修改httpd.conf后无法解析.php3后缀。phpstudy中64与32系
    问题解决参考自:https://www.likecs.com/show-965809.html 注意:VC运行库(V14-x64)版本必须与Apache、PHP版本相同;VC就是MicrosoftVisualC++,可以通过控制面板查看否则......
  • v8 setup
    记录下笔者本人搭建v8环境的过程,记得挂好代理环境:处于一些原因笔者选择在kali2023上搭建v8gitclonehttps://chromium.googlesource.com/chromium/tools/depot_tools.g......
  • 【实战】yolov8 tensorrt模型加速部署
    【实战】yolov8tensorrt模型加速部署TensorRT-Alpha基于tensorrt+cudac++实现模型end2end的gpu加速,支持win10、linux,在2023年已经更新模型:YOLOv8,YOLOv7,YOLOv6,YOLO......
  • 大展宏图、首创基于.NET 7强大内核-Zoomla!逐浪CMS v8.7.0发布
    【逐浪官网z01.com】开放下载2022年底,微软.NETConf在线活动正式开幕。作为微软开源、跨平台开发平台,.NET7现已推出首个正式版,这也代表微软的“统一工作”终于完成。......
  • hexrays sdk study
    Thereare20examplesin/ida_path/plugins/hexrays_sdk/plugins,youcanlearnfromthat,youcanalsoseeitathttps://hex-rays.com/products/decompiler/manual......
  • daily study 15
    初识指针2;野指针:指针指向的位置是不可知的1.int*p;*P=20;指针未初始化;2.intarr[10]={0};int*p=arr;inti=0;for(i=0;i<=10;i++){*p=i;p++;}越界访问;3.指针指向了空间释放in......
  • daily study 14
    初识指针;指针是什么?在计算机科学中,指针(Pointer)是编程语言中的一个对象,利用地址,它的值直接指向(pointsto)存在电脑存储器中另一个地方的值。由于通过地址能找到所需......
  • YOLOv8 初体验
    简介YOLOv8模型设计快速,准确,易于使用,使其成为广泛的目标检测和图像分割任务的绝佳选择。TheYOLOv8modelisdesignedtobefast,accurate,andeasytouse,making......
  • daily study 13
    4.赋值操作符=,+=,-=,*=....复合赋值,一个=为赋值,==为判断支持连续赋值,从右赋到左5.单目操作符!,-,+,&,sizeof,~(对一个数的二进制位按位取反),--,++,*(间接访问操作符)sizeof(a),计算a所占字......
  • YOLO家族系列模型的演变:从v1到v8(下)
    昨天的文章中,我们回顾了YOLO家族的前9个架构。本文中将继续总结最后3个框架,还有本月最新发布的YOLOV8.Backbone最初由一个分支(GoogLeNet、VGG、Darknet)组成,然后过......