new.py 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. import hashlib
  2. import base64
  3. import random
  4. import json
  5. import time
  6. import uuid
  7. from collections import OrderedDict, defaultdict
  8. from typing import Any, Callable, Dict, List
  9. from datetime import (
  10. datetime,
  11. timedelta,
  12. timezone
  13. )
  14. cores = [16, 24, 32]
  15. screens = [3000, 4000, 6000]
  16. maxAttempts = 500000
  17. navigator_keys = [
  18. "registerProtocolHandler−function registerProtocolHandler() { [native code] }",
  19. "storage−[object StorageManager]",
  20. "locks−[object LockManager]",
  21. "appCodeName−Mozilla",
  22. "permissions−[object Permissions]",
  23. "appVersion−5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0",
  24. "share−function share() { [native code] }",
  25. "webdriver−false",
  26. "managed−[object NavigatorManagedData]",
  27. "canShare−function canShare() { [native code] }",
  28. "vendor−Google Inc.",
  29. "vendor−Google Inc.",
  30. "mediaDevices−[object MediaDevices]",
  31. "vibrate−function vibrate() { [native code] }",
  32. "storageBuckets−[object StorageBucketManager]",
  33. "mediaCapabilities−[object MediaCapabilities]",
  34. "getGamepads−function getGamepads() { [native code] }",
  35. "bluetooth−[object Bluetooth]",
  36. "share−function share() { [native code] }",
  37. "cookieEnabled−true",
  38. "virtualKeyboard−[object VirtualKeyboard]",
  39. "product−Gecko",
  40. "mediaDevices−[object MediaDevices]",
  41. "canShare−function canShare() { [native code] }",
  42. "getGamepads−function getGamepads() { [native code] }",
  43. "product−Gecko",
  44. "xr−[object XRSystem]",
  45. "clipboard−[object Clipboard]",
  46. "storageBuckets−[object StorageBucketManager]",
  47. "unregisterProtocolHandler−function unregisterProtocolHandler() { [native code] }",
  48. "productSub−20030107",
  49. "login−[object NavigatorLogin]",
  50. "vendorSub−",
  51. "login−[object NavigatorLogin]",
  52. "userAgent−Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0",
  53. "getInstalledRelatedApps−function getInstalledRelatedApps() { [native code] }",
  54. "userAgent−Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0",
  55. "mediaDevices−[object MediaDevices]",
  56. "locks−[object LockManager]",
  57. "webkitGetUserMedia−function webkitGetUserMedia() { [native code] }",
  58. "vendor−Google Inc.",
  59. "xr−[object XRSystem]",
  60. "mediaDevices−[object MediaDevices]",
  61. "virtualKeyboard−[object VirtualKeyboard]",
  62. "userAgent−Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0",
  63. "virtualKeyboard−[object VirtualKeyboard]",
  64. "appName−Netscape",
  65. "storageBuckets−[object StorageBucketManager]",
  66. "presentation−[object Presentation]",
  67. "onLine−true",
  68. "mimeTypes−[object MimeTypeArray]",
  69. "credentials−[object CredentialsContainer]",
  70. "presentation−[object Presentation]",
  71. "getGamepads−function getGamepads() { [native code] }",
  72. "vendorSub−",
  73. "virtualKeyboard−[object VirtualKeyboard]",
  74. "serviceWorker−[object ServiceWorkerContainer]",
  75. "xr−[object XRSystem]",
  76. "product−Gecko",
  77. "keyboard−[object Keyboard]",
  78. "gpu−[object GPU]",
  79. "getInstalledRelatedApps−function getInstalledRelatedApps() { [native code] }",
  80. "webkitPersistentStorage−[object DeprecatedStorageQuota]",
  81. "doNotTrack",
  82. "clearAppBadge−function clearAppBadge() { [native code] }",
  83. "presentation−[object Presentation]",
  84. "serial−[object Serial]",
  85. "locks−[object LockManager]",
  86. "requestMIDIAccess−function requestMIDIAccess() { [native code] }",
  87. "locks−[object LockManager]",
  88. "requestMediaKeySystemAccess−function requestMediaKeySystemAccess() { [native code] }",
  89. "vendor−Google Inc.",
  90. "pdfViewerEnabled−true",
  91. "language−zh-CN",
  92. "setAppBadge−function setAppBadge() { [native code] }",
  93. "geolocation−[object Geolocation]",
  94. "userAgentData−[object NavigatorUAData]",
  95. "mediaCapabilities−[object MediaCapabilities]",
  96. "requestMIDIAccess−function requestMIDIAccess() { [native code] }",
  97. "getUserMedia−function getUserMedia() { [native code] }",
  98. "mediaDevices−[object MediaDevices]",
  99. "webkitPersistentStorage−[object DeprecatedStorageQuota]",
  100. "userAgent−Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0",
  101. "sendBeacon−function sendBeacon() { [native code] }",
  102. "hardwareConcurrency−32",
  103. "appVersion−5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0",
  104. "credentials−[object CredentialsContainer]",
  105. "storage−[object StorageManager]",
  106. "cookieEnabled−true",
  107. "pdfViewerEnabled−true",
  108. "windowControlsOverlay−[object WindowControlsOverlay]",
  109. "scheduling−[object Scheduling]",
  110. "pdfViewerEnabled−true",
  111. "hardwareConcurrency−32",
  112. "xr−[object XRSystem]",
  113. "userAgent−Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0",
  114. "webdriver−false",
  115. "getInstalledRelatedApps−function getInstalledRelatedApps() { [native code] }",
  116. "getInstalledRelatedApps−function getInstalledRelatedApps() { [native code] }",
  117. "bluetooth−[object Bluetooth]"
  118. ]
  119. window_keys = [
  120. "0",
  121. "window",
  122. "self",
  123. "document",
  124. "name",
  125. "location",
  126. "customElements",
  127. "history",
  128. "navigation",
  129. "locationbar",
  130. "menubar",
  131. "personalbar",
  132. "scrollbars",
  133. "statusbar",
  134. "toolbar",
  135. "status",
  136. "closed",
  137. "frames",
  138. "length",
  139. "top",
  140. "opener",
  141. "parent",
  142. "frameElement",
  143. "navigator",
  144. "origin",
  145. "external",
  146. "screen",
  147. "innerWidth",
  148. "innerHeight",
  149. "scrollX",
  150. "pageXOffset",
  151. "scrollY",
  152. "pageYOffset",
  153. "visualViewport",
  154. "screenX",
  155. "screenY",
  156. "outerWidth",
  157. "outerHeight",
  158. "devicePixelRatio",
  159. "clientInformation",
  160. "screenLeft",
  161. "screenTop",
  162. "styleMedia",
  163. "onsearch",
  164. "isSecureContext",
  165. "trustedTypes",
  166. "performance",
  167. "onappinstalled",
  168. "onbeforeinstallprompt",
  169. "crypto",
  170. "indexedDB",
  171. "sessionStorage",
  172. "localStorage",
  173. "onbeforexrselect",
  174. "onabort",
  175. "onbeforeinput",
  176. "onbeforematch",
  177. "onbeforetoggle",
  178. "onblur",
  179. "oncancel",
  180. "oncanplay",
  181. "oncanplaythrough",
  182. "onchange",
  183. "onclick",
  184. "onclose",
  185. "oncontentvisibilityautostatechange",
  186. "oncontextlost",
  187. "oncontextmenu",
  188. "oncontextrestored",
  189. "oncuechange",
  190. "ondblclick",
  191. "ondrag",
  192. "ondragend",
  193. "ondragenter",
  194. "ondragleave",
  195. "ondragover",
  196. "ondragstart",
  197. "ondrop",
  198. "ondurationchange",
  199. "onemptied",
  200. "onended",
  201. "onerror",
  202. "onfocus",
  203. "onformdata",
  204. "oninput",
  205. "oninvalid",
  206. "onkeydown",
  207. "onkeypress",
  208. "onkeyup",
  209. "onload",
  210. "onloadeddata",
  211. "onloadedmetadata",
  212. "onloadstart",
  213. "onmousedown",
  214. "onmouseenter",
  215. "onmouseleave",
  216. "onmousemove",
  217. "onmouseout",
  218. "onmouseover",
  219. "onmouseup",
  220. "onmousewheel",
  221. "onpause",
  222. "onplay",
  223. "onplaying",
  224. "onprogress",
  225. "onratechange",
  226. "onreset",
  227. "onresize",
  228. "onscroll",
  229. "onsecuritypolicyviolation",
  230. "onseeked",
  231. "onseeking",
  232. "onselect",
  233. "onslotchange",
  234. "onstalled",
  235. "onsubmit",
  236. "onsuspend",
  237. "ontimeupdate",
  238. "ontoggle",
  239. "onvolumechange",
  240. "onwaiting",
  241. "onwebkitanimationend",
  242. "onwebkitanimationiteration",
  243. "onwebkitanimationstart",
  244. "onwebkittransitionend",
  245. "onwheel",
  246. "onauxclick",
  247. "ongotpointercapture",
  248. "onlostpointercapture",
  249. "onpointerdown",
  250. "onpointermove",
  251. "onpointerrawupdate",
  252. "onpointerup",
  253. "onpointercancel",
  254. "onpointerover",
  255. "onpointerout",
  256. "onpointerenter",
  257. "onpointerleave",
  258. "onselectstart",
  259. "onselectionchange",
  260. "onanimationend",
  261. "onanimationiteration",
  262. "onanimationstart",
  263. "ontransitionrun",
  264. "ontransitionstart",
  265. "ontransitionend",
  266. "ontransitioncancel",
  267. "onafterprint",
  268. "onbeforeprint",
  269. "onbeforeunload",
  270. "onhashchange",
  271. "onlanguagechange",
  272. "onmessage",
  273. "onmessageerror",
  274. "onoffline",
  275. "ononline",
  276. "onpagehide",
  277. "onpageshow",
  278. "onpopstate",
  279. "onrejectionhandled",
  280. "onstorage",
  281. "onunhandledrejection",
  282. "onunload",
  283. "crossOriginIsolated",
  284. "scheduler",
  285. "alert",
  286. "atob",
  287. "blur",
  288. "btoa",
  289. "cancelAnimationFrame",
  290. "cancelIdleCallback",
  291. "captureEvents",
  292. "clearInterval",
  293. "clearTimeout",
  294. "close",
  295. "confirm",
  296. "createImageBitmap",
  297. "fetch",
  298. "find",
  299. "focus",
  300. "getComputedStyle",
  301. "getSelection",
  302. "matchMedia",
  303. "moveBy",
  304. "moveTo",
  305. "open",
  306. "postMessage",
  307. "print",
  308. "prompt",
  309. "queueMicrotask",
  310. "releaseEvents",
  311. "reportError",
  312. "requestAnimationFrame",
  313. "requestIdleCallback",
  314. "resizeBy",
  315. "resizeTo",
  316. "scroll",
  317. "scrollBy",
  318. "scrollTo",
  319. "setInterval",
  320. "setTimeout",
  321. "stop",
  322. "structuredClone",
  323. "webkitCancelAnimationFrame",
  324. "webkitRequestAnimationFrame",
  325. "chrome",
  326. "g_opr",
  327. "opr",
  328. "ethereum",
  329. "caches",
  330. "cookieStore",
  331. "ondevicemotion",
  332. "ondeviceorientation",
  333. "ondeviceorientationabsolute",
  334. "launchQueue",
  335. "documentPictureInPicture",
  336. "getScreenDetails",
  337. "queryLocalFonts",
  338. "showDirectoryPicker",
  339. "showOpenFilePicker",
  340. "showSaveFilePicker",
  341. "originAgentCluster",
  342. "credentialless",
  343. "speechSynthesis",
  344. "onscrollend",
  345. "webkitRequestFileSystem",
  346. "webkitResolveLocalFileSystemURL",
  347. "__remixContext",
  348. "__oai_SSR_TTI",
  349. "__remixManifest",
  350. "__reactRouterVersion",
  351. "DD_RUM",
  352. "__REACT_INTL_CONTEXT__",
  353. "filterCSS",
  354. "filterXSS",
  355. "__SEGMENT_INSPECTOR__",
  356. "DD_LOGS",
  357. "regeneratorRuntime",
  358. "_g",
  359. "__remixRouteModules",
  360. "__remixRouter",
  361. "__STATSIG_SDK__",
  362. "__STATSIG_JS_SDK__",
  363. "__STATSIG_RERENDER_OVERRIDE__",
  364. "_oaiHandleSessionExpired"
  365. ]
  366. def get_parse_time():
  367. now = datetime.now(timezone(timedelta(hours=-5)))
  368. return now.strftime("%a %b %d %Y %H:%M:%S") + " GMT+0200 (Central European Summer Time)"
  369. def get_config(user_agent):
  370. core = random.choice(cores)
  371. screen = random.choice(screens)
  372. # partially hardcoded config
  373. config = [
  374. core + screen,
  375. get_parse_time(),
  376. 4294705152,
  377. random.random(),
  378. user_agent,
  379. None,
  380. "remix-prod-15f1ec0f78ad898b9606a88d384ef76345b82b82", #document.documentElement.getAttribute("data-build"),
  381. "en-US",
  382. "en-US,es-US,en,es",
  383. 0,
  384. random.choice(navigator_keys),
  385. 'location',
  386. random.choice(window_keys),
  387. time.perf_counter(),
  388. str(uuid.uuid4()),
  389. ]
  390. return config
  391. def get_answer_token(seed, diff, config):
  392. answer, solved = generate_answer(seed, diff, config)
  393. if solved:
  394. return "gAAAAAB" + answer
  395. else:
  396. raise Exception("Failed to solve 'gAAAAAB' challenge")
  397. def generate_answer(seed, diff, config):
  398. diff_len = len(diff)
  399. seed_encoded = seed.encode()
  400. p1 = (json.dumps(config[:3], separators=(',', ':'), ensure_ascii=False)[:-1] + ',').encode()
  401. p2 = (',' + json.dumps(config[4:9], separators=(',', ':'), ensure_ascii=False)[1:-1] + ',').encode()
  402. p3 = (',' + json.dumps(config[10:], separators=(',', ':'), ensure_ascii=False)[1:]).encode()
  403. target_diff = bytes.fromhex(diff)
  404. for i in range(maxAttempts):
  405. d1 = str(i).encode()
  406. d2 = str(i >> 1).encode()
  407. string = (
  408. p1
  409. + d1
  410. + p2
  411. + d2
  412. + p3
  413. )
  414. base_encode = base64.b64encode(string)
  415. hash_value = hashlib.new("sha3_512", seed_encoded + base_encode).digest()
  416. if hash_value[:diff_len] <= target_diff:
  417. return base_encode.decode(), True
  418. return 'wQ8Lk5FbGpA2NcR9dShT6gYjU7VxZ4D' + base64.b64encode(f'"{seed}"'.encode()).decode(), False
  419. def get_requirements_token(config):
  420. require, solved = generate_answer(format(random.random()), "0fffff", config)
  421. if solved:
  422. return 'gAAAAAC' + require
  423. else:
  424. raise Exception("Failed to solve 'gAAAAAC' challenge")
  425. ### processing turnstile token
  426. class OrderedMap:
  427. def __init__(self):
  428. self.map = OrderedDict()
  429. def add(self, key: str, value: Any):
  430. self.map[key] = value
  431. def to_json(self):
  432. return json.dumps(self.map)
  433. def __str__(self):
  434. return self.to_json()
  435. TurnTokenList = List[List[Any]]
  436. FloatMap = Dict[float, Any]
  437. StringMap = Dict[str, Any]
  438. FuncType = Callable[..., Any]
  439. start_time = time.time()
  440. def get_turnstile_token(dx: str, p: str) -> str:
  441. decoded_bytes = base64.b64decode(dx)
  442. # print(decoded_bytes.decode())
  443. return process_turnstile_token(decoded_bytes.decode(), p)
  444. def process_turnstile_token(dx: str, p: str) -> str:
  445. result = []
  446. p_length = len(p)
  447. if p_length != 0:
  448. for i, r in enumerate(dx):
  449. result.append(chr(ord(r) ^ ord(p[i % p_length])))
  450. else:
  451. result = list(dx)
  452. return "".join(result)
  453. def is_slice(input_val: Any) -> bool:
  454. return isinstance(input_val, (list, tuple))
  455. def is_float(input_val: Any) -> bool:
  456. return isinstance(input_val, float)
  457. def is_string(input_val: Any) -> bool:
  458. return isinstance(input_val, str)
  459. def to_str(input_val: Any) -> str:
  460. if input_val is None:
  461. return "undefined"
  462. elif is_float(input_val):
  463. return f"{input_val:.16g}"
  464. elif is_string(input_val):
  465. special_cases = {
  466. "window.Math": "[object Math]",
  467. "window.Reflect": "[object Reflect]",
  468. "window.performance": "[object Performance]",
  469. "window.localStorage": "[object Storage]",
  470. "window.Object": "function Object() { [native code] }",
  471. "window.Reflect.set": "function set() { [native code] }",
  472. "window.performance.now": "function () { [native code] }",
  473. "window.Object.create": "function create() { [native code] }",
  474. "window.Object.keys": "function keys() { [native code] }",
  475. "window.Math.random": "function random() { [native code] }",
  476. }
  477. return special_cases.get(input_val, input_val)
  478. elif isinstance(input_val, list) and all(
  479. isinstance(item, str) for item in input_val
  480. ):
  481. return ",".join(input_val)
  482. else:
  483. # print(f"Type of input is: {type(input_val)}")
  484. return str(input_val)
  485. def get_func_map() -> FloatMap:
  486. process_map: FloatMap = defaultdict(lambda: None)
  487. def func_1(e: float, t: float):
  488. e_str = to_str(process_map[e])
  489. t_str = to_str(process_map[t])
  490. if e_str is not None and t_str is not None:
  491. res = process_turnstile_token(e_str, t_str)
  492. process_map[e] = res
  493. else:
  494. pass
  495. # print(f"Warning: Unable to process func_1 for e={e}, t={t}")
  496. def func_2(e: float, t: Any):
  497. process_map[e] = t
  498. def func_5(e: float, t: float):
  499. n = process_map[e]
  500. tres = process_map[t]
  501. if n is None:
  502. process_map[e] = tres
  503. elif is_slice(n):
  504. nt = n + [tres] if tres is not None else n
  505. process_map[e] = nt
  506. else:
  507. if is_string(n) or is_string(tres):
  508. res = to_str(n) + to_str(tres)
  509. elif is_float(n) and is_float(tres):
  510. res = n + tres
  511. else:
  512. res = "NaN"
  513. process_map[e] = res
  514. def func_6(e: float, t: float, n: float):
  515. tv = process_map[t]
  516. nv = process_map[n]
  517. if is_string(tv) and is_string(nv):
  518. res = f"{tv}.{nv}"
  519. if res == "window.document.location":
  520. process_map[e] = "https://chatgpt.com/"
  521. else:
  522. process_map[e] = res
  523. else:
  524. pass
  525. # print("func type 6 error")
  526. def func_24(e: float, t: float, n: float):
  527. tv = process_map[t]
  528. nv = process_map[n]
  529. if is_string(tv) and is_string(nv):
  530. process_map[e] = f"{tv}.{nv}"
  531. else:
  532. pass
  533. # print("func type 24 error")
  534. def func_7(e: float, *args):
  535. n = [process_map[arg] for arg in args]
  536. ev = process_map[e]
  537. if isinstance(ev, str):
  538. if ev == "window.Reflect.set":
  539. obj = n[0]
  540. key_str = str(n[1])
  541. val = n[2]
  542. obj.add(key_str, val)
  543. elif callable(ev):
  544. ev(*n)
  545. def func_17(e: float, t: float, *args):
  546. i = [process_map[arg] for arg in args]
  547. tv = process_map[t]
  548. res = None
  549. if isinstance(tv, str):
  550. if tv == "window.performance.now":
  551. current_time = time.time_ns()
  552. elapsed_ns = current_time - int(start_time * 1e9)
  553. res = (elapsed_ns + random.random()) / 1e6
  554. elif tv == "window.Object.create":
  555. res = OrderedMap()
  556. elif tv == "window.Object.keys":
  557. if isinstance(i[0], str) and i[0] == "window.localStorage":
  558. res = [
  559. "STATSIG_LOCAL_STORAGE_INTERNAL_STORE_V4",
  560. "STATSIG_LOCAL_STORAGE_STABLE_ID",
  561. "client-correlated-secret",
  562. "oai/apps/capExpiresAt",
  563. "oai-did",
  564. "STATSIG_LOCAL_STORAGE_LOGGING_REQUEST",
  565. "UiState.isNavigationCollapsed.1",
  566. ]
  567. elif tv == "window.Math.random":
  568. res = random.random()
  569. elif callable(tv):
  570. res = tv(*i)
  571. process_map[e] = res
  572. def func_8(e: float, t: float):
  573. process_map[e] = process_map[t]
  574. def func_14(e: float, t: float):
  575. tv = process_map[t]
  576. if is_string(tv):
  577. try:
  578. token_list = json.loads(tv)
  579. process_map[e] = token_list
  580. except json.JSONDecodeError:
  581. # print(f"Warning: Unable to parse JSON for key {t}")
  582. process_map[e] = None
  583. else:
  584. # print(f"Warning: Value for key {t} is not a string")
  585. process_map[e] = None
  586. def func_15(e: float, t: float):
  587. tv = process_map[t]
  588. process_map[e] = json.dumps(tv)
  589. def func_18(e: float):
  590. ev = process_map[e]
  591. e_str = to_str(ev)
  592. decoded = base64.b64decode(e_str).decode()
  593. process_map[e] = decoded
  594. def func_19(e: float):
  595. ev = process_map[e]
  596. e_str = to_str(ev)
  597. encoded = base64.b64encode(e_str.encode()).decode()
  598. process_map[e] = encoded
  599. def func_20(e: float, t: float, n: float, *args):
  600. o = [process_map[arg] for arg in args]
  601. ev = process_map[e]
  602. tv = process_map[t]
  603. if ev == tv:
  604. nv = process_map[n]
  605. if callable(nv):
  606. nv(*o)
  607. else:
  608. pass
  609. # print("func type 20 error")
  610. def func_21(*args):
  611. pass
  612. def func_23(e: float, t: float, *args):
  613. i = list(args)
  614. ev = process_map[e]
  615. tv = process_map[t]
  616. if ev is not None and callable(tv):
  617. tv(*i)
  618. process_map.update(
  619. {
  620. 1: func_1,
  621. 2: func_2,
  622. 5: func_5,
  623. 6: func_6,
  624. 7: func_7,
  625. 8: func_8,
  626. 10: "window",
  627. 14: func_14,
  628. 15: func_15,
  629. 17: func_17,
  630. 18: func_18,
  631. 19: func_19,
  632. 20: func_20,
  633. 21: func_21,
  634. 23: func_23,
  635. 24: func_24,
  636. }
  637. )
  638. return process_map
  639. def process_turnstile(dx: str, p: str) -> str:
  640. tokens = get_turnstile_token(dx, p)
  641. res = ""
  642. token_list = json.loads(tokens)
  643. process_map = get_func_map()
  644. def func_3(e: str):
  645. nonlocal res
  646. res = base64.b64encode(e.encode()).decode()
  647. process_map[3] = func_3
  648. process_map[9] = token_list
  649. process_map[16] = p
  650. for token in token_list:
  651. try:
  652. e = token[0]
  653. t = token[1:]
  654. f = process_map.get(e)
  655. if callable(f):
  656. f(*t)
  657. else:
  658. pass
  659. # print(f"Warning: No function found for key {e}")
  660. except Exception as exc:
  661. raise Exception(f"Error processing token {token}: {exc}")
  662. # print(f"Error processing token {token}: {exc}")
  663. return res