当前位置:网站首页>汇编语言与逆向工程 栈溢出漏洞逆向分析实验报告
汇编语言与逆向工程 栈溢出漏洞逆向分析实验报告
2022-04-23 08:28:00 【蜕寒】
汇编语言与逆向工程 栈溢出漏洞逆向分析实验报告
实验环境:windows xp professional VC6.0 OllyDBG
- 实验现象
c语言 源代码:#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");
}
正常情况:若输入的密码为1234567(已define的PASSWORD)则输出congratulations,反之输出incorrect password!。
栈溢出情况:在输入某些特定的字符串,如”12345678”时依旧输出congratulations。如下所示:
- 实验分析
将StackOverFlow.cpp在OD中打开 分析汇编语言:
main函数对应的汇编语言:
verify_password函数对应的汇编语言:
流程分析:

为main函数创建栈空间

循环:将eax赋值为1,进行与运算,易知永远不会跳转,对应while(1),不控制循环的结束。

打印:00427064存储要打印的话。

输入:将输入的password保存至ebp-404。

调用函数:将输入结果保存至数据寄存器中,然后调用地址为00401005的verify_password函数。

保存main函数环境:将调用函数前的寄存器压入栈中,以便回到主函数以后恢复main函数的环境。

创建变量

比较:先将定义的PASSWORD入栈,然后将输入的password入栈,进行比较。

将strcmp的返回值放入eax。

先将ebp+8(passward)入栈,再将buffer(ebp-c)的地址交给edx,最后将password赋值给
buffer。

将函数的返回值(ebp-4)存入到eax中,恢复环境变量,返回原函数。

将返回值存入栈底,比较0和返回值,若相等则打印incorrect password!,不相等则打印congratulations。
情况分类:
- 输入为123456时:

因为123456比1234567小 ebp-4存放FFFFFFFF,ebp-12存放着123456的ASCII码与一个截断字符00。
比较FFFFFFFF与0不等,打印incorrect password!。为正常情况。
2.输入为1234567时:

1234567与1234567相等 所以ebp-4为0,ebp-12存放1234567的ASCII码与一个阶段字符00。
比较0与0相等,打印congratulations,为正常轻狂。
3.输入为12345678时:

12345678大于1234567,所以返回01,存在ebp-4中,在strcpy前栈底如图所示。
当strcpy执行后,在ebp-12存储了12345678的ASCII码占八位,此外还有一个截断字符00,因为没有预留空间,所以存储在ebp-4的地方,此时ebp-4为0。当回到main函数时进行比较时,0与0相等,打印congratulations,发生栈溢出。
三、实验结论
由以上实验,栈溢出发生的原因主要是输入字符过长,导致截断字符占据了返回值的空 间,造成了数据的错误。
版权声明
本文为[蜕寒]所创,转载请带上原文链接,感谢
https://blog.csdn.net/anewpunpkin/article/details/124277925
边栏推荐
- 数论求a^b(a,b为1e12级别)的因子之和
- idea配置连接远程数据库MySQL,或者是Navicat连接远程数据库失败问题(已解决)
- 怎样读取Excel表格到数据库
- pdf加水印
- STM32使用HAL库,整体结构和函数原理介绍
- JSP page coding
- On time atom joins hands with oneos live broadcast, and the oneos system tutorial is fully launched
- Notes on 30 steps of introduction to the Internet of things of yangtao electronics STM32 III. cubemx graphical programming and setting the IO port on the development board
- Failed to convert a NumPy array to a Tensor(Unsupported Object type int)
- rust 使用tokio的Notify 和timeout实现类似可超时条件变量的效果
猜你喜欢

Excle plus watermark

跨域配置报错: When allowCredentials is true, allowedOrigins cannot contain the special value “*“

Failed to convert a NumPy array to a Tensor(Unsupported Object type int)

Test your machine learning pipeline

第一性原理 思维导图

How to generate assembly file

Let the earth have less "carbon" and rest on the road

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

'恶霸' Oracle 又放大招,各大企业连夜删除 JDK。。。

396. Rotate Function
随机推荐
耳穴减肥自身感受细节描述0422
关于数组复制问题
数论求a^b(a,b为1e12级别)的因子之和
请问中衍期货安全靠谱吗?
LeetCode-199-二叉树的右视图
Redis Desktop Manager for Mac(Redis可视化工具)
《深度学习》学习笔记(八)
Stm32f103zet6 [development of standard library functions] - Introduction to library functions
MATLAB 画五星红旗
Description of the abnormity that the key frame is getting closer and closer in the operation of orb slam
xctf刷题小记
记录:js删除数组中某一项或几项的几种方法
Word plus watermark
On time atom joins hands with oneos live broadcast, and the oneos system tutorial is fully launched
form表单 post提交 数据量大的问题
uni-app和微信小程序中的getCurrentPages()
Using qlst excel file
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导入commons-logging-1.2.jar包
线程的调度(优先级)
