调用约定
windows64位调用约定
微软文档
ret_2_init <_libc_csu_init>有一些万能gadget,汇编如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 #!bash 00000000004005a0 <__libc_csu_init>: 4005a0: 48 89 6c 24 d8 mov %rbp,-0x28(%rsp) 4005a5: 4c 89 64 24 e0 mov %r12,-0x20(%rsp) 4005aa: 48 8d 2d 73 08 20 00 lea 0x200873(%rip),%rbp # 600e24 <__init_array_end> 4005b1: 4c 8d 25 6c 08 20 00 lea 0x20086c(%rip),%r12 # 600e24 <__init_array_end> 4005b8: 4c 89 6c 24 e8 mov %r13,-0x18(%rsp) 4005bd: 4c 89 74 24 f0 mov %r14,-0x10(%rsp) 4005c2: 4c 89 7c 24 f8 mov %r15,-0x8(%rsp) 4005c7: 48 89 5c 24 d0 mov %rbx,-0x30(%rsp) 4005cc: 48 83 ec 38 sub $0x38,%rsp 4005d0: 4c 29 e5 sub %r12,%rbp 4005d3: 41 89 fd mov %edi,%r13d 4005d6: 49 89 f6 mov %rsi,%r14 4005d9: 48 c1 fd 03 sar $0x3,%rbp 4005dd: 49 89 d7 mov %rdx,%r15 4005e0: e8 1b fe ff ff callq 400400 <_init> 4005e5: 48 85 ed test %rbp,%rbp 4005e8: 74 1c je 400606 <__libc_csu_init+0x66> 4005ea: 31 db xor %ebx,%ebx 4005ec: 0f 1f 40 00 nopl 0x0(%rax) 4005f0: 4c 89 fa mov %r15,%rdx 4005f3: 4c 89 f6 mov %r14,%rsi 4005f6: 44 89 ef mov %r13d,%edi 4005f9: 41 ff 14 dc callq *(%r12,%rbx,8) 4005fd: 48 83 c3 01 add $0x1,%rbx 400601: 48 39 eb cmp %rbp,%rbx 400604: 75 ea jne 4005f0 <__libc_csu_init+0x50> 400606: 48 8b 5c 24 08 mov 0x8(%rsp),%rbx 40060b: 48 8b 6c 24 10 mov 0x10(%rsp),%rbp 400610: 4c 8b 64 24 18 mov 0x18(%rsp),%r12 400615: 4c 8b 6c 24 20 mov 0x20(%rsp),%r13 40061a: 4c 8b 74 24 28 mov 0x28(%rsp),%r14 40061f: 4c 8b 7c 24 30 mov 0x30(%rsp),%r15 400624: 48 83 c4 38 add $0x38,%rsp 400628: c3 retq
gcc的编译选项: 1 2 3 4 5 6 7 8 9 10 11 -z execstack关闭NX -z noexecstack开启NX -no-pie关闭PIE -pie开启PIE -g 参数可以用GDB加载时l,b <line>在源代码第<line>行下断点 关于canary的几个编译选项: -fstack-protector 启用保护,不过只为局部变量中含有数组的函数插入保护 -fstack-protector-all 启用保护,为所有函数插入保护 -fstack-protector-strong 类似windows下GS的一个编译选项,以下加入canary1)在本地变量地址作为右值表达式或作为函数参数2)本地变量是数组或含数组的union -fstack-protector-explicit 只对有明确stack_protect attribute的函数开启保护 -fno-stack-protector 禁用保护
readelf readelf -S <filename>查看文件段偏移 readelf -r <filename>查看文件重定位表,.rel.dyn和.rel.plt
gdb-peda安装 1 2 git clone https://github.com/longld/peda.git ~/peda echo "source ~/peda/peda.py" >> ~/.gdbinit
pwndbg安装 1 2 3 git clone https://github.com/pwndbg/pwndbg cd pwndbg ./setup.sh
windbg调试 1 2 3 4 5 6 7 !gflag +hpa 这条命令用于定位堆溢出点,hpa=place heap allocations at the end of pages. sx set exceptions。sxe ld:<moudle name>,set exceptions enable when load <moudle name> windbg dump内存 .writemem <DumpFile_Full_Path> <Dump_Start_Addr> L?<Dump_Length> .childdbg 1 启用子线程调试
objdump查看plt、got、汇编 1 2 3 objdump -d -j .plt <filename> 查看<filename>的plt表 objdump -R <filename> 查看<filename>的got表 objdump -M intel -d <filename> 可以查看<filename>bin文件的intel汇编,默认at&t
SSH下载远程文件 scp -P<port> user@computername:<path> 下载远程文件<path>到本地
Linux查看进程信息 cat /proc/[pid]/maps 查看进程加载信息
Linux ASLR 1 sudo bash -c "echo 0 > /proc/sys/kernel/randomize_va_space"
关闭系统ASLR 0:没有随机化。即关闭 ASLR。 1:保留的随机化。共享库、栈、mmap() 以及 VDSO 将被随机化。 2:完全的随机化。在 1 的基础上,通过 brk() 分配的内存空间也将被随机化。 ASLR并不负责代码段和数据段的随机化
gdb查找system,’/bin/sh’ print system 查找system函数地址 print __libc_start_main 查找main入口 find ,+,”/bin/sh” 查找”/bin/sh”官方说明
关于RELRO 1 2 3 4 5 6 7 部分RELRO(由ld -z relro启用): 将.got段映射为只读(但.got.plt还是可以写) 重新排列各个段来减少全局变量溢出导致覆盖代码段的可能性. 完全RELRO(由ld -z relro -z now启用) 执行部分RELRO的所有操作. 让链接器在链接期间(执行程序之前)解析所有的符号, 然后去除.got的写权限. 将.got.plt合并到.got段中, 所以.got.plt将不复存在.
1 2 3 p=process('<process_name>',env={"LD_PRELOAD":"<libc_absolute_path>"}) pwntools带参数args启动<proc> p=process(argv=['./proc',args])
angr安装 (一定要在mkvirtualenv的虚拟环境下装,不然本地pwntools会报各种各样的错。人生苦短少瞎折腾;b)
1 2 3 4 5 6 7 8 apt-get install python-dev libffi-dev build-essential virtualenvwrapper find / -name virtualenvwrapper.sh //找到的virtualenvwrapper.sh路径记为<path> export WORKON_HOME=~/Envs //这里最好切到根目录下 source <path> 创建angr虚拟环境安装angr(进入虚拟环境后使用pwntools还需在此环境下重新安装,pip install pwntools) mkvirtualenv angr && pip install angr
Windows手动下载符号表 cmd:/symchk.exe /s SRV**http://msdl.microsoft.com/download/symbols
windows下利用管理员权限CMD替换系统DLL 1 2 takeown /f <dll_path> icacls <dll_path> /grant administrators:F
windbg在进程启动时附加 注册表[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options<app>.exe]添加字符串值debugger,value为windbg.exe系统环境变量path添加windbg安装路径;或者value值设置为windbg.exe的安装路径
查看<filename>符号表 nm -C <filename>
Linux libc源码 apt-get source libc6-dev 下载源码
grep ““ -r .// 查找在的位置
_IO_file pwn 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 struct _IO_FILE { int _flags; /* High-order word is _IO_MAGIC; rest is flags. */ #define _IO_file_flags _flags /* The following pointers correspond to the C++ streambuf protocol. */ /* Note: Tk uses the _IO_read_ptr and _IO_read_end fields directly. */ char* _IO_read_ptr; /* Current read pointer */ char* _IO_read_end; /* End of get area. */ char* _IO_read_base; /* Start of putback+get area. */ char* _IO_write_base; /* Start of put area. */ char* _IO_write_ptr; /* Current put pointer. */ char* _IO_write_end; /* End of put area. */ char* _IO_buf_base; /* Start of reserve area. */ char* _IO_buf_end; /* End of reserve area. */ /* The following fields are used to support backing up and undo. */ char *_IO_save_base; /* Pointer to start of non-current get area. */ char *_IO_backup_base; /* Pointer to first valid character of backup area */ char *_IO_save_end; /* Pointer to end of non-current get area. */ struct _IO_marker *_markers; struct _IO_FILE *_chain; int _fileno; #if 0 int _blksize; #else int _flags2; #endif _IO_off_t _old_offset; /* This used to be _offset but it's too small. */ #define __HAVE_COLUMN /* temporary */ /* 1+column number of pbase(); 0 is unknown. */ unsigned short _cur_column; signed char _vtable_offset; char _shortbuf[1]; /* char* _save_gptr; char* _save_egptr; */ _IO_lock_t *_lock; #ifdef _IO_USE_OLD_IO_FILE }; struct _IO_FILE_plus { FILE file; //FILE=_IO_FILE const struct _IO_jump_t *vtable; }; struct _IO_FILE; /* The opaque type of streams. This is the definition used elsewhere. */ typedef struct _IO_FILE FILE; struct _IO_jump_t { JUMP_FIELD(size_t, __dummy); JUMP_FIELD(size_t, __dummy2); JUMP_FIELD(_IO_finish_t, __finish); JUMP_FIELD(_IO_overflow_t, __overflow); JUMP_FIELD(_IO_underflow_t, __underflow); JUMP_FIELD(_IO_underflow_t, __uflow); JUMP_FIELD(_IO_pbackfail_t, __pbackfail); /* showmany */ JUMP_FIELD(_IO_xsputn_t, __xsputn); JUMP_FIELD(_IO_xsgetn_t, __xsgetn); JUMP_FIELD(_IO_seekoff_t, __seekoff); JUMP_FIELD(_IO_seekpos_t, __seekpos); JUMP_FIELD(_IO_setbuf_t, __setbuf); JUMP_FIELD(_IO_sync_t, __sync); JUMP_FIELD(_IO_doallocate_t, __doallocate); JUMP_FIELD(_IO_read_t, __read); JUMP_FIELD(_IO_write_t, __write); JUMP_FIELD(_IO_seek_t, __seek); JUMP_FIELD(_IO_close_t, __close); JUMP_FIELD(_IO_stat_t, __stat); JUMP_FIELD(_IO_showmanyc_t, __showmanyc); JUMP_FIELD(_IO_imbue_t, __imbue); };
关于_IO_file的利用:
p _IO_2_1_stdout_可以找到vtable的地址,然后覆盖vtable的指针即可改变程序的流程
p *(struct _IO_jump_t *)可以查看vtable的内容
pwndbg相对偏移断点 pwndbg的一个姿势(程序运行状态有效,在需要输入的位置CTRL+C即可)
1 b *$rebase(offset) offset替换为断点的相对偏移
ROP ROPgadget –binary <filename> –only “pop|ret” | grep <reg>
过滤<filename>中<reg>的rop gadget
关于FORTIFY机制 传送门 按我个人的理解这是缓冲区溢出的缓解措施,这个机制会进行如下操作: 1)在gcc编译阶段使用编译选项-D_FORTIFY_SOURCE=2(1 或者 2),gcc会检测到使用strcpy及类似危险函数时未检查边界的情况,给出warning 2)对格式化字符串利用的限制,包括参数解析的地址不能位于可读可写区域、使用类似%2$x必须使用%1$x 3)对于需要解析地址的函数替换成对应的__*_chk函数
apt-get 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 # apt-get update——在修改/etc/apt/sources.list或者/etc/apt/preferences之後运行该命令。此外您需要定期运行这一命令以确保您的软件包列表是最新的。 # apt-get install packagename——安装一个新软件包(参见下文的aptitude) # apt-get remove packagename——卸载一个已安装的软件包(保留配置文件) # apt-get --purge remove packagename——卸载一个已安装的软件包(删除配置文件) # dpkg --force-all --purge packagename 有些软件很难卸载,而且还阻止了别的软件的应用,就可以用这个,不过有点冒险。 # apt-get autoclean apt会把已装或已卸的软件都备份在硬盘上,所以如果需要空间的话,可以让这个命令来删除你已经删掉的软件 # apt-get clean 这个命令会把安装的软件的备份也删除,不过这样不会影响软件的使用的。 # apt-get upgrade——更新所有已安装的软件包 # apt-get dist-upgrade——将系统升级到新版本 # apt-cache search string——在软件包列表中搜索字符串 # dpkg -l package-name-pattern——列出所有与模式相匹配的软件包。如果您不知道软件包的全名,您可以使用“*package-name-pattern*”。 # aptitude——详细查看已安装或可用的软件包。与apt-get类似,aptitude可以通过命令行方式调用,但仅限于某些命令——最常见的有安装和卸载命令。由于aptitude比apt-get了解更多信息,可以说它更适合用来进行安装和卸载。 # apt-cache showpkg pkgs——显示软件包信息。 # apt-cache dumpavail——打印可用软件包列表。 # apt-cache show pkgs——显示软件包记录,类似于dpkg –print-avail。 # apt-cache pkgnames——打印软件包列表中所有软件包的名称。 # dpkg -S file——这个文件属于哪个已安装软件包。 # dpkg -L package——列出软件包中的所有文件。 # apt-file search filename——查找包含特定文件的软件包(不一定是已安装的),这些文件的文件名中含有指定的字符串。apt-file是一个独立的软件包。您必须先使用apt-get install来安装它,然後运行apt-file update。如果apt-file search filename输出的内容太多,您可以尝试使用apt-file search filename | grep -w filename(只显示指定字符串作为完整的单词出现在其中的那些文件名)或者类似方法,例如:apt-file search filename | grep /bin/(只显示位于诸如/bin或/usr/bin这些文件夹中的文件,如果您要查找的是某个特定的执行文件的话,这样做是有帮助的)。 apt-get update 系统软件包更新
linux下使用代(敏感词敏感词)理 配置小飞机,下载传送门
安装
1 2 dpkg -i xxx apt-get -f install
设置成全局代(敏感词敏感词)理
设置终端代(敏感词敏感词)理,我使用的是privoxy
安装
修改/etc/privoxy/config配置
1 2 3 1.搜索字符串去掉listen-address 127.0.0.1:8118 这一句的注释(#) 2.搜索forward-socks5t,改成forward-socks5t / 127.0.0.1:1080 . 并去掉注释
修改.bashrc,(路径~/.bashrc),结尾添加如下配置
1 2 3 export http_proxy=http://127.0.0.1:8118 export https_proxy=http://127.0.0.1:8118 export ftp_proxy=http://127.0.0.1:8118
配置修改完毕运行bash即可
本地socat部署pwn环境 1 socat tcp4-listen:<port>,reuseaddr,fork exec:"env LD_PRELOAD=<libc_path> <execute_file_path>" &
socat安装:
1 2 3 4 5 6 wget http://www.dest-unreach.org/socat/download/socat-1.7.3.2.tar.gz tar zxf socat-1.7.3.2.tar.gz cd socat-1.7.3.2 ./configure make make install
Linux FD含义 在Linux中,值为0、1、2的fd分别代表标准输入、标准输出和标准错误输出,在程序中打开文件得到的fd从3开始增长
Docker安装 1 2 3 4 5 6 7 8 9 10 #!/bin/bash apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D; echo 'deb https://apt.dockerproject.org/repo debian-stretch main' > /etc/apt/sources.list.d/docker.list; apt-get install -y apt-transport-https ca-certificates; apt-get update && sudo apt-get install -y docker-engine; systemctl start docker; systemctl enable docker; systemctl status docker; exit; EOF
运行以上脚本
安装docker-compose
1 pip install docker-compose
测试安装(需要注册docker账号)传送门
1 2 docker login docker run hello-world
docker加速
docker网络问题传送门
使用阿里云docker镜像加速 ,获取加速地址
附
1 2 3 阿里:http://mirrors.aliyun.com/help/docker-ce 清华:https://mirrors.tuna.tsinghua.edu.cn/help/docker-ce/ 中科大:http://mirrors.ustc.edu.cn/help/docker-ce.html
修改/etc/docker/daemon.json(没有则新建)
1 2 3 4 5 6 7 8 9 10 11 12 13 { "registry-mirrors": [ "https://registry.docker-cn.com", "https://kfwkfulq.mirror.aliyuncs.com", "https://2lqq34jg.mirror.aliyuncs.com", "https://pee6w651.mirror.aliyuncs.com", "https://registry.docker-cn.com", "http://hub-mirror.c.163.com" ], "dns": ["8.8.8.8","8.8.4.4"] } sudo service docker restart
加速细节传送门
shellcode 记录一个shellcode编写时突破字节限制的奇技淫巧
1 2 3 sc=asm('xchg rdi,rsi') sc+=asm('mov dl,xx') sc+=asm('syscall')
即通过交换rdi和rsi的值,执行一次sys_read(rdi,xx),这样汇编之后的shellcode只有7字节(在除rdi外寄存器全部置零的情况下就可以发挥作用了)
ropper ropper github
1 2 ropper --file <filename> |grep syscall 寻找<filename>字节码中的syscall
pwn加载指定libc pwn使用题目给定的libc动态调试
使用libcdatabase查找所给libc版本
修改所给elf文件,启动时使用参数LD_PRELOAD=。pwntools中使用p=process(‘./<elf>’,env={“LD_PRELOAD”:”./<libc>”})
1 2 3 4 5 patchelf --set-interpreter <libc_ld_path> <elf_name> LD_PRELOAD=<libc_name> <elf_name>或者patchelf --set-rpath <libc_parent_folder>:/<libc_name> <elf_name> example: patchelf --set-rpath /media/sf_pwn_share/ctf-challenges-master/pwn/heap/chunk-extend-shrink/2015_hacklu_bookstore/:/libc.so.6 ./books
注:是libc对应版本的加载程序,可以从这里 下载
linux查找代码命令 1 2 3 find / -name <file-name> 查找名为<filenname>的文件 cat -n <file-name> <file-name>以带行数的形式展示 grep "<string>" -r <dir> 在dir目录查找包含string的文件
afl qemu模式 1 2 3 4 5 6 7 https://cloud.tencent.com/developer/article/1128539 https://www.cnblogs.com/WangAoBo/p/8280352.html /usr/include/x86_64-linux-gnu/bits/mman-shared.h +++static int memfd_create (const char *__name, unsigned int __flags) __THROW; make install完把afl-fuzz根目录下的afl-qemu-trace放到whereis afl-fuzz所在目录下
人生苦短,为什么不选择apt-get却偏偏想自己编译然后因为各种编译错误怀疑人生呢
1 2 3 apt search afl //找到可用的afl包,我这里是afl++;还有的同学可能是afl包 apt-get install afl++
WSL (WSL真香,啊我死了)wsl管理工具,可以迁移wsl安装路径
软件地址
使用说明
wsl修改为阿里源
1 2 3 4 sudo vim /etc/apt/sources.list :%s/security.ubuntu/mirrors.aliyun/g :%s/archive.ubuntu/mirrors.aliyun/g :wq
wsl安装图形界面,工具下载地址
(最新版有bug,我这里安装的是vcxsrv-64.1.20.1.4),配置地址
配置完成之后wsl内输入
1 2 export DISPLAY=localhost:0 sudo compiz
即可
修改pip源 1 2 3 4 5 6 7 8 9 10 11 12 13 14 mkdir ~/.pip gedit ~/.pip/pip.conf 阿里(貌似不能用了?) [global] index-url = http://mirrors.aliyun.com/pypi/simple/ [install] trusted-host = mirrors.aliyun.com 清华 [global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple [install] trusted-host = pypi.tuna.tsinghua.edu.cn
标志寄存器 1 2 3 4 5 6 7 8 9 10 11 12 条件标志:反映包含在ALU算术逻辑运算后的结果特征 OF 溢出标志 :运算时,若操作数超出了机器所能表示的范围为,则产生溢出,OF=1,否则OF=0 SF 符号标志 ;设置成运算操作结果的符号状态。当结果为负时,SF=1,否则SF=0 ZF 零标志 结果=0,ZF=1,结果≠0,ZF=0 AF 辅助进位标志 ,运算过程中第三位有进位,置AF=1,否则AF=0 PF 奇偶标志: 当操作数中有偶数个1时,置PF=1,否则PF=0 CF进位标志 : 最高有效位产生的进位值,例如 执行加法指令时,MSB有进,置CF=1;否则CF=0 控制标志:控制执行特殊的功能 DF放向标志:用于字符串操作指令程序设计。 DF置0,则串操作控制处理方向,从带有最低地址的第一个元素逐个处理,否则,从高向低 ID中断允许标志: IF=1,CPU允许中断,IF=0,则CPU关闭中断 TF跟踪标志:TF=1,机器进入单步工作方式,每条机器指令执行后,显示结果及寄存器状态,若TF=0,则机器处在连续工作方式。此标志为调试机器或调试程序发现故障而设置。
可见字符汇编指令 机器码在0x1f<opcode<=0x7f的汇编指令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 1.数据传送: push/pop eax… pusha/popa 2.算术运算: inc/dec eax… sub al, 立即数 sub byte ptr [eax… + 立即数], al dl… sub byte ptr [eax… + 立即数], ah dh… sub dword ptr [eax… + 立即数], esi edi sub word ptr [eax… + 立即数], si di sub al dl…, byte ptr [eax… + 立即数] sub ah dh…, byte ptr [eax… + 立即数] sub esi edi, dword ptr [eax… + 立即数] sub si di, word ptr [eax… + 立即数] 3.逻辑运算: and al, 立即数 and dword ptr [eax… + 立即数], esi edi and word ptr [eax… + 立即数], si di and ah dh…, byte ptr [ecx edx… + 立即数] and esi edi, dword ptr [eax… + 立即数] and si di, word ptr [eax… + 立即数] xor al, 立即数 xor byte ptr [eax… + 立即数], al dl… xor byte ptr [eax… + 立即数], ah dh… xor dword ptr [eax… + 立即数], esi edi xor word ptr [eax… + 立即数], si di xor al dl…, byte ptr [eax… + 立即数] xor ah dh…, byte ptr [eax… + 立即数] xor esi edi, dword ptr [eax… + 立即数] xor si di, word ptr [eax… + 立即数] 4.比较指令: cmp al, 立即数 cmp byte ptr [eax… + 立即数], al dl… cmp byte ptr [eax… + 立即数], ah dh… cmp dword ptr [eax… + 立即数], esi edi cmp word ptr [eax… + 立即数], si di cmp al dl…, byte ptr [eax… + 立即数] cmp ah dh…, byte ptr [eax… + 立即数] cmp esi edi, dword ptr [eax… + 立即数] cmp si di, word ptr [eax… + 立即数] 5.转移指令: push 56h pop eax cmp al, 43h jnz lable <=> jmp lable 6.交换al, ah push eax xor ah, byte ptr [esp] // ah ^= al xor byte ptr [esp], ah // al ^= ah xor ah, byte ptr [esp] // ah ^= al pop eax 7.清零: push 44h pop eax sub al, 44h ; eax = 0 push esi push esp pop eax xor [eax], esi ; esi = 0
virtualbox ubuntu访问共享文件夹 1 2 sudo usermod -a -G vboxsf <user_name> sudo reboot
qemu安装 1 sudo apt-get install qemu qemu-system
debian ubuntu更新public key不匹配 1 sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com <key>
ubuntu安装chrome 1 2 wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb sudo apt install ./google-chrome-stable_current_amd64.deb
linux查找某行代码
r表示递归查找
n表示显示代码在文件中出现的行号
“xxx”支持正则查询
v8调试 修改gdbinit
添加v8安装目录下tools目录里的gdbinit路径
加载v8后设置启动参数
1 set args --allow-natives-syntax xxx.js
在要调试的xxx.js中设置断点
1 2 %DebugPrint(obj) // 输出对象地址 %SystemBreak() // 触发调试中断
gdb中r即可
v8拉取旧的commit的时候报错 1 2 3 4 Error: 4> 4> ____ v8/buildtools at xxx 4> You have unstaged changes. 4> Please commit, stash, or reset.
解决
gdb写入栈回溯信息到文件 1 2 3 4 set logging file xxx set logging on thread apply all bt set logging off
全部调试信息写入文件,启动时使用
Linux 16进制显示控制台程序输出
以16进制显示控制台的输出
npm配置代理 修改~/.npmrc文件
1 2 3 proxy=http://127.0.0.1:8123/ https-proxy=http://127.0.0.1:8123 registry=http://registry.npmjs.org/
ubuntu 18.04 fuzzilli JavascriptCore编译 fuzzilli编译
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 git clone https://git.webkit.org/git/WebKit.git WebKit brew: sudo apt install linuxbrew-wrapper icu4c: brew install icu4c clang: sudo apt install clang gedit bashrc: export PATH=$PATH:"/home/linuxbrew/.linuxbrew/bin" export PATH=$PATH:"/home/linuxbrew/.linuxbrew/Cellar/icu4c/66.1" gedit fuzzbuild.sh export PATH=$PATH:"/home/linuxbrew/.linuxbrew/Cellar/icu4c/66.1"
正常编译
1 2 3 4 5 去掉Tools/gtk/install-dependencies里边installDependenciesWithApt里边的pipenv包 执行 Tools/gtk/install-dependencies Tools/Scripts/build-webkit --jsc-only
切换commit,一例
1 git checkout -b local_branch_name commit_hash
编译Debug带符号时使用
1 ./Tools/Scripts/build-jsc --jsc-only --debug --cmakeargs="-DENABLE_STATIC_JSC=ON -DCMAKE_C_COMPILER='/usr/bin/clang' -DCMAKE_CXX_COMPILER='/usr/bin/clang++' -DCMAKE_CXX_FLAGS='-fsanitize-coverage=trace-pc-guard -O3 -lrt'"
lldb输入崩溃日志 1 bugreport unwind --outfile <path/to/logfile>
git 更新本地文件 1 2 3 git fetch --all git reset --hard origin/master git pull
linux安装dotnet 1 2 3 4 ~/.bashrc添加环境变量 export DOTNET_ROOT="/path/to/dotnet/" export PATH=$PATH:"/path/to/dotnet/"
linux sudo复制当前环境变量 修改~/.bashrc
1 alias sudo='sudo env PATH=$PATH'
turbolizer安装 1 2 3 4 5 6 7 8 9 cd /path/to/v8/tools/turbolizer npm i npm run-script build python -m SimpleHTTPServer 8000 google-chrome访问 localhost:8000 npm使用代理可以参考上面配置npmrc
windbg chrome&firefox符号表 1 2 3 srv*d:\symbols*http://chromium-browser-symsrv.commondatastorage.googleapis.com; srv*d:\symbols*http://symbols.mozilla.org
chrome代码更新 https://www.chromium.org/developers/how-tos/get-the-code/working-with-release-branches
1 2 3 4 5 6 7 8 git reset --hard origin/master gclient sync git fetch --tags git checkout -b your_release_branch 74.0.3729.131 gclient sync --with_branch_heads --with_tags git删除本地branch git branch -d <branch_name>
PS:更新代码的时候没有
1 2 git reset --hard gclient sync -f
解决不了的问题
linux编译链接库的一些问题 -L 指定库绝对路径 -l指定库名 如链接libjasper.so:
1 afl-cc afl_fuzzer.c -I /home/r00t/fuzz/target/jasper/src/libjasper/include -L /home/r00t/fuzz/target/jasper/src/libjasper/ -ljasper -o ./fuzzer
1)”error while loading shared libraries: : cannot open shared object file: No such file or directory” /etc/ld.so.conf.d/添加动态库路径
1 2 sudo gedit /etc/ld.so.conf.d/my.conf sudo ldconfig
2)undefined reference to `__asan_init’ 编译时链接asan -fsanitize=address
3)undefined reference to std::xxx
编译时加上链接选项 -lstdc++
chrome asan 获取crash符号表
1 xx |& ./tools/valgrind/asan/asan_symbolize.py
本地build
gn flags
1 2 3 4 5 is_asan = true is_debug = false # Release build. symbol_level = 2 blink_symbol_level = 2 is_component_build = true
1 autoninja -C out/asan chrome
chrome 调试 xx.html目录下启动HTTPServer
1 python -m SimpleHTTPServer
gdb 启动脚本init,启动时在//src/out/asan目录下gdb -x init
1 2 3 file /home/r00t/chromium/src/out/asan/chrome set args --enable-blink-features=MojoJS --user-data-dir=/tmp/non 'http://localhost:8000/' set follow-fork-mode parent
windows下开启SimpleHTTPServer
1 //python.exe -m http.server