当前位置:网站首页>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
边栏推荐
- K210学习笔记(二) K210与STM32进行串口通信
- Flink同时读取mysql与pgsql程序会卡住且没有日志
- LeetCode396.旋转数组
- Yangtao electronic STM32 Internet of things entry 30 step notes IV. engineering compilation and download
- 调包求得每个样本的k个邻居
- Output first order traversal according to second order and middle order traversal (25 points)
- DJ音乐管理软件Pioneer DJ rekordbox
- 匿名類型(C# 指南 基礎知識)
- PCTP考试经验分享
- STM32使用HAL库,整体结构和函数原理介绍
猜你喜欢

2022-04-22 OpenEBS云原生存储

虚拟线上展会-线上vr展馆实现24h沉浸式看展

Learn SQL injection in sqli liabs (Level 11 ~ level 20)

The K neighbors of each sample are obtained by packet switching

MySQL查询两张表属性值非重复的数据

Yangtao electronic STM32 Internet of things entry 30 step notes IV. engineering compilation and download

Yangtao electronic STM32 Internet of things introduction 30 steps notes 1. The difference between Hal library and standard library

cadence的工艺角仿真、蒙特卡洛仿真、PSRR

L2-3 romantic silhouette (25 points)

洋桃电子STM32物联网入门30步笔记三、CubeMX图形化编程、设置开发板上的IO口
随机推荐
Test your machine learning pipeline
bashdb下载安装
synchronized 锁的基本用法
STM32F103ZET6【标准库函数开发】----库函数介绍
L2-023 graph coloring problem (25 points) (graph traversal)
idea打包 jar文件
Study notes of deep learning (8)
RCC introduction of Hal Library
Notes on 30 steps of introduction to Internet of things of yangtao electronics STM32 III. Explanation of new cubeide project and setting
Search tree judgment (25 points)
使用flask和h5搭建网站/应用的简要步骤
虚拟线上展会-线上vr展馆实现24h沉浸式看展
rembg 分割mask
Star Trek强势来袭 开启元宇宙虚拟与现实的梦幻联动
swagger文档导出自定义v2/api-docs拦截
【精品】利用动态代理实现事务统一管理 二
ESP32程序下载失败,提示超时
匿名類型(C# 指南 基礎知識)
在sqli-liabs学习SQL注入之旅(第十一关~第二十关)
Consensus Token:web3. 0 super entrance of ecological flow
