实际应用
利用配置问题
在实际应用中的攻击,也许对方网管会采取作Squid的ACL方法来屏蔽此种攻击,但是实际环境中的攻击种类和方法会更加多样化,例如利用Squid默认配置中存在的问题,一样可以达到灵巧利用此问题,并具有一定隐蔽性。
场景某网管在Squid通过ACL做了no-cache过滤,使得加杂no-cahce的指令无法穿过,但是一样遭到了Cache拒绝服务攻击。
攻击原理
Squid的处理方式当返回为404、403时,通过cache处理减轻后台Web系统的负担。
通过程序用GET方式访问500次不存在的文件“index.html。”
查看squid的日志,cache住了绝大多数请求。
root@coolc:~/squid-2.5.STABLE12# cat squid_access.log wc -l
499
root@coolc:~/squid-2.5.STABLE12# cat squid_access.log awk '{print $4'} uniq -c
499 TCP_NEGATIVE_HIT/404
root@coolc:~/squid-2.5.STABLE12# cat apache-access_log wc -l
0 |
而实际上传到到Apache上的压力为0,也就是几乎没有压力。TCP_NEGATIVE_HIT解决了大多数的负载,导致攻击压力全部不能施加在后台的Web服务器。
从Squid的配置文件里可以看到,Squid对于特殊错误的返回也是做了处理的,一样做了Cache。
# TAG: negative_ttl time-units
# Time-to-Live (TTL) for failed requests. Certain types of
# failures (such as "connection refused" and "404 Not Found") are
# negatively-cached for a configurable amount of time. The
# default is 5 minutes. Note that this is different from
# negative caching of DNS lookups. |
是否有方式可以绕过cache机制和ACL限制,将类似404压力施加到服务器上?答案时肯定的,那就是通过访问cgi-bin目录下的文件。
通过执行攻击代码我们同样实现了对后台主机的攻击,穿透了Cache。
root@coolc:~/squid-2.5.STABLE12# cat squid_access.log awk '{print $4'} uniq -c
499 TCP_MISS/404
root@coolc:~/squid-2.5.STABLE12# cat apache-access_log wc -l
499 |
从日志中可以发现如下痕迹。
172.16.10.1 - - [08/Apr/2006:16:33:50 -0800] "GET /cgi-bin/index.html1 HTTP/1.0" 404 298
172.16.10.1 - - [08/Apr/2006:16:33:50 -0800] "GET /cgi-bin/index.html1 HTTP/1.0" 404 298
172.16.10.1 - - [08/Apr/2006:16:33:50 -0800] "GET /cgi-bin/index.html1 HTTP/1.0" 404 298
172.16.10.1 - - [08/Apr/2006:16:33:50 -0800] "GET /cgi-bin/index.html1 HTTP/1.0" 404 298 |
实际上造成上述原因就死活因为默认配置中对于cgi-bin目录做了特殊处理,导致对于其放开了Cache的限制。
# TAG: hierarchy_stoplist
# A list of words which, if found in a URL, cause the object to
# be handled directly by this cache. In other words, use this
# to not query neighbor caches for certain objects. You may
# list this option multiple times. Note: never_direct overrides
# this option.
#We recommend you to use at least the following line.
hierarchy_stoplist cgi-bin ?
# TAG: no_cache
# A list of ACL elements which, if matched, cause the request to
# not be satisfied from the cache and the reply to not be cached.
# In other words, use this to force certain objects to never be cached.
#
# You must use the word 'DENY' to indicate the ACL names which should
# NOT be cached.
#
#We recommend you to use the following two lines.
acl QUERY urlpath_regex cgi-bin \?
no_cache deny QUERY |

发表评论