首页
社区
课程
招聘
[原创]关于第七章的SEH_stack.c程序调试心得
2008-6-27 12:07 6530

[原创]关于第七章的SEH_stack.c程序调试心得

2008-6-27 12:07
6530
请注意将strcpy函数提前到__asm int 3语句之前,否则在0x002FE98地址中将看不到90909090的数据,我当时就在这里被郁闷了一下午.

/*****************************************************************************
      To be the apostrophe which changed "Impossible" into "I'm possible"!
               
POC code of chapter 7.2 in book "Vulnerability Exploit and Analysis Technique"

file name        : SEH_stack.c
author                : failwest  
date                : 2007.07.04
description        : demo show of how SEH be exploited
Noticed                :        1 only run on windows 2000
                        2 complied with VC 6.0
                        3 build into release version
                        4 SEH offset and shellcode address may need
                          to make sure via runtime debug
version                : 1.0
E-mail                : failwest@gmail.com
               
        Only for educational purposes    enjoy the fun from exploiting :)
******************************************************************************/
#include <windows.h>
char shellcode[]=
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90";
//"\x90\x90\x90\x90\x90\x90\x90\x90";
DWORD MyExceptionhandler(void)
{
        printf("got an exception, press Enter to kill process!\n");
        getchar();
        ExitProcess(1);
}

void test(char * input)
{
        char buf[200];
        int zero=0;
   strcpy(buf,input); //overrun the stack
    __asm int 3 //used to break process for debug
        __try
        {
                //strcpy(buf,input); //overrun the stack
                zero=4/zero; //generate an exception       
        }
        __except(MyExceptionhandler()){}       
}

main()
{
        test(shellcode);       
}

[培训]二进制漏洞攻防(第3期);满10人开班;模糊测试与工具使用二次开发;网络协议漏洞挖掘;Linux内核漏洞挖掘与利用;AOSP漏洞挖掘与利用;代码审计。

收藏
点赞7
打赏
分享
最新回复 (1)
雪    币: 223
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
xieph 2008-6-27 13:42
2
0
顶一下,虽然还没看到那里,希望到时LZ的文章会给我很大的启发!谢谢分享~沙发~
游客
登录 | 注册 方可回帖
返回