Rfym21 commited on
Commit
0db1606
·
verified ·
1 Parent(s): 4615e18

Delete chatgpt/proofofWork.py

Browse files
Files changed (1) hide show
  1. chatgpt/proofofWork.py +0 -512
chatgpt/proofofWork.py DELETED
@@ -1,512 +0,0 @@
1
- import hashlib
2
- import json
3
- import random
4
- import re
5
- import time
6
- import uuid
7
- from datetime import datetime, timedelta, timezone
8
- from html.parser import HTMLParser
9
-
10
- import pybase64
11
-
12
- from utils.Logger import logger
13
- from utils.config import conversation_only
14
-
15
- cores = [16, 24, 32]
16
- screens = [3000, 4000, 6000]
17
- timeLayout = "%a %b %d %Y %H:%M:%S"
18
-
19
- cached_scripts = []
20
- cached_dpl = ""
21
- cached_time = 0
22
- cached_require_proof = ""
23
-
24
- navigator_key = [
25
- "registerProtocolHandler−function registerProtocolHandler() { [native code] }",
26
- "storage−[object StorageManager]",
27
- "locks−[object LockManager]",
28
- "appCodeName−Mozilla",
29
- "permissions−[object Permissions]",
30
- "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",
31
- "share−function share() { [native code] }",
32
- "webdriver−false",
33
- "managed−[object NavigatorManagedData]",
34
- "canShare−function canShare() { [native code] }",
35
- "vendor−Google Inc.",
36
- "vendor−Google Inc.",
37
- "mediaDevices−[object MediaDevices]",
38
- "vibrate−function vibrate() { [native code] }",
39
- "storageBuckets−[object StorageBucketManager]",
40
- "mediaCapabilities−[object MediaCapabilities]",
41
- "getGamepads−function getGamepads() { [native code] }",
42
- "bluetooth−[object Bluetooth]",
43
- "share−function share() { [native code] }",
44
- "cookieEnabled−true",
45
- "virtualKeyboard−[object VirtualKeyboard]",
46
- "product−Gecko",
47
- "mediaDevices−[object MediaDevices]",
48
- "canShare−function canShare() { [native code] }",
49
- "getGamepads−function getGamepads() { [native code] }",
50
- "product−Gecko",
51
- "xr−[object XRSystem]",
52
- "clipboard−[object Clipboard]",
53
- "storageBuckets−[object StorageBucketManager]",
54
- "unregisterProtocolHandler−function unregisterProtocolHandler() { [native code] }",
55
- "productSub−20030107",
56
- "login−[object NavigatorLogin]",
57
- "vendorSub−",
58
- "login−[object NavigatorLogin]",
59
- "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",
60
- "getInstalledRelatedApps−function getInstalledRelatedApps() { [native code] }",
61
- "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",
62
- "mediaDevices−[object MediaDevices]",
63
- "locks−[object LockManager]",
64
- "webkitGetUserMedia−function webkitGetUserMedia() { [native code] }",
65
- "vendor−Google Inc.",
66
- "xr−[object XRSystem]",
67
- "mediaDevices−[object MediaDevices]",
68
- "virtualKeyboard−[object VirtualKeyboard]",
69
- "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",
70
- "virtualKeyboard−[object VirtualKeyboard]",
71
- "appName−Netscape",
72
- "storageBuckets−[object StorageBucketManager]",
73
- "presentation−[object Presentation]",
74
- "onLine−true",
75
- "mimeTypes−[object MimeTypeArray]",
76
- "credentials−[object CredentialsContainer]",
77
- "presentation−[object Presentation]",
78
- "getGamepads−function getGamepads() { [native code] }",
79
- "vendorSub−",
80
- "virtualKeyboard−[object VirtualKeyboard]",
81
- "serviceWorker−[object ServiceWorkerContainer]",
82
- "xr−[object XRSystem]",
83
- "product−Gecko",
84
- "keyboard−[object Keyboard]",
85
- "gpu−[object GPU]",
86
- "getInstalledRelatedApps−function getInstalledRelatedApps() { [native code] }",
87
- "webkitPersistentStorage−[object DeprecatedStorageQuota]",
88
- "doNotTrack",
89
- "clearAppBadge−function clearAppBadge() { [native code] }",
90
- "presentation−[object Presentation]",
91
- "serial−[object Serial]",
92
- "locks−[object LockManager]",
93
- "requestMIDIAccess−function requestMIDIAccess() { [native code] }",
94
- "locks−[object LockManager]",
95
- "requestMediaKeySystemAccess−function requestMediaKeySystemAccess() { [native code] }",
96
- "vendor−Google Inc.",
97
- "pdfViewerEnabled−true",
98
- "language−zh-CN",
99
- "setAppBadge−function setAppBadge() { [native code] }",
100
- "geolocation−[object Geolocation]",
101
- "userAgentData−[object NavigatorUAData]",
102
- "mediaCapabilities−[object MediaCapabilities]",
103
- "requestMIDIAccess−function requestMIDIAccess() { [native code] }",
104
- "getUserMedia−function getUserMedia() { [native code] }",
105
- "mediaDevices−[object MediaDevices]",
106
- "webkitPersistentStorage−[object DeprecatedStorageQuota]",
107
- "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",
108
- "sendBeacon−function sendBeacon() { [native code] }",
109
- "hardwareConcurrency−32",
110
- "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",
111
- "credentials−[object CredentialsContainer]",
112
- "storage−[object StorageManager]",
113
- "cookieEnabled−true",
114
- "pdfViewerEnabled−true",
115
- "windowControlsOverlay−[object WindowControlsOverlay]",
116
- "scheduling−[object Scheduling]",
117
- "pdfViewerEnabled−true",
118
- "hardwareConcurrency−32",
119
- "xr−[object XRSystem]",
120
- "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",
121
- "webdriver−false",
122
- "getInstalledRelatedApps−function getInstalledRelatedApps() { [native code] }",
123
- "getInstalledRelatedApps−function getInstalledRelatedApps() { [native code] }",
124
- "bluetooth−[object Bluetooth]"
125
- ]
126
- document_key = ['_reactListeningo743lnnpvdg', 'location']
127
- window_key = [
128
- "0",
129
- "window",
130
- "self",
131
- "document",
132
- "name",
133
- "location",
134
- "customElements",
135
- "history",
136
- "navigation",
137
- "locationbar",
138
- "menubar",
139
- "personalbar",
140
- "scrollbars",
141
- "statusbar",
142
- "toolbar",
143
- "status",
144
- "closed",
145
- "frames",
146
- "length",
147
- "top",
148
- "opener",
149
- "parent",
150
- "frameElement",
151
- "navigator",
152
- "origin",
153
- "external",
154
- "screen",
155
- "innerWidth",
156
- "innerHeight",
157
- "scrollX",
158
- "pageXOffset",
159
- "scrollY",
160
- "pageYOffset",
161
- "visualViewport",
162
- "screenX",
163
- "screenY",
164
- "outerWidth",
165
- "outerHeight",
166
- "devicePixelRatio",
167
- "clientInformation",
168
- "screenLeft",
169
- "screenTop",
170
- "styleMedia",
171
- "onsearch",
172
- "isSecureContext",
173
- "trustedTypes",
174
- "performance",
175
- "onappinstalled",
176
- "onbeforeinstallprompt",
177
- "crypto",
178
- "indexedDB",
179
- "sessionStorage",
180
- "localStorage",
181
- "onbeforexrselect",
182
- "onabort",
183
- "onbeforeinput",
184
- "onbeforematch",
185
- "onbeforetoggle",
186
- "onblur",
187
- "oncancel",
188
- "oncanplay",
189
- "oncanplaythrough",
190
- "onchange",
191
- "onclick",
192
- "onclose",
193
- "oncontentvisibilityautostatechange",
194
- "oncontextlost",
195
- "oncontextmenu",
196
- "oncontextrestored",
197
- "oncuechange",
198
- "ondblclick",
199
- "ondrag",
200
- "ondragend",
201
- "ondragenter",
202
- "ondragleave",
203
- "ondragover",
204
- "ondragstart",
205
- "ondrop",
206
- "ondurationchange",
207
- "onemptied",
208
- "onended",
209
- "onerror",
210
- "onfocus",
211
- "onformdata",
212
- "oninput",
213
- "oninvalid",
214
- "onkeydown",
215
- "onkeypress",
216
- "onkeyup",
217
- "onload",
218
- "onloadeddata",
219
- "onloadedmetadata",
220
- "onloadstart",
221
- "onmousedown",
222
- "onmouseenter",
223
- "onmouseleave",
224
- "onmousemove",
225
- "onmouseout",
226
- "onmouseover",
227
- "onmouseup",
228
- "onmousewheel",
229
- "onpause",
230
- "onplay",
231
- "onplaying",
232
- "onprogress",
233
- "onratechange",
234
- "onreset",
235
- "onresize",
236
- "onscroll",
237
- "onsecuritypolicyviolation",
238
- "onseeked",
239
- "onseeking",
240
- "onselect",
241
- "onslotchange",
242
- "onstalled",
243
- "onsubmit",
244
- "onsuspend",
245
- "ontimeupdate",
246
- "ontoggle",
247
- "onvolumechange",
248
- "onwaiting",
249
- "onwebkitanimationend",
250
- "onwebkitanimationiteration",
251
- "onwebkitanimationstart",
252
- "onwebkittransitionend",
253
- "onwheel",
254
- "onauxclick",
255
- "ongotpointercapture",
256
- "onlostpointercapture",
257
- "onpointerdown",
258
- "onpointermove",
259
- "onpointerrawupdate",
260
- "onpointerup",
261
- "onpointercancel",
262
- "onpointerover",
263
- "onpointerout",
264
- "onpointerenter",
265
- "onpointerleave",
266
- "onselectstart",
267
- "onselectionchange",
268
- "onanimationend",
269
- "onanimationiteration",
270
- "onanimationstart",
271
- "ontransitionrun",
272
- "ontransitionstart",
273
- "ontransitionend",
274
- "ontransitioncancel",
275
- "onafterprint",
276
- "onbeforeprint",
277
- "onbeforeunload",
278
- "onhashchange",
279
- "onlanguagechange",
280
- "onmessage",
281
- "onmessageerror",
282
- "onoffline",
283
- "ononline",
284
- "onpagehide",
285
- "onpageshow",
286
- "onpopstate",
287
- "onrejectionhandled",
288
- "onstorage",
289
- "onunhandledrejection",
290
- "onunload",
291
- "crossOriginIsolated",
292
- "scheduler",
293
- "alert",
294
- "atob",
295
- "blur",
296
- "btoa",
297
- "cancelAnimationFrame",
298
- "cancelIdleCallback",
299
- "captureEvents",
300
- "clearInterval",
301
- "clearTimeout",
302
- "close",
303
- "confirm",
304
- "createImageBitmap",
305
- "fetch",
306
- "find",
307
- "focus",
308
- "getComputedStyle",
309
- "getSelection",
310
- "matchMedia",
311
- "moveBy",
312
- "moveTo",
313
- "open",
314
- "postMessage",
315
- "print",
316
- "prompt",
317
- "queueMicrotask",
318
- "releaseEvents",
319
- "reportError",
320
- "requestAnimationFrame",
321
- "requestIdleCallback",
322
- "resizeBy",
323
- "resizeTo",
324
- "scroll",
325
- "scrollBy",
326
- "scrollTo",
327
- "setInterval",
328
- "setTimeout",
329
- "stop",
330
- "structuredClone",
331
- "webkitCancelAnimationFrame",
332
- "webkitRequestAnimationFrame",
333
- "chrome",
334
- "caches",
335
- "cookieStore",
336
- "ondevicemotion",
337
- "ondeviceorientation",
338
- "ondeviceorientationabsolute",
339
- "launchQueue",
340
- "documentPictureInPicture",
341
- "getScreenDetails",
342
- "queryLocalFonts",
343
- "showDirectoryPicker",
344
- "showOpenFilePicker",
345
- "showSaveFilePicker",
346
- "originAgentCluster",
347
- "onpageswap",
348
- "onpagereveal",
349
- "credentialless",
350
- "speechSynthesis",
351
- "onscrollend",
352
- "webkitRequestFileSystem",
353
- "webkitResolveLocalFileSystemURL",
354
- "sendMsgToSolverCS",
355
- "webpackChunk_N_E",
356
- "__next_set_public_path__",
357
- "next",
358
- "__NEXT_DATA__",
359
- "__SSG_MANIFEST_CB",
360
- "__NEXT_P",
361
- "_N_E",
362
- "regeneratorRuntime",
363
- "__REACT_INTL_CONTEXT__",
364
- "DD_RUM",
365
- "_",
366
- "filterCSS",
367
- "filterXSS",
368
- "__SEGMENT_INSPECTOR__",
369
- "__NEXT_PRELOADREADY",
370
- "Intercom",
371
- "__MIDDLEWARE_MATCHERS",
372
- "__STATSIG_SDK__",
373
- "__STATSIG_JS_SDK__",
374
- "__STATSIG_RERENDER_OVERRIDE__",
375
- "_oaiHandleSessionExpired",
376
- "__BUILD_MANIFEST",
377
- "__SSG_MANIFEST",
378
- "__intercomAssignLocation",
379
- "__intercomReloadLocation"
380
- ]
381
-
382
-
383
- class ScriptSrcParser(HTMLParser):
384
- def handle_starttag(self, tag, attrs):
385
- global cached_scripts, cached_dpl, cached_time
386
- if tag == "script":
387
- attrs_dict = dict(attrs)
388
- if "src" in attrs_dict:
389
- src = attrs_dict["src"]
390
- cached_scripts.append(src)
391
- match = re.search(r"c/[^/]*/_", src)
392
- if match:
393
- cached_dpl = match.group(0)
394
- cached_time = int(time.time())
395
-
396
-
397
- def get_data_build_from_html(html_content):
398
- global cached_scripts, cached_dpl, cached_time
399
- parser = ScriptSrcParser()
400
- parser.feed(html_content)
401
- if not cached_scripts:
402
- cached_scripts.append("https://chatgpt.com/backend-api/sentinel/sdk.js")
403
- if not cached_dpl:
404
- match = re.search(r'<html[^>]*data-build="([^"]*)"', html_content)
405
- if match:
406
- data_build = match.group(1)
407
- cached_dpl = data_build
408
- cached_time = int(time.time())
409
- logger.info(f"Found dpl: {cached_dpl}")
410
-
411
-
412
- async def get_dpl(service):
413
- global cached_scripts, cached_dpl, cached_time
414
- if int(time.time()) - cached_time < 15 * 60:
415
- return True
416
- headers = service.base_headers.copy()
417
- cached_scripts = []
418
- cached_dpl = ""
419
- try:
420
- if conversation_only:
421
- return True
422
- r = await service.s.get(f"{service.host_url}/", headers=headers, timeout=5)
423
- r.raise_for_status()
424
- get_data_build_from_html(r.text)
425
- if not cached_dpl:
426
- raise Exception("No Cached DPL")
427
- else:
428
- return True
429
- except Exception as e:
430
- logger.info(f"Failed to get dpl: {e}")
431
- cached_dpl = None
432
- cached_time = int(time.time())
433
- return False
434
-
435
-
436
- def get_parse_time():
437
- now = datetime.now(timezone(timedelta(hours=-5)))
438
- return now.strftime(timeLayout) + " GMT-0500 (Eastern Standard Time)"
439
-
440
-
441
- def get_config(user_agent):
442
- core = random.choice(cores)
443
- screen = random.choice(screens)
444
- config = [
445
- core + screen,
446
- get_parse_time(),
447
- 4294705152,
448
- 0,
449
- user_agent,
450
- random.choice(cached_scripts) if cached_scripts else None,
451
- cached_dpl,
452
- "en-US",
453
- "en-US,es-US,en,es",
454
- 0,
455
- random.choice(navigator_key),
456
- random.choice(document_key),
457
- random.choice(window_key),
458
- time.perf_counter(),
459
- str(uuid.uuid4()),
460
- ]
461
- return config
462
-
463
-
464
- def get_answer_token(seed, diff, config):
465
- start = time.time()
466
- answer, solved = generate_answer(seed, diff, config)
467
- end = time.time()
468
- logger.info(f'diff: {diff}, time: {int((end - start) * 1e6) / 1e3}ms, solved: {solved}')
469
- return "gAAAAAB" + answer, solved
470
-
471
-
472
- def generate_answer(seed, diff, config):
473
- diff_len = len(diff)
474
- seed_encoded = seed.encode()
475
- static_config_part1 = (json.dumps(config[:3], separators=(',', ':'), ensure_ascii=False)[:-1] + ',').encode()
476
- static_config_part2 = (',' + json.dumps(config[4:9], separators=(',', ':'), ensure_ascii=False)[1:-1] + ',').encode()
477
- static_config_part3 = (',' + json.dumps(config[10:], separators=(',', ':'), ensure_ascii=False)[1:]).encode()
478
-
479
- target_diff = bytes.fromhex(diff)
480
-
481
- for i in range(500000):
482
- dynamic_json_i = str(i).encode()
483
- dynamic_json_j = str(i >> 1).encode()
484
- final_json_bytes = static_config_part1 + dynamic_json_i + static_config_part2 + dynamic_json_j + static_config_part3
485
- base_encode = pybase64.b64encode(final_json_bytes)
486
- hash_value = hashlib.sha3_512(seed_encoded + base_encode).digest()
487
- if hash_value[:diff_len] <= target_diff:
488
- return base_encode.decode(), True
489
-
490
- return "wQ8Lk5FbGpA2NcR9dShT6gYjU7VxZ4D" + pybase64.b64encode(f'"{seed}"'.encode()).decode(), False
491
-
492
-
493
- def get_requirements_token(config):
494
- require, solved = generate_answer(format(random.random()), "0fffff", config)
495
- return 'gAAAAAC' + require
496
-
497
-
498
- if __name__ == "__main__":
499
- # cached_scripts.append(
500
- # "https://cdn.oaistatic.com/_next/static/cXh69klOLzS0Gy2joLDRS/_ssgManifest.js?dpl=453ebaec0d44c2decab71692e1bfe39be35a24b3")
501
- # cached_dpl = "453ebaec0d44c2decab71692e1bfe39be35a24b3"
502
- # cached_time = int(time.time())
503
- # for i in range(10):
504
- # seed = format(random.random())
505
- # diff = "000032"
506
- # config = get_config("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome")
507
- # answer = get_answer_token(seed, diff, config)
508
- cached_scripts.append(
509
- "https://cdn.oaistatic.com/_next/static/cXh69klOLzS0Gy2joLDRS/_ssgManifest.js?dpl=453ebaec0d44c2decab71692e1bfe39be35a24b3")
510
- cached_dpl = "dpl=453ebaec0d44c2decab71692e1bfe39be35a24b3"
511
- config = get_config("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36")
512
- get_requirements_token(config)