win7下模拟溢出漏洞利用shellcode弹出计算器

来源:互联网 发布:学设计软件计划 编辑:程序博客网 时间:2024/06/05 09:01

详细步骤见

http://blog.csdn.net/rectsuly/article/details/70179755

这里只是几点补充

1、win7有内存保护需要在程序里调用VirtualProtect方法,将内存改为可以执行,如下:

#include "stdio.h"#include "stdlib.h"#include "string.h"int main() {    char name[512];    printf("Reading name from file...\n");    FILE *f = fopen("c:\\Users\\Administrator\\Desktop\\tmp\\name.dat", "rb");    if (!f)        return -1;    fseek(f, 0L, SEEK_END);    long bytes = ftell(f);    fseek(f, 0L, SEEK_SET);    fread(name, 1, bytes, f);     name[bytes] = '\0';    fclose(f);    printf("Hi, %s!\n", name);    DWORD dwOld=0;    VirtualProtect(name,516,PAGE_EXECUTE_READWRITE,&dwOld);    system("pause");    return 0;}

2、用vs编写漏洞程序时最好把一些东西给关了:
项目-属性-C/C++-代码生成-缓冲区安全检查设为否

3、name.dat的生成的话 ret_eip 自己找,其他的直接按文中写的就行,本人开od时每次都是sub esp,24C 而不是 sub esp,200 ,导致计算fillbytes长度错误,最后od debug发现跳错位置了 0_0 。后来觉得应该是一些局部变量多占了一些空间。

这里写图片描述

原创粉丝点击