<?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://zhoumo123.cn/category/wangluoanquan/feed" rel="self" type="application/rss+xml" />
	<link>http://zhoumo123.cn</link>
	<description>知识分享，共同进步。zhoumo123.cn</description>
	<lastBuildDate>Thu, 07 Nov 2019 05:53:49 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.0.1</generator>
	<item>
		<title>采用参数化查询SQL语句避免SQL注入</title>
		<link>http://zhoumo123.cn/wangluoanquan/3532.html</link>
		<comments>http://zhoumo123.cn/wangluoanquan/3532.html#comments</comments>
		<pubDate>Thu, 28 Jan 2016 06:44:37 +0000</pubDate>
		<dc:creator><![CDATA[zhangc]]></dc:creator>
				<category><![CDATA[网络安全]]></category>
		<category><![CDATA[参数化SQL查询]]></category>

		<guid isPermaLink="false">http://zhoumo123.cn/?p=3532</guid>
		<description><![CDATA[SQL参数化查询可以防止SQL注入，避免SQL注入的方法有两种： 第一种方案： 所有的SQL语句都存放在存储过程中，这样不但可以避免SQL注入，还能提高一些性能，并且存储过程可以由专门的数据库管理员(DBA)编写和集中管理，不过这种做法有时候针对相同的几个表有不同条件的查询，SQL语句可能不同，这样就会编写大量的存储过程， 第二种方案： 参数化SQL语句。例如我们在本篇中创建的表UserInfo中查找所有女性用户，那么通常情况下我们的SQL语句可能是这样： select * from UserInfo where sex=0 在参数化SQL语句中我们将数值以参数化的形式提供，对于上面的查询，我 ...  <a href="http://zhoumo123.cn/wangluoanquan/3532.html">  阅读全文 </a>]]></description>
				<content:encoded><![CDATA[<p>SQL参数化查询可以防止SQL注入，避免SQL注入的方法有两种：</p>
<p><strong>第一种方案：</strong></p>
<p>所有的SQL语句都存放在存储过程中，这样不但可以避免SQL注入，还能提高一些性能，并且存储过程可以由专门的数据库管理员(DBA)编写和集中管理，不过这种做法有时候针对相同的几个表有不同条件的查询，SQL语句可能不同，这样就会编写大量的存储过程，</p>
<p><strong>第二种方案：</strong></p>
<p>参数化SQL语句。例如我们在本篇中创建的表UserInfo中查找所有女性用户，那么通常情况下我们的SQL语句可能是这样：</p>
<p><span style="color: #0000ff;">select * from UserInfo where sex=0</span></p>
<p>在参数化SQL语句中我们将数值以参数化的形式提供，对于上面的查询，我们用参数化SQL语句表示为：</p>
<p><span style="color: #0000ff;">select * from UserInfo where sex=@sex</span></p>
<p>再对代码中对这个SQL语句中的参数进行赋值，假如我们要查找UserInfo表中所有年龄大于30岁的男性用户，这个参数化SQL语句可以这么写：</p>
<p><span style="color: #0000ff;">select * from UserInfo where sex=@sex and age&gt;@age</span></p>
<p>下面是执行这个查询并且将查询结果集以DataTable的方式返回的代码：</p>
<pre class="brush: php; title: ; notranslate">
//实例化Connection对象
SqlConnection connection = new SqlConnection(&quot;server=localhost;database=pubs;uid=sa;pwd=''&quot;);
//实例化Command对象
SqlCommand command = new SqlCommand(&quot;select * from UserInfo where sex=@sex and age&amp;gt;@age&quot;, connection);
//第一种添加查询参数的例子
command.Parameters.AddWithValue(&quot;@sex&quot;, true);
//第二种添加查询参数的例子
SqlParameter parameter = new SqlParameter(&quot;@age&quot;, SqlDbType.Int);//注意UserInfo表里age字段是int类型的
parameter.Value = 30;
command.Parameters.Add(parameter);//添加参数
//实例化DataAdapter
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataTable data = new DataTable();

</pre>
<p>上面的代码是访问SQL Server数据库的代码。如果本文中提到的数据分别在Access、MySQL、Oracle数据库，那么对应的参数化SQL语句及参数分别如下：</p>
<table cellpadding="1" border="1" cellspacing="1" width="98%">
<tbody>
<tr>
<td width="8%">数据库</td>
<td width="29%">Access</td>
<td width="32%">MySQL</td>
<td width="31%">Oracle</td>
</tr>
<tr>
<td> SQL语句</td>
<td>select * from UserInfo <br />
        where sex=? and age&gt;?</td>
<td>select * from UserInfo <br />
        where sex=?sex and age&gt;?age</td>
<td>select * from UserInfo <br />
        where sex=:sex and age&gt;:age</td>
</tr>
<tr>
<td>参数</td>
<td>OleDbParameter</td>
<td>MySqlParameter</td>
<td>OracleParameter</td>
</tr>
<tr>
<td>实例化参数</td>
<td>OleDbParameter p=new OleDbParameter(&ldquo;?&rdquo;, OleDbType. Boolean);</td>
<td>MySqlParameter p=new MySqlParameter(&ldquo;?sex&rdquo;, MySqlDbType.Bit);</td>
<td>OracleParameter p=new OracleParameter(&ldquo;:sex&rdquo;, OracleType.Byte);</td>
</tr>
<tr>
<td>赋值</td>
<td>p.Value=true;</td>
<td>p.Value=1;</td>
<td>p.Value=1;</td>
</tr>
</tbody>
</table>
<p>http://www.cnblogs.com/aito/archive/2010/08/25/1808569.html</p>
]]></content:encoded>
			<wfw:commentRss>http://zhoumo123.cn/wangluoanquan/3532.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>检测出SSLv3存在严重设计缺陷漏洞(CVE-2014-3566)的修复办法</title>
		<link>http://zhoumo123.cn/wangluoanquan/3529.html</link>
		<comments>http://zhoumo123.cn/wangluoanquan/3529.html#comments</comments>
		<pubDate>Wed, 27 Jan 2016 09:54:16 +0000</pubDate>
		<dc:creator><![CDATA[zhangc]]></dc:creator>
				<category><![CDATA[网络安全]]></category>
		<category><![CDATA[SSLv3]]></category>
		<category><![CDATA[安全漏洞]]></category>

		<guid isPermaLink="false">http://zhoumo123.cn/?p=3529</guid>
		<description><![CDATA[最新的安全漏洞 (CVE­-2014-3566) 代号是 POODLE, 这是一个缩写；这个漏洞和之前的 B.E.A.S.T (Browser Exploit Against SSL TLS) 非常相似，但是目前还没有可靠的解决办法，除非完全禁用 SSLv3 的支持。简单的说，攻击者可获取你加密流中的明文数据。 还是让我们来看看如何处理吧，Mozilla Security Wiki Serverside TLS 之前建议使用严格的协议和加密方法限制，值得我们注意。 Apache 在Apache 的 SSL 配置中禁用 SSLv3 和 SSLv3： Nginx 在 Nginx 只允许使用 TLS ...  <a href="http://zhoumo123.cn/wangluoanquan/3529.html">  阅读全文 </a>]]></description>
				<content:encoded><![CDATA[<p>最新的安全漏洞 (CVE­-2014-3566) 代号是 POODLE, 这是一个缩写；这个漏洞和之前的 B.E.A.S.T (Browser Exploit Against SSL TLS) 非常相似，但是目前还没有可靠的解决办法，除非完全禁用 SSLv3 的支持。简单的说，攻击者可获取你加密流中的明文数据。</p>
<p>还是让我们来看看如何处理吧，Mozilla Security Wiki Serverside TLS 之前建议使用严格的协议和加密方法限制，值得我们注意。</p>
<p><strong>Apache</strong></p>
<p>在Apache 的 SSL 配置中禁用 SSLv3 和 SSLv3：</p>
<pre class="brush: php; title: ; notranslate">
SSLProtocol all -SSLv2 -SSLv3
</pre>
<p><strong>Nginx</strong></p>
<p>在 Nginx 只允许使用 TLS 协议：</p>
<pre class="brush: php; title: ; notranslate">
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
</pre>
<p><strong>MySQL</strong></p>
<p>值得注意的是，除非你在 MySQL 5.6 中部署 sha256_password 插件，plugin for MySQL 5.6 就会在验证握手之前必须完成SSL/TLS连接协商，因此这种攻击向量只成为一个问题 —— 有效的登录访问的数据流。（ sha256_password 提供一个选项使用 SSL/TLS 的认证）</p>
<p>这使得事情变得更加有趣，和 Apache 和 Nginx 不同的是，没有方法来完全启用和禁用 SSL/TLS 协议，但可以 指定 SSL 通讯的加密规范.</p>
<p>要在 MySQL 删除 SSLv3 的支持，你只需要确定在配置中不使用 SSLv3 加密。</p>
<p>在这个 bug 中你可以找到 SSLv3 加密方法列表：</p>
<pre class="brush: php; title: ; notranslate">

openssl ciphers -v 'DEFAULT' | awk '/SSLv3 Kx=(RSA|DH|DH(512))/ { print $1 }'
DHE-RSA-AES256-SHA
DHE-DSS-AES256-SHA
DHE-RSA-CAMELLIA256-SHA
DHE-DSS-CAMELLIA256-SHA
AES256-SHA
CAMELLIA256-SHA
EDH-RSA-DES-CBC3-SHA
EDH-DSS-DES-CBC3-SHA
DES-CBC3-SHA
DHE-RSA-AES128-SHA
DHE-DSS-AES128-SHA
DHE-RSA-SEED-SHA
DHE-DSS-SEED-SHA
DHE-RSA-CAMELLIA128-SHA
DHE-DSS-CAMELLIA128-SHA
AES128-SHA
SEED-SHA
CAMELLIA128-SHA
RC4-SHA
RC4-MD5
EDH-RSA-DES-CBC-SHA
EDH-DSS-DES-CBC-SHA
DES-CBC-SHA
EXP-EDH-RSA-DES-CBC-SHA
EXP-EDH-DSS-DES-CBC-SHA
EXP-DES-CBC-SHA
EXP-RC2-CBC-MD5
EXP-RC4-MD5

</pre>
<p>删除 ssl-cipher 配置中的上述信息就可以禁用 SSLv3 支持。当然，确保 MySQL 服务不提供一般访问是迄今为止对抗 CVE-2014-3566 漏洞最重要的一个步骤。</p>
<p>你可以了解更多关于 POODLE 的资讯。</p>
<p>以下脚本可以识别你的服务是否提供没有密码的 SSLv3 支持：</p>
<pre class="brush: php; title: ; notranslate">

mysql -se “SHOW STATUS LIKE ‘Ssl_cipher_list'” | sed ‘s/:/n/g’ | sed ‘s/Ssl_cipher_listss//g’ |
while read sspec;
do SPEC=openssl ciphers -v “$sspec” 2&gt;/dev/null | grep -v SSLv3 | awk ‘{print $1}';
[[ &quot;$sspec&quot; == &quot;$SPEC&quot; ]] &amp;&amp; mysql –ssl-cipher=$sspec -e QUIT 2&gt;/dev/null &amp;&amp; echo “$sspec OK”;
done

</pre>
<p>http://www.oschina.net/question/12_175450</p>
]]></content:encoded>
			<wfw:commentRss>http://zhoumo123.cn/wangluoanquan/3529.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
