当前位置:网站首页>汇编语言与逆向工程 栈溢出漏洞逆向分析实验报告
汇编语言与逆向工程 栈溢出漏洞逆向分析实验报告
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
边栏推荐
- RPC过程
- 经典题目刷一刷
- Generate and parse tokens using JWT
- Detailed explanation of ansible automatic operation and maintenance (I) installation and deployment, parameter use, list management, configuration file parameters and user level ansible operating envi
- 程序,进程,线程;内存结构图;线程的创建和启动;Thread的常用方法
- Go语言自学系列 | golang结构体指针
- 洋桃电子STM32物联网入门30步笔记三、CubeMX图形化编程、设置开发板上的IO口
- 5.6 comprehensive case - RTU-
- Ansible Automation Operation and Maintenance details (ⅰ) Installation and Deployment, Parameter use, list Management, Profile Parameters and user level ansible operating environment Construction
- JSP page coding
猜你喜欢
分布式消息中间件框架选型-数字化架构设计(7)
Reference passing 1
[explanation] get ora-12838: cannot read / modify an object after modifying it in parallel
项目上传部分
K210学习笔记(二) K210与STM32进行串口通信
396. Rotate Function
数据可视化:使用Excel制作雷达图
CGM optimizes blood glucose monitoring and management -- Yiyu technology appears in Sichuan International Medical Exchange Promotion Association
ESP32程序下载失败,提示超时
Knowledge points and problem solutions related to information collection
随机推荐
uni-app和微信小程序中的getCurrentPages()
【IndexOf】【lastIndexOf】【split】【substring】用法详解
Add random attributes to the Li class array objects and sort them
微信小程序 catchtap=“toDetail“ 事件问题
Yangtao electronic STM32 Internet of things entry 30 step notes IV. engineering compilation and download
Navicat remote connection MySQL
Let the earth have less "carbon" and rest on the road
Use of applicationreadyevent
Type anonyme (Principes fondamentaux du Guide c)
Knowledge points and problem solutions related to information collection
Redis master-slave server problem
Transformer XL: attention language modelsbbeyond a fixed length context paper summary
跨域配置报错: When allowCredentials is true, allowedOrigins cannot contain the special value “*“
input元素添加监听事件
xctf刷题小记
Stm32f103zet6 [development of standard library functions] - Introduction to library functions
PgSQL wants to implement all kinds of column sub query operations of MySQL
Idea import commons-logging-1.2 Jar package
Word plus watermark
[C语言] 文件操作《一》