当前位置:网站首页>Experimental report on analysis of overflow vulnerability of assembly language and reverse engineering stack
Experimental report on analysis of overflow vulnerability of assembly language and reverse engineering stack
2022-04-23 08:50:00 【Shed cold】
Assembly language and reverse engineering Reverse analysis of stack overflow vulnerability Experimental report
Experimental environment :windows xp professional VC6.0 OllyDBG
- Experimental phenomena
c Language Source code :#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define PASSWORD "1234567"
int verify_password(char *password){
int authentication;
char buffer[8];
authentication=strcmp(password,PASSWORD);
strcpy(buffer,password);
return authentication;
}
main(){
int valid_flag=0;
char password[1024];
while(1){
printf("please input pssword: ");
scanf("%s",password);
valid_flag=verify_password(password);
if(valid_flag){
printf("incorrect password!\n\n");
}
else{
printf("congratulations");
break;
}
}
system("pause");
}
Normal condition : If the password entered is 1234567( has define Of PASSWORD) The output congratulations, On the contrary, output incorrect password!.
Stack overflow : Enter some specific strings in the , Such as ”12345678” Still output when congratulations. As shown below :
- experimental analysis
take StackOverFlow.cpp stay OD Open in Analytical assembly language :
main Assembly language corresponding to function :
verify_password Assembly language corresponding to function :
Process analysis :

by main Function to create stack space

loop : take eax The assignment is 1, Operation and operation , Yi Zhi will never jump , Corresponding while(1), Do not control the end of the cycle .

Print :00427064 Store words to print .

Input : Will input password Save to ebp-404.

Call function : Save the input result to the data register , And then call the address base note. 00401005 Of verify_password function .

preservation main Function of the environment : Push the register before calling the function onto the stack , So that it can be restored after returning to the main function main Function environment .

Create variables

Compare : First define the PASSWORD Push , Then enter the password Push , Compare .

take strcmp The return value of eax.

First the ebp+8(passward) Push , then buffer(ebp-c) Address to edx, The final will be password Assign a value to
buffer.

The return value of the function (ebp-4) Deposit to eax in , Restore environment variables , Return the original function .

Store the return value at the bottom of the stack , Compare 0 And return values , Print if equal incorrect password!, Print if not equal congratulations.
Situation classification :
- Input is 123456 when :

because 123456 Than 1234567 Small ebp-4 Deposit FFFFFFFF,ebp-12 Stored 123456 Of ASCII Code and a truncated character 00.
Compare FFFFFFFF And 0 Unequal , Print incorrect password!. It's normal .
2. Input is 1234567 when :

1234567 And 1234567 equal therefore ebp-4 by 0,ebp-12 Deposit 1234567 Of ASCII Code and a stage character 00.
Compare 0 And 0 equal , Print congratulations, Normal frivolity .
3. Input is 12345678 when :

12345678 Greater than 1234567, So back 01, There is ebp-4 in , stay strcpy The bottom of the front stack is shown in the figure .
When strcpy After execution , stay ebp-12 Store 12345678 Of ASCII The code occupies eight digits , There is also a truncated character 00, Because there is no reserved space , So it's stored in ebp-4 The place of , here ebp-4 by 0. When back to main When comparing functions ,0 And 0 equal , Print congratulations, A stack overflow occurred .
3、 ... and 、 The experimental conclusion
From the above experiment , The main reason for stack overflow is that the input character is too long , Causes the truncated character to occupy the null of the return value between , Caused data error .
版权声明
本文为[Shed cold]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230827420015.html
边栏推荐
- Harbor企业级镜像管理系统实战
- 洋桃电子STM32物联网入门30步笔记三、新建CubeIDE工程和设置讲解
- 汇编语言与逆向工程 栈溢出漏洞逆向分析实验报告
- Flash project cross domain interception and DBM database learning [Baotou cultural and creative website development]
- MATLAB 画五星红旗
- PLC的点表(寄存器地址和点表定义)破解探测方案--方便工业互联网数据采集
- Notes d'apprentissage oneflow: de functor à opexprinterpreter
- Go语言自学系列 | golang结构体作为函数参数
- Correct method of calculating inference time of neural network
- Cadence process angle simulation, Monte Carlo simulation, PSRR
猜你喜欢

正点原子携手OneOS直播 OneOS系统教程全面上线

使用flask和h5搭建网站/应用的简要步骤

Automatic differentiation and higher order derivative in deep learning framework

flask项目跨域拦截处理以及dbm数据库学习【包头文创网站开发】

STM32使用HAL库,整体结构和函数原理介绍

idea底栏打开services

企业微信应用授权/静默登录

valgrind和kcachegrind使用運行分析

Consensus Token:web3. 0 super entrance of ecological flow

深度学习框架中的自动微分及高阶导数
随机推荐
LeetCode396.旋转数组
BK3633 规格书
LaTeX数学公式
面了一圈,整理了这套面试题。。
PLC的点表(寄存器地址和点表定义)破解探测方案--方便工业互联网数据采集
Notes d'apprentissage oneflow: de functor à opexprinterpreter
Latex mathematical formula
Go语言自学系列 | golang嵌套结构体
DJ音乐管理软件Pioneer DJ rekordbox
mycat配置
valgrind和kcachegrind使用運行分析
洋桃电子STM32物联网入门30步笔记三、CubeMX图形化编程、设置开发板上的IO口
K210 learning notes (II) serial communication between k210 and stm32
Search tree judgment (25 points)
Share the office and improve the settled experience
L2-024 部落 (25 分)(并查集)
Whether the same binary search tree (25 points)
经典题目刷一刷
关于堆的判断 (25 分) 两种插入方式
Introduction to GUI programming swing
