OD: Exploit Me - Overwrite Nearby Varible
实验代码:
#include<stdio.h>
#include<string.h>
#define PASSWORD "1234567" int verify_password(char *password)
{
int authenticated;
char buffer[]; // add local buf to be overflowed
authenticated=strcmp(password,PASSWORD);
strcpy(buffer, password); // overflow here
return authenticated;
} int main()
{
int valid_flag=;
char password[];
while(){
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\n\n");
break;
}
}
return ;
}
注意以上第 8 行和第 10 行的代码,对于猜测变量在内存的相对位置和溢出尝试有用。
栈帧
程序执行到 int verify_password(char *password) 时的栈帧如图:

(变量在内存中的位置可能因编译优化而与上图不一致)
可见 authenticated (int 类型,内存中为 DWORD,占 4 字节)恰在 buffer 的 “下方”,如果 buffer 越界,那么 buffer[8..11] 刚好能覆盖 authenticated !
如果输入的字符超过 7 个字符(null 会占第 8 个字符),则越界字符会覆盖 authenticated。若 authenticated 被覆盖为 0,则溢出成功。
TIPS:用 OllyDBG 调试时可在栈区用【右键→Go to EBP】快速定位当前的 EBP,如图:

TIPS:用 OllyDBG 调试时可用 F2 设置断点。
OllyDbg 调试可见,输入 8 位密码 12345678,当程序执行完第 10 行后,authenticated 的值恰好被 password 的第九位字符串结束符 \0 覆盖为 0x00000000
但需注意 authenticated 的值来源于第 9 行的 strcpy,如果输入的密码是 01234567,则 strcpy 返回 -1,authenticated 为 -1 的补码 0xFFFFFFFF,此时溢出后不能欺骗成功。
OD: Exploit Me - Overwrite Nearby Varible的更多相关文章
- OD: Exploit Me - Overwrite Return Address
修改邻接变量的方法对代码环境限制比较多,更通用.更强大的方法是修改 EBP.返回地址等状态值. 为了方便调试,修改之前的代码如下: #include<stdio.h> #include&l ...
- OD: Exploit Me - Inject Instruction
修改之前的代码: #include<stdio.h> #include<stdlib.h> #include<string.h> #include<windo ...
- OD: Shellcode / Exploit & DLL Trampolining
看到第五章了. 标题中 Dll Tramplining(跳板)名字是从如下地址找到的,写的很好: http://en.wikipedia.org/wiki/Buffer_overflow#The_ju ...
- OD: Kernel Exploit - 2 Programming
本节接前方,对 exploitme.sys 进行利用. exploitme.sys 存在任意地址写任意内容的内核漏洞,现在采用执行 Ring0 Shellcode 的方式进行利用. 获取 HalDis ...
- OD: Kernel Exploit - 1
第 22 章,内核漏洞利用技术 首先编写具有漏洞的驱动 exploitme.sys,再展开内核漏洞利用思路和方法: /***************************************** ...
- OD: Heap Exploit : DWORD Shooting & Opcode Injecting
堆块分配时的任意地址写入攻击原理 堆管理系统的三类操作:分配.释放.合并,归根到底都是对堆块链表的修改.如果能伪造链表结点的指针,那么在链表装卸的过程中就有可能获得读写内存的机会.堆溢出利用的精髓就是 ...
- struts2 CVE-2012-0392 S2-008 Strict DMI does not work correctly allows remote command execution and arbitrary file overwrite
catalog . Description . Effected Scope . Exploit Analysis . Principle Of Vulnerability . Patch Fix 1 ...
- gdb windbg and od use
gdb aslr -- 显示/设置 gdb 的 ASLR asmsearch -- Search for ASM instructions in memory asmsearch "int ...
- An iOS zero-click radio proximity exploit odyssey
NOTE: This specific issue was fixed before the launch of Privacy-Preserving Contact Tracing in iOS 1 ...
随机推荐
- NetBeans使用技巧记录
1.窗体字体大小设置: 在etc文件夹下的netbeans.conf中添加,12表示字体大小,12正合适. netbeans_default_options="--fontsize 12 - ...
- inline-block元素的空白间距解决方法
方法1 <ul><li>item1</li><li>item2</li><li>item3</li><li&g ...
- mvvm框架正式名字确定
经过长时间的选名,今天终于把名字定下来了,ddrjs data drive render,其实框架的核心还是 数据驱动渲染,其实现在市面上的大部分mvvm框架如:angular.vue.avalon ...
- Win10使用小技巧
Win10技巧4.命令行支持Ctrl+V 这项功能使用的人不多,但绝对是跨时代的,因为你终于可以放心大胆地在命令提示符里使用Ctrl+V来粘贴剪贴板内容了.而在此之前,Ctrl+V换来的结果只是一个^ ...
- 06 - 从Algorithm 算法派生类中删除ExecuteInformation() 和ExecuteData() VTK 6.0 迁移
在先前的vtk中,如vtkPointSetAlgorithm 等算法派生类中定义了虚方法:ExecuteInformation() 和 ExecuteData().这些方法的定义是为了平稳的从VTK4 ...
- 摇滚吧HTML5!Jsonic超声波前端交互!
前些年吹过一阵canvas制作html5游戏的东风,相信不少同学重温了一把高中物理课本上的牛顿定律.时光如梭,你是否还记得牛顿定律后面一章的各种机械波的物理定律?环视四周,光纤.wifi.蓝牙.广播都 ...
- web api 2 学习笔记 (Odata ODataQueryOptions 使用)
[ODataRoutePrefix("products")] public class ProductController : BaseController { [ODataRou ...
- 基础 ADO.NET 访问MYSQL 与 MSSQL 数据库例子
虽然实际开发时都是用 Entity 了,但是基础还是要掌握和复习的 ^^ //set connection string, server,database,username,password MySq ...
- SQLiteDatabase里面的简单操作数据库的方法
1.使用insert方法插入记录SQLiteDatabase的insert方法的签名为long insert(String table,String nullColumnHack,ContentVal ...
- OpenRTSP的使用
由于需要研究OpenRTSP的源码,所以先学习下使用. -d [time]--------这个是录制时间,就是单位秒,超时后,程序自动结束. -i -----------以.avi文件格式生成. ...