HTML注入的一些简单想法
HTML injection的背景: <BR><BR>1 现在的XSS就是跨站脚本攻击一般都是在有服务器交互的情况下在客户端产生的一些问题,那么在没有服务器交互的情况下呢?<BR>2 另外就是很多人都认为html文件是绝对安全的,那么真的是这样么?<BR><BR>什么是HTML injection:<BR><BR> 有交互才会产生漏洞,无论交互是怎么进行的,HTML文件并不是像大家想的那样没有任何交互,在HTML文件里还是会用到一些javascript来完成自己需要的一些动态效果,这样其实交互的地方还是有的,譬如地址栏的参数也就是location,用户所做的点击触发的事件,以及一些动态的DOM交互都会影响到javascript的执行导致漏洞的产生。<BR><BR>为什么要做HTML injection:<BR><BR> 在Windows本地存在大量的HTML文件,如果这些HTML文件可以被injection的话,那么就可以利用本地的HTML文件在本地域内执行javascript,权限是非常高的。<BR><BR>如何寻找HTML injection:<BR><BR> 寻找交互的地方:交互的地方就是上面说的地址栏等可能可以交互的地方,最常用的就是地址栏了,也就是javascript里的location,所以在HTML文件里寻找location.可能找到你需要的东西。<BR> 寻找危险的操作:HTML里危险的操作包括document.write,eval,对innerHTML这些属性的操作等等都可能会造成jnjection,当然也包括一些其他的可能导致执行脚本的操作。<BR><BR>实际的一个例子:<BR><BR> 如果你安装了iis,那么很容易在c:\windows\Help\iisHelp\common\下面找到类似于下面的代码:<BR><TABLE class=ubb_code cellSpacing=1 cellPadding=0 width="90%" border=0>
<TBODY>
<TR>
<TD>
<TABLE style="BORDER-RIGHT: #cccccc 1px dotted; TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-LEFT: #cccccc 1px dotted; BORDER-BOTTOM: #cccccc 1px dotted" cellSpacing=0 cellPadding=6 width="95%" align=center border=0>
<TBODY>
<TR>
<TD style="WORD-WRAP: break-word" bgColor=#f3f3f3><FONT style="FONT-WEIGHT: bold; COLOR: #990000">以下是引用片段:</FONT><BR><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><BR><html dir=ltr><BR><head><BR><style><BR>a:link {font:9pt/11pt 宋体; color:FF0000}<BR>a:visited {font:9pt/11pt 宋体; color:#4e4e4e}<BR></style><BR><META NAME="ROBOTS" CONTENT="NOINDEX"><BR><title>无法显示网页</title><BR><META HTTP-EQUIV="Content-Type" Content="text-html; charset=gb2312"><BR></head><BR><script> <BR>function Homepage(){<BR><!--<BR>// in real bits, urls get returned to our script like this:<BR>// res://shdocvw.dll/http_404.htm#http://www.DocURL.com/bar.htm <BR>//For testing use DocURL = "res://shdocvw.dll/http_404.htm#https://www.microsoft.com/bar.htm"<BR> DocURL=document.URL;<BR> //this is where the http or https will be, as found by searching for :// but skipping the res://<BR> protocolIndex=DocURL.indexOf("://",4);<BR> //this finds the ending slash for the domain server <BR> serverIndex=DocURL.indexOf("/",protocolIndex + 3);<BR> //for the href, we need a valid URL to the domain. We search for the # symbol to find the begining <BR> //of the true URL, and add 1 to skip it - this is the BeginURL value. We use serverIndex as the end marker.<BR> //urlresult=DocURL.substring(protocolIndex - 4,serverIndex);<BR> BeginURL=DocURL.indexOf("#",1) + 1;<BR> urlresult=DocURL.substring(BeginURL,serverIndex);<BR> //for display, we need to skip after http://, and go to the next slash<BR> displayresult=DocURL.substring(protocolIndex + 3 ,serverIndex);<BR> insertElementAnchor(urlresult, displayresult);<BR>}<BR>function HtmlEncode(text)<BR>{<BR>return text.replace(/&/g, '&amp').replace(/'/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');<BR>}<BR>function TagAttrib(name, value)<BR>{<BR>return ' '+name+'="'+HtmlEncode(value)+'"';<BR>}<BR>function PrintTag(tagName, needCloseTag, attrib, inner){<BR>document.write( '<' + tagName + attrib + '>' + HtmlEncode(inner) );<BR>if (needCloseTag) document.write( '</' + tagName +'>' );<BR>}<BR>function URI(href)<BR>{<BR>IEVer = window.navigator.appVersion;<BR>IEVer = IEVer.substr( IEVer.indexOf('MSIE') + 5, 3 );<BR>return (IEVer.charAt(1)=='.' && IEVer >= '5.5') ?<BR>encodeURI(href) :<BR>escape(href).replace(/%3A/g, ':').replace(/%3B/g, ';');<BR>}<BR>function insertElementAnchor(href, text)<BR>{<BR>PrintTag('A', true, TagAttrib('HREF', URI(href)), text);<BR>}<BR>//--><BR></script><BR><body bgcolor="FFFFFF"><BR><table width="410" cellpadding="3" cellspacing="5"><BR><tr> <BR><td align="left" valign="middle" width="360"><BR><h1 style="COLOR:000000; FONT: 12pt/15pt 宋体"><!--Problem-->无法显示网页</h1><BR></td><BR></tr><BR><tr><BR><td width="400" colspan="2"><BR> <font style="COLOR:000000; Font: 9pt/11pt 宋体">试图访问的网页出现问题,无法显示。</font></td><BR></tr><BR><tr><BR><td width="400" colspan="2"><BR> <font style="COLOR:000000; FONT: 9pt/11pt 宋体"><BR> <hr color="#C0C0C0" noshade><BR> <p>请尝试执行下列操作:</p><BR> <ul><BR><li>打开 <BR> <script><BR> <!--<BR> if (!((window.navigator.userAgent.indexOf("MSIE") > 0) && (window.navigator.appVersion.charAt(0) == "2")))<BR> {<BR> Homepage();<BR> }<BR> //--><BR> </script><BR><BR> 主页,然后查找与所需信息相关的链接。</li><BR><li>单击<a href="javascript:location.reload( target=_blank)">刷新</a>按钮,或稍后重试。<br><BR></li><BR></ul><BR><h2 style="font:9pt/11pt 宋体; color:000000">HTTP 错误 414 - 请求 - URI 太长<br> Internet 信息服务</h2><BR> <hr color="#C0C0C0" noshade><BR> <p>技术信息(用于支持人员)</p><BR><ul><BR><p><BR><li>背景<br><BR><p>请求的 URI 太长,服务器拒绝处理请求。这种情况仅在下列情形下才会发生:</p><BR><p>客户端错误地将 POST 请求转换为带有长查询信息的 GET 请求。</p><BR><p>客户端遇到重定向问题(例如,重定向 URL 的前缀指向自身的后缀)。</p><BR><p>服务器遭到客户端的攻击,该客户端试图找出那些使用定长缓冲区来读取或控制请求 URI 的服务器上的安全漏洞。</p><BR></li><BR><li>详细信息:<br><a href="http://www.microsoft.com/ContentRedirect.asp?prd=iis&sbp=&pver=5.0&pid=&ID=414&cat=web&os=&over=&hrd=&Opt1=&Opt2=&Opt3=" target="_blank">Microsoft 支持</a><BR target=_blank></li><BR></ul> <BR></font></td><BR></tr><BR></table><BR></body><BR></html></TD></TR></TBODY></TABLE> </TD></TR></TBODY></TABLE><BR><BR> 注意其中使用了DocURL=document.URL也就是地址栏参数,这些参数在后面参与了各种运算和操作,跟踪这个参数最后可以见到是进入了document.write的,不过之前是做了htmlEncode,不过还是没关系,我们可以用javascript:的形式执行需要的代码<BR><BR> file:///C:/WINDOWS/Help/iisHelp/common/400.htm#javascript:alert('loveshell')/<BR><BR> 将产生一个连接,点击的话代码将会执行,但是也可以很遗憾地注意到,在这之前IE会提示说有代码会执行......<BR><BR>我们在YY么:<BR><BR> 在Windows下面存在大量的HTML文件,甚至包括chm里面带的HTML文件,dll文件里的HTML资源文件,这种漏洞只要挖掘还是会有的,在老版的IE里是允许用iframe和a这些标签引用本地文件的,但是在IE的新版里禁止了这种操作,注意是IE禁止了这种操作,那么其他的程序呢?譬如realone,譬如其他的协议hcp?
re:HTML注入的一些简单想法
<P>生日快乐!!!!!!!!!!!</P><BR><P>哈哈!哈哈!!!!</P>
页:
[1]