当前位置:网站首页>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
边栏推荐
- STM32 uses Hal library. The overall structure and function principle are introduced
- Anonymous type (c Guide Basics)
- tsdf +mvs
- 求简单类型的矩阵和
- php基于哈希算法出现的强弱比较漏洞
- 经典题目刷一刷
- Automatic differentiation and higher order derivative in deep learning framework
- Go语言自学系列 | golang结构体指针
- Use include in databinding
- 深度学习框架中的自动微分及高阶导数
猜你喜欢

Chris LATTNER, father of llvm: the golden age of compilers

RCC introduction of Hal Library

Test your machine learning pipeline

L2-022 重排链表 (25 分)(map+结构体模拟)

Noyer électronique stm32 Introduction à l'Internet des objets 30 étapes notes I. différences entre la Bibliothèque Hal et la Bibliothèque standard

idea配置连接远程数据库MySQL,或者是Navicat连接远程数据库失败问题(已解决)

GUI编程简介 swing

OneFlow学习笔记:从Functor到OpExprInterpreter

经典题目刷一刷

PLC的点表(寄存器地址和点表定义)破解探测方案--方便工业互联网数据采集
随机推荐
洋桃电子STM32物联网入门30步笔记二、CubeIDE下载、安装、汉化、设置
爬虫使用xpath解析时返回为空,获取不到相应的元素的原因和解决办法
正点原子携手OneOS直播 OneOS系统教程全面上线
Yangtao electronic STM32 Internet of things entry 30 step notes IV. engineering compilation and download
Search tree judgment (25 points)
玩转二叉树 (25 分)
MySQL查询两张表属性值非重复的数据
OneFlow學習筆記:從Functor到OpExprInterpreter
《深度学习》学习笔记(八)
LaTeX论文排版操作
IDEA导入commons-logging-1.2.jar包
L2-022 rearrange linked list (25 points) (map + structure simulation)
Noyer électronique stm32 Introduction à l'Internet des objets 30 étapes notes I. différences entre la Bibliothèque Hal et la Bibliothèque standard
bashdb下载安装
STM32使用HAL库,整体结构和函数原理介绍
Error: cannot find or load main class
STM32F103ZET6【标准库函数开发】----库函数介绍
Go语言自学系列 | golang结构体的初始化
Whether the same binary search tree (25 points)
Get the absolute path of the class according to the bytecode
