当前位置:网站首页>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
边栏推荐
- 企业微信应用授权/静默登录
- Illegal character in scheme name at index 0:
- 微信:获取单个标签所有人
- After a circle, I sorted out this set of interview questions..
- Use include in databinding
- 汇编语言与逆向工程 栈溢出漏洞逆向分析实验报告
- Yangtao electronic STM32 Internet of things entry 30 step notes II. Cube ide download, installation, sinicization and setting
- L2-024 tribe (25 points) (and check the collection)
- Introduction to GUI programming swing
- 在sqli-liabs学习SQL注入之旅(第十一关~第二十关)
猜你喜欢

2022-04-22 openebs cloud native storage

L2-024 部落 (25 分)(并查集)

bashdb下载安装

LeetCode_DFS_中等_1254. 统计封闭岛屿的数目

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

请提前布局 Star Trek突破链游全新玩法,市场热度持续高涨

Idea is configured to connect to the remote database mysql, or Navicat fails to connect to the remote database (solved)

Consensus Token:web3. 0 super entrance of ecological flow

Study notes of deep learning (8)

Chris LATTNER, father of llvm: the golden age of compilers
随机推荐
扣缴义务人
2021李宏毅机器学习之Adaptive Learning Rate
Enterprise wechat application authorization / silent login
Idea package jar file
Judgment on heap (25 points) two insertion methods
Notes d'apprentissage oneflow: de functor à opexprinterpreter
Yangtao electronic STM32 Internet of things entry 30 step notes IV. engineering compilation and download
L2-024 tribe (25 points) (and check the collection)
虚拟线上展会-线上vr展馆实现24h沉浸式看展
求简单类型的矩阵和
L2-024 部落 (25 分)(并查集)
深度学习框架中的自动微分及高阶导数
是否完全二叉搜索树 (30 分)
swagger文档导出自定义v2/api-docs拦截
单片机数码管秒表
Anonymous type (c Guide Basics)
Learn SQL injection in sqli liabs (Level 11 ~ level 20)
Output first order traversal according to second order and middle order traversal (25 points)
OneFlow学习笔记:从Functor到OpExprInterpreter
ESP32程序下载失败,提示超时
