⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 webdav漏洞简单分析及通用exploit设计.html

📁 里面收集的是发表在www.xfocus.org上的文章
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head><title>WebDav漏洞简单分析及通用exploit设计 </title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><meta name="Keywords" content="安全焦点, xfocus, 陷阱网络, honeynet, honeypot, 调查取证, forensic, 入侵检测, intrusion detection, 无线安全, wireless security, 安全论坛, security forums, 安全工具, security tools, 攻击程序, exploits, 安全公告, security advisories, 安全漏洞, security vulnerabilities, 安全教程, security tutorials, 安全培训, security training, 安全帮助, security help, 安全标准, security standards, 安全代码, security code, 安全资源, security resources, 安全编程, security programming, 加密, cryptography," /><link rel="stylesheet" href="../../css/plone.css" type="text/css"></head><body bgcolor="#FFFFFF" text="#000000"><div class="top">  <div class="searchBox">    <form name="searchform" action="http://www.google.com/search" method="get">      <input type="hidden" name="domains" value="www.xfocus.net">      <input type="hidden" name="sitesearch" value="www.xfocus.net">      <input type="text" name="q" size="20">      <input type="submit" name="btnG" value="Google Search">    </form>  </div>  <img src="../../images/logo.gif" border="0" width="180" height="80" alt="xfocus logo">  <img src="../../images/title.gif" border="0" width="230" height="20" alt="xfocus title"></div><div class="tabs">  <a href="../../index.html" class="plain">首页</a>  <a href="../../releases/index.html" class="plain">焦点原创</a>  <a href="../../articles/index.html" class="selected">安全文摘</a>  <a href="../../tools/index.html" class="plain">安全工具</a>  <a href="../../vuls/index.html" class="plain">安全漏洞</a>  <a href="../../projects/index.html" class="plain">焦点项目</a>  <a href="https://www.xfocus.net/bbs/index.php?lang=cn" class="plain">焦点论坛</a>  <a href="../../about/index.html" class="plain">关于我们</a></div><div class="personalBar">  <a href='https://www.xfocus.net/php/add_article.php'>添加文章</a> <a href='http://www.xfocus.org/'>English Version</a></div><table class="columns">  <tr>    <td class="left"><div class="box">  <h5>&nbsp;文章分类&nbsp;</h5>  <div class="body">    <div class="content odd">       <div style="white-space: nowrap;">	    <img src='../../images/folder_icon.gif' border='0'> <a href='../../articles/4.html'>专题文章</a><br><img src='../../images/folder_icon.gif' border='0'> <a href='../../articles/2.html'><b>漏洞分析 <<</b></a><br><img src='../../images/folder_icon.gif' border='0'> <a href='../../articles/3.html'>安全配置</a><br><img src='../../images/folder_icon.gif' border='0'> <a href='../../articles/1.html'>黑客教学</a><br><img src='../../images/folder_icon.gif' border='0'> <a href='../../articles/5.html'>编程技术</a><br><img src='../../images/folder_icon.gif' border='0'> <a href='../../articles/7.html'>工具介绍</a><br><img src='../../images/folder_icon.gif' border='0'> <a href='../../articles/6.html'>火墙技术</a><br><img src='../../images/folder_icon.gif' border='0'> <a href='../../articles/8.html'>入侵检测</a><br><img src='../../images/folder_icon.gif' border='0'> <a href='../../articles/9.html'>破解专题</a><br><img src='../../images/folder_icon.gif' border='0'> <a href='../../articles/11.html'>焦点公告</a><br><img src='../../images/folder_icon.gif' border='0'> <a href='../../articles/12.html'>焦点峰会</a><br>       </div>	        </div>  </div></div><div class="box">  <h5>&nbsp;文章推荐&nbsp;</h5>  <div class="body">    <div class="content odd">	    <img src='../../images/document_icon.gif' border='0'> <a href='../../articles/200307/579.html'>LSD RPC 溢出漏洞之分析</a><br><img src='../../images/document_icon.gif' border='0'> <a href='../../articles/200306/562.html'>任意用户模式下执行 ring 0 代码</a><br><img src='../../images/document_icon.gif' border='0'> <a href='../../articles/200307/563.html'>IIS的NSIISLOG.DLL溢出问题分析</a><br>    </div>  </div></div>	</td>    <td class="main">	  <h1>WebDav漏洞简单分析及通用exploit设计</h1><br>创建时间:2003-05-09<br>文章属性:原创<br>文章提交:<a href='https://www.xfocus.net/bbs/index.php?lang=cn&act=Profile&do=03&MID=33'>eyas</a> (ey4s_at_21cn.com)<br><br>WebDav漏洞简单分析及通用exploit设计<br />
ey4s&lt;cooleyas@21cn.com&gt;<br />
2003-04-25<br />
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;拜读了isno写的&lt;&lt;WebDav远程溢出漏洞分析&gt;&gt;、&lt;&lt;通用的攻击WebDAV漏洞的方法&gt;&gt;,以及Nankia写的<br />
&lt;&lt;Webdav漏洞ISNO方法的补充&gt;&gt;之后,用他们发布的exploit、以及能在网上找到的exploit在我的一些测试<br />
机上测试,有些成功,有些不成功。于是便想自己调试一下。在后来的调试过程中,参考了大量资料,特别<br />
是yuange所写的&lt;&lt;widechar的字符串缓冲溢出攻击技术&gt;&gt;。在这过程中我学到了很多东西,自己也有些心<br />
得体会,其中可能有不少错误的地方,于是便想写下来,一来请各位高手多多指点,二来可以当做笔记供日<br />
后参考(我记性不好:-))。<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;建议各位在阅读了以上提及的文章后再继续往下看。以下测试是在windows 2000 简体中文版本进行的。<br />
<br />
<br />
&nbsp;&nbsp; -=-=-=- 第一部分 漏洞简单分析 -=-=-=-<br />
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;webdav溢出具体是怎么发生的我就不罗嗦了,请大家参考isno所写的文章,这里只简述一下。我们向<br />
IIS发送如下数据:<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;SEARCH /O HTTP/1.0<br />
&nbsp;&nbsp;&nbsp;&nbsp;Host:xxx<br />
&nbsp;&nbsp;&nbsp;&nbsp;Content-Type: text/xml<br />
&nbsp;&nbsp;&nbsp;&nbsp;Content-length: 3<br />
&nbsp;&nbsp;&nbsp;&nbsp;xxx<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;IIS把我们请求的文件名转换成UNICODE,在前面加上路径,然后作为文件名参数传给了<br />
GetFileAttributesExW(先加上路径再转换成UNICODE,还是转换成UNICODE再加路径,我没有仔细看,但这<br />
并不重要)。假如IIS根目录是c:\inetpub\wwwroot,那么传递给GetFileAttributesExW的文件名就是<br />
&quot;\\?\c:\inetpub\wwwroot\O&quot;的UNICODE形式,如下:<br />
0197efe0&nbsp;&nbsp;5c 00 5c 00 3f 00 5c 00-63 00 3a 00 5c 00 69 00&nbsp;&nbsp;\.\.?.\.c.:.\.i.<br />
0197eff0&nbsp;&nbsp;6e 00 65 00 74 00 70 00-75 00 62 00 5c 00 77 00&nbsp;&nbsp;n.e.t.p.u.b.\.w.<br />
0197f000&nbsp;&nbsp;77 00 77 00 72 00 6f 00-6f 00 74 00 5c 00 4f 00&nbsp;&nbsp;w.w.r.o.o.t.\.O.<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;漏洞引用关系如下:<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;GetFileAttributesExW<br />
&nbsp;&nbsp;&nbsp;&nbsp;|__RtlDosPathNameToNtPathName_U<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|__RtlInitUnicodeString &lt;-buff超过65535就会导致短整型数溢出<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|__在这后面的代码进行字符copy的时候就会触发堆栈溢出<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;我们来看看UNICODE_STRING结构的定义:<br />
&nbsp;&nbsp;&nbsp;&nbsp;typedef struct _UNICODE_STRING <br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;USHORT Length; &lt;--这长度指的是buffer的字节数,并不是unicode字符的个数<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;USHORT MaximumLength;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PWSTR Buffer;<br />
&nbsp;&nbsp;&nbsp;&nbsp;} UNICODE_STRING *PUNICODE_STRING;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;从上面的分析我们可以看到,事实上只要我们保证($FileName+$IIS_Path)*2 &gt; 65535就可以触发<br />
存储buff长度的短整型数溢出,其中$FileName是我们提交的文件名(非UNICODE形式)。<br />
<br />
&nbsp;&nbsp;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;-=-=-=- 第二部分 关于widechar的字符串 -=-=-=-<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;IIS在接收到我们发送的buff之后,会调用MultiByteToWideChar函数把我们的buff转换成widechar,<br />
即UNICODE,用的CodePage是系统默认的CodePage,在简体中文系统上是936。在转换过程中,不符合<br />
相应code page widechar范围的双字节字符会被替换掉,单字节字符会被转换成&quot;\xXX\x00&quot;的形式。<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;怎么判断字符是单字节字符还是双字节字符?&nbsp;&nbsp;简体中文、繁体中文、韩文、日文都是双字节语言,<br />
即double-byte character set (DBCS)。上述四种语言双字节中的第一个字节都大于等于0x80。所以<br />
某个字符如果大于等于0x80的话,那么后面就还有一个字节的字符一起跟这个字符组成一个完整&quot;字符&quot;。<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;不信的话,可以写程序验证一下,调用一个API就可以了。<br />
&nbsp;&nbsp;&nbsp;&nbsp;The IsDBCSLeadByteEx function determines whether a specified byte is a lead byte <br />
that is, the first byte of a character in a double-byte character set (DBCS). <br />
&nbsp;&nbsp;&nbsp;&nbsp;BOOL IsDBCSLeadByteEx(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UINT CodePage,&nbsp;&nbsp; // identifier of code page<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BYTE TestChar&nbsp;&nbsp;&nbsp;&nbsp;// byte to test<br />
&nbsp;&nbsp;&nbsp;&nbsp;);<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;假如我们发送的字符是&quot;\x61\x81\x81&quot;的话,用简体中文的CodePage经过MultiByteToWideChar函数<br />
转换后就成了&quot;\x61\x00\xXX\xXX&quot;,当然,前提是&quot;\x81\x81&quot;转换成Unicode后符合简体中文的wide <br />
char范围。所以我们要确定shellcode在经过MultiByteToWideChar转换后,符合相应code page的wide<br />
char范围。<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;反复拜读了yuange的文章&lt;&lt;widechar的字符串缓冲溢出攻击技术&gt;&gt;后,由衷佩服yuange技术之高!<br />
向他致敬!<br />
&nbsp;&nbsp;&nbsp;&nbsp;yuange在他的文章中提出:<br />
&nbsp;&nbsp;&nbsp;&nbsp;(1)把real shellcode编码成可见字符,即小于0x80。这样在经过MultiByteToWideChar转换后就成为<br />
&quot;\xXX\x00&quot;,字符不会被改变。<br />
&nbsp;&nbsp;&nbsp;&nbsp;(2)再精心编写一段符合相应code page widechar范围的代码,用这些代码来解码上述经过编码的<br />
real shellcode。<br />
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;yuange在那篇文章里面还提供了一段解码shellcode的代码,这些代码符合简体中文WideChar范围。<br />
后来台湾网友Nankia说这些代码在繁体中文上面无法使用,然后Nankia自己又写了个符合繁体中文<br />
widechar范围的解码代码。<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;后来我花了不少时间,在yuange发布的代码的基础上,修改了一些地方,写了一段符合简体中文、繁体<br />
中文、韩文、日文 widechar范围的解码代码。以下是我测试这些解码代码是否符合相应widechar范围的<br />
c代码。不知yuange和Nankia是怎么调试解码代码的??<br />
<br />
-=-=-=-=-=-=-=-=-=-=-=-=-=-= CheckCode.c -=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-==-=-=-=-=<br />
#include &lt;windows.h&gt;<br />
#include &lt;stdio.h&gt;<br />
<br />
#define CODE_CN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;936// ANSI/OEM - Simplified Chinese (PRC, Singapore)<br />
#define CODE_TW&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;950// ANSI/OEM - Traditional Chinese (Taiwan; Hong Kong SAR, PRC)<br />
#define CODE_JP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;932// ANSI/OEM - Japanese, Shift-JIS<br />
#define CODE_Korean&nbsp;&nbsp;&nbsp;&nbsp;949// ANSI/OEM - Korean (Unified Hangeul Code)<br />
int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;g_iCodePageList[]={936,950,932,949};<br />
//如果为合法的wide char范围,则此byte值为1,否则为0<br />
char&nbsp;&nbsp;&nbsp;&nbsp;*g_szWideCharShort;<br />
<br />
void checkcode(unsigned char *shellcode,int iLen);<br />
void printsc(unsigned char *sc, int len);<br />
BOOL MakeWideCharList();<br />
void SaveToFile();<br />
void&nbsp;&nbsp;shellcodefnlock();<br />
<br />

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -