<?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>无风的港湾 &#187; 防注入</title>
	<atom:link href="http://www.5bay.cn/tag/%E9%98%B2%E6%B3%A8%E5%85%A5/feed" rel="self" type="application/rss+xml" />
	<link>http://www.5bay.cn</link>
	<description>让你我停泊~</description>
	<lastBuildDate>Fri, 16 Dec 2011 09:18:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>ASP防注入新方式，希望对大家是有用的</title>
		<link>http://www.5bay.cn/server-building/aspeaojie.html</link>
		<comments>http://www.5bay.cn/server-building/aspeaojie.html#comments</comments>
		<pubDate>Wed, 28 Jul 2010 02:00:27 +0000</pubDate>
		<dc:creator>江小邪</dc:creator>
				<category><![CDATA[服务器构建&安全]]></category>
		<category><![CDATA[ASP]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[url]]></category>
		<category><![CDATA[人]]></category>
		<category><![CDATA[代码]]></category>
		<category><![CDATA[工具]]></category>
		<category><![CDATA[数据]]></category>
		<category><![CDATA[数据库]]></category>
		<category><![CDATA[方法]]></category>
		<category><![CDATA[程序]]></category>
		<category><![CDATA[类]]></category>
		<category><![CDATA[网站]]></category>
		<category><![CDATA[诫]]></category>
		<category><![CDATA[连接]]></category>
		<category><![CDATA[防注入]]></category>

		<guid isPermaLink="false">http://www.5bay.cn/?p=527</guid>
		<description><![CDATA[<a href="http://www.5bay.cn/server-building/aspeaojie.html"><img align="left" hspace="5" width="150" height="150" src="http://www.5bay.cn/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>最近我的网站经常把js脚本注入到数据，清除了又来。先后在网上找了很多的方法，还是没有用的，十分恼火。 首先先告诉大家一个批量清除代码的sql语句。 update 表名 set 字段=replace(字段,&#8217;script src=http://3b3.org/c.js&#62; 1、分析那些无聊的人，或者有些病态的人究竟做了些什么 。 通过iis的日志或者microsoft urlscan 日志查看，在一些通过id查询数据库内容的时候后面被人加了一段很长的字符窜。 %%3B%%44%%65%%43%%4C%%61%%52%%45%%类似这样的字符窜，一定是其他的方式编码 首先我们先用工具分析下如此之长的字符窜究竟包含了些什么内容。 通过批量替换工具把%%全部替换成空，然后把得到的字符串通过其他的转码工具，转成字符窜。 ;DeCLaRE @S NvArCHaR(4000);SeT @S=CaSt(0&#215;45这里代码去掉了06F007200 aS NvArChAR(4000));ExEc(@S);&#8211; 就是一段与通过id查询数据库同时执行的sql，就给数据库某些表的字段加入了js病毒连接。 2、所以我们的原来的防sql注入的字符串就需要升级了。 如果过滤16进制 ; 对应 3B DeCLaRE 对应 4465434C615245 @ 对应 40 NvArCHaR 对应 4E76417243486152 set 对应 536554 CaSt 对应 43615374 as 对应 6153 exec 对应 45784563 - 对应 2D 把16进制的代码用&#124;隔开放到injdata 里面 injdata = [...]]]></description>
			<content:encoded><![CDATA[<p>最近我的网站经常把js脚本注入到数据，清除了又来。先后在网上找了很多的方法，还是没有用的，十分恼火。</p>
<p>首先先告诉大家一个批量清除代码的sql语句。</p>
<p>update 表名 set 字段=replace(字段,&#8217;script src=http://3b3.org/c.<a href="http://www.5bay.cn/tag/js" class="st_tag internal_tag" rel="tag" title="标签 js 下的日志">js</a>&gt;<br />
1、分析那些无聊的人，或者有些病态的人究竟做了些什么 。</p>
<p>通过iis的日志或者microsoft urlscan 日志查看，在一些通过id查询数据库内容的时候后面被人加了一段很长的字符窜。</p>
<p>%%3B%%44%%65%%43%%4C%%61%%52%%45%%类似这样的字符窜，一定是其他的方式编码</p>
<p>首先我们先用工具分析下如此之长的字符窜究竟包含了些什么内容。</p>
<p>通过批量替换工具把%%全部替换成空，然后把得到的字符串通过其他的转码工具，转成字符窜。</p>
<p>;DeCLaRE @S NvArCHaR(4000);SeT @S=CaSt(0&#215;45这里代码去掉了06F007200 aS NvArChAR(4000));ExEc(@S);&#8211;</p>
<p>就是一段与通过id查询数据库同时执行的sql，就给数据库某些表的字段加入了js病毒连接。</p>
<p>2、所以我们的原来的防sql注入的字符串就需要升级了。</p>
<p>如果过滤16进制</p>
<p>; 对应 3B</p>
<p>DeCLaRE 对应 4465434C615245</p>
<p>@ 对应 40</p>
<p>NvArCHaR 对应 4E76417243486152</p>
<p>set 对应 536554</p>
<p>CaSt 对应 43615374</p>
<p>as 对应 6153</p>
<p>exec 对应 45784563</p>
<p>- 对应 2D</p>
<p>把16进制的代码用|隔开放到injdata 里面</p>
<p>injdata = “3B|2D|&#8217;|;|and|exec|insert|select|delete%20from|update|count|”</p>
<p>然后自己测试下，程序是否拦击了这些16进制的代码，本人测试过是可以拦击的，如果不加入这些是不拦击的</p>
<p>照样可以注入到数据库。</p>
<h2  class="related_post_title">相关博文</h2><ul class="related_post"><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eesoneeajaxeehuai.html" title="基于JSON的高级AJAX开发技术">基于JSON的高级AJAX开发技术</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eeeeeeee.html" title="最令PHP初学者头痛的十四个问题">最令PHP初学者头痛的十四个问题</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeefangeredoc.html" title="php的文档句法(heredoc)<<<和PHP字符串操作">php的文档句法(heredoc)<<<和PHP字符串操作</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/eejaxeeeeee.html" title="使用Ajax时的十个常犯的错误">使用Ajax时的十个常犯的错误</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeezhanchang.html" title="PHP安全之数据过滤">PHP安全之数据过滤</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/rsyncxiangjie.html" title="Rsync详解">Rsync详解</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/network-programming/phpfengzhuangchangyongjavascriptweijsleiyibiankuaisudiaoyong.html" title="PHP封装常用Javascript为JS类以便快速调用">PHP封装常用Javascript为JS类以便快速调用</a> (1)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/mysqlyouhuajiquanwensousuo.html" title="mysql优化及全文搜索">mysql优化及全文搜索</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeeeeeeeehuai.html" title="PHP对文本数据库的基本操作方法">PHP对文本数据库的基本操作方法</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxeeee.html" title="Ajax的工作原理">Ajax的工作原理</a> (1)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajax.html" title="AJAX的各种控件和类库">AJAX的各种控件和类库</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/xmlhttpe.html" title="XMLHTTP对象封装技术">XMLHTTP对象封装技术</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/ajaxxuan.html" title="ajax的缺点">ajax的缺点</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/eacceleratoryumemcachedequbieyuyongtu.html" title="eAccelerator与memcache的区别与用途">eAccelerator与memcache的区别与用途</a> (2)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeecketee.html" title="PHP和Socket简介">PHP和Socket简介</a> (0)</li></ul>
	标签Tags：<a href="http://www.5bay.cn/tag/asp" title="ASP" rel="tag">ASP</a>, <a href="http://www.5bay.cn/tag/js" title="js" rel="tag">js</a>, <a href="http://www.5bay.cn/tag/sql" title="sql" rel="tag">sql</a>, <a href="http://www.5bay.cn/tag/url" title="url" rel="tag">url</a>, <a href="http://www.5bay.cn/tag/%E4%BA%BA" title="人" rel="tag">人</a>, <a href="http://www.5bay.cn/tag/%E4%BB%A3%E7%A0%81" title="代码" rel="tag">代码</a>, <a href="http://www.5bay.cn/tag/%E5%B7%A5%E5%85%B7" title="工具" rel="tag">工具</a>, <a href="http://www.5bay.cn/tag/%E6%95%B0%E6%8D%AE" title="数据" rel="tag">数据</a>, <a href="http://www.5bay.cn/tag/%E6%95%B0%E6%8D%AE%E5%BA%93" title="数据库" rel="tag">数据库</a>, <a href="http://www.5bay.cn/tag/%E6%96%B9%E6%B3%95" title="方法" rel="tag">方法</a>, <a href="http://www.5bay.cn/category/server-building" title="服务器构建&amp;安全" rel="tag">服务器构建&amp;安全</a>, <a href="http://www.5bay.cn/tag/%E7%A8%8B%E5%BA%8F" title="程序" rel="tag">程序</a>, <a href="http://www.5bay.cn/tag/%E7%B1%BB" title="类" rel="tag">类</a>, <a href="http://www.5bay.cn/tag/%E7%BD%91%E7%AB%99" title="网站" rel="tag">网站</a>, <a href="http://www.5bay.cn/tag/e" title="诫" rel="tag">诫</a>, <a href="http://www.5bay.cn/tag/%E8%BF%9E%E6%8E%A5" title="连接" rel="tag">连接</a>, <a href="http://www.5bay.cn/tag/%E9%98%B2%E6%B3%A8%E5%85%A5" title="防注入" rel="tag">防注入</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.5bay.cn/server-building/aspeaojie.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP一些防注入函数</title>
		<link>http://www.5bay.cn/network-programming/php/php%E4%B8%80%E4%BA%9B%E9%98%B2%E6%B3%A8%E5%85%A5%E5%87%BD%E6%95%B0.html</link>
		<comments>http://www.5bay.cn/network-programming/php/php%E4%B8%80%E4%BA%9B%E9%98%B2%E6%B3%A8%E5%85%A5%E5%87%BD%E6%95%B0.html#comments</comments>
		<pubDate>Sun, 07 Jan 2007 04:55:22 +0000</pubDate>
		<dc:creator>江小邪</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[函数]]></category>
		<category><![CDATA[防注入]]></category>

		<guid isPermaLink="false">?p=188</guid>
		<description><![CDATA[<a href="http://www.5bay.cn/network-programming/php/php%E4%B8%80%E4%BA%9B%E9%98%B2%E6%B3%A8%E5%85%A5%E5%87%BD%E6%95%B0.html"><img align="left" hspace="5" width="150" height="150" src="http://www.5bay.cn/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>[codes=php]&#60;?php &#160; /* &#160;函数名称：inject_check() &#160;函数作用：检测提交的值是不是含有SQL注射的字符，防止注射，保护服务器安全 &#160;参　　数：$sql_str: 提交的变量 &#160;返 回 值：返回检测结果，ture or false &#160;*/ &#160;function inject_check($sql_str) { &#160; &#160;return eregi(&#039;select&#124;insert&#124;update&#124;delete&#124;&#92;&#039;&#124;&#92;/&#92;*&#124;&#92;*&#124;&#92;.&#92;.&#92;/&#124;&#92;.&#92;/&#124;union&#124;into&#124;load_file&#124;outfile&#039;, $sql_str); &#160; &#160;// 进行过滤 &#160; } &#160; &#160;/* &#160;函数名称：verify_id() &#160;函数作用：校验提交的ID类值是否合法 &#160;参　　数：$id: 提交的ID值 &#160;返 回 值：返回处理后的ID &#160;*/ &#160;function verify_id($id=null) { &#160; &#160;if (!$id) { exit(&#039;没有提交参数！&#039;); } &#160; &#160;// 是否为空判断 &#160; &#160;elseif (inject_check($id)) { exit(&#039;提交的参数非法！&#039;); } &#160; &#160;// [...]]]></description>
			<content:encoded><![CDATA[<p><span id="more-188"></span><br/><br/>[codes=<a href="http://www.5bay.cn/tag/php" class="st_tag internal_tag" rel="tag" title="标签 PHP 下的日志">php</a>]<br/>&lt;?php &nbsp; <br/> <br/>/* &nbsp;<br/>函数名称：inject_check() &nbsp;<br/>函数作用：检测提交的值是不是含有SQL注射的字符，防止注射，保护服务器安全 &nbsp;<br/>参　　数：$<a href="http://www.5bay.cn/tag/sql" class="st_tag internal_tag" rel="tag" title="标签 sql 下的日志">sql</a>_str: 提交的变量 &nbsp;<br/>返 回 值：返回检测结果，ture or false &nbsp;<br/>*/ &nbsp;<br/>function inject_check($sql_str) { &nbsp; <br/> &nbsp;return eregi(&#039;select&#124;insert&#124;update&#124;delete&#124;&#92;&#039;&#124;&#92;/&#92;*&#124;&#92;*&#124;&#92;.&#92;.&#92;/&#124;&#92;.&#92;/&#124;union&#124;into&#124;load_file&#124;outfile&#039;, $sql_str); &nbsp; &nbsp;// 进行过滤 &nbsp; <br/>} &nbsp; <br/> &nbsp;<br/>/* &nbsp;<br/>函数名称：verify_id() &nbsp;<br/>函数作用：校验提交的ID类值是否合法 &nbsp;<br/>参　　数：$id: 提交的ID值 &nbsp;<br/>返 回 值：返回处理后的ID &nbsp;<br/>*/ &nbsp;<br/>function verify_id($id=null) { &nbsp; <br/> &nbsp;if (!$id) { exit(&#039;没有提交参数！&#039;); } &nbsp; &nbsp;// 是否为空判断 &nbsp; <br/> &nbsp;elseif (inject_check($id)) { exit(&#039;提交的参数非法！&#039;); } &nbsp; &nbsp;// 注射判断 &nbsp; <br/> &nbsp;elseif (!is_numeric($id)) { exit(&#039;提交的参数非法！&#039;); } &nbsp; &nbsp;// 数字判断 &nbsp; <br/> &nbsp;$id = intval($id); &nbsp; &nbsp;// 整型化 &nbsp; <br/> &nbsp;<br/> &nbsp;return &nbsp;$id; &nbsp; <br/>} &nbsp; <br/> &nbsp;<br/>/* &nbsp;<br/>函数名称：str_check() &nbsp;<br/>函数作用：对提交的字符串进行过滤 &nbsp;<br/>参　　数：$var: 要处理的字符串 &nbsp;<br/>返 回 值：返回过滤后的字符串 &nbsp;<br/>*/ &nbsp;<br/>function str_check( $str ) { &nbsp; <br/> &nbsp;if (!get_magic_quotes_gpc()) { &nbsp; &nbsp;// 判断magic_quotes_gpc是否打开 &nbsp; <br/> &nbsp; &nbsp;$str = addslashes($str); &nbsp; &nbsp;// 进行过滤 &nbsp; <br/> &nbsp;} &nbsp; <br/> &nbsp;$str = str_replace(&quot;_&quot;, &quot;&#92;_&quot;, $str); &nbsp; &nbsp;// 把 &#039;_&#039;过滤掉 &nbsp; <br/> &nbsp;$str = str_replace(&quot;%&quot;, &quot;&#92;%&quot;, $str); &nbsp; &nbsp;// 把 &#039;%&#039;过滤掉 &nbsp; <br/> &nbsp;<br/> &nbsp;return $str; &nbsp; &nbsp;<br/>} &nbsp; <br/> &nbsp;<br/>/* &nbsp;<br/>函数名称：post_check() &nbsp;<br/>函数作用：对提交的编辑内容进行处理 &nbsp;<br/>参　　数：$post: 要提交的内容 &nbsp;<br/>返 回 值：$post: 返回过滤后的内容 &nbsp;<br/>*/ &nbsp;<br/>function post_check($post) { &nbsp; <br/> &nbsp;if (!get_magic_quotes_gpc()) { &nbsp; &nbsp;// 判断magic_quotes_gpc是否为打开 &nbsp; <br/> &nbsp; &nbsp;$post = addslashes($post); &nbsp; &nbsp;// 进行magic_quotes_gpc没有打开的情况对提交数据的过滤 &nbsp; <br/> &nbsp;} &nbsp; <br/> &nbsp;$post = str_replace(&quot;_&quot;, &quot;&#92;_&quot;, $post); &nbsp; &nbsp;// 把 &#039;_&#039;过滤掉 &nbsp; <br/> &nbsp;$post = str_replace(&quot;%&quot;, &quot;&#92;%&quot;, $post); &nbsp; &nbsp;// 把 &#039;%&#039;过滤掉 &nbsp; <br/> &nbsp;$post = nl2br($post); &nbsp; &nbsp;// 回车转换 &nbsp; <br/> &nbsp;$post = htmlspecialchars($post); &nbsp; &nbsp;// html标记转换 &nbsp; <br/> &nbsp;<br/> &nbsp;return $post; &nbsp; <br/>} &nbsp; <br/>?&gt;<br/> [/codes]</p>
<h2  class="related_post_title">相关博文</h2><ul class="related_post"><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeecketee.html" title="PHP和Socket简介">PHP和Socket简介</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeefangeredoc.html" title="php的文档句法(heredoc)<<<和PHP字符串操作">php的文档句法(heredoc)<<<和PHP字符串操作</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/peeeeee.html" title="深入探讨PHP中的内存管理问题">深入探讨PHP中的内存管理问题</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/requireeecludexi.html" title="require和include的异同">require和include的异同</a> (0)</li><li>2010年07月26日 -- <a href="http://www.5bay.cn/network-programming/phpeeeeee-3.html" title="PHP生成随机字符串">PHP生成随机字符串</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/mysqlyouhuajiquanwensousuo.html" title="mysql优化及全文搜索">mysql优化及全文搜索</a> (0)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/server-building/eacceleratoryumemcachedequbieyuyongtu.html" title="eAccelerator与memcache的区别与用途">eAccelerator与memcache的区别与用途</a> (2)</li><li>2010年05月23日 -- <a href="http://www.5bay.cn/network-programming/phpzhongdememcachehanshukumemcachefunctions.html" title="PHP中的Memcache函数库（Memcache Functions）">PHP中的Memcache函数库（Memcache Functions）</a> (0)</li><li>2006年12月27日 -- <a href="http://www.5bay.cn/network-programming/php/php%E8%AF%BB%E5%8F%96%E6%9F%90%E7%AB%99%E7%82%B9%E7%9A%84%E9%93%BE%E6%8E%A5%E7%9A%84%E5%87%BD%E6%95%B0.html" title="PHP读取某站点的链接的函数">PHP读取某站点的链接的函数</a> (1)</li><li>2006年12月27日 -- <a href="http://www.5bay.cn/network-programming/php/%E4%B8%80%E4%B8%AA%E5%A5%BD%E7%94%A8%E7%9A%84%E5%88%86%E9%A1%B5%E5%87%BD%E6%95%B0.html" title="一个好用的分页函数">一个好用的分页函数</a> (0)</li><li>2006年12月27日 -- <a href="http://www.5bay.cn/network-programming/php/%E4%B8%80%E4%BA%9B%E5%B8%B8%E7%94%A8%E7%9A%84php%E5%87%BD%E6%95%B0.html" title="一些常用的php函数">一些常用的php函数</a> (0)</li><li>2006年12月27日 -- <a href="http://www.5bay.cn/network-programming/php/%E4%B8%80%E4%BA%9B%E5%B8%B8%E7%94%A8%E7%9A%84php%E5%87%BD%E6%95%B0.html" title="一些常用的php函数">一些常用的php函数</a> (0)</li><li>2011年06月29日 -- <a href="http://www.5bay.cn/me/kaiyuanruanjiandeyinglimoshi.html" title="开源软件的盈利模式">开源软件的盈利模式</a> (0)</li><li>2010年08月17日 -- <a href="http://www.5bay.cn/server-building/nginxxiansu.html" title="Nginx限速">Nginx限速</a> (0)</li><li>2010年07月28日 -- <a href="http://www.5bay.cn/server-building/aspeaojie.html" title="ASP防注入新方式，希望对大家是有用的">ASP防注入新方式，希望对大家是有用的</a> (0)</li></ul>
	标签Tags：<a href="http://www.5bay.cn/category/network-programming/php" title="PHP" rel="tag">PHP</a>, <a href="http://www.5bay.cn/tag/php" title="PHP" rel="tag">PHP</a>, <a href="http://www.5bay.cn/tag/%E5%87%BD%E6%95%B0" title="函数" rel="tag">函数</a>, <a href="http://www.5bay.cn/tag/%E9%98%B2%E6%B3%A8%E5%85%A5" title="防注入" rel="tag">防注入</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.5bay.cn/network-programming/php/php%E4%B8%80%E4%BA%9B%E9%98%B2%E6%B3%A8%E5%85%A5%E5%87%BD%E6%95%B0.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

