new.py 21 KB

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