The Classic Notes App
题目功能
create_note: 先分配一个新的 void* notes[note_count] 再分配新的note
write_note: 按 offset 偏移写入 note ,长度有检查,但 offset 没有
题目自定义了发生 SIGSEGV 时的 handler
1 | sigemptyset(&s.sa_mask); |
handler 中对 void *my_function_frames[] 进行了遍历,这个结构体 +0 位置是一个 char* name,如果这个字符串为 exit 就会调用 +8 位置的函数指针指向的函数
1 | void __noreturn handler() |
flag 函数读取并输出 flag。
原有的 my_function_frame 已经有 name 为 flag 的 flag 函数了,只需要把 name 从 flag 改成 exit 就会在触发 SIGSEGV 后调用到。
漏洞点
在 W 指令里面没有检查 offset ,导致堆 oob 任意 offset 写
利用思路
部分写篡改 void* notes[] 中的 char* note (1/16) , 将它指向 my_function_frames
然后把 frame 中 name 字段的值从 flag 改成 exit
最后写非法地址触发 SIGSEGV
exp
1 | #!/usr/bin/env python |
DataDefinition
题目功能
运行 dd
能控制 dd 参数和运行 dd 后的一次输入
1 | # Copyright 2025 Google LLC |
漏洞点
写入 /proc/$pid/mem 篡改进程的内存
而用 dd 可以自选偏移写入文件,也就可以偏移到 rx 段写入 shellcode,进而劫持控制流
利用思路
python3.12 进程在结束时会调用 Py_FinalizeEx,所以 dd 设置偏移到这个函数的位置写入 execve("/bin/sh",0,0) shellcode
然而 python 读入时进行了 encode() ,意味着只能读入 unicode 范围内的字符
所以 shellcode 要全部为 unicode 字符
exp
1 | from pwncli import * |