IT你好

加入 |登录

IT你好技术论坛广场红黑技术 › 查看主题

221

查看

1

回复
返回列表

Rank: 8Rank: 8

帖子
62 
精华
积分
641 
UID
68 
go

获取“跳板”的地址

1
发表于 2010-3-20 16:08 | 只看该作者 | 倒序看帖 | 打印
在缓冲区溢出的攻击中,本来已经调试好的漏洞利用程序,由于动态链接库的装入和卸载等原因,
windows进程的函数栈帧很可能产生“移位”,因此:利用成片数据简单地把返回地址覆盖成一个定值的做法往往不能让exploit奏效,
为了不至于10次中只有2次才能成功运行shellcode,我们通常使用“跳板”技术来完善这段shellcode,
常用“跳板”有:jmp eax;机器码为(16制)FF E0,jmp esp;机器码为(16制)FF E4,call esp;机器码为(16制)FF D4等等,
下面以USER32.DLL中的一个“jmp esp”为例,搜索内存中的跳板,实现代码如下:

#include <windows.h>
#include <stdio.h>
#define DLL_NAME "user32.dll"      //此处可改为内存中其它的动态链接库
main()
{
        BYTE* ptr;
        int position,address;
        HINSTANCE handle;
        BOOL done_flag = FALSE;

        handle=LoadLibrary(DLL_NAME);

        if(!handle)
        {
                printf(" load dll erro !");
                exit(0);
        }

        ptr = (BYTE*)handle;
        
        for(position = 0; !done_flag; position++)
        {
                try
                {
                        if(ptr[position] == 0xFF && ptr[position+1] == 0xE4)
                        {
                                //0xFFE4是JMP ESP的机器码,可改为其它的跳板                                
                                                                int address = (int)ptr + position;
                                printf("OPCODE found at 0x%x\n",address);
                        }
                }
                catch(...)
                {
                        int address = (int)ptr + position;
                        printf("END OF 0x%x\n", address);
                        done_flag = true;
                }
        }
}
1

评分人数

Impossible into I'm possible

TOP

IT你好技术论坛

GMT+8, 2026-1-13 07:29, Processed in 0.019745 second(s), 11 queries.

Powered by Discuz! X1

© 2001-2010 Comsenz Inc.