<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>80sec &#187; web安全架构</title>
	<atom:link href="http://www.80sec.com/category/webservice-security/feed" rel="self" type="application/rss+xml" />
	<link>http://www.80sec.com</link>
	<description>Know it then hack it!</description>
	<lastBuildDate>Thu, 19 Aug 2010 08:43:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Mysql charset Truncation vulnerability</title>
		<link>http://www.80sec.com/mysql-charset-truncation-vulnerability.html</link>
		<comments>http://www.80sec.com/mysql-charset-truncation-vulnerability.html#comments</comments>
		<pubDate>Fri, 12 Sep 2008 15:50:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[web安全架构]]></category>
		<category><![CDATA[web应用程序安全]]></category>

		<guid isPermaLink="false">http://www.80sec.com/?p=38</guid>
		<description><![CDATA[Mysql charset Truncation vulnerability
By http://www.80sec.com/
We found that there is a interesting feature in mysql database,when you are using utf8,gbk or other charsets.This feature may make your application unsecure.

Stefen Esser shows some attack manners of mysql in his paper[1], in which he issues the SQL Column Truncation vulnerability.
The application is a forum where new users can [...]]]></description>
			<content:encoded><![CDATA[<p>Mysql charset Truncation vulnerability</p>
<p>By http://www.80sec.com/</p>
<p>We found that there is a interesting feature in mysql database,when you are using utf8,gbk or other charsets.This feature may make your application unsecure.<br />
<span id="more-38"></span><br />
Stefen Esser shows some attack manners of mysql in his paper[1], in which he issues the SQL Column Truncation vulnerability.</p>
<p>The application is a forum where new users can register<br />
The administrator’s name is known e.g. &#8216;admin&#8217;<br />
MySQL is used in the default mode<br />
There is no application restriction on the length of new user names<br />
The database column username is limited to 16 characters </p>
<p>Although the application restrict the length of the username, we can bypass it in the following example:</p>
<p><code><br />
&#60;?php<br />
    $user=$_REQUEST['user'];<br />
    mysql_connect("localhost", "root", "") or<br />
        die("Could not connect: " . mysql_error());<br />
    mysql_select_db("test");<br />
	mysql_query("SET names utf8");<br />
    $result = mysql_query("SELECT * from test_user where user='$user'");<br />
	if(trim($user)=='' or strlen($user)>20 ){<br />
		die("Input user Invalid");<br />
	}<br />
	if(@mysql_fetch_array($result, MYSQL_NUM)) {<br />
		die("already exist");<br />
	}<br />
    else {<br />
		$sql="insert test_user values ('$user')";<br />
		mysql_query($sql);<br />
		echo "$user register OK!";<br />
	}<br />
    mysql_free_result($result);<br />
?><br />
</code></p>
<p>Read the code here:</p>
<p><code><br />
    $result = mysql_query("SELECT * from test_user where user='$user'");<br />
</code></p>
<p>If the attacker input a username &#8216;admin                      z&#8217;, and the sql will be like this:</p>
<p><code><br />
SELECT * FROM user WHERE username='admin                      z'<br />
</code></p>
<p>And the application will check the length of username with the following code:</p>
<p><code><br />
if(trim($user)=='' or strlen($user)>20 ){<br />
die("Input user Invalid");<br />
}<br />
</code></p>
<p>The attack will failed because the length of the username  &#8216;admin                      z&#8217; is greater then 20.</p>
<p>But it will not end here, attacker can input username &#8216;admin0xc1zzz&#8217;, and the sql will be like this:</p>
<p><code><br />
SELECT * FROM user WHERE username='admin0xc1zzz'<br />
</code></p>
<p>This pass the application&#8217;s logic,when the insert commond executes:</p>
<p><code><br />
insert test_user values ('admin0xc1zzz')<br />
</code></p>
<p>because the table is created in charset utf8,the 0xc1 is not a valid utf8 character,it will be striped,also all of the next characters will be striped too.Then the attacker got a user &#8220;admin&#8221;;</p>
<p>As you see,when mysql works at utf8,the invalid data will be striped ,but the webapplication doesn&#8217;t know this,it works at binaray.The difference between webapplication and database make a vulnerability.</p>
<p>Reference: </p>
<p>[1] http://www.suspekt.org/2008/08/18/mysql-and-sql-column-truncation-vulnerabilities/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.80sec.com/mysql-charset-truncation-vulnerability.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dedecms 内置Mysqlids(80sec)</title>
		<link>http://www.80sec.com/dedecms-with-mysqlids8.html</link>
		<comments>http://www.80sec.com/dedecms-with-mysqlids8.html#comments</comments>
		<pubDate>Wed, 03 Sep 2008 05:02:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[web安全架构]]></category>
		<category><![CDATA[web应用程序安全]]></category>

		<guid isPermaLink="false">http://www.80sec.com/?p=36</guid>
		<description><![CDATA[	DeDecms是国内采用比较广泛的一款cms软件，在之前的版本中，陆续被披漏存在SQL注射等安全问题，而SQL注射也是其安全问题的主要所在。为了解决SQL注射的问题，DedeCms在其发布的最新版和补丁中包括了80sec的Mysqlids，以用来抵御和检测Sql注射漏洞。
	Mysqlids作为一个ids存在于php应用程序和数据库操作之间，完全以Mysql的语法来分析执行的SQL语句，而不是采用传统的关键字检测的方法，经过合适的部署，基本不存在误报问题。对于一些非正常的SQL语句能进行阻止并且记录相关的信息，这样就可以很快地定位程序中存在注射漏洞的地方，为漏洞的及时修复提供必要的信息。Mysqlids的检测工作使用php实现，相对于SQL语句来说消耗的时间非常小，合理地部署Mysqlids可以极大地提高程序的安全性。
	DeDecms官方网站：http://www.dedecms.com
	有什么问题和建议欢迎与root#80sec.com联系：）
]]></description>
			<content:encoded><![CDATA[<p>	DeDecms是国内采用比较广泛的一款cms软件，在之前的版本中，陆续被披漏存在SQL注射等安全问题，而SQL注射也是其安全问题的主要所在。为了解决SQL注射的问题，DedeCms在其发布的最新版和补丁中包括了80sec的Mysqlids，以用来抵御和检测Sql注射漏洞。<br />
	Mysqlids作为一个ids存在于php应用程序和数据库操作之间，完全以Mysql的语法来分析执行的SQL语句，而不是采用传统的关键字检测的方法，经过合适的部署，基本不存在误报问题。对于一些非正常的SQL语句能进行阻止并且记录相关的信息，这样就可以很快地定位程序中存在注射漏洞的地方，为漏洞的及时修复提供必要的信息。Mysqlids的检测工作使用php实现，相对于SQL语句来说消耗的时间非常小，合理地部署Mysqlids可以极大地提高程序的安全性。</p>
<p>	DeDecms官方网站：http://www.dedecms.com</p>
<p>	有什么问题和建议欢迎与root#80sec.com联系：）</p>
]]></content:encoded>
			<wfw:commentRss>http://www.80sec.com/dedecms-with-mysqlids8.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Html富文本过滤</title>
		<link>http://www.80sec.com/richtext-xssfilter.html</link>
		<comments>http://www.80sec.com/richtext-xssfilter.html#comments</comments>
		<pubDate>Thu, 28 Aug 2008 05:06:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[web安全架构]]></category>
		<category><![CDATA[web应用程序安全]]></category>
		<category><![CDATA[未分类]]></category>

		<guid isPermaLink="false">http://www.80sec.com/?p=34</guid>
		<description><![CDATA[程序背景：80sec注意到很多web应用程序在一些场合需要允许一些Html标签，和一些标签里的一些属性，如一些日志发表的地方，书写文章的地方，但是由于程序员对安全的不太了解，或者在自己进行的安全过滤时考虑不周，都容易带来跨站脚本攻击，在一些web2.0站点甚至引发Xss Worm。常规的一些检测措施包括黑名单，白名单等等，但是都因为过滤得并不全面，很容易被绕过。其实有另外一种过滤相对严格的方法，就是基于Html语法分析的filter，在满足应用的同时可以最大限度保证程序的安全，一些过滤比较严谨的如Yahoo Mail，Gmail等等就是基于该原理进行的过滤。SafeHtml就是其中一款使用Php的开源过滤器。官方站点在：http://pixel-apes.com/safehtml。

原理介绍：这种filter通过对输入的文档进行html解析，去掉不合法的标签和字符，如去掉html标签里的\0，得到一个标准的文档Dom，通过对该Dom的遍历，结合自己的策略就可以抛弃如script，link，style,Xml这种危险的标签，然后再针对标签的属性进行过滤，抛弃如On*这种属性，然后加入对src这种属性的检测，只允许特定的协议，对style属性进行检测，抛弃非法的style属性，最后补齐需要闭合的html标签，实现对整个文档的过滤。
程序优点：可以对整个文档进行非常安全的过滤，完全开源，也可以根据自己的需要进行适当的调整，来实现自己的安全需求。
程序缺点：非常严格的限制了一些标签的使用，对于整个程序的白名单和黑名单可能需要根据自己的需要进行调整，而一些调整可能带来安全问题，而且在过滤的时候并没有完全考虑字符集的因素，可能在GBK，Gb2312等字符集下绕过。
程序下载：80sec提供配置好的样例程序包（包括HTMLSax3类），Planet Chinese Security Community即使用该过滤包。
程序演示：程序测试，如果你有发现程序的问题，也请与root#80sec.com联系：）
]]></description>
			<content:encoded><![CDATA[<p>程序背景：80sec注意到很多web应用程序在一些场合需要允许一些Html标签，和一些标签里的一些属性，如一些日志发表的地方，书写文章的地方，但是由于程序员对安全的不太了解，或者在自己进行的安全过滤时考虑不周，都容易带来跨站脚本攻击，在一些web2.0站点甚至引发Xss Worm。常规的一些检测措施包括黑名单，白名单等等，但是都因为过滤得并不全面，很容易被绕过。其实有另外一种过滤相对严格的方法，就是基于Html语法分析的filter，在满足应用的同时可以最大限度保证程序的安全，一些过滤比较严谨的如Yahoo Mail，Gmail等等就是基于该原理进行的过滤。SafeHtml就是其中一款使用Php的开源过滤器。官方站点在：http://pixel-apes.com/safehtml。</p>
<p><span id="more-34"></span><br />
原理介绍：这种filter通过对输入的文档进行html解析，去掉不合法的标签和字符，如去掉html标签里的\0，得到一个标准的文档Dom，通过对该Dom的遍历，结合自己的策略就可以抛弃如script，link，style,Xml这种危险的标签，然后再针对标签的属性进行过滤，抛弃如On*这种属性，然后加入对src这种属性的检测，只允许特定的协议，对style属性进行检测，抛弃非法的style属性，最后补齐需要闭合的html标签，实现对整个文档的过滤。</p>
<p>程序优点：可以对整个文档进行非常安全的过滤，完全开源，也可以根据自己的需要进行适当的调整，来实现自己的安全需求。</p>
<p>程序缺点：非常严格的限制了一些标签的使用，对于整个程序的白名单和黑名单可能需要根据自己的需要进行调整，而一些调整可能带来安全问题，而且在过滤的时候并没有完全考虑字符集的因素，可能在GBK，Gb2312等字符集下绕过。</p>
<p>程序下载：80sec提供配置好的<a href="http://www.80sec.com/release/html.rar">样例程序包</a>（包括HTMLSax3类），<A href="http://planet.ph4nt0m.org/">Planet Chinese Security Community</a>即使用该过滤包。</p>
<p>程序演示：<A href="http://www.80sec.com/codz/HTML_Safe_example.php">程序测试</a>，如果你有发现程序的问题，也请与root#80sec.com联系：）</p>
]]></content:encoded>
			<wfw:commentRss>http://www.80sec.com/richtext-xssfilter.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MYSQL Injection IDS [ver.1.0][Updated]</title>
		<link>http://www.80sec.com/mysql-injection-ids-ver10.html</link>
		<comments>http://www.80sec.com/mysql-injection-ids-ver10.html#comments</comments>
		<pubDate>Mon, 14 Jul 2008 02:12:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[web安全架构]]></category>
		<category><![CDATA[web应用程序安全]]></category>

		<guid isPermaLink="false">http://www.80sec.com/?p=26</guid>
		<description><![CDATA[/*
MYSQL Injection IDS [ver.1.0]
BY 80sec	http://www.80sec.com/
函数严格限制SQL文里出现
###########################################
union查询
select子查询
不常用的注释
文件操作
benchmark等危险函数
###########################################

原始地址: http://www.80sec.com/release/Mysql-injection-ids-1.0.txt
本函数适合一些开放代码的程序(因为这些程序需要考虑到在各种版本的Mysql里运行),但是可能并不适合在你的程序里,你可以通过修改自己的程序或者做合适的配置来适应它另外对于正常的SQL语句，由于本程序使用的是操作相对来说比较快的strpos来实现的，所以效率影响不是很大：）
关于使用:
		1	本函数是在MYSQL操作层来检测非法的SQL查询,大部分情况下该查询是由入侵者引起的,您可能也需要调整自己的程序,本程序不能作为过滤函数
		2	本函数需要部署在mysql_query函数前面,作为检测即将执行的SQL语句,最好将他部署在你的MYSQL操作类的前面
		3	非法操作默认记录在根目录下，名字为站点根目录的md5值
任何建议与部署上的问题欢迎与
root#80sec.com
联系
  
*/

function check_sql($db_string){
		$clean = '';
		$error='';
		$old_pos = 0;
		$pos = -1;
		$log_file=$_SERVER['DOCUMENT_ROOT'].md5($_SERVER['DOCUMENT_ROOT']).".php";
		while (true)
		{
			$pos = strpos($db_string, '\'', $pos + 1);
			if ($pos === false)
				break;
			$clean .= substr($db_string, $old_pos, $pos - $old_pos);
			while (true)
			{
				$pos1 = strpos($db_string, '\'', $pos + 1);
				$pos2 = strpos($db_string, '\\', $pos + 1);
				if ($pos1 === false)
					break;
				elseif ($pos2 == false &#124;&#124; $pos2 > $pos1)
				{
					$pos = [...]]]></description>
			<content:encoded><![CDATA[<p>/*</p>
<p>MYSQL Injection IDS [ver.1.0]</p>
<p>BY 80sec	http://www.80sec.com/</p>
<p>函数严格限制SQL文里出现</p>
<p>###########################################<br />
union查询<br />
select子查询<br />
不常用的注释<br />
文件操作<br />
benchmark等危险函数<br />
###########################################<br />
<span id="more-26"></span></p>
<p>原始地址: <a href=http://www.80sec.com/release/Mysql-injection-ids-1.0.txt>http://www.80sec.com/release/Mysql-injection-ids-1.0.txt</a></p>
<p>本函数适合一些开放代码的程序(因为这些程序需要考虑到在各种版本的Mysql里运行),但是可能并不适合在你的程序里,你可以通过修改自己的程序或者做合适的配置来适应它另外对于正常的SQL语句，由于本程序使用的是操作相对来说比较快的strpos来实现的，所以效率影响不是很大：）</p>
<p>关于使用:<br />
		1	本函数是在MYSQL操作层来检测非法的SQL查询,大部分情况下该查询是由入侵者引起的,您可能也需要调整自己的程序,本程序不能作为过滤函数<br />
		2	本函数需要部署在mysql_query函数前面,作为检测即将执行的SQL语句,最好将他部署在你的MYSQL操作类的前面<br />
		3	非法操作默认记录在根目录下，名字为站点根目录的md5值</p>
<p>任何建议与部署上的问题欢迎与</p>
<p>root#80sec.com</p>
<p>联系</p>
<p> <img src='http://www.80sec.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>*/</p>
<p><code><br />
function check_sql($db_string){</p>
<p>		$clean = '';<br />
		$error='';<br />
		$old_pos = 0;<br />
		$pos = -1;<br />
		$log_file=$_SERVER['DOCUMENT_ROOT'].md5($_SERVER['DOCUMENT_ROOT']).".php";</p>
<p>		while (true)<br />
		{<br />
			$pos = strpos($db_string, '\'', $pos + 1);<br />
			if ($pos === false)<br />
				break;<br />
			$clean .= substr($db_string, $old_pos, $pos - $old_pos);</p>
<p>			while (true)<br />
			{<br />
				$pos1 = strpos($db_string, '\'', $pos + 1);<br />
				$pos2 = strpos($db_string, '\\', $pos + 1);<br />
				if ($pos1 === false)<br />
					break;<br />
				elseif ($pos2 == false || $pos2 > $pos1)<br />
				{<br />
					$pos = $pos1;<br />
					break;<br />
				}</p>
<p>				$pos = $pos2 + 1;<br />
			}<br />
			$clean .= '$s$';</p>
<p>			$old_pos = $pos + 1;<br />
		}</p>
<p>		$clean .= substr($db_string, $old_pos);</p>
<p>		$clean = trim(strtolower(preg_replace(array('~\s+~s' ), array(' '), $clean)));</p>
<p>		//老版本的Mysql并不支持union，常用的程序里也不使用union，但是一些黑客使用它，所以检查它<br />
		if (strpos($clean, 'union') !== false &#038;&#038; preg_match('~(^|[^a-z])union($|[^[a-z])~s', $clean) != 0){<br />
			$fail = true;<br />
			$error="union detect";<br />
		}<br />
		//发布版本的程序可能比较少包括--,#这样的注释，但是黑客经常使用它们<br />
		elseif (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, '#') !== false){<br />
			$fail = true;<br />
			$error="comment detect";<br />
		}<br />
		//这些函数不会被使用，但是黑客会用它来操作文件，down掉数据库<br />
		elseif (strpos($clean, 'sleep') !== false &#038;&#038; preg_match('~(^|[^a-z])sleep($|[^[a-z])~s', $clean) != 0){<br />
			$fail = true;<br />
			$error="slown down detect";<br />
		}<br />
		elseif (strpos($clean, 'benchmark') !== false &#038;&#038; preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0){<br />
			$fail = true;<br />
			$error="slown down detect";<br />
		}<br />
		elseif (strpos($clean, 'load_file') !== false &#038;&#038; preg_match('~(^|[^a-z])load_file($|[^[a-z])~s', $clean) != 0){<br />
			$fail = true;<br />
			$error="file fun detect";<br />
		}<br />
		elseif (strpos($clean, 'into outfile') !== false &#038;&#038; preg_match('~(^|[^a-z])into\s+outfile($|[^[a-z])~s', $clean) != 0){<br />
			$fail = true;<br />
			$error="file fun detect";<br />
		}<br />
		//老版本的MYSQL不支持子查询，我们的程序里可能也用得少，但是黑客可以使用它来查询数据库敏感信息<br />
		elseif (preg_match('~\([^)]*?select~s', $clean) != 0){<br />
			$fail = true;<br />
			$error="sub select detect";<br />
		}</p>
<p>		if (!empty($fail))<br />
		{</p>
<p>			fputs(fopen($log_file,'a+'),"&#60;?php die();?>||$db_string||$error\r\n");<br />
			die("Hacking Detect&#60;br>&#60;a href=http://www.80sec.com/>http://www.80sec.com</a>");<br />
		}</p>
<p>		else {<br />
			return $db_string;<br />
		}<br />
}</p>
<p>/*<br />
$sql="select * from news where id='".$_GET[id]."'";	//程序功能的SQL语句，有用户数据进入，可能存在SQL注射</p>
<p>check_sql($sql);		//用我们的函数检查SQL语句</p>
<p>mysql_query($sql);		//安全的数据库执行<br />
*/</p>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.80sec.com/mysql-injection-ids-ver10.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>NTFS 数据流和web安全[tips]</title>
		<link>http://www.80sec.com/ntfs-web-security.html</link>
		<comments>http://www.80sec.com/ntfs-web-security.html#comments</comments>
		<pubDate>Thu, 05 Jun 2008 10:04:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[web安全架构]]></category>

		<guid isPermaLink="false">http://www.80sec.com/?p=7</guid>
		<description><![CDATA[							&#124;=&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;=&#124;
							&#124;=&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;=[ NTFS数据流和web安全 ]=&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-=&#124;
							&#124;=&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;=&#124;
							&#124;=&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-=[ By 80sec ]=&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;=&#124;
							&#124;=&#8212;&#8212;&#8212;&#8212;&#8212;-=[ xy7@80sec.com&#038;jianxin@80sec.com ]=&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;=&#124;
							&#124;=&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;=&#124;
From:http://www.80sec.com/release/ntfs-web-security.txt
NTFS流简单介绍：
	NTFS因为它的稳定性 强大的功能 以及它所提供的安全性而成为一种更优越的文件系统,NTFS交换数据流(ADSs)是为了和Macintosh的HFS文件系统兼容而设计的，它使用资源派生(resource forks)来维持与文件相关的信息，比如说图标及其他的东西。创建ADSs的语法相对比较简单和直接，比如说创建和文件myfile.txt相关联的ADSs，只需简单的用冒号把文件名和ADSs名分开即可如：


D:\ads>echo This is an ADS > myfile.txt:hidden

	那么这种问题和脚本安全有什么关系呢？80sec的xy7提供了如下的测试代码：

/*-----------------------------------------------------------------------------------------------------------------
&#60?php
$fp = fopen ("$_GET[a].txt", "a");
fwirte($fp,'80sec.com');
?>
-------------------------------------------------------------------------------------------------------------------*/

	当提供一个80sec.php?a=x.php:的时候，在windows系统下会发现在当前目录创建了一个x.php文件，但是内容为空：）但是实际上这已经扰乱了程序的逻辑，生成php文件就是不允许的事情。那么到底怎么回事呢？用记事本执行
notepad x.php:.txt
就可以看到真实的文件路径。那么这个路径在其他文件操作函数是否可用呢？经过测试，像file_exists，include都可以使用这个路径，尽管这个路径在文件目录和dir命令下不可见，并且测试发现，在普通文件名里不允许的以及&#8221;等字符，在这个路径里是允许存在的，而这些字符就可能在文件操作时不注意而引发一些安全问题。
	另外可以看到，这种文件可以很容易在windows系统里隐藏自己的某些代码，譬如将自己的后门代码隐藏在某个php文件里，然后可以在另外一个地方include进来执行，并且这种隐藏在脚本级别是无法查看的，必须借助相应的工具才能查看。
	由于文件名的特殊性，可能可以bypass一些文件上传的安全检查，但是经过测试，我们发现并不能在apache和iis里对这种类型文件进行访问，所以即使能上传成功也许也并不能直接访问作为代码直接执行：）但是不排除一些windows下的其他http server能正确处理好这种文件名，而不发生问题，这种问题应该是windows的问题，所以在像其他脚本如asp里也应该是一样存在的。
]]></description>
			<content:encoded><![CDATA[<p>							|=&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;=|<br />
							|=&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;=[ NTFS数据流和web安全 ]=&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-=|<br />
							|=&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;=|<br />
							|=&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-=[ By 80sec ]=&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;=|<br />
							|=&#8212;&#8212;&#8212;&#8212;&#8212;-=[ xy7@80sec.com&#038;jianxin@80sec.com ]=&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;=|<br />
							|=&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;=|</p>
<p>From:http://www.80sec.com/release/ntfs-web-security.txt</p>
<p>NTFS流简单介绍：</p>
<p>	NTFS因为它的稳定性 强大的功能 以及它所提供的安全性而成为一种更优越的文件系统,NTFS交换数据流(ADSs)是为了和Macintosh的HFS文件系统兼容而设计的，它使用资源派生(resource forks)来维持与文件相关的信息，比如说图标及其他的东西。创建ADSs的语法相对比较简单和直接，比如说创建和文件myfile.txt相关联的ADSs，只需简单的用冒号把文件名和ADSs名分开即可如：<br />
<span id="more-7"></span></p>
<p><code><br />
D:\ads>echo This is an ADS > myfile.txt:hidden<br />
</code><br />
	那么这种问题和脚本安全有什么关系呢？80sec的xy7提供了如下的测试代码：<br />
<code><br />
/*-----------------------------------------------------------------------------------------------------------------<br />
&#60?php<br />
$fp = fopen ("$_GET[a].txt", "a");<br />
fwirte($fp,'80sec.com');<br />
?><br />
-------------------------------------------------------------------------------------------------------------------*/<br />
</code><br />
	当提供一个80sec.php?a=x.php:的时候，在windows系统下会发现在当前目录创建了一个x.php文件，但是内容为空：）但是实际上这已经扰乱了程序的逻辑，生成php文件就是不允许的事情。那么到底怎么回事呢？用记事本执行<br />
notepad x.php:.txt<br />
就可以看到真实的文件路径。那么这个路径在其他文件操作函数是否可用呢？经过测试，像file_exists，include都可以使用这个路径，尽管这个路径在文件目录和dir命令下不可见，并且测试发现，在普通文件名里不允许的<>以及&#8221;等字符，在这个路径里是允许存在的，而这些字符就可能在文件操作时不注意而引发一些安全问题。</p>
<p>	另外可以看到，这种文件可以很容易在windows系统里隐藏自己的某些代码，譬如将自己的后门代码隐藏在某个php文件里，然后可以在另外一个地方include进来执行，并且这种隐藏在脚本级别是无法查看的，必须借助相应的工具才能查看。</p>
<p>	由于文件名的特殊性，可能可以bypass一些文件上传的安全检查，但是经过测试，我们发现并不能在apache和iis里对这种类型文件进行访问，所以即使能上传成功也许也并不能直接访问作为代码直接执行：）但是不排除一些windows下的其他http server能正确处理好这种文件名，而不发生问题，这种问题应该是windows的问题，所以在像其他脚本如asp里也应该是一样存在的。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.80sec.com/ntfs-web-security.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
