-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathfuckCaptcha.py
344 lines (296 loc) · 15.6 KB
/
fuckCaptcha.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
# Developed by cryonicx#1337 / dirt#3009
from multiprocessing.connection import answer_challenge
import requests, json, time, hashlib, base64, math, urllib
from json import dumps
from datetime import datetime
from concurrent.futures import ThreadPoolExecutor
from unittest import mock
config = json.loads(open("./config.json", "r", encoding="utf-8").read())
class fuckCaptcha:
def __init__(self) -> None:
self.session = requests.Session()
self.host = config["host"]
self.sitekey = config["site_key"]
self.builder = {
'v':"44fc726",
"job_mode": "image_label_binary",
"answers": {},
"serverdomain": self.host,
"sitekey": self.sitekey,
"motionData": {"st": str(int(round(time.time() * 1000))),"dct": str(int(round(time.time() * 1000))), "mm": []}
}
self.c = {}
self.starttime = time.time()
self.headers = {
"Host": "hcaptcha.com",
"Connection": "keep-alive",
"sec-ch-ua": 'Chromium";v="92", " Not A;Brand";v="99", "Google Chrome";v="92',
"Accept": "application/json",
"sec-ch-ua-mobile": "?0",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36",
"Content-type": "application/json; charset=utf-8",
"Origin": "https://newassets.hcaptcha.com",
"Sec-Fetch-Site": "same-site",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Dest": "empty",
"Referer": "https://newassets.hcaptcha.com/",
"Accept-Language": "en-US,en;q=0.9"
}
self.endpoint = "https://www.wolframcloud.com/obj/42d2ca71-06c7-47dd-823b-63b684cb2fe9"
self.mockJson = f"""{self.responseForward()}"""
print(self.mockJson)
self.mockJson = self.mockJson.replace("і", "i").replace("ο", "o").replace("ѕ", "s").replace("а", "a").replace("е", "e").replace("р", "p").replace("у", "y").replace("х", "x").replace("ԁ", "d").replace("ԛ", "q").replace("ԝ", "w")
self.mockDict = json.loads(self.mockJson)
self.key = self.mockDict["key"]
self.seaplane = [
"plane",
"flying boat",
"pontoon"
]
self.train = [
"train",
"locomotive",
"carrier",
"rail",
"railroad",
"railcar",
"caboose"
]
self.motorcycle = [
"sprocket",
"motor vehicle",
"motorcycle",
"motor cycle",
"locomotive engine",
"self-propelled vehicle",
]
self.bicycle = [
"bicycle wheel",
"bicycle",
"bike",
"mountain bike"
]
self.truck = [
"truck",
"fire truck",
"garbage truck"
]
self.boat = [
"yawl",
"sailing ship",
"ketch",
"fireboat",
"ship",
"boat",
"catboat",
"trimaran",
"catamaran",
"sailboat",
"cruise ship",
"ocean liner",
"passenger ship",
"barque",
"brig",
"houseboat",
"barge"
]
self.motorbus = [
"streetcar",
"subway train",
"bus",
"autobus",
"motorbus",
]
self.car = [
"car",
"vehicle",
"auto",
"automobile"
]
if self.mockDict["requester_question"]["en"] == "Please click each image containing a seaplane":
self.challenge_type = self.seaplane
elif self.mockDict["requester_question"]["en"] == "Please click each image containing a motorbus":
self.challenge_type = self.motorbus
elif self.mockDict["requester_question"]["en"] == "Please click each image containing a boat":
self.challenge_type = self.boat
elif self.mockDict["requester_question"]["en"] == "Please click each image containing a truck":
self.challenge_type = self.truck
elif self.mockDict["requester_question"]["en"] == "Please click each image containing a bicycle":
self.challenge_type = self.bicycle
elif self.mockDict["requester_question"]["en"] == "Please click each image containing a motorcycle":
self.challenge_type = self.motorcycle
elif self.mockDict["requester_question"]["en"] == "Please click each image containing a train":
self.challenge_type = self.train
elif self.mockDict["requester_question"]["en"] == "Please click each image containing a car":
self.challenge_type = self.car
else:
print("Not supported.")
def NData(self, req):
try:
"""
this part takes the req value inside the getsiteconfig and converts it into our hash, we need this for the final step.
(thanks to h0nde for this function btw, you can find the original code for this at the top of the file.)
"""
x = "0123456789/:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
req = req.split(".")
req = {
"header": json.loads(
base64.b64decode(
req[0] +
"=======").decode("utf-8")),
"payload": json.loads(
base64.b64decode(
req[1] +
"=======").decode("utf-8")),
"raw": {
"header": req[0],
"payload": req[1],
"signature": req[2]}}
def a(r):
for t in range(len(r) - 1, -1, -1):
if r[t] < len(x) - 1:
r[t] += 1
return True
r[t] = 0
return False
def ix(r):
t = ""
for n in range(len(r)):
t += x[r[n]]
return t
def o(r, e):
n = e
hashed = hashlib.sha1(e.encode())
o = hashed.hexdigest()
t = hashed.digest()
e = None
n = -1
o = []
for n in range(n + 1, 8 * len(t)):
e = t[math.floor(n / 8)] >> n % 8 & 1
o.append(e)
a = o[:r]
def index2(x, y):
if y in x:
return x.index(y)
return -1
return 0 == a[0] and index2(a, 1) >= r - 1 or -1 == index2(a, 1)
def get():
for e in range(25):
n = [0 for i in range(e)]
while a(n):
u = req["payload"]["d"] + "::" + ix(n)
if o(req["payload"]["s"], u):
return ix(n)
result = get()
hsl = ":".join([
"1",
str(req["payload"]["s"]),
datetime.now().isoformat()[:19]
.replace("T", "")
.replace("-", "")
.replace(":", ""),
req["payload"]["d"],
"",
result
])
return hsl
except Exception as e:
print(e)
return False
def ReqData(self, host, sitekey):
try:
r = self.session.get(f"https://hcaptcha.com/checksiteconfig?host={host}&sitekey={sitekey}&sc=1&swa=1",
headers=self.headers, timeout=4)
if r.json()["pass"]:
return r.json()["c"]
else:
return False
except:
return False
def GetCaptcha(self, host, sitekey, n, req):
try:
json = {
"sitekey": sitekey,
"v": "44fc726",
"host": host,
"n": n,
'motiondata': '{"st":{ ' + str(round(
time.time() * 1000)) + '},"mm":[[203,16,1628923874730],[155,42,1628923874753],[137,53,1628923874770],[122,62,1628923874793],[120,62,1628923875020],[107,62,1628923875042],[100,61,1628923875058],[93,60,1628923875074],[89,59,1628923875090],[88,59,1628923875106],[87,59,1628923875131],[87,59,1628923875155],[84,56,1628923875171],[76,51,1628923875187],[70,47,1628923875203],[65,44,1628923875219],[63,42,1628923875235],[62,41,1628923875251],[61,41,1628923875307],[58,39,1628923875324],[54,38,1628923875340],[49,36,1628923875363],[44,36,1628923875380],[41,35,1628923875396],[40,35,1628923875412],[38,35,1628923875428],[38,35,1628923875444],[37,35,1628923875460],[37,35,1628923875476],[37,35,1628923875492]],"mm-mp":13.05084745762712,"md":[[37,35,1628923875529]],"md-mp":0,"mu":[[37,35,1628923875586]],"mu-mp":0,"v":1,"topLevel":{"st":1628923867123,"sc":{"availWidth":1680,"availHeight":932,"width":1680,"height":1050,"colorDepth":30,"pixelDepth":30,"availLeft":0,"availTop":23},"nv":{"vendorSub":"","productSub":"20030107","vendor":"Google Inc.","maxTouchPoints":0,"userActivation":{},"doNotTrack":null,"geolocation":{},"connection":{},"webkitTemporaryStorage":{},"webkitPersistentStorage":{},"hardwareConcurrency":12,"cookieEnabled":true,"appCodeName":"Mozilla","appName":"Netscape","appVersion":"5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36","platform":"MacIntel","product":"Gecko","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36","language":"en-US","languages":["en-US","en"],"onLine":true,"webdriver":false,"serial":{},"scheduling":{},"xr":{},"mediaCapabilities":{},"permissions":{},"locks":{},"usb":{},"mediaSession":{},"clipboard":{},"credentials":{},"keyboard":{},"mediaDevices":{},"storage":{},"serviceWorker":{},"wakeLock":{},"deviceMemory":8,"hid":{},"presentation":{},"userAgentData":{},"bluetooth":{},"managed":{},"plugins":["internal-pdf-viewer","mhjfbmdgcfjbbpaeojofohoefgiehjai","internal-nacl-plugin"]},"dr":"https://discord.com/","inv":false,"exec":false,"wn":[[1463,731,2,1628923867124],[733,731,2,1628923871704]],"wn-mp":4580,"xy":[[0,0,1,1628923867125]],"xy-mp":0,"mm":[[1108,233,1628923867644],[1110,230,1628923867660],[1125,212,1628923867678],[1140,195,1628923867694],[1158,173,1628923867711],[1179,152,1628923867727],[1199,133,1628923867744],[1221,114,1628923867768],[1257,90,1628923867795],[1272,82,1628923867811],[1287,76,1628923867827],[1299,71,1628923867844],[1309,68,1628923867861],[1315,66,1628923867877],[1326,64,1628923867894],[1331,62,1628923867911],[1336,60,1628923867927],[1339,58,1628923867944],[1343,56,1628923867961],[1345,54,1628923867978],[1347,53,1628923867994],[1348,52,1628923868011],[1350,51,1628923868028],[1354,49,1628923868045],[1366,44,1628923868077],[1374,41,1628923868094],[1388,36,1628923868110],[1399,31,1628923868127],[1413,25,1628923868144],[1424,18,1628923868161],[1436,10,1628923868178],[1445,3,1628923868195],[995,502,1628923871369],[722,324,1628923874673],[625,356,1628923874689],[523,397,1628923874705],[457,425,1628923874721]],"mm-mp":164.7674418604651},"session":[],"widgetList":["0a1l5c3yudk4"],"widgetId":"0a1l5c3yudk4","href":"https://discord.com/register","prev":{"escaped":false,"passed":false,"expiredChallenge":false,"expiredResponse":false}}',
"hl": "en",
"c": dumps(req)
}
data = urllib.parse.urlencode(json)
headers = {
"Host": "hcaptcha.com",
"Connection": "keep-alive",
"sec-ch-ua": 'Chromium";v="92", " Not A;Brand";v="99", "Google Chrome";v="92',
"Accept": "application/json",
"sec-ch-ua-mobile": "?0",
"Content-length": str(len(data)),
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36",
"Content-type": "application/x-www-form-urlencoded",
"Origin": "https://newassets.hcaptcha.com",
"Sec-Fetch-Site": "same-site",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Dest": "empty",
"Referer": "https://newassets.hcaptcha.com/",
"Accept-Language": "en-US,en;q=0.9"
}
cookies = {
"hc_accessibility": "VdfzG99DjOoLGlqlwSuIjToEryE7Xcx0z4lPWbLBLLCqCfpG9z2X5J+BwkOMrjbNFUKB60TAPpTsW7pzcBQIu0vztY6DQDLzZqpvKUKjyx9RxILDx8wCXq/z1OLjRPib7Cu4t+b4gEaoTbGD240IIXCRN33czAf3d4nr4HxcUsedKNT/cMp4xDo93HBxiSHYMBg3HvE4M3frwKUlSEDrSVG5Bg5FqxlokBLSIhWuQ2SAmiwiOwGLpvknsZHClqPnaI6KA3iyhMrDOO/f8fFxTpGiik3xqlfpKzc783UKVR8Epwbhdeq7bfhNKQMnZkG4Ac9j5PFHgA1GePaKIETUuxVyABISiA4lEg5B0HuEGJUd5Rxl2qlv/AvFAtyqwYU8XUgMIML35IMUXtr4CVeihSLhqeV5+IBOHakiD54vu0IwuEi/BjYh+jkcks4=1qyF568EcE9myCKI"}
r = self.session.post(f"https://hcaptcha.com/getcaptcha?s={sitekey}", cookies=cookies, data=data, headers=headers,
timeout=4)
return r.text
except Exception as e:
print(e)
return False
def responseForward(self):
req = self.ReqData(self.host, self.sitekey)
req["type"] = "hsl"
self.builder['n'] = self.NData(req["req"])
self.builder['c'] = json.dumps(req)
payload = self.GetCaptcha(self.host, self.sitekey, self.NData(req["req"]), req)
print(f"Received payload")
return payload
def checkImage(self, channelType, task):
image = requests.get(task["datapoint_uri"])
files = {'image': ('img.jfif', image.content)}
res = requests.post(self.endpoint, data={}, files=files)
for substring in channelType:
if substring in res.text:
self.builder['answers'][task["task_key"]] = "true"
# answersDict[['task_key']] = True
match = True
else:
self.builder['answers'][task["task_key"]] = "false"
# answersDict[['task_key']] = False
match = False
print(task["task_key"] + " | " + str(bool(match)))
# def worker(self):
# executor = ThreadPoolExecutor(max_workers=50)
# for i in self.mockDict["tasklist"]:
# executor.submit(self.checkImage, self.challenge_type, i)
def submit(self, key):
executor = ThreadPoolExecutor(max_workers=50)
for i in self.mockDict["tasklist"]:
executor.submit(self.checkImage, self.challenge_type, i)
executor.shutdown(wait=True)
#print(key)
#print(self.builder)
r = self.session.post(
f'https://hcaptcha.com/checkcaptcha/{key}',
headers = self.headers,
data=self.builder
)
print(r.json())
if "pass" in r.json():
print(f"hCaptcha has been solved...")
print(r.json()['generated_pass_UUID'])
else:
print(f"Retrying...")
self.____________________()
def ____________________(self):
self.submit(self.key)
if __name__ == "__main__":
fuckCaptcha().____________________()