File size: 13,732 Bytes
08ca036 |
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 |
import pybase64
import json
import random
import time
from typing import Any, Callable, Dict, List, Union
class OrderedMap:
def __init__(self):
self.keys = []
self.values = {}
def add(self, key: str, value: Any):
if key not in self.values:
self.keys.append(key)
self.values[key] = value
def to_json(self):
return json.dumps({k: self.values[k] for k in self.keys})
TurnTokenList = List[List[Any]]
FloatMap = Dict[float, Any]
StringMap = Dict[str, Any]
FuncType = Callable[..., Any]
def get_turnstile_token(dx: str, p: str) -> Union[str, None]:
try:
decoded_bytes = pybase64.b64decode(dx)
return process_turnstile_token(decoded_bytes.decode(), p)
except Exception as e:
print(f"Error in get_turnstile_token: {e}")
return None
def process_turnstile_token(dx: str, p: str) -> str:
result = []
p_length = len(p)
if p_length != 0:
for i, r in enumerate(dx):
result.append(chr(ord(r) ^ ord(p[i % p_length])))
else:
result = list(dx)
return ''.join(result)
def is_slice(input_val: Any) -> bool:
return isinstance(input_val, (list, tuple))
def is_float(input_val: Any) -> bool:
return isinstance(input_val, float)
def is_string(input_val: Any) -> bool:
return isinstance(input_val, str)
def to_str(input_val: Any) -> str:
if input_val is None:
return "undefined"
elif is_float(input_val):
return str(input_val)
elif is_string(input_val):
special_cases = {
"window.Math": "[object Math]",
"window.Reflect": "[object Reflect]",
"window.performance": "[object Performance]",
"window.localStorage": "[object Storage]",
"window.Object": "function Object() { [native code] }",
"window.Reflect.set": "function set() { [native code] }",
"window.performance.now": "function () { [native code] }",
"window.Object.create": "function create() { [native code] }",
"window.Object.keys": "function keys() { [native code] }",
"window.Math.random": "function random() { [native code] }"
}
return special_cases.get(input_val, input_val)
elif isinstance(input_val, list) and all(isinstance(item, str) for item in input_val):
return ','.join(input_val)
else:
return str(input_val)
def get_func_map() -> FloatMap:
process_map: FloatMap = {}
def func_1(e: float, t: float):
e_str = to_str(process_map[e])
t_str = to_str(process_map[t])
res = process_turnstile_token(e_str, t_str)
process_map[e] = res
def func_2(e: float, t: Any):
process_map[e] = t
def func_5(e: float, t: float):
n = process_map[e]
tres = process_map[t]
if is_slice(n):
nt = n + [tres]
process_map[e] = nt
else:
if is_string(n) or is_string(tres):
res = to_str(n) + to_str(tres)
elif is_float(n) and is_float(tres):
res = n + tres
else:
res = "NaN"
process_map[e] = res
def func_6(e: float, t: float, n: float):
tv = process_map[t]
nv = process_map[n]
if is_string(tv) and is_string(nv):
res = f"{tv}.{nv}"
if res == "window.document.location":
process_map[e] = "https://chatgpt.com/"
else:
process_map[e] = res
else:
print("func type 6 error")
def func_24(e: float, t: float, n: float):
tv = process_map[t]
nv = process_map[n]
if is_string(tv) and is_string(nv):
process_map[e] = f"{tv}.{nv}"
else:
print("func type 24 error")
def func_7(e: float, *args):
n = [process_map[arg] for arg in args]
ev = process_map[e]
if isinstance(ev, str):
if ev == "window.Reflect.set":
obj = n[0]
key_str = str(n[1])
val = n[2]
obj.add(key_str, val)
elif callable(ev):
ev(*n)
def func_17(e: float, t: float, *args):
i = [process_map[arg] for arg in args]
tv = process_map[t]
res = None
if isinstance(tv, str):
if tv == "window.performance.now":
current_time = time.time_ns()
elapsed_ns = current_time - int(start_time * 1e9)
res = (elapsed_ns + random.random()) / 1e6
elif tv == "window.Object.create":
res = OrderedMap()
elif tv == "window.Object.keys":
if isinstance(i[0], str) and i[0] == "window.localStorage":
res = ["STATSIG_LOCAL_STORAGE_INTERNAL_STORE_V4", "STATSIG_LOCAL_STORAGE_STABLE_ID",
"client-correlated-secret", "oai/apps/capExpiresAt", "oai-did",
"STATSIG_LOCAL_STORAGE_LOGGING_REQUEST", "UiState.isNavigationCollapsed.1"]
elif tv == "window.Math.random":
res = random.random()
elif callable(tv):
res = tv(*i)
process_map[e] = res
def func_8(e: float, t: float):
process_map[e] = process_map[t]
def func_14(e: float, t: float):
tv = process_map[t]
if is_string(tv):
token_list = json.loads(tv)
process_map[e] = token_list
else:
print("func type 14 error")
def func_15(e: float, t: float):
tv = process_map[t]
process_map[e] = json.dumps(tv)
def func_18(e: float):
ev = process_map[e]
e_str = to_str(ev)
decoded = pybase64.b64decode(e_str).decode()
process_map[e] = decoded
def func_19(e: float):
ev = process_map[e]
e_str = to_str(ev)
encoded = pybase64.b64encode(e_str.encode()).decode()
process_map[e] = encoded
def func_20(e: float, t: float, n: float, *args):
o = [process_map[arg] for arg in args]
ev = process_map[e]
tv = process_map[t]
if ev == tv:
nv = process_map[n]
if callable(nv):
nv(*o)
else:
print("func type 20 error")
def func_21(*args):
pass
def func_23(e: float, t: float, *args):
i = list(args)
ev = process_map[e]
tv = process_map[t]
if ev is not None:
if callable(tv):
tv(*i)
process_map.update({
1: func_1, 2: func_2, 5: func_5, 6: func_6, 24: func_24, 7: func_7,
17: func_17, 8: func_8, 10: "window", 14: func_14, 15: func_15,
18: func_18, 19: func_19, 20: func_20, 21: func_21, 23: func_23
})
return process_map
start_time = 0
def process_turnstile(dx: str, p: str) -> str:
global start_time
start_time = time.time()
tokens = get_turnstile_token(dx, p)
if tokens is None:
return ""
token_list = json.loads(tokens)
# print(token_list)
res = ""
process_map = get_func_map()
def func_3(e: str):
nonlocal res
res = pybase64.b64encode(e.encode()).decode()
process_map[3] = func_3
process_map[9] = token_list
process_map[16] = p
for token in token_list:
try:
e = token[0]
t = token[1:]
f = process_map.get(e)
if callable(f):
f(*t)
else:
pass
# print(f"Warning: No function found for key {e}")
except Exception as exc:
pass
# print(f"Error processing token {token}: {exc}")
return res
if __name__ == "__main__":
result = process_turnstile(
"PBp5bWF1cHlLe1ttQhRfaTdmXEpidGdEYU5JdGJpR3xfHFVuGHVEY0tZVG18Vh54RWJ5CXpxKXl3SUZ7b2FZAWJaTBl6RGQZURh8BndUcRlQVgoYalAca2QUX24ffQZgdVVbbmBrAH9FV08Rb2oVVgBeQVRrWFp5VGZMYWNyMnoSN0FpaQgFT1l1f3h7c1RtcQUqY1kZbFJ5BQRiZEJXS3RvHGtieh9PaBlHaXhVWnVLRUlKdwsdbUtbKGFaAlN4a0V/emUJe2J2dl9BZkAxZWU/WGocRUBnc3VyT3F4WkJmYSthdBIGf0RwQ2FjAUBnd3ZEelgbVUEIDAJjS1VZbU9sSWFjfk55J2lZFV0HWX1cbVV5dWdAfkFIAVQVbloUXQtYaAR+VXhUF1BZdG4CBHRyK21AG1JaHhBFaBwCWUlocyQGVT4NBzNON2ASFVtXeQRET1kARndjUEBDT2RKeQN7RmJjeVtvZGpDeWJ1EHxafVd+Wk1AbzdLVTpafkd9dWZKeARecGJrS0xcenZIEEJQOmcFa01menFOeVRiSGFZC1JnWUA0SU08QGgeDFFgY34YWXAdZHYaHRhANFRMOV0CZmBfVExTWh9lZlVpSnx6eQURb2poa2RkQVJ0cmF0bwJbQgB6RlRbQHRQaQFKBHtENwVDSWpgHAlbTU1hXEpwdBh2eBlNY3l2UEhnblx7AmpaQ08JDDAzJUVAbn5IA2d8XX5ZFVlrYWhSXWlYQlEdZlQ/QUwuYwJgTG5GZghSRHdCYk1CWWBjclp0aWo3TWMSQmFaaAdge05FbmFhH3hxCFZuIX1BY01WV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