Chinaunix首页 | 论坛 | 博客
  • 博客访问: 379456
  • 博文数量: 715
  • 博客积分: 40000
  • 博客等级: 大将
  • 技术积分: 5005
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-13 14:46
文章分类

全部博文(715)

文章存档

2011年(1)

2008年(714)

我的朋友

分类:

2008-10-13 16:34:13

// MmSlfDel.cpp : Defines the entry point for the console application.
//
// Coder Jozu

#include "stdafx.h"
#include

int main(int argc, char* argv[])
{
unsigned char* p = NULL, *pHeap;
unsigned char pMem[] =
{
0xE8, 0x00, 0x00, 0x00, 0x00, // call $ + 5
0x5B, // pop ebx
0x83, 0xEB, 0x05, // sub ebx, offset next - offset start
0x8B, 0xC3, // mov eax, ebx
0x81, 0xEB, 0x00, 0x10, 0x40, 0x00, // sub ebx, offset start
0x89, 0x83, 0x35, 0x10, 0x40, 0x00, // mov dword ptr [ebx + membase], eax
0x58, // pop eax
0x68, 0x00, 0x80, 0x00, 0x00, // push 8000h
0xFF, 0xB3, 0x39, 0x10, 0x40, 0x00, // push dword ptr [ebx + memsize]
0xFF, 0xB3, 0x35, 0x10, 0x40, 0x00, // push dword ptr [ebx + membase]
0x50, // push eax
0xFF, 0xB3, 0x31, 0x10, 0x40, 0x00, // push dword ptr [ebx + fnVadFree]
0xC3 // ret
};

p = (unsigned char*)VirtualAlloc(NULL, 0x1000, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if(!p)
{
printf("memalloc error.\n");
return 1;
}

__try
{
*p = 0;
}
__except(puts("in filter1"), 1)
{
puts("in except1");
}

memcpy(p, pMem, sizeof(pMem));

pHeap = p + sizeof(pMem);
*(ULONG*)&pHeap[0] = (ULONG)VirtualFree;
*(ULONG*)&pHeap[8] = 0x00000000;

((FARPROC)p)();

__try
{
*p = 0;
}
__except(puts("in filter1"), 1)
{
puts("in except2");
}

return 0;
}

--------------------next---------------------

阅读(188) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~