<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title type="text">博客园_Leven's Blog</title><subtitle type="text">只谈技术</subtitle><id>http://feed.cnblogs.com/blog/u/37850/rss</id><updated>2010-10-24T07:33:50Z</updated><author><name>Leven</name><uri>http://www.cnblogs.com/leven/</uri></author><generator>feed.cnblogs.com</generator><link rel="alternate" type="text/html" href="http://www.cnblogs.com/leven/"/><link rel="self" type="application/atom+xml" href="http://feed.cnblogs.com/blog/u/37850/rss"/><entry><id>http://www.cnblogs.com/leven/archive/2010/06/15/levenblog-cc.html</id><title type="text">levenblog一次被CC攻击的分析以及应对攻击记录</title><summary type="text">  前段时间，本站遭遇了一次CC攻击，具体攻击的原因未知，攻击持续时间大概在1天左右，攻击器使用了大量IP对本站进行了CC攻击，使得本站一度过载出现无法访问的情况，通过一番努力，在攻击开始后一段时间以后成功封堵了攻击者，本文简要记述了当日的攻击和防御过程，谨以为戒。</summary><published>2010-06-15T06:02:00Z</published><updated>2010-06-15T06:02:00Z</updated><author><name>Leven</name><uri>http://www.cnblogs.com/leven/</uri></author><link rel="alternate" href="http://www.cnblogs.com/leven/archive/2010/06/15/levenblog-cc.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/leven/archive/2010/06/15/levenblog-cc.html"/><content type="html">&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 前段时间，本站遭遇了一次CC攻击，具体攻击的原因未知，攻击持续时间大概在1天左右，攻击器使用了大量IP对本站进行了CC攻击，使得本站一度过载出现无法访问的情况，通过一番努力，在攻击开始后一段时间以后成功封堵了攻击者，本文简要记述了当日的攻击和防御过程，谨以为戒。&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 首先给出本站的基本构架，本站采用asp.net mvc 1.0开发，基于sqlite数据库系统，部署在win2008+IIS7的系统上，本次攻击是典型的CC攻击，攻击者使用大量肉鸡发起大量无效http请求，而导致程序过载。&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 攻击大概在某天上午开始了，由于本站采用的sqlite为单文件数据库，在大并发情况下负载能力较低，对于一般blog程序自然是绰绰有余，但是在大量攻击的情况下，该数据库就无法充分利用系统资源了，在服务器cpu占用率在30%左右的时候，本站开始变得极为缓慢甚至出现程序执行错误，正常访问出现问题。&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 出现问题后，我进入服务器，发现流量达到5M左右，活动http连接在200以上，在此情况下，sqlite负载下的本程序显然已经无法正常服务，于是开始考虑应对方法。&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 对付CC攻击，一般采用防火墙封锁或者负载均衡的方式处理，负载均衡显然不太现实，因此，我们考虑采用防火墙系统封堵大量非法请求IP，win2008中自带了功能极为强大的防火墙系统，因此，我们使用它来封锁非法请求。&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 由于访问IP量巨大，因此，手动处理和辨别非法ip是不现实的，因此，我考虑使用程序分析攻击ip的方式，对iis日志访问记录进行详细分析，分析方法如下：&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.对当日的访问ip进行统计&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2.攻击者的典型特征是短时间多次连接，通过该方式，筛选出大量可疑IP&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3.对可疑IP进行分析，剔除搜索引擎蜘蛛IP&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5.最后剩下的基本上就是攻击者IP&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 通过以上方法，我们可以在较高精确度的情况下找出攻击者IP，通过对本次攻击的日志分析，在封堵大量攻击者IP之前，找到嫌疑度很高的IP988个。&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 然后需要做的就是在防火墙封堵这些IP，规则采用入站规则，这样，防火墙封堵将获得很高的效率，经过试验发现，windows防火墙一条规则大概可以封堵600多个单一IP，因此，我创建了两条规则，通过脚本，将这些可疑度很高的ip全部加入拒绝ip列表，完成之后，服务器流量和cpu占用率马上下降到正常水平。&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;在攻击过程中，经常出现攻击者攻击一段时间，停止一段时间，因此，我采用系统通知的方式，在服务器负载或者流量突然很大的时候进行通知，这样就可以在第一时间得知攻击情况并进行封堵。&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 在一天以后，攻击停止，我解开了这两条规则，由于攻击者经常使用合法ip进行攻击，因此这些ip的用户也很可能访问本站，因此在攻击停止之后需要解开规则。&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 本次规则，共出现攻击ip&lt;span style="color: #f00;"&gt;998&lt;/span&gt;个，在封堵之前，攻击次数最多的ip202.108.xxx.xxx进行了&lt;span style="color: #f00;"&gt;1401&lt;/span&gt;此攻击连接，最少的攻击IP189.31.xxx.xxx进行了&lt;span style="color: #f00;"&gt;11&lt;/span&gt;次攻击连接，在攻击停止之后，再次对日志进行分析，共产生&lt;span style="color: #f00;"&gt;116494&lt;/span&gt;次攻击访问请求，同时将系统最高在线人数刷新到&lt;span style="color: #f00;"&gt;331&lt;/span&gt;人，考虑在攻击不久之后便封堵了大量攻击IP，因此本次攻击量还是比较大的。&lt;/p&gt;&lt;img src="http://www.cnblogs.com/leven/aggbug/1758611.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/leven/archive/2010/06/15/levenblog-cc.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/leven/archive/2010/05/13/decoratorsharp-aop-demo01.html</id><title type="text">初试轻量级AOP框架 DecoratorSharp-另类的Hello World</title><summary type="text">  DecoratorSharp是一个轻量级的AOP框架，它的创造灵感来自python的decorator，通过目前提供的0.2.0版本，我们可以轻松使用该框架进行切面编程。本文通过一个简单的Demo来看看如何简单的使用这一框架，同时，本文也是上次未完结文章《轻量级AOP框架-移植python的装饰器(Decorator)到C#》的续集。注意，目前的DecoratorSharp还在开发中，API有可能仍然变动，因此在最终版本出现之后，本文可能仅能作为参考。 </summary><published>2010-05-13T14:43:00Z</published><updated>2010-05-13T14:43:00Z</updated><author><name>Leven</name><uri>http://www.cnblogs.com/leven/</uri></author><link rel="alternate" href="http://www.cnblogs.com/leven/archive/2010/05/13/decoratorsharp-aop-demo01.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/leven/archive/2010/05/13/decoratorsharp-aop-demo01.html"/><content type="text">  DecoratorSharp是一个轻量级的AOP框架，它的创造灵感来自python的decorator，通过目前提供的0.2.0版本，我们可以轻松使用该框架进行切面编程。本文通过一个简单的Demo来看看如何简单的使用这一框架，同时，本文也是上次未完结文章《轻量级AOP框架-移植python的装饰器(Decorator)到C#》的续集。注意，目前的DecoratorSharp还在开发中，API有可能仍然变动，因此在最终版本出现之后，本文可能仅能作为参考。 </content></entry><entry><id>http://www.cnblogs.com/leven/archive/2010/05/09/decorator-preview.html</id><title type="text">DecoratorSharp主页上线,提供第一个preview版本测试</title><summary type="text">去年年底到今年年初的时候,书写了两篇关于c#实现python的decorator的文章,由于时间和精力的原因,该系列还未完结,但是decoratorsharp项目却是完成了第一个可用的预览版,虽然在效率和api设计上还有些问题,但总算是没有bug了.现做了一个DecoratorSharp的官网,并放出库和源代码测试.</summary><published>2010-05-09T12:23:00Z</published><updated>2010-05-09T12:23:00Z</updated><author><name>Leven</name><uri>http://www.cnblogs.com/leven/</uri></author><link rel="alternate" href="http://www.cnblogs.com/leven/archive/2010/05/09/decorator-preview.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/leven/archive/2010/05/09/decorator-preview.html"/><content type="text">去年年底到今年年初的时候,书写了两篇关于c#实现python的decorator的文章,由于时间和精力的原因,该系列还未完结,但是decoratorsharp项目却是完成了第一个可用的预览版,虽然在效率和api设计上还有些问题,但总算是没有bug了.现做了一个DecoratorSharp的官网,并放出库和源代码测试.</content></entry><entry><id>http://www.cnblogs.com/leven/archive/2010/04/24/debian-vpn-pptp.html</id><title type="text">在Debian上建立基于PPTP的VPN</title><summary type="text">VPN的英文全称是“Virtual Private Network”，翻译过来就是“虚拟专用网络”。顾名思义，虚拟专用网络可以把它理解成是虚拟出来的企业内部专线。 今天我们的目的是在自己的debian系统上构造一个VPN系统,废话不多说,下面开始配置系统. .... 本文详细内容请参考:http://leven.com.cn/blog/view/10...</summary><published>2010-04-24T08:32:00Z</published><updated>2010-04-24T08:32:00Z</updated><author><name>Leven</name><uri>http://www.cnblogs.com/leven/</uri></author><link rel="alternate" href="http://www.cnblogs.com/leven/archive/2010/04/24/debian-vpn-pptp.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/leven/archive/2010/04/24/debian-vpn-pptp.html"/><content type="text">VPN的英文全称是“Virtual Private Network”，翻译过来就是“虚拟专用网络”。顾名思义，虚拟专用网络可以把它理解成是虚拟出来的企业内部专线。 今天我们的目的是在自己的debian系统上构造一个VPN系统,废话不多说,下面开始配置系统. .... 本文详细内容请参考:http://leven.com.cn/blog/view/10...</content></entry><entry><id>http://www.cnblogs.com/leven/archive/2010/03/29/wcf-rest-routing.html</id><title type="text">为WCF REST启用UrlRouting</title><summary type="text">  在基于Rest的WCF开发中,我们有必要将原来的/xxx.svc/xxx的Url更改为/xxx/xxx,在WCF4中,使用Asp.Net模式可以通过System.Web.Routing组件来完成这一操作.本文将简要给出实现方法.</summary><published>2010-03-29T15:38:00Z</published><updated>2010-03-29T15:38:00Z</updated><author><name>Leven</name><uri>http://www.cnblogs.com/leven/</uri></author><link rel="alternate" href="http://www.cnblogs.com/leven/archive/2010/03/29/wcf-rest-routing.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/leven/archive/2010/03/29/wcf-rest-routing.html"/><content type="text">  在基于Rest的WCF开发中,我们有必要将原来的/xxx.svc/xxx的Url更改为/xxx/xxx,在WCF4中,使用Asp.Net模式可以通过System.Web.Routing组件来完成这一操作.本文将简要给出实现方法.</content></entry><entry><id>http://www.cnblogs.com/leven/archive/2010/02/28/1675202.html</id><title type="text">管理linux服务器的一些tips</title><summary type="text">  前几天将本站迁往了linux服务器上,测试的情况看来,除了由于线路原因刷新速度略显慢之外倒没有其他可挑剔的地方.在管理linux服务器的时候个人整理了一些tips.</summary><published>2010-02-28T09:31:00Z</published><updated>2010-02-28T09:31:00Z</updated><author><name>Leven</name><uri>http://www.cnblogs.com/leven/</uri></author><link rel="alternate" href="http://www.cnblogs.com/leven/archive/2010/02/28/1675202.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/leven/archive/2010/02/28/1675202.html"/><content type="text">  前几天将本站迁往了linux服务器上,测试的情况看来,除了由于线路原因刷新速度略显慢之外倒没有其他可挑剔的地方.在管理linux服务器的时候个人整理了一些tips.</content></entry><entry><id>http://www.cnblogs.com/leven/archive/2010/01/14/mono-levenblog.html</id><title type="text">以levenblog为例,尝试在linux+mono平台上部署asp.net mvc程序</title><summary type="text">  一直以来都十分关注mono的发展,在不久之前,mono正式发布了2.6.1版本,该版本已经是一个比较完善的版本了,不仅完整支持了.net2.0的全部内容,以及大部分.net3.5甚至还支持了.net4.0的内容(可选),在mono官方已经包含了asp.net mvc1.0版本,因此,部署levenblog到mono的条件完全成熟,不过由于linux和windows的差异,因此,也并不是所有程序都可以直接部署的,本次将完整记录levenblog部署到mono2.6.1的过程.</summary><published>2010-01-13T16:03:00Z</published><updated>2010-01-13T16:03:00Z</updated><author><name>Leven</name><uri>http://www.cnblogs.com/leven/</uri></author><link rel="alternate" href="http://www.cnblogs.com/leven/archive/2010/01/14/mono-levenblog.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/leven/archive/2010/01/14/mono-levenblog.html"/><content type="text">  一直以来都十分关注mono的发展,在不久之前,mono正式发布了2.6.1版本,该版本已经是一个比较完善的版本了,不仅完整支持了.net2.0的全部内容,以及大部分.net3.5甚至还支持了.net4.0的内容(可选),在mono官方已经包含了asp.net mvc1.0版本,因此,部署levenblog到mono的条件完全成熟,不过由于linux和windows的差异,因此,也并不是所有程序都可以直接部署的,本次将完整记录levenblog部署到mono2.6.1的过程.</content></entry><entry><id>http://www.cnblogs.com/leven/archive/2009/12/28/decorator-csharp-2.html</id><title type="text">轻量级AOP框架-移植python的装饰器(Decorator)到C#(编码篇)</title><summary type="text">  在《轻量级AOP框架-移植python的装饰器(Decorator)到C#(思考篇)》中，文章分析了Python中Decorator的原理以及C#移植的可行性，在本篇中，文章将继续探讨如何将这个想法实实在在的表现出来，因此本篇的目标是：一个初级但是可用的Decorator实现。   如果您对本文的基本思路存在疑惑，请先阅读思考篇。 </summary><published>2009-12-28T09:25:00Z</published><updated>2009-12-28T09:25:00Z</updated><author><name>Leven</name><uri>http://www.cnblogs.com/leven/</uri></author><link rel="alternate" href="http://www.cnblogs.com/leven/archive/2009/12/28/decorator-csharp-2.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/leven/archive/2009/12/28/decorator-csharp-2.html"/><content type="text">  在《轻量级AOP框架-移植python的装饰器(Decorator)到C#(思考篇)》中，文章分析了Python中Decorator的原理以及C#移植的可行性，在本篇中，文章将继续探讨如何将这个想法实实在在的表现出来，因此本篇的目标是：一个初级但是可用的Decorator实现。   如果您对本文的基本思路存在疑惑，请先阅读思考篇。 </content></entry><entry><id>http://www.cnblogs.com/leven/archive/2009/12/28/decorator-csharp-1.html</id><title type="text">轻量级AOP框架-移植python的装饰器(Decorator)到C#(思考篇)</title><summary type="text">今天我们展示的是Python中一个很有用特性：“Decorator”，中文可以译作“装饰器”，它是一个对函数的封装，它可以让你不改变函数本身的情况下对函数的执行进行干预，比如在执行前进行权限认证，日志记录，甚至修改传入参数，或者在执行后对返回结果进行预处理，甚至可以截断函数的执行等等,没错，本质上来说，它就是我们常说的面向方面编程（Aspect-Oriented Programming），简称AOP，本文将尝试将这一特性移植到c#平台.</summary><published>2009-12-28T04:22:00Z</published><updated>2009-12-28T04:22:00Z</updated><author><name>Leven</name><uri>http://www.cnblogs.com/leven/</uri></author><link rel="alternate" href="http://www.cnblogs.com/leven/archive/2009/12/28/decorator-csharp-1.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/leven/archive/2009/12/28/decorator-csharp-1.html"/><content type="text">今天我们展示的是Python中一个很有用特性：“Decorator”，中文可以译作“装饰器”，它是一个对函数的封装，它可以让你不改变函数本身的情况下对函数的执行进行干预，比如在执行前进行权限认证，日志记录，甚至修改传入参数，或者在执行后对返回结果进行预处理，甚至可以截断函数的执行等等,没错，本质上来说，它就是我们常说的面向方面编程（Aspect-Oriented Programming），简称AOP，本文将尝试将这一特性移植到c#平台.</content></entry><entry><id>http://www.cnblogs.com/leven/archive/2009/12/08/instanse_create_comparison.html</id><title type="text">探究.net对象的创建,质疑《再谈Activator.CreateInstance(Type type)方法创建对象和Expression Tree创建对象性能的比较》</title><summary type="text">今日, Will Meng发布了一篇名为《再谈Activator.CreateInstance(Type type)方法创建对象和Expression Tree创建对象性能的比较》的博文,文中通过一系列的对比测试,得到了一个结论:” 结果方法Activator.CreateInstance()比表达式树要快了。”,但是在我个人的使用中,感觉并非如此,因此特别进行了测试.</summary><published>2009-12-08T04:20:00Z</published><updated>2009-12-08T04:20:00Z</updated><author><name>Leven</name><uri>http://www.cnblogs.com/leven/</uri></author><link rel="alternate" href="http://www.cnblogs.com/leven/archive/2009/12/08/instanse_create_comparison.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/leven/archive/2009/12/08/instanse_create_comparison.html"/><content type="text">今日, Will Meng发布了一篇名为《再谈Activator.CreateInstance(Type type)方法创建对象和Expression Tree创建对象性能的比较》的博文,文中通过一系列的对比测试,得到了一个结论:” 结果方法Activator.CreateInstance()比表达式树要快了。”,但是在我个人的使用中,感觉并非如此,因此特别进行了测试.</content></entry></feed>
