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 ...
随机推荐
- Swift - 38 - 枚举的基本语法
//: Playground - noun: a place where people can play import UIKit // 创建一个枚举类型就相当于创建了一个新的数据类型, 所以首字母应 ...
- java学习——集合框架(Collection,List,Set)
集合类的由来: 对象用于封装特有数据,对象多了需要存储,如果对象的个数不确定,就使用集合容器进行存储. 集合特点:1,用于存储对象的容器.2,集合的长度是可变的.3,集合中不可以存储基本数据类型值. ...
- uva 10077 - The Stern-Brocot Number System
想法: 初始化三個數L=0/1, M=1/1, R=1/0,設輸入的分數為a: 如果a<M,那麼要往左邊走, R = M; M = (L分子+M分子)/(L分母+M分母); 如果a& ...
- jquery 获取 outerHtml 包含当前节点本身的代码
在开发过程中,jQuery.html() 是获取当前节点下的html代码,并不包含当前节点本身的代码,然后我们有时候确需要,找遍jQuery api文档也没有任何方法可以拿到. 看到有的人通过pare ...
- 《Javascript模式》之对象创建模式读书笔记
引言: 在javascript中创建对象是很容易的,可以使用对象字面量或者构造函数或者object.creat.在接下来的介绍中,我们将越过这些方法去寻求一些其他的对象创建模式. 我们知道js是一种简 ...
- PHP备份数据库的原理和方法 57
1.PHP备份数据库的原理查找所有表--查找所有字段(需要列出所有字段名, 字段类型等相关信 息)---查找所有数据(读取数据出来注意 特殊符号的转换 addslashes ())--生成SQL(把数 ...
- SCM管理器
OpenSCManager 打开SCM管理器 CloseServiceHandle 关闭句柄 CreateService 创建服务 OpenService 打开服务 ControlService 控制 ...
- web Service试用简例
1.打开文件,选择新建Asp.Net web服务. 2.出现新建页面如下. using System; using System.Collections.Generic; using System.L ...
- 推荐IOS开发3个工具:Homebrew、TestFight、Crashlytics-备
1. Homebrew 什么是Homebrew? Homebrew is the easiest and most flexible way to install the UNIX tools App ...
- 01 - 概述 VTK 6.0 迁移
摘要 对vtk版本4和5的管道机制重新架架构的主要目的是:迁移数据对象和算法对象中的管道执行逻辑到一个新集合的类中,我们称这个集合类叫executives.分离数据和执行模型的代码后,可以双双简化修改 ...