-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflow.py
More file actions
118 lines (89 loc) · 3.17 KB
/
Copy pathflow.py
File metadata and controls
118 lines (89 loc) · 3.17 KB
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
import time
import random
import json
import string
from urllib.parse import quote
import uuid
import requests
from curl_cffi import requests as cffi_requests
from PIL import Image
import base64
from predictor import cnn
def url_encode(data):
return quote(str(data))
def uuidv4():
return str(uuid.uuid4())
def current_time():
return int(time.time())
TSH = "TH[cba9a83bbafbda3aa35158aa08d04e4c]"
TSH1 = url_encode(TSH)
BD = "www.sfr.fr"
MTPublicKey = "MTPublic-YVOJkLMVR"
randkey = ''.join(random.choices(string.ascii_lowercase + string.digits, k=6))
s = uuidv4()
# 1: Setup vars
RT = current_time()
urlstep1 = f'https://service.mtcaptcha.com/mtcv1/api/getchallenge.json?sk=MTPublic-YVOJkLMVR&bd=www.sfr.fr&rt={RT}&tsh={TSH1}&act=%24&ss={s}&lf=0&tl=%24&lg=fr&tp=s'
proxies = {
"https": f"INPUT UR PROXY HERE"
}
browsers = ["safari","chrome"]
session = cffi_requests.Session(impersonate=random.choice(browsers))
session.proxies = proxies
r = session.get(f"{urlstep1}")
data = r.json()
ct = data['result']['challenge']['ct']
fseed = data['result']['challenge']['foldChlg']['fseed']
fslots = data['result']['challenge']['foldChlg']['fslots']
fdepth = data['result']['challenge']['foldChlg']['fdepth']
kt = "$$"
print(f"CT: {ct[:10]}... | Seed: {fseed[:10]}... | Slots: {fslots} | Depth: {fdepth} | KT: {kt}")
ct_enc = ct.replace(',', '%2C')
# Get image (req2)
urlstep2 = f'https://service.mtcaptcha.com/mtcv1/api/getimage.json?sk=MTPublic-YVOJkLMVR&ct={ct_enc}&fa=%24&ss={s}'
b = session.get(f"{urlstep2}")
data2 = b.json()
if 'result' not in data2 or 'img' not in data2['result'] or 'image64' not in data2['result']['img']:
print("Captcha not found due to fingerprint being banned")
exit()
image64 = data2['result']['img']['image64']
image = base64.b64decode(image64)
with open("captcha.gif", "wb") as f:
f.write(image)
print("Captcha saved as captcha.gif")
# Calculate FA
print("Calculating FA...")
try:
calc_payload = {
"fseed": fseed,
"fslots": fslots,
"fdepth": fdepth
}
calc_resp = requests.post("http://localhost:9091/calculate", json=calc_payload)
if calc_resp.status_code == 200:
fa = calc_resp.json().get("fa")
print(f"Calculated FA: {fa}")
else:
print(f"Failed to calculate FA: {calc_resp.text}")
fa = "$"
except Exception as e:
print(f"Error calling calculate: {e}")
fa = "$"
# Solve
print("Sending Captcha image to CNN...")
ans = cnn("captcha.gif")
print(f"CNN Answer: {ans}")
def enc(x): return url_encode(x)
solveUrl = f"https://service.mtcaptcha.com/mtcv1/api/solvechallenge.json?ct={enc(ct)}&sk={enc(MTPublicKey)}&st={enc(ans)}&lf=0&bd={enc(BD)}&rt={enc(RT)}&tsh={TSH1}&fa={enc(fa)}&qh=%24&act=%24&ss={enc(s)}&tl=%24&lg=fr&tp=s&kt={enc(kt)}&fs={enc(fseed)}"
print("Solving...")
solve_resp = session.get(solveUrl)
solveData = solve_resp.json()
verifyResult = solveData.get("result", {}).get("verifyResult", {})
isVerified = verifyResult.get("isVerified")
print(f"Valid Cnn answer ? : {isVerified}")
if isVerified:
vt = verifyResult.get("verifiedToken", {}).get("vt")
print(f"Captcha Answer: {vt}")
else:
print("Captcha not verified cos of cnn :(")
print(solve_resp.text)