标签:函数 验证 verify 入口 valid 绕过 password strcmp 溢出
栈溢出绕过验证
自己动手通过反汇编分析的一个栈溢出的案例。
1.程序代码
/*****************************************************************************
To be the apostrophe which changed "Impossible" into "I'm possible"!
POC code of chapter 2.2 in book "Vulnerability Exploit and Analysis Technique"
file name : stack_overflow_var.c
author : failwest
date : 2006.9.20
description : demo show nearby var overrun in stack
input 8 letters to bypass authentication
Noticed : complied with VC6.0 and build into begug version
version : 1.0
E-mail : failwest@gmail.com
Only for educational purposes enjoy the fun from exploiting :)
******************************************************************************/
#include <stdio.h>
#define PASSWORD "1234567"
int verify_password (char *password)
{
int authenticated;
char buffer[8];// add local buff
authenticated=strcmp(password,PASSWORD);
strcpy(buffer,password);//over flowed here!
return authenticated;
}
main()
{
int valid_flag=0;
char password[1024];
while(1)
{
printf("please input password: ");
scanf("%s",password);
valid_flag = verify_password(password);
if(valid_flag)
{
printf("incorrect password!\n\n");
}
else
{
printf("Congratulation! You have passed the verification!\n");
break;
}
}
}
2.分析过程
- 利用OllyDbg打开已经编译好的stack_overflow_var.exe程序
- 找到main函数入口。从GetCommandLineA往下数,第5个Call一般就是程序入口点的Call,F7进入。
- 一路F8,输入字符串12345678,然后往下几步到verify_password函数入口
- 进入verify_password函数,函数栈帧如下图所示
- 继续往下执行,下图为strcmp函数入口地址,以及结果保存位置,局部变量的第一个位置
- 下图中0019FAD0为栈中第一个位置保存的为strcmp结果,为1
- 继续往下执行,来到strcpy函数入口
- 0019FAD0处原本保存的是strcmp结果1,执行完strcpy函数后值被覆盖为0,如下图
- 行完verify_password后,返回到main函数中继续执行,判断strcmp的结果为0,成功绕过验证
over!
标签:函数,验证,verify,入口,valid,绕过,password,strcmp,溢出 来源: https://blog.csdn.net/weixin_50972562/article/details/121866613
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。