qileilove

blog已经转移至github,大家请访问 http://qaseven.github.io/

在Linux下如何查CC攻击?

 什么是CC攻击?CC攻击就是利用大量代理服务器对目标计算机发起大量连接,导致目标服务器资源枯竭造成拒绝服务。那么如何判断查询CC攻击呢?本文主要介绍了一些Linux下判断CC攻击的命令。

  查看所有80端口的连接数

  netstat -nat|grep -i "80"|wc -l

  对连接的IP按连接数量进行排序

  netstat -anp | grep 'tcp\|udp' | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
  netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
  netstat -ntu | awk '{print $5}' | egrep -o "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" | sort | uniq -c | sort -nr

  查看TCP连接状态

  netstat -nat |awk '{print $6}'|sort|uniq -c|sort -rn
  netstat -n | awk '/^tcp/ {print $NF}'|sort|uniq -c|sort -rn
  netstat -n | awk '/^tcp/ {++S[$NF]};END {for(a in S) print a, S[a]}'
  netstat -n | awk '/^tcp/ {++state[$NF]}; END {for(key in state) print key,"\t",state[key]}'
  netstat -n | awk '/^tcp/ {++arr[$NF]};END {for(k in arr) print k,"\t",arr[k]}'
  netstat -ant | awk '{print $NF}' | grep -v '[a-z]' | sort | uniq -c

  查看80端口连接数最多的20个IP

  cat /www/web_logs/waitalone.cn_access.log|awk '{print $1}'|sort|uniq -c|sort -nr|head -100
  tail -n 10000 /www/web_logs/waitalone.cn_access.log|awk '{print $1}'|sort|uniq -c|sort -nr|head -100
  cat /www/web_logs/waitalone.cn_access.log|awk '{print $1}'|sort|uniq -c|sort -nr|head -100
  netstat -anlp|grep 80|grep tcp|awk '{print $5}'|awk -F: '{print $1}'|sort|uniq -c|sort -nr|head -n20
  netstat -ant |awk '/:80/{split($5,ip,":");++A[ip[1]]}END{for(i in A) print A,i}' |sort -rn|head -n20

  用tcpdump嗅探80端口的访问看看谁最高

  tcpdump -i eth0 -tnn dst port 80 -c 1000 | awk -F"." '{print $1"."$2"."$3"."$4}' | sort | uniq -c | sort -nr |head -20

  查找较多time_wait连接

  netstat -n|grep TIME_WAIT|awk '{print $5}'|sort|uniq -c|sort -rn|head -n20

  查找较多的SYN连接

  netstat -an | grep SYN | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | sort -nr | more

  linux下实用iptables封ip段的一些常见命令:

  封单个IP的命令是:

  iptables -I INPUT -s 211.1.0.0 -j DROP

  封IP段的命令是:

  iptables -I INPUT -s 211.1.0.0/16 -j DROP
  iptables -I INPUT -s 211.2.0.0/16 -j DROP
  iptables -I INPUT -s 211.3.0.0/16 -j DROP

  封整个段的命令是:

  iptables -I INPUT -s 211.0.0.0/8 -j DROP

  封几个段的命令是:

  iptables -I INPUT -s 61.37.80.0/24 -j DROP

  iptables -I INPUT -s 61.37.81.0/24 -j DROP

  想在服务器启动自运行的话有三个方法:

  1、把它加到/etc/rc.local中

  2、iptables-save >/etc/sysconfig/iptables可以把你当前的iptables规则放到/etc/sysconfig/iptables中,系统启动iptables时自动执行。

  3、service iptables save 也可以把你当前的iptables规则放/etc/sysconfig/iptables中,系统启动iptables时自动执行。

  后两种更好此,一般iptables服务会在network服务之前启来,更安全。

  解封的话:

  iptables -D INPUT -s IP地址 -j REJECT

  iptables -F 全清掉了

posted on 2013-05-15 10:14 顺其自然EVO 阅读(133) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
 
<2013年5月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

导航

统计

常用链接

留言簿(55)

随笔分类

随笔档案

文章分类

文章档案

搜索

最新评论

阅读排行榜

评论排行榜